Browse Source

Reworked the declaration ignore system so we can still process declarations as part of type maps even if they do not have mirror classes generated.

pull/1/head
triton 13 years ago
parent
commit
e9129ed27f
  1. 69
      src/Bridge/Declaration.cs
  2. 13
      src/Bridge/Library.cs
  3. 19
      src/Bridge/Namespace.cs
  4. 2
      src/Generator/Driver.cs
  5. 4
      src/Generator/Library.cs
  6. 4
      src/Generator/Passes/CleanInvalidDeclNamesPass.cs

69
src/Bridge/Declaration.cs

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using Cxxi;
namespace Cxxi
@ -14,6 +15,15 @@ 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
}
/// <summary>
/// Represents a C++ declaration.
/// </summary>
@ -51,17 +61,64 @@ namespace Cxxi @@ -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 @@ -77,11 +134,13 @@ namespace Cxxi
protected Declaration()
{
IgnoreFlags = IgnoreFlags.None;
}
protected Declaration(string name)
{
Name = name;
IgnoreFlags = IgnoreFlags.None;
}
public override string ToString()

13
src/Bridge/Library.cs

@ -1,7 +1,6 @@ @@ -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 @@ -33,10 +32,16 @@ namespace Cxxi
/// Contains the macros present in the unit.
public List<MacroDefinition> 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; }

19
src/Bridge/Namespace.cs

@ -19,7 +19,6 @@ namespace Cxxi @@ -19,7 +19,6 @@ namespace Cxxi
public List<Template> Templates;
public List<TypedefDecl> Typedefs;
// Translation unit the declaration is contained in.
public TranslationUnit TranslationUnit
{
get
@ -31,10 +30,22 @@ namespace Cxxi @@ -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()

2
src/Generator/Driver.cs

@ -127,7 +127,7 @@ namespace Cxxi @@ -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)

4
src/Generator/Library.cs

@ -276,8 +276,12 @@ namespace Cxxi @@ -276,8 +276,12 @@ namespace Cxxi
m => Regex.Match(m.FilePath, pattern).Success);
foreach (var module in modules)
{
module.IsGenerated = false;
module.IsProcessed = true;
module.ExplicityIgnored = true;
}
}
#endregion
}

4
src/Generator/Passes/CleanInvalidDeclNamesPass.cs

@ -1,8 +1,6 @@ @@ -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 @@ -18,7 +16,7 @@ namespace Cxxi.Passes
public override bool ProcessUnit(TranslationUnit unit)
{
if (unit.ExplicityIgnored)
if (unit.Ignore)
return false;
if (unit.IsSystemHeader)

Loading…
Cancel
Save