Browse Source

Replaced declaration IgnoreFlags by GenerationKind. Added methods IsInternal and IsDeclared to declaration. Replaced IsGenerated = true by GeneratioKind = GeneratioKind.Internal. Deprecated Ignore, replace Ignore set by ExplicityIgnored, replace Ignore get by IsGenerated, IsInternal or IsDeclared.

Conflicts:
	src/Generator/Passes/CheckOperatorsOverloads.cs
pull/228/merge
marcos henrich 11 years ago committed by triton
parent
commit
3f96bdbfe3
  1. 4
      src/AST/Class.cs
  2. 2
      src/AST/ClassExtensions.cs
  3. 2
      src/AST/ClassLayout.cs
  4. 105
      src/AST/Declaration.cs
  5. 8
      src/AST/Namespace.cs
  6. 12
      src/AST/TranslationUnit.cs
  7. 2
      src/CppParser/Bindings/ParserGen.cs
  8. 8
      src/Generator/AST/Utils.cs
  9. 2
      src/Generator/Generator.cs
  10. 32
      src/Generator/Generators/CLI/CLIHeadersTemplate.cs
  11. 4
      src/Generator/Generators/CLI/CLIMarshal.cs
  12. 30
      src/Generator/Generators/CLI/CLISourcesTemplate.cs
  13. 4
      src/Generator/Generators/CLI/CLITypeReferences.cs
  14. 2
      src/Generator/Generators/CSharp/CSharpMarshal.cs
  15. 110
      src/Generator/Generators/CSharp/CSharpTextTemplate.cs
  16. 1
      src/Generator/Library.cs
  17. 2
      src/Generator/Passes/CheckAmbiguousFunctions.cs
  18. 2
      src/Generator/Passes/CheckDuplicatedNamesPass.cs
  19. 4
      src/Generator/Passes/CheckIgnoredDecls.cs
  20. 27
      src/Generator/Passes/CheckMacrosPass.cs
  21. 63
      src/Generator/Passes/CheckOperatorsOverloads.cs
  22. 4
      src/Generator/Passes/CheckStaticClass.cs
  23. 35
      src/Generator/Passes/CleanUnitPass.cs
  24. 2
      src/Generator/Passes/FunctionToInstanceMethodPass.cs
  25. 2
      src/Generator/Passes/FunctionToStaticMethodPass.cs
  26. 2
      src/Generator/Passes/GenerateInlinesCodePass.cs
  27. 6
      src/Generator/Passes/GetterSetterToPropertyAdvancedPass.cs
  28. 6
      src/Generator/Passes/GetterSetterToPropertyPass.cs
  29. 2
      src/Generator/Passes/MoveFunctionToClassPass.cs
  30. 2
      src/Generator/Passes/MoveOperatorToClassPass.cs
  31. 14
      src/Generator/Passes/MultipleInheritancePass.cs
  32. 6
      src/Generator/Passes/ResolveIncompleteDeclsPass.cs

4
src/AST/Class.cs

