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 Templates;
public List Typedefs;
- // Translation unit the declaration is contained in.
public TranslationUnit TranslationUnit
{
get
@@ -31,10 +30,22 @@ namespace Cxxi
}
}
- /// If the namespace should be ignored.
- public override bool Ignore
+ public override bool IsGenerated
{
- get { return ExplicityIgnored || Parent.Ignore; }
+ get
+ {
+ return !IgnoreFlags.HasFlag(IgnoreFlags.Generation) ||
+ Parent.IsGenerated;
+ }
+ }
+
+ public override bool IsProcessed
+ {
+ get
+ {
+ return !IgnoreFlags.HasFlag(IgnoreFlags.Processing) ||
+ Parent.IsProcessed;
+ }
}
public Namespace()
diff --git a/src/Generator/Driver.cs b/src/Generator/Driver.cs
index ff9c90c2..fbd71357 100644
--- a/src/Generator/Driver.cs
+++ b/src/Generator/Driver.cs
@@ -127,7 +127,7 @@ namespace Cxxi
// Process everything in the global namespace for now.
foreach (var unit in Library.TranslationUnits)
{
- if (unit.ExplicityIgnored || !unit.HasDeclarations)
+ if (unit.Ignore || !unit.HasDeclarations)
continue;
if (unit.IsSystemHeader)
diff --git a/src/Generator/Library.cs b/src/Generator/Library.cs
index 49468c3c..e3fa7208 100644
--- a/src/Generator/Library.cs
+++ b/src/Generator/Library.cs
@@ -276,7 +276,11 @@ namespace Cxxi
m => Regex.Match(m.FilePath, pattern).Success);
foreach (var module in modules)
+ {
+ module.IsGenerated = false;
+ module.IsProcessed = true;
module.ExplicityIgnored = true;
+ }
}
#endregion
diff --git a/src/Generator/Passes/CleanInvalidDeclNamesPass.cs b/src/Generator/Passes/CleanInvalidDeclNamesPass.cs
index ef60eed1..2d754b39 100644
--- a/src/Generator/Passes/CleanInvalidDeclNamesPass.cs
+++ b/src/Generator/Passes/CleanInvalidDeclNamesPass.cs
@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
-using System.Diagnostics;
using System.Linq;
-using Cxxi.Types;
namespace Cxxi.Passes
{
@@ -18,7 +16,7 @@ namespace Cxxi.Passes
public override bool ProcessUnit(TranslationUnit unit)
{
- if (unit.ExplicityIgnored)
+ if (unit.Ignore)
return false;
if (unit.IsSystemHeader)