Browse Source

Improved generation of enumerations from macros.

We now keep track if a certain macro has already been generated in an enum and skip it in future calls to GenerateEnumFromMacros.
pull/155/merge
Joao Matos 12 years ago
parent
commit
3c27e0fad6
  1. 3
      src/AST/Preprocessor.cs
  2. 5
      src/Generator/Library.cs

3
src/AST/Preprocessor.cs

@ -49,6 +49,9 @@ @@ -49,6 +49,9 @@
// Contains the macro definition text.
public string Expression;
// Backing enumeration if one was generated.
public Enumeration Enumeration;
public override T Visit<T>(IDeclVisitor<T> visitor)
{
return visitor.VisitMacroDefinition(this);

5
src/Generator/Library.cs

@ -136,8 +136,13 @@ namespace CppSharp @@ -136,8 +136,13 @@ namespace CppSharp
var match = regex.Match(macro.Name);
if (!match.Success) continue;
if (macro.Enumeration != null)
continue;
var item = GenerateEnumItemFromMacro(context, macro);
@enum.AddItem(item);
macro.Enumeration = @enum;
}
if (@enum.Items.Count > 0)

Loading…
Cancel
Save