Browse Source

Fixed parser to include enumerations which don't have an identifier set.

pull/229/head
Elias Holzer 11 years ago
parent
commit
521845be81
  1. 24
      src/Parser/Parser.cpp

24
src/Parser/Parser.cpp

@ -1714,14 +1714,34 @@ CppSharp::AST::Enumeration^ Parser::WalkEnum(clang::EnumDecl* ED)
assert(NS && "Expected a valid namespace"); assert(NS && "Expected a valid namespace");
auto Name = marshalString<E_UTF8>(GetTagDeclName(ED)); auto Name = marshalString<E_UTF8>(GetTagDeclName(ED));
auto E = NS->FindEnum(Name, /*Create=*/false); CppSharp::AST::Enumeration^ E = nullptr;
if (!System::String::IsNullOrEmpty(Name))
E = NS->FindEnum(Name, /*Create=*/false);
else
{
// Enum with no identifier - try to find existing enum through enum items
for (auto it = ED->enumerator_begin(); it != ED->enumerator_end(); ++it)
{
EnumConstantDecl* ECD = (*it);
auto EnumItemName = marshalString<E_UTF8>(ECD->getNameAsString());
E = NS->FindEnumWithItem(EnumItemName);
break;
}
}
if (E && !E->IsIncomplete) if (E && !E->IsIncomplete)
return E; return E;
if (!E) if (!E)
{ {
E = NS->FindEnum(Name, /*Create=*/true); if (!System::String::IsNullOrEmpty(Name))
E = NS->FindEnum(Name, /*Create=*/true);
else
{
E = gcnew CppSharp::AST::Enumeration();
E->Namespace = NS;
NS->Enums->Add(E);
}
HandleDeclaration(ED, E); HandleDeclaration(ED, E);
} }

Loading…
Cancel
Save