diff --git a/src/Bridge/Declaration.cs b/src/Bridge/Declaration.cs index 45f1134d..a1586bce 100644 --- a/src/Bridge/Declaration.cs +++ b/src/Bridge/Declaration.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using Cxxi; namespace Cxxi @@ -14,6 +15,15 @@ namespace Cxxi QualifiedType QualifiedType { get; } } + [Flags] + public enum IgnoreFlags + { + None = 0, + Generation = 1 << 0, + Processing = 1 << 1, + Explicit = 1 << 2 + } + /// /// Represents a C++ declaration. /// @@ -51,17 +61,64 @@ namespace Cxxi // Doxygen-style brief comment. public string BriefComment; - // Whether the declaration should be ignored. - public virtual bool Ignore + // Keeps flags to know the type of ignore. + public IgnoreFlags IgnoreFlags { get; set; } + + // Whether the declaration should be generated. + public virtual bool IsGenerated { get { - return ExplicityIgnored || Namespace.Ignore; + return !IgnoreFlags.HasFlag(IgnoreFlags.Generation) || + Namespace.IsGenerated; + } + + set + { + if (value) + IgnoreFlags |= IgnoreFlags.Generation; + else + IgnoreFlags &= ~IgnoreFlags.Generation; + } + } + + // Whether the declaration should be processed. + public virtual bool IsProcessed + { + get + { + return !IgnoreFlags.HasFlag(IgnoreFlags.Processing) || + Namespace.IsProcessed; + } + + set + { + if (value) + IgnoreFlags |= IgnoreFlags.Processing; + else + IgnoreFlags &= ~IgnoreFlags.Processing; } } // Whether the declaration was explicitly ignored. - public bool ExplicityIgnored; + public bool ExplicityIgnored + { + get { return IgnoreFlags.HasFlag(IgnoreFlags.Explicit); } + + set + { + if (value) + IgnoreFlags |= IgnoreFlags.Explicit; + else + IgnoreFlags &= ~IgnoreFlags.Explicit; + } + } + + // Whether the declaration should be ignored. + public bool Ignore + { + get { return IgnoreFlags != IgnoreFlags.None; } + } // Contains debug text about the declaration. public string DebugText; @@ -77,11 +134,13 @@ namespace Cxxi protected Declaration() { + IgnoreFlags = IgnoreFlags.None; } protected Declaration(string name) { Name = name; + IgnoreFlags = IgnoreFlags.None; } public override string ToString() diff --git a/src/Bridge/Library.cs b/src/Bridge/Library.cs index 46755c09..a5aee0a4 100644 --- a/src/Bridge/Library.cs +++ b/src/Bridge/Library.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; -using System.Linq; namespace Cxxi { @@ -33,10 +32,16 @@ namespace Cxxi /// Contains the macros present in the unit. public List Macros; - /// If the module should be ignored. - public override bool Ignore + // Whether the unit should be generated. + public override bool IsGenerated { - get { return ExplicityIgnored; } + get { return !IgnoreFlags.HasFlag(IgnoreFlags.Generation); } + } + + // Whether the unit should be processed. + public override bool IsProcessed + { + get { return !IgnoreFlags.HasFlag(IgnoreFlags.Processing); } } public bool IsSystemHeader { get; set; } diff --git a/src/Bridge/Namespace.cs b/src/Bridge/Namespace.cs index 6e2df816..424889ab 100644 --- a/src/Bridge/Namespace.cs +++ b/src/Bridge/Namespace.cs @@ -19,7 +19,6 @@ namespace Cxxi public List