diff --git a/src/Parser/Parser.cpp b/src/Parser/Parser.cpp index b2441b07..e3af86fd 100644 --- a/src/Parser/Parser.cpp +++ b/src/Parser/Parser.cpp @@ -1222,6 +1222,10 @@ CppSharp::AST::Enumeration^ Parser::WalkEnum(clang::EnumDecl* ED) EnumItem->Comment = marshalString(BriefText); //EnumItem->ExplicitValue = ECD->getExplicitValue(); + std::string Text; + if (GetDeclText(ECD->getSourceRange(), Text)) + EnumItem->Expression = marshalString(Text); + E->AddItem(EnumItem); } @@ -1539,13 +1543,13 @@ void Parser::HandleComments(clang::Decl* D, CppSharp::AST::Declaration^ Decl) //-----------------------------------// -bool Parser::GetPreprocessedEntityText(clang::PreprocessedEntity* PE, std::string& Text) +bool Parser::GetDeclText(clang::SourceRange SR, std::string& Text) { using namespace clang; SourceManager& SM = C->getSourceManager(); const LangOptions &LangOpts = C->getLangOpts(); - auto Range = CharSourceRange::getTokenRange(PE->getSourceRange()); + auto Range = CharSourceRange::getTokenRange(SR); bool Invalid; Text = Lexer::getSourceText(Range, SM, LangOpts, &Invalid); @@ -1575,7 +1579,7 @@ void Parser::HandlePreprocessedEntities(CppSharp::AST::Declaration^ Decl, Entity = gcnew CppSharp::AST::MacroExpansion(); std::string Text; - if (!GetPreprocessedEntityText(PPEntity, Text)) + if (!GetDeclText(PPEntity->getSourceRange(), Text)) continue; static_cast(Entity)->Text = diff --git a/src/Parser/Parser.h b/src/Parser/Parser.h index 8de359c1..b88b25d0 100644 --- a/src/Parser/Parser.h +++ b/src/Parser/Parser.h @@ -158,7 +158,7 @@ protected: bool IsDependent = false); void HandlePreprocessedEntities(CppSharp::AST::Declaration^ Decl, clang::SourceRange sourceRange, CppSharp::AST::MacroLocation macroLocation = CppSharp::AST::MacroLocation::Unknown); - bool GetPreprocessedEntityText(clang::PreprocessedEntity*, std::string& Text); + bool GetDeclText(clang::SourceRange, std::string& Text); CppSharp::AST::TranslationUnit^ GetTranslationUnit(clang::SourceLocation Loc, SourceLocationKind *Kind = 0);