@ -149,8 +149,8 @@ namespace CppSharp.AST
{ {
foreach (var @base in Bases) foreach (var @base in Bases)
{ {
if (@base.IsClass && !@base.Class.ExplicityIgnored) if (@base.IsClass && @base.Class.IsDeclared)
return @base.Class; return @base.Class;
} }
return null; return null;

2
src/AST/ClassExtensions.cs

@ -85,7 +85,7 @@ namespace CppSharp.AST
return property; return property;
Declaration decl; Declaration decl;
foreach (var baseClassSpecifier in c.Bases.Where( foreach (var baseClassSpecifier in c.Bases.Where(
b => b.Type.IsTagDecl(out decl) && !b.Class.Ignore)) b => b.Type.IsTagDecl(out decl) && b.Class.IsDeclared))
{ {
property = baseClassSpecifier.Class.GetPropertyByName(propertyName); property = baseClassSpecifier.Class.GetPropertyByName(propertyName);
if (property != null) if (property != null)

2
src/AST/ClassLayout.cs

@ -43,7 +43,7 @@ namespace CppSharp.AST
get get
{ {
return Method != null && return Method != null &&
Method.Ignore && !Method.IsDeclared &&
((Class) Method.Namespace).GetPropertyByConstituentMethod(Method) == null; ((Class) Method.Namespace).GetPropertyByConstituentMethod(Method) == null;
} }
} }

105
src/AST/Declaration.cs

@ -25,13 +25,27 @@ namespace CppSharp.AST
string Mangled { get; set; } string Mangled { get; set; }
} }
[Flags] /// <summary>
public enum IgnoreFlags /// Kind of the generated declaration
/// </summary>
public enum GenerationKind
{ {
None = 0, /// <summary>
Generation = 1 << 0, // Declaration is not generated.
Processing = 1 << 1, /// </summary>
Explicit = 1 << 2 None,
/// <summary>
/// Declaration is generated.
/// </summary>
Generate,
/// <summary>
/// Declaration is generated to be used internally.
/// </summary>
Internal,
/// <summary>
/// Declaration was already generated in a linked assembly.
/// </summary>
Link,
} }
/// <summary> /// <summary>
@ -172,65 +186,71 @@ namespace CppSharp.AST
// Comment associated with declaration. // Comment associated with declaration.
public RawComment Comment; public RawComment Comment;
// Keeps flags to know the type of ignore. private GenerationKind? generationKind;
public IgnoreFlags IgnoreFlags { get; set; }
// Whether the declaration should be generated. public GenerationKind GenerationKind
public virtual bool IsGenerated
{ {
get get
{ {
var isGenerated = !IgnoreFlags.HasFlag(IgnoreFlags.Generation); if(ExplicityIgnored)
return GenerationKind.None;
if (Namespace == null) if (generationKind.HasValue)
return isGenerated; return generationKind.Value;
return isGenerated && Namespace.IsGenerated; if (Namespace != null)
} return Namespace.GenerationKind;
set return GenerationKind.Generate;
{
if (value)
IgnoreFlags &= ~IgnoreFlags.Generation;
else
IgnoreFlags |= IgnoreFlags.Generation;
} }
set { generationKind = value; }
} }
// Whether the declaration was explicitly ignored. /// <summary>
public bool ExplicityIgnored /// Whether the declaration should be generated.
/// </summary>
public virtual bool IsGenerated
{ {
get get
{ {
var isExplicitlyIgnored = IgnoreFlags.HasFlag(IgnoreFlags.Explicit); return GenerationKind == GenerationKind.Generate;
if (Namespace == null)
return isExplicitlyIgnored;
return isExplicitlyIgnored || Namespace.ExplicityIgnored;
} }
}
set /// <summary>
/// Whether the declaration internal bindings should be generated.
/// </summary>
public bool IsInternal
{
get
{ {
if (value) var k = GenerationKind;
IgnoreFlags |= IgnoreFlags.Explicit; return k == GenerationKind.Generate
else || k == GenerationKind.Internal;
IgnoreFlags &= ~IgnoreFlags.Explicit;
} }
} }
// Whether the declaration should be ignored. /// <summary>
public virtual bool Ignore /// Whether a binded version of this declaration is available.
/// </summary>
public bool IsDeclared
{ {
get get
{ {
var isIgnored = IgnoreFlags != IgnoreFlags.None; var k = GenerationKind;
return k == GenerationKind.Generate
|| k == GenerationKind.Internal
|| k == GenerationKind.Link;
}
}
if (Namespace != null) public bool ExplicityIgnored { get; set; }
isIgnored |= Namespace.Ignore;
return isIgnored; [Obsolete("Replace set by ExplicityIgnored. Replace get by IsGenerated, IsInternal or IsDeclared.")]
} public virtual bool Ignore
{
get { return GenerationKind == GenerationKind.None; }
set { ExplicityIgnored = value; }
} }
public AccessSpecifier Access { get; set; } public AccessSpecifier Access { get; set; }
@ -264,7 +284,6 @@ namespace CppSharp.AST
protected Declaration() protected Declaration()
{ {
Access = AccessSpecifier.Public; Access = AccessSpecifier.Public;
IgnoreFlags = IgnoreFlags.None;
ExcludeFromPasses = new HashSet<System.Type>(); ExcludeFromPasses = new HashSet<System.Type>();
PreprocessedEntities = new List<PreprocessedEntity>(); PreprocessedEntities = new List<PreprocessedEntity>();
Attributes = new List<Attribute>(); Attributes = new List<Attribute>();
@ -283,7 +302,7 @@ namespace CppSharp.AST
OriginalName = declaration.OriginalName; OriginalName = declaration.OriginalName;
name = declaration.Name; name = declaration.Name;
Comment = declaration.Comment; Comment = declaration.Comment;
IgnoreFlags = declaration.IgnoreFlags; generationKind = declaration.generationKind;
Access = declaration.Access; Access = declaration.Access;
DebugText = declaration.DebugText; DebugText = declaration.DebugText;
IsIncomplete = declaration.IsIncomplete; IsIncomplete = declaration.IsIncomplete;

8
src/AST/Namespace.cs

@ -335,8 +335,8 @@ namespace CppSharp.AST
public bool HasDeclarations public bool HasDeclarations
{ {
get get
{ {
Predicate<Declaration> pred = (t => !t.Ignore); Predicate<Declaration> pred = (t => t.IsGenerated);
return Enums.Exists(pred) || HasFunctions || Typedefs.Exists(pred) return Enums.Exists(pred) || HasFunctions || Typedefs.Exists(pred)
|| Classes.Any() || Namespaces.Exists(n => n.HasDeclarations); || Classes.Any() || Namespaces.Exists(n => n.HasDeclarations);
} }
@ -345,8 +345,8 @@ namespace CppSharp.AST
public bool HasFunctions public bool HasFunctions
{ {
get get
{ {
Predicate<Declaration> pred = (t => !t.Ignore); Predicate<Declaration> pred = (t => t.IsGenerated);
return Functions.Exists(pred) || Namespaces.Exists(n => n.HasFunctions); return Functions.Exists(pred) || Namespaces.Exists(n => n.HasFunctions);
} }
} }

12
src/AST/TranslationUnit.cs

@ -24,18 +24,6 @@ namespace CppSharp.AST
/// Contains the macros present in the unit. /// Contains the macros present in the unit.
public List<MacroDefinition> Macros; public List<MacroDefinition> Macros;
// Whether the unit should be generated.
public override bool IsGenerated
{
get { return !IgnoreFlags.HasFlag(IgnoreFlags.Generation); }
}
// Whether the unit should be ignored.
public override bool Ignore
{
get { return IgnoreFlags != IgnoreFlags.None; }
}
public bool IsSystemHeader { get; set; } public bool IsSystemHeader { get; set; }
public bool IsValid { get { return FilePath != "<invalid>"; } } public bool IsValid { get { return FilePath != "<invalid>"; } }

2
src/CppParser/Bindings/ParserGen.cs

@ -145,7 +145,7 @@ namespace CppSharp
{ {
public override bool VisitFieldDecl(Field field) public override bool VisitFieldDecl(Field field)
{ {
if (field.Ignore) if (!field.IsGenerated)
return false; return false;
if (!IsStdType(field.QualifiedType)) return false; if (!IsStdType(field.QualifiedType)) return false;

8
src/Generator/AST/Utils.cs

@ -9,7 +9,7 @@ namespace CppSharp.AST
{ {
public static bool CheckIgnoreFunction(Function function, DriverOptions options) public static bool CheckIgnoreFunction(Function function, DriverOptions options)
{ {
if (function.Ignore) return true; if (!function.IsGenerated) return true;
if (function is Method) if (function is Method)
return CheckIgnoreMethod(function as Method, options); return CheckIgnoreMethod(function as Method, options);
@ -19,7 +19,7 @@ namespace CppSharp.AST
public static bool CheckIgnoreMethod(Method method, DriverOptions options) public static bool CheckIgnoreMethod(Method method, DriverOptions options)
{ {
if (method.Ignore) return true; if (!method.IsGenerated) return true;
var isEmptyCtor = method.IsConstructor && method.Parameters.Count == 0; var isEmptyCtor = method.IsConstructor && method.Parameters.Count == 0;
@ -52,7 +52,7 @@ namespace CppSharp.AST
var copyConstructor = baseClass.Methods.FirstOrDefault(m => m.IsCopyConstructor); var copyConstructor = baseClass.Methods.FirstOrDefault(m => m.IsCopyConstructor);
if (copyConstructor == null if (copyConstructor == null
|| copyConstructor.Access == AccessSpecifier.Private || copyConstructor.Access == AccessSpecifier.Private
|| copyConstructor.Ignore) || !copyConstructor.IsDeclared)
return true; return true;
} }
} }
@ -65,7 +65,7 @@ namespace CppSharp.AST
if (field.Access == AccessSpecifier.Private) if (field.Access == AccessSpecifier.Private)
return true; return true;
return field.Ignore; return !field.IsGenerated;
} }
} }

2
src/Generator/Generator.cs

@ -68,7 +68,7 @@ namespace CppSharp.Generators
foreach (var unit in Driver.ASTContext.TranslationUnits) foreach (var unit in Driver.ASTContext.TranslationUnits)
{ {
if (unit.Ignore || !unit.HasDeclarations) if (!unit.IsGenerated || !unit.HasDeclarations)
continue; continue;
if (unit.IsSystemHeader) if (unit.IsSystemHeader)

32
src/Generator/Generators/CLI/CLIHeadersTemplate.cs

@ -68,8 +68,8 @@ namespace CppSharp.Generators.CLI
var include = typeRef.Include; var include = typeRef.Include;
var unit = include.TranslationUnit; var unit = include.TranslationUnit;
if (unit != null && unit.ExplicityIgnored) if (unit != null && !unit.IsDeclared)
continue; continue;
if(!string.IsNullOrEmpty(include.File) && include.InHeader) if(!string.IsNullOrEmpty(include.File) && include.InHeader)
@ -151,7 +151,7 @@ namespace CppSharp.Generators.CLI
// Generate all the enum declarations for the module. // Generate all the enum declarations for the module.
foreach (var @enum in decl.Enums) foreach (var @enum in decl.Enums)
{ {
if (@enum.Ignore || @enum.IsIncomplete) if (!@enum.IsGenerated || @enum.IsIncomplete)
continue; continue;
PushBlock(CLIBlockKind.Enum, @enum); PushBlock(CLIBlockKind.Enum, @enum);
@ -165,7 +165,7 @@ namespace CppSharp.Generators.CLI
// Generate all the struct/class declarations for the module. // Generate all the struct/class declarations for the module.
foreach (var @class in decl.Classes) foreach (var @class in decl.Classes)
{ {
if (@class.Ignore || @class.IsIncomplete) if (!@class.IsGenerated || @class.IsIncomplete)
continue; continue;
if (@class.IsOpaque) if (@class.IsOpaque)
@ -210,7 +210,7 @@ namespace CppSharp.Generators.CLI
{ {
foreach (var typedef in decl.Typedefs) foreach (var typedef in decl.Typedefs)
{ {
if (typedef.Ignore) if (!typedef.IsGenerated)
continue; continue;
GenerateTypedef(typedef); GenerateTypedef(typedef);
@ -240,7 +240,7 @@ namespace CppSharp.Generators.CLI
public void GenerateClass(Class @class) public void GenerateClass(Class @class)
{ {
if (@class.Ignore || @class.IsIncomplete) if (!@class.IsGenerated || @class.IsIncomplete)
return; return;
GenerateDeclarationCommon(@class); GenerateDeclarationCommon(@class);
@ -306,7 +306,7 @@ namespace CppSharp.Generators.CLI
PushIndent(); PushIndent();
foreach (var template in @class.Templates) foreach (var template in @class.Templates)
{ {
if (template.Ignore) continue; if (!template.IsGenerated) continue;
var functionTemplate = template as FunctionTemplate; var functionTemplate = template as FunctionTemplate;
if (functionTemplate == null) continue; if (functionTemplate == null) continue;
@ -417,7 +417,7 @@ namespace CppSharp.Generators.CLI
// properties to the managed value subtypes. // properties to the managed value subtypes.
if (@class.IsValueType) if (@class.IsValueType)
{ {
foreach (var @base in @class.Bases.Where(b => b.IsClass && !b.Class.Ignore)) foreach (var @base in @class.Bases.Where(b => b.IsClass && b.Class.IsGenerated))
{ {
GenerateClassFields(@base.Class); GenerateClassFields(@base.Class);
} }
@ -426,7 +426,7 @@ namespace CppSharp.Generators.CLI
PushIndent(); PushIndent();
// check for value types because some of the ignored fields may back properties; // check for value types because some of the ignored fields may back properties;
// not the case for ref types because the NativePtr pattern is used there // not the case for ref types because the NativePtr pattern is used there
foreach (var field in @class.Fields.Where(f => !f.Ignore || @class.IsValueType)) foreach (var field in @class.Fields.Where(f => f.IsGenerated || @class.IsValueType))
{ {
var property = @class.Properties.FirstOrDefault(p => p.Field == field); var property = @class.Properties.FirstOrDefault(p => p.Field == field);
if (property != null && !property.IsInRefTypeAndBackedByValueClassField()) if (property != null && !property.IsInRefTypeAndBackedByValueClassField())
@ -454,7 +454,7 @@ namespace CppSharp.Generators.CLI
{ {
foreach (var @event in @class.Events) foreach (var @event in @class.Events)
{ {
if (@event.Ignore) continue; if (!@event.IsGenerated) continue;
var cppTypePrinter = new CppTypePrinter(Driver.TypeDatabase); var cppTypePrinter = new CppTypePrinter(Driver.TypeDatabase);
var cppArgs = cppTypePrinter.VisitParameters(@event.Parameters, hasNames: true); var cppArgs = cppTypePrinter.VisitParameters(@event.Parameters, hasNames: true);
@ -522,7 +522,7 @@ namespace CppSharp.Generators.CLI
foreach(var variable in @class.Variables) foreach(var variable in @class.Variables)
{ {
if (variable.Ignore) continue; if (!variable.IsGenerated) continue;
if (variable.Access != AccessSpecifier.Public) if (variable.Access != AccessSpecifier.Public)
continue; continue;
@ -592,14 +592,14 @@ namespace CppSharp.Generators.CLI
// properties to the managed value subtypes. // properties to the managed value subtypes.
if (@class.IsValueType) if (@class.IsValueType)
{ {
foreach (var @base in @class.Bases.Where(b => b.IsClass && !b.Class.Ignore)) foreach (var @base in @class.Bases.Where(b => b.IsClass && b.Class.IsGenerated))
{ {
GenerateClassProperties(@base.Class); GenerateClassProperties(@base.Class);
} }
} }
PushIndent(); PushIndent();
foreach (var prop in @class.Properties.Where(prop => !prop.Ignore)) foreach (var prop in @class.Properties.Where(prop => prop.IsGenerated))
{ {
if (prop.IsInRefTypeAndBackedByValueClassField()) if (prop.IsInRefTypeAndBackedByValueClassField())
{ {
@ -701,7 +701,7 @@ namespace CppSharp.Generators.CLI
public bool GenerateTypedef(TypedefDecl typedef) public bool GenerateTypedef(TypedefDecl typedef)
{ {
if (typedef.Ignore) if (!typedef.IsGenerated)
return false; return false;
FunctionType function; FunctionType function;
@ -726,7 +726,7 @@ namespace CppSharp.Generators.CLI
public void GenerateFunction(Function function) public void GenerateFunction(Function function)
{ {
if (function.Ignore) if (!function.IsGenerated)
return; return;
PushBlock(CLIBlockKind.Function, function); PushBlock(CLIBlockKind.Function, function);
@ -745,7 +745,7 @@ namespace CppSharp.Generators.CLI
public void GenerateEnum(Enumeration @enum) public void GenerateEnum(Enumeration @enum)
{ {
if (@enum.Ignore || @enum.IsIncomplete) if (!@enum.IsGenerated || @enum.IsIncomplete)
return; return;
PushBlock(CLIBlockKind.Enum, @enum); PushBlock(CLIBlockKind.Enum, @enum);

4
src/Generator/Generators/CLI/CLIMarshal.cs

@ -618,14 +618,14 @@ namespace CppSharp.Generators.CLI
public void MarshalValueClassProperties(Class @class, string marshalVar) public void MarshalValueClassProperties(Class @class, string marshalVar)
{ {
foreach (var @base in @class.Bases.Where(b => b.IsClass && !b.Class.Ignore)) foreach (var @base in @class.Bases.Where(b => b.IsClass && b.Class.IsGenerated))
{ {
MarshalValueClassProperties(@base.Class, marshalVar); MarshalValueClassProperties(@base.Class, marshalVar);
} }
foreach (var property in @class.Properties) foreach (var property in @class.Properties)
{ {
if (property.Ignore || property.Field == null) if (!property.IsGenerated || property.Field == null)
continue; continue;
MarshalValueClassProperty(property, marshalVar); MarshalValueClassProperty(property, marshalVar);

30
src/Generator/Generators/CLI/CLISourcesTemplate.cs

@ -86,7 +86,7 @@ namespace CppSharp.Generators.CLI
PushBlock(CLIBlockKind.Namespace); PushBlock(CLIBlockKind.Namespace);
foreach (var @class in @namespace.Classes) foreach (var @class in @namespace.Classes)
{ {
if (@class.Ignore) if (!@class.IsGenerated)
continue; continue;
if (@class.IsOpaque || @class.IsIncomplete) if (@class.IsOpaque || @class.IsIncomplete)
@ -100,7 +100,7 @@ namespace CppSharp.Generators.CLI
// Generate all the function declarations for the module. // Generate all the function declarations for the module.
foreach (var function in @namespace.Functions) foreach (var function in @namespace.Functions)
{ {
if (function.Ignore) if (!function.IsGenerated)
continue; continue;
GenerateFunction(function, @namespace); GenerateFunction(function, @namespace);
@ -112,12 +112,12 @@ namespace CppSharp.Generators.CLI
{ {
foreach (var template in @namespace.Templates) foreach (var template in @namespace.Templates)
{ {
if (template.Ignore) continue; if (!template.IsGenerated) continue;
var functionTemplate = template as FunctionTemplate; var functionTemplate = template as FunctionTemplate;
if (functionTemplate == null) continue; if (functionTemplate == null) continue;
if (functionTemplate.Ignore) if (!functionTemplate.IsGenerated)
continue; continue;
GenerateFunctionTemplate(functionTemplate); GenerateFunctionTemplate(functionTemplate);
@ -174,7 +174,7 @@ namespace CppSharp.Generators.CLI
foreach (var @event in @class.Events) foreach (var @event in @class.Events)
{ {
if (@event.Ignore) if (!@event.IsGenerated)
continue; continue;
GenerateDeclarationCommon(@event); GenerateDeclarationCommon(@event);
@ -183,7 +183,7 @@ namespace CppSharp.Generators.CLI
foreach (var variable in @class.Variables) foreach (var variable in @class.Variables)
{ {
if (variable.Ignore) if (!variable.IsGenerated)
continue; continue;
if (variable.Access != AccessSpecifier.Public) if (variable.Access != AccessSpecifier.Public)
@ -216,14 +216,14 @@ namespace CppSharp.Generators.CLI
{ {
if (@class.IsValueType) if (@class.IsValueType)
{ {
foreach (var @base in @class.Bases.Where(b => b.IsClass && !b.Class.Ignore)) foreach (var @base in @class.Bases.Where(b => b.IsClass && b.Class.IsGenerated))
{ {
GenerateClassProperties(@base.Class, realOwner); GenerateClassProperties(@base.Class, realOwner);
} }
} }
foreach (var property in @class.Properties.Where( foreach (var property in @class.Properties.Where(
p => !p.Ignore && !p.IsInRefTypeAndBackedByValueClassField())) p => p.IsGenerated && !p.IsInRefTypeAndBackedByValueClassField()))
GenerateProperty(property, realOwner); GenerateProperty(property, realOwner);
} }
@ -309,7 +309,7 @@ namespace CppSharp.Generators.CLI
private void GenerateProperty(Property property, Class realOwner) private void GenerateProperty(Property property, Class realOwner)
{ {
if (property.Ignore) return; if (!property.IsGenerated) return;
PushBlock(CLIBlockKind.Property); PushBlock(CLIBlockKind.Property);
@ -628,14 +628,14 @@ namespace CppSharp.Generators.CLI
private void GenerateStructMarshaling(Class @class, string nativeVar) private void GenerateStructMarshaling(Class @class, string nativeVar)
{ {
foreach (var @base in @class.Bases.Where(b => b.IsClass && !b.Class.Ignore)) foreach (var @base in @class.Bases.Where(b => b.IsClass && b.Class.IsGenerated))
{ {
GenerateStructMarshaling(@base.Class, nativeVar); GenerateStructMarshaling(@base.Class, nativeVar);
} }
foreach (var property in @class.Properties) foreach (var property in @class.Properties)
{ {
if (property.Ignore || property.Field == null) continue; if (!property.IsGenerated || property.Field == null) continue;
var nativeField = string.Format("{0}{1}", var nativeField = string.Format("{0}{1}",
nativeVar, property.Field.OriginalName); nativeVar, property.Field.OriginalName);
@ -659,7 +659,7 @@ namespace CppSharp.Generators.CLI
private bool GenerateClassConstructorBase(Class @class, bool isIntPtr, Method method = null) private bool GenerateClassConstructorBase(Class @class, bool isIntPtr, Method method = null)
{ {
var hasBase = @class.HasBase && @class.Bases[0].IsClass && !@class.Bases[0].Class.ExplicityIgnored; var hasBase = @class.HasBase && @class.Bases[0].IsClass && @class.Bases[0].Class.IsDeclared;
if (!hasBase) if (!hasBase)
return false; return false;
@ -777,14 +777,14 @@ namespace CppSharp.Generators.CLI
private void GenerateValueTypeConstructorCallProperties(Class @class) private void GenerateValueTypeConstructorCallProperties(Class @class)
{ {
foreach (var @base in @class.Bases.Where(b => b.IsClass && !b.Class.ExplicityIgnored)) foreach (var @base in @class.Bases.Where(b => b.IsClass && b.Class.IsDeclared))
{ {
GenerateValueTypeConstructorCallProperties(@base.Class); GenerateValueTypeConstructorCallProperties(@base.Class);
} }
foreach (var property in @class.Properties) foreach (var property in @class.Properties)
{ {
if (property.ExplicityIgnored || property.Field == null) continue; if (!property.IsDeclared || property.Field == null) continue;
var varName = string.Format("_native.{0}", property.Field.OriginalName); var varName = string.Format("_native.{0}", property.Field.OriginalName);
@ -806,7 +806,7 @@ namespace CppSharp.Generators.CLI
public void GenerateFunction(Function function, DeclarationContext @namespace) public void GenerateFunction(Function function, DeclarationContext @namespace)
{ {
if (function.Ignore) if (!function.IsGenerated)
return; return;
GenerateDeclarationCommon(function); GenerateDeclarationCommon(function);

4
src/Generator/Generators/CLI/CLITypeReferences.cs

@ -115,7 +115,7 @@ namespace CppSharp.Generators.CLI
if (translationUnit.IsSystemHeader) if (translationUnit.IsSystemHeader)
return; return;
if(decl.ExplicityIgnored) if(!decl.IsDeclared)
return; return;
if(IsBuiltinTypedef(decl)) if(IsBuiltinTypedef(decl))
@ -181,7 +181,7 @@ namespace CppSharp.Generators.CLI
if (decl.Namespace != null && decl.Namespace.TranslationUnit.IsSystemHeader) if (decl.Namespace != null && decl.Namespace.TranslationUnit.IsSystemHeader)
return false; return false;
return !decl.ExplicityIgnored; return decl.IsDeclared;
} }
public override bool VisitClassDecl(Class @class) public override bool VisitClassDecl(Class @class)

2
src/Generator/Generators/CSharp/CSharpMarshal.cs

@ -268,7 +268,7 @@ namespace CppSharp.Generators.CSharp
// Call the copy constructor. // Call the copy constructor.
TypeMap typeMap; TypeMap typeMap;
if (copyCtorMethod.Ignore && FindTypeMap(ctx.Driver.TypeDatabase, @class, out typeMap)) if (!copyCtorMethod.IsGenerated && FindTypeMap(ctx.Driver.TypeDatabase, @class, out typeMap))
{ {
typeMap.CSharpMarshalCopyCtorToManaged(Context); typeMap.CSharpMarshalCopyCtorToManaged(Context);
} }

110
src/Generator/Generators/CSharp/CSharpTextTemplate.cs

@ -203,8 +203,8 @@ namespace CppSharp.Generators.CSharp
// Generate all the enum declarations. // Generate all the enum declarations.
foreach (var @enum in context.Enums) foreach (var @enum in context.Enums)
{ {
if (@enum.Ignore || @enum.IsIncomplete) if (!@enum.IsGenerated || @enum.IsIncomplete)
continue; continue;
GenerateEnum(@enum); GenerateEnum(@enum);
@ -241,8 +241,8 @@ namespace CppSharp.Generators.CSharp
// Generate all the internal function declarations. // Generate all the internal function declarations.
foreach (var function in context.Functions) foreach (var function in context.Functions)
{ {
if (function.Ignore) continue; if (!function.IsInternal) continue;
GenerateInternalFunction(function); GenerateInternalFunction(function);
} }
@ -251,8 +251,8 @@ namespace CppSharp.Generators.CSharp
PopBlock(NewLineKind.BeforeNextBlock); PopBlock(NewLineKind.BeforeNextBlock);
foreach (var function in context.Functions) foreach (var function in context.Functions)
{ {
if (function.Ignore) continue; if (!function.IsGenerated) continue;
GenerateFunction(function); GenerateFunction(function);
} }
@ -262,8 +262,8 @@ namespace CppSharp.Generators.CSharp
} }
foreach (var @event in context.Events) foreach (var @event in context.Events)
{ {
if (@event.Ignore) continue; if (!@event.IsGenerated) continue;
GenerateEvent(@event); GenerateEvent(@event);
} }
@ -350,9 +350,9 @@ namespace CppSharp.Generators.CSharp
GenerateClassInternals(@class); GenerateClassInternals(@class);
GenerateDeclContext(@class); GenerateDeclContext(@class);
if (@class.Ignore || @class.IsDependent) if (!@class.IsGenerated || @class.IsDependent)
goto exit; goto exit;
if (ShouldGenerateClassNativeField(@class)) if (ShouldGenerateClassNativeField(@class))
{ {
PushBlock(CSharpBlockKind.Field); PushBlock(CSharpBlockKind.Field);
@ -403,8 +403,8 @@ namespace CppSharp.Generators.CSharp
} }
private void GenerateInterface(Class @class) private void GenerateInterface(Class @class)
{ {
if (@class.Ignore || @class.IsIncomplete) if (!@class.IsGenerated || @class.IsIncomplete)
return; return;
PushBlock(CSharpBlockKind.Interface); PushBlock(CSharpBlockKind.Interface);
@ -432,8 +432,8 @@ namespace CppSharp.Generators.CSharp
WriteLine(");"); WriteLine(");");
PopBlock(NewLineKind.BeforeNextBlock); PopBlock(NewLineKind.BeforeNextBlock);
} }
foreach (var prop in @class.Properties.Where(p => !p.Ignore)) foreach (var prop in @class.Properties.Where(p => p.IsGenerated))
{ {
PushBlock(CSharpBlockKind.Property); PushBlock(CSharpBlockKind.Property);
var type = prop.Type; var type = prop.Type;
@ -595,8 +595,8 @@ namespace CppSharp.Generators.CSharp
private void GenerateStructMarshalingProperties(Class @class) private void GenerateStructMarshalingProperties(Class @class)
{ {
foreach (var @base in @class.Bases) foreach (var @base in @class.Bases)
{ {
if (!@base.IsClass || @base.Class.Ignore) if (!@base.IsClass || !@base.Class.IsGenerated)
continue; continue;
GenerateStructMarshalingProperties(@base.Class); GenerateStructMarshalingProperties(@base.Class);
@ -604,8 +604,8 @@ namespace CppSharp.Generators.CSharp
for (int i = 0; i < @class.Properties.Count; i++) for (int i = 0; i < @class.Properties.Count; i++)
{ {
var property = @class.Properties[i]; var property = @class.Properties[i];
if (property.Ignore || property.Field == null) continue; if (!property.IsGenerated || property.Field == null) continue;
var nativeField = string.Format("{0}->{1}", var nativeField = string.Format("{0}->{1}",
Generator.GeneratedIdentifier("ptr"), Generator.GeneratedIdentifier("ptr"),
@ -646,8 +646,8 @@ namespace CppSharp.Generators.CSharp
private void GenerateStructInternalMarshalingProperties(Class @class, string marshalVar) private void GenerateStructInternalMarshalingProperties(Class @class, string marshalVar)
{ {
foreach (var @base in @class.Bases) foreach (var @base in @class.Bases)
{ {
if (!@base.IsClass || @base.Class.Ignore) if (!@base.IsClass || !@base.Class.IsGenerated)
continue; continue;
var baseClass = @base.Class; var baseClass = @base.Class;
@ -655,8 +655,8 @@ namespace CppSharp.Generators.CSharp
} }
foreach (var property in @class.Properties) foreach (var property in @class.Properties)
{ {
if (property.Ignore || property.Field == null) if (!property.IsGenerated || property.Field == null)
continue; continue;
GenerateStructInternalMarshalingProperty(property, marshalVar); GenerateStructInternalMarshalingProperty(property, marshalVar);
@ -710,7 +710,7 @@ namespace CppSharp.Generators.CSharp
baseClass = @class.Bases[0].Class; baseClass = @class.Bases[0].Class;
var hasRefBase = baseClass != null && baseClass.IsRefType var hasRefBase = baseClass != null && baseClass.IsRefType
&& !baseClass.ExplicityIgnored; && baseClass.IsDeclared;
return hasRefBase; return hasRefBase;
} }
@ -723,9 +723,9 @@ namespace CppSharp.Generators.CSharp
public void GenerateClassProlog(Class @class) public void GenerateClassProlog(Class @class)
{ {
if (@class.IsUnion) if (@class.IsUnion)
WriteLine("[StructLayout(LayoutKind.Explicit)]"); WriteLine("[StructLayout(LayoutKind.Explicit)]");
Write(@class.Ignore ? "internal " : Helpers.GetAccess(@class.Access)); Write(!@class.IsGenerated ? "internal " : Helpers.GetAccess(@class.Access));
Write("unsafe "); Write("unsafe ");
if (Driver.Options.GenerateAbstractImpls && @class.IsAbstract) if (Driver.Options.GenerateAbstractImpls && @class.IsAbstract)
@ -737,11 +737,11 @@ namespace CppSharp.Generators.CSharp
Write(@class.IsInterface ? "interface " : (@class.IsValueType ? "struct " : "class ")); Write(@class.IsInterface ? "interface " : (@class.IsValueType ? "struct " : "class "));
Write("{0}", @class.Name); Write("{0}", @class.Name);
var bases = new List<string>(); var bases = new List<string>();
var needsBase = @class.HasBaseClass && !@class.IsValueType && !@class.Ignore var needsBase = @class.HasBaseClass && !@class.IsValueType && @class.IsGenerated
&& !@class.Bases[0].Class.IsValueType && !@class.Bases[0].Class.IsValueType
&& !@class.Bases[0].Class.Ignore; && @class.Bases[0].Class.IsGenerated;
if (needsBase) if (needsBase)
{ {
@ -749,9 +749,9 @@ namespace CppSharp.Generators.CSharp
from @base in @class.Bases from @base in @class.Bases
where @base.IsClass where @base.IsClass
select QualifiedIdentifier(@base.Class)); select QualifiedIdentifier(@base.Class));
} }
if (!@class.Ignore) if (@class.IsGenerated)
{ {
if (@class.IsRefType) if (@class.IsRefType)
bases.Add("IDisposable"); bases.Add("IDisposable");
@ -770,8 +770,8 @@ namespace CppSharp.Generators.CSharp
{ {
foreach (var @base in @class.Bases.Where(b => !(b.Type is DependentNameType))) foreach (var @base in @class.Bases.Where(b => !(b.Type is DependentNameType)))
{ {
TypeMap typeMap; TypeMap typeMap;
if ((!Driver.TypeDatabase.FindTypeMap(@base.Type, out typeMap) && @base.Class.Ignore) || if ((!Driver.TypeDatabase.FindTypeMap(@base.Type, out typeMap) && !@base.Class.IsGenerated) ||
@base.Class.OriginalClass == @class) @base.Class.OriginalClass == @class)
continue; continue;
@ -806,13 +806,13 @@ namespace CppSharp.Generators.CSharp
if (field.Expression != null) if (field.Expression != null)
{ {
var fieldValuePrinted = field.Expression.CSharpValue(ExpressionPrinter); var fieldValuePrinted = field.Expression.CSharpValue(ExpressionPrinter);
Write("{0} {1} {2} = {3};", field.Ignore ? "internal" : "public", Write("{0} {1} {2} = {3};", !field.IsGenerated ? "internal" : "public",
fieldTypePrinted.Type, safeIdentifier, fieldValuePrinted); fieldTypePrinted.Type, safeIdentifier, fieldValuePrinted);
} }
else else
{ {
Write("{0} {1} {2};", field.Ignore ? "internal" : "public", Write("{0} {1} {2};", !field.IsGenerated ? "internal" : "public",
fieldTypePrinted.Type, safeIdentifier); fieldTypePrinted.Type, safeIdentifier);
} }
@ -1167,8 +1167,8 @@ namespace CppSharp.Generators.CSharp
public void GenerateClassVariables(Class @class) public void GenerateClassVariables(Class @class)
{ {
foreach (var variable in @class.Variables) foreach (var variable in @class.Variables)
{ {
if (variable.Ignore) continue; if (!variable.IsGenerated) continue;
if (variable.Access != AccessSpecifier.Public) if (variable.Access != AccessSpecifier.Public)
continue; continue;
@ -1182,8 +1182,8 @@ namespace CppSharp.Generators.CSharp
private void GenerateClassProperties(Class @class) private void GenerateClassProperties(Class @class)
{ {
if (@class.IsValueType) if (@class.IsValueType)
{ {
foreach (var @base in @class.Bases.Where(b => b.IsClass && !b.Class.Ignore)) foreach (var @base in @class.Bases.Where(b => b.IsClass && b.Class.IsGenerated))
{ {
GenerateClassProperties(@base.Class); GenerateClassProperties(@base.Class);
} }
@ -1193,8 +1193,8 @@ namespace CppSharp.Generators.CSharp
} }
private void GenerateProperties(Class @class) private void GenerateProperties(Class @class)
{ {
foreach (var prop in @class.Properties.Where(p => !p.Ignore)) foreach (var prop in @class.Properties.Where(p => p.IsGenerated))
{ {
if (prop.IsInRefTypeAndBackedByValueClassField()) if (prop.IsInRefTypeAndBackedByValueClassField())
{ {
@ -1513,8 +1513,8 @@ namespace CppSharp.Generators.CSharp
var marshals = new List<string>(); var marshals = new List<string>();
for (int i = 0; i < method.Parameters.Count; i++) for (int i = 0; i < method.Parameters.Count; i++)
{ {
var param = method.Parameters[i]; var param = method.Parameters[i];
if (param.Ignore) if (!param.IsGenerated)
continue; continue;
if (param.Kind == ParameterKind.IndirectReturnType) if (param.Kind == ParameterKind.IndirectReturnType)
@ -1957,7 +1957,7 @@ namespace CppSharp.Generators.CSharp
private bool GenerateClassConstructorBase(Class @class, Method method) private bool GenerateClassConstructorBase(Class @class, Method method)
{ {
var hasBase = @class.HasBaseClass && !@class.Bases[0].Class.Ignore; var hasBase = @class.HasBaseClass && @class.Bases[0].Class.IsGenerated;
if (hasBase && !@class.IsValueType) if (hasBase && !@class.IsValueType)
{ {
@ -2528,8 +2528,8 @@ namespace CppSharp.Generators.CSharp
#endregion #endregion
public bool GenerateTypedef(TypedefDecl typedef) public bool GenerateTypedef(TypedefDecl typedef)
{ {
if (typedef.Ignore) if (!typedef.IsGenerated)
return false; return false;
GenerateDeclarationCommon(typedef); GenerateDeclarationCommon(typedef);
@ -2562,8 +2562,8 @@ namespace CppSharp.Generators.CSharp
} }
public void GenerateEnum(Enumeration @enum) public void GenerateEnum(Enumeration @enum)
{ {
if (@enum.Ignore) return; if (!@enum.IsGenerated) return;
PushBlock(CSharpBlockKind.Enum); PushBlock(CSharpBlockKind.Enum);
GenerateDeclarationCommon(@enum); GenerateDeclarationCommon(@enum);
@ -2654,7 +2654,7 @@ namespace CppSharp.Generators.CSharp
public void GenerateInternalFunction(Function function) public void GenerateInternalFunction(Function function)
{ {
if (function.ExplicityIgnored || function.IsPure) if (!function.IsInternal || function.IsPure)
return; return;
if (function.OriginalFunction != null) if (function.OriginalFunction != null)

1
src/Generator/Library.cs

@ -334,7 +334,6 @@ namespace CppSharp
foreach (var unit in units) foreach (var unit in units)
{ {
unit.IsGenerated = false;
unit.ExplicityIgnored = true; unit.ExplicityIgnored = true;
} }
} }

2
src/Generator/Passes/CheckAmbiguousFunctions.cs

@ -40,7 +40,7 @@ namespace CppSharp.Passes
if (overload == function) continue; if (overload == function) continue;
if (overload.Ignore) continue; if (!overload.IsGenerated) continue;
if (!CheckDefaultParameters(function, overload)) if (!CheckDefaultParameters(function, overload))
continue; continue;

2
src/Generator/Passes/CheckDuplicatedNamesPass.cs

@ -180,7 +180,7 @@ namespace CppSharp.Passes
void CheckDuplicate(Declaration decl) void CheckDuplicate(Declaration decl)
{ {
if (decl.IsDependent || decl.Ignore) if (decl.IsDependent || !decl.IsGenerated)
return; return;
if (string.IsNullOrWhiteSpace(decl.Name)) if (string.IsNullOrWhiteSpace(decl.Name))

4
src/Generator/Passes/CheckIgnoredDecls.cs

@ -168,7 +168,7 @@ namespace CppSharp.Passes
if (method.IsOverride) if (method.IsOverride)
{ {
var baseOverride = @class.GetRootBaseMethod(method); var baseOverride = @class.GetRootBaseMethod(method);
if (baseOverride != null && baseOverride.Ignore) if (baseOverride != null && !baseOverride.IsDeclared)
{ {
Log.Debug( Log.Debug(
"Virtual method '{0}' was ignored due to ignored override '{1}'", "Virtual method '{0}' was ignored due to ignored override '{1}'",
@ -199,7 +199,7 @@ namespace CppSharp.Passes
continue; continue;
ignoredBase = @base; ignoredBase = @base;
isIgnored |= @base.Ignore isIgnored |= !@base.IsDeclared
|| HasIgnoredBaseClass(@override, @base, out ignoredBase); || HasIgnoredBaseClass(@override, @base, out ignoredBase);
if (isIgnored) if (isIgnored)

27
src/Generator/Passes/CheckMacrosPass.cs

@ -74,22 +74,21 @@ namespace CppSharp.Passes
e.Location != MacroLocation.ClassBody && e.Location != MacroLocation.ClassBody &&
e.Location != MacroLocation.FunctionBody && e.Location != MacroLocation.FunctionBody &&
e.Location != MacroLocation.FunctionParameters)) e.Location != MacroLocation.FunctionParameters))
decl.IsGenerated = false; decl.GenerationKind = GenerationKind.Link;
}
public override bool VisitTranslationUnit(TranslationUnit unit)
{
var expansions = unit.PreprocessedEntities.OfType<MacroExpansion>();
if (expansions.Any(e => e.Text == Prefix + "_IGNORE_FILE"))
{
unit.ExplicityIgnored = true;
}
return base.VisitTranslationUnit(unit);
} }
public override bool VisitTranslationUnit(TranslationUnit unit)
{
var expansions = unit.PreprocessedEntities.OfType<MacroExpansion>();
if (expansions.Any(e => e.Text == Prefix + "_IGNORE_FILE"))
{
unit.IsGenerated = false;
unit.ExplicityIgnored = true;
}
return base.VisitTranslationUnit(unit);
}
public override bool VisitClassDecl(Class @class) public override bool VisitClassDecl(Class @class)
{ {
var expansions = @class.PreprocessedEntities.OfType<MacroExpansion>(); var expansions = @class.PreprocessedEntities.OfType<MacroExpansion>();

63
src/Generator/Passes/CheckOperatorsOverloads.cs

@ -47,7 +47,7 @@ namespace CppSharp.Passes
private void CheckInvalidOperators(Class @class) private void CheckInvalidOperators(Class @class)
{ {
foreach (var @operator in @class.Operators.Where(o => !o.Ignore)) foreach (var @operator in @class.Operators.Where(o => o.IsGenerated))
{ {
if (!IsValidOperatorOverload(@operator)) if (!IsValidOperatorOverload(@operator))
{ {
@ -95,28 +95,29 @@ namespace CppSharp.Passes
Access = @operator.Access, Access = @operator.Access,
Namespace = @class, Namespace = @class,
GetMethod = @operator GetMethod = @operator
}; };
if (!@operator.ReturnType.Qualifiers.IsConst && @operator.ReturnType.Type.IsAddress()) if (!@operator.ReturnType.Qualifiers.IsConst && @operator.ReturnType.Type.IsAddress())
property.SetMethod = @operator; property.SetMethod = @operator;
if (Driver.Options.IsCLIGenerator) if (Driver.Options.IsCLIGenerator)
{ {
// If we've a setter use the pointee as the type of the property. // If we've a setter use the pointee as the type of the property.
var pointerType = property.Type as PointerType; var pointerType = property.Type as PointerType;
if (pointerType != null && property.HasSetter) if (pointerType != null && property.HasSetter)
{ {
property.QualifiedType = new QualifiedType(pointerType.Pointee, property.QualifiedType.Qualifiers); property.QualifiedType = new QualifiedType(pointerType.Pointee, property.QualifiedType.Qualifiers);
property.GetMethod.ReturnType = property.QualifiedType; property.GetMethod.ReturnType = property.QualifiedType;
} }
// C++/CLI uses "default" as the indexer property name. // C++/CLI uses "default" as the indexer property name.
property.Name = "default"; property.Name = "default";
} }
property.Parameters.AddRange(@operator.Parameters); property.Parameters.AddRange(@operator.Parameters);
@class.Properties.Add(property); @class.Properties.Add(property);
@operator.IsGenerated = false;
@operator.GenerationKind = GenerationKind.Internal;
} }
static void HandleMissingOperatorOverloadPair(Class @class, CXXOperatorKind op1, static void HandleMissingOperatorOverloadPair(Class @class, CXXOperatorKind op1,
@ -129,7 +130,7 @@ namespace CppSharp.Passes
var missingKind = CheckMissingOperatorOverloadPair(@class, out index, op1, op2, var missingKind = CheckMissingOperatorOverloadPair(@class, out index, op1, op2,
op.Parameters.Last().Type); op.Parameters.Last().Type);
if (missingKind == CXXOperatorKind.None || op.Ignore) if (missingKind == CXXOperatorKind.None || !op.IsGenerated)
continue; continue;
var method = new Method() var method = new Method()
@ -158,13 +159,13 @@ namespace CppSharp.Passes
var hasFirst = first != null; var hasFirst = first != null;
var hasSecond = second != null; var hasSecond = second != null;
if (hasFirst && (!hasSecond || second.Ignore)) if (hasFirst && (!hasSecond || !second.IsGenerated))
{ {
index = @class.Methods.IndexOf(first); index = @class.Methods.IndexOf(first);
return op2; return op2;
} }
if (hasSecond && (!hasFirst || first.Ignore)) if (hasSecond && (!hasFirst || !first.IsGenerated))
{ {
index = @class.Methods.IndexOf(second); index = @class.Methods.IndexOf(second);
return op1; return op1;
@ -196,18 +197,18 @@ namespace CppSharp.Passes
// The array indexing operator can be overloaded // The array indexing operator can be overloaded
case CXXOperatorKind.Subscript: case CXXOperatorKind.Subscript:
// The conversion operator can be overloaded // The conversion operator can be overloaded
case CXXOperatorKind.Conversion: case CXXOperatorKind.Conversion:
return true; return true;
// The comparison operators can be overloaded if their return type is bool // The comparison operators can be overloaded if their return type is bool
case CXXOperatorKind.EqualEqual: case CXXOperatorKind.EqualEqual:
case CXXOperatorKind.ExclaimEqual: case CXXOperatorKind.ExclaimEqual:
case CXXOperatorKind.Less: case CXXOperatorKind.Less:
case CXXOperatorKind.Greater: case CXXOperatorKind.Greater:
case CXXOperatorKind.LessEqual: case CXXOperatorKind.LessEqual:
case CXXOperatorKind.GreaterEqual: case CXXOperatorKind.GreaterEqual:
return @operator.ReturnType.Type.IsPrimitiveType(PrimitiveType.Bool); return @operator.ReturnType.Type.IsPrimitiveType(PrimitiveType.Bool);
// Only prefix operators can be overloaded // Only prefix operators can be overloaded
case CXXOperatorKind.PlusPlus: case CXXOperatorKind.PlusPlus:

4
src/Generator/Passes/CheckStaticClass.cs

@ -63,10 +63,10 @@ namespace CppSharp.Passes
// Ignore the special methods for static classes. // Ignore the special methods for static classes.
foreach (var ctor in @class.Constructors) foreach (var ctor in @class.Constructors)
ctor.IsGenerated = false; ctor.GenerationKind = GenerationKind.Internal;
foreach (var dtor in @class.Destructors) foreach (var dtor in @class.Destructors)
dtor.IsGenerated = false; dtor.GenerationKind = GenerationKind.Internal;
return true; return true;
} }

35
src/Generator/Passes/CleanUnitPass.cs

@ -13,9 +13,9 @@ namespace CppSharp.Passes
public override bool VisitTranslationUnit(TranslationUnit unit) public override bool VisitTranslationUnit(TranslationUnit unit)
{ {
if (IsTranslationGenerated(unit)) if (IsExternalDeclaration(unit))
unit.IsGenerated = false; unit.GenerationKind = GenerationKind.Link;
// Try to get an include path that works from the original include // Try to get an include path that works from the original include
// directories paths. // directories paths.
@ -52,19 +52,20 @@ namespace CppSharp.Passes
return includePath.Replace('\\', '/'); return includePath.Replace('\\', '/');
} }
bool IsTranslationGenerated(TranslationUnit translationUnit)
{ bool IsExternalDeclaration(TranslationUnit translationUnit)
if (DriverOptions.NoGenIncludeDirs == null) {
return false; if (DriverOptions.NoGenIncludeDirs == null)
return false;
foreach (var path in DriverOptions.NoGenIncludeDirs)
{ foreach (var path in DriverOptions.NoGenIncludeDirs)
if (translationUnit.FilePath.StartsWith(path)) {
return true; if (translationUnit.FilePath.StartsWith(path))
} return true;
}
return false;
} return false;
}
} }
} }

2
src/Generator/Passes/FunctionToInstanceMethodPass.cs

@ -18,7 +18,7 @@ namespace CppSharp.Passes
public override bool VisitFunctionDecl(Function function) public override bool VisitFunctionDecl(Function function)
{ {
if (function.Ignore) if (!function.IsGenerated)
return false; return false;
// Check if this function can be converted. // Check if this function can be converted.

2
src/Generator/Passes/FunctionToStaticMethodPass.cs

@ -14,7 +14,7 @@ namespace CppSharp.Passes
public override bool VisitFunctionDecl(Function function) public override bool VisitFunctionDecl(Function function)
{ {
if (function.Ignore) if (!function.IsGenerated)
return false; return false;
var types = StringHelpers.SplitCamelCase(function.Name); var types = StringHelpers.SplitCamelCase(function.Name);

2
src/Generator/Passes/GenerateInlinesCodePass.cs

@ -81,7 +81,7 @@ namespace CppSharp.Passes
{ {
string symbol = mangled.Mangled; string symbol = mangled.Mangled;
var declaration = (Declaration) mangled; var declaration = (Declaration) mangled;
if (!declaration.Ignore && AccessValid(declaration) && if (declaration.IsGenerated && AccessValid(declaration) &&
!Driver.Symbols.FindSymbol(ref symbol) && !Driver.Symbols.FindSymbol(ref symbol) &&
!currentUnit.FilePath.EndsWith("_impl.h") && !currentUnit.FilePath.EndsWith("_impl.h") &&
!currentUnit.FilePath.EndsWith("_p.h")) !currentUnit.FilePath.EndsWith("_p.h"))

6
src/Generator/Passes/GetterSetterToPropertyAdvancedPass.cs

@ -70,7 +70,7 @@ namespace CppSharp.Passes
public override bool VisitMethodDecl(Method method) public override bool VisitMethodDecl(Method method)
{ {
if (!method.IsConstructor && !method.IsDestructor && !method.IsOperator && if (!method.IsConstructor && !method.IsDestructor && !method.IsOperator &&
!method.Ignore) method.IsGenerated)
DistributeMethod(method); DistributeMethod(method);
return base.VisitMethodDecl(method); return base.VisitMethodDecl(method);
} }
@ -205,9 +205,9 @@ namespace CppSharp.Passes
property.Comment = comment; property.Comment = comment;
} }
type.Properties.Add(property); type.Properties.Add(property);
getter.IsGenerated = false; getter.GenerationKind = GenerationKind.Internal;
if (setter != null) if (setter != null)
setter.IsGenerated = false; setter.GenerationKind = GenerationKind.Internal;
} }
} }

6
src/Generator/Passes/GetterSetterToPropertyPass.cs

@ -95,7 +95,7 @@ namespace CppSharp.Passes
prop.Access = method.Access; prop.Access = method.Access;
// Do not generate the original method now that we know it is a getter. // Do not generate the original method now that we know it is a getter.
method.IsGenerated = false; method.GenerationKind = GenerationKind.Internal;
Driver.Diagnostics.Debug("Getter created: {0}::{1}", @class.Name, name); Driver.Diagnostics.Debug("Getter created: {0}::{1}", @class.Name, name);
@ -111,8 +111,8 @@ namespace CppSharp.Passes
prop.SetMethod = method; prop.SetMethod = method;
prop.Access = method.Access; prop.Access = method.Access;
// Ignore the original method now that we know it is a setter. // Ignore the original method now that we know it is a setter.
method.IsGenerated = false; method.GenerationKind = GenerationKind.Internal;
Driver.Diagnostics.Debug("Setter created: {0}::{1}", @class.Name, name); Driver.Diagnostics.Debug("Setter created: {0}::{1}", @class.Name, name);

2
src/Generator/Passes/MoveFunctionToClassPass.cs

@ -13,7 +13,7 @@ namespace CppSharp.Passes
if (!VisitDeclaration(function)) if (!VisitDeclaration(function))
return false; return false;
if (function.Ignore || function.Namespace is Class) if (!function.IsGenerated || function.Namespace is Class)
return false; return false;
var @class = FindClassToMoveFunctionTo(function.Namespace); var @class = FindClassToMoveFunctionTo(function.Namespace);

2
src/Generator/Passes/MoveOperatorToClassPass.cs

@ -12,7 +12,7 @@ namespace CppSharp.Passes
public override bool VisitFunctionDecl(Function function) public override bool VisitFunctionDecl(Function function)
{ {
if (function.Ignore || !function.IsOperator) if (!function.IsGenerated || !function.IsOperator)
return false; return false;
Class @class = null; Class @class = null;

14
src/Generator/Passes/MultipleInheritancePass.cs

@ -67,13 +67,13 @@ namespace CppSharp.Passes
select new BaseClassSpecifier { Type = new TagType(i) }); select new BaseClassSpecifier { Type = new TagType(i) });
@interface.Methods.AddRange( @interface.Methods.AddRange(
from m in @base.Methods from m in @base.Methods
where !m.IsConstructor && !m.IsDestructor && !m.IsStatic && !m.Ignore && !m.IsOperator where !m.IsConstructor && !m.IsDestructor && !m.IsStatic && m.IsDeclared && !m.IsOperator
select new Method(m) { Namespace = @interface }); select new Method(m) { Namespace = @interface });
@interface.Properties.AddRange( @interface.Properties.AddRange(
from property in @base.Properties from property in @base.Properties
where !property.Ignore where property.IsDeclared
select new Property(property) { Namespace = @interface }); select new Property(property) { Namespace = @interface });
@interface.Fields.AddRange(@base.Fields); @interface.Fields.AddRange(@base.Fields);
@ -112,8 +112,8 @@ namespace CppSharp.Passes
IsVirtual = false, IsVirtual = false,
IsOverride = false IsOverride = false
}; };
var rootBaseMethod = @class.GetRootBaseMethod(method, true); var rootBaseMethod = @class.GetRootBaseMethod(method, true);
if (rootBaseMethod != null && !rootBaseMethod.Ignore) if (rootBaseMethod != null && rootBaseMethod.IsDeclared)
impl.ExplicitInterfaceImpl = @interface; impl.ExplicitInterfaceImpl = @interface;
@class.Methods.Add(impl); @class.Methods.Add(impl);
} }
@ -126,8 +126,8 @@ namespace CppSharp.Passes
foreach (var property in @interface.Properties.Where(p => p.Name != Helpers.InstanceIdentifier)) foreach (var property in @interface.Properties.Where(p => p.Name != Helpers.InstanceIdentifier))
{ {
var impl = new Property(property) { Namespace = @class }; var impl = new Property(property) { Namespace = @class };
var rootBaseProperty = @class.GetRootBaseProperty(property, true); var rootBaseProperty = @class.GetRootBaseProperty(property, true);
if (rootBaseProperty != null && !rootBaseProperty.Ignore) if (rootBaseProperty != null && rootBaseProperty.IsDeclared)
impl.ExplicitInterfaceImpl = @interface; impl.ExplicitInterfaceImpl = @interface;
@class.Properties.Add(impl); @class.Properties.Add(impl);
} }

6
src/Generator/Passes/ResolveIncompleteDeclsPass.cs

@ -9,7 +9,7 @@ namespace CppSharp.Passes
if (AlreadyVisited(decl)) if (AlreadyVisited(decl))
return false; return false;
return !decl.Ignore; return decl.IsGenerated;
} }
public override bool VisitClassDecl(Class @class) public override bool VisitClassDecl(Class @class)
@ -25,7 +25,7 @@ namespace CppSharp.Passes
if (@class.CompleteDeclaration == null) if (@class.CompleteDeclaration == null)
{ {
@class.IsGenerated = false; @class.GenerationKind = GenerationKind.Internal;
Driver.Diagnostics.Debug("Unresolved declaration: {0}", Driver.Diagnostics.Debug("Unresolved declaration: {0}",
@class.Name); @class.Name);
} }
@ -51,7 +51,7 @@ namespace CppSharp.Passes
if (@enum.CompleteDeclaration == null) if (@enum.CompleteDeclaration == null)
{ {
@enum.IsGenerated = false; @enum.GenerationKind = GenerationKind.Internal;
Driver.Diagnostics.EmitWarning(DiagnosticId.UnresolvedDeclaration, Driver.Diagnostics.EmitWarning(DiagnosticId.UnresolvedDeclaration,
"Unresolved declaration: {0}", @enum.Name); "Unresolved declaration: {0}", @enum.Name);
} }

Loading…
Cancel
Save