Browse Source

Deprecated ExplicityIgnored use ExplicitlyIgnore(). Getting ExplicityIgnored and setting ExplicityIgnored to false don't make much sense anymore.

Conflicts:
	src/Generator/Passes/CheckOperatorsOverloads.cs
pull/228/merge
marcos henrich 12 years ago committed by triton
parent
commit
7125109e3f
  1. 20
      src/AST/Declaration.cs
  2. 4
      src/CppParser/Bindings/ParserGen.cs
  3. 8
      src/Generator.Tests/Passes/TestPasses.cs
  4. 14
      src/Generator/Library.cs
  5. 8
      src/Generator/Passes/CheckAmbiguousFunctions.cs
  6. 4
      src/Generator/Passes/CheckDuplicatedNamesPass.cs
  7. 38
      src/Generator/Passes/CheckIgnoredDecls.cs
  8. 8
      src/Generator/Passes/CheckMacrosPass.cs
  9. 2
      src/Generator/Passes/CheckOperatorsOverloads.cs
  10. 6
      src/Generator/Passes/CleanInvalidDeclNamesPass.cs
  11. 2
      src/Generator/Passes/FindSymbolsPass.cs
  12. 2
      src/Generator/Passes/FunctionToInstanceMethodPass.cs
  13. 2
      src/Generator/Passes/FunctionToStaticMethodPass.cs
  14. 4
      src/Generator/Passes/MoveFunctionToClassPass.cs
  15. 2
      src/Generator/Passes/MoveOperatorToClassPass.cs

20
src/AST/Declaration.cs

@ -192,9 +192,6 @@ namespace CppSharp.AST
{ {
get get
{ {
if(ExplicityIgnored)
return GenerationKind.None;
if (generationKind.HasValue) if (generationKind.HasValue)
return generationKind.Value; return generationKind.Value;
@ -244,13 +241,24 @@ namespace CppSharp.AST
} }
} }
public bool ExplicityIgnored { get; set; } public void ExplicitlyIgnore()
{
GenerationKind = GenerationKind.None;
}
[Obsolete("Replace set by ExplicitlyIgnore(). Replace get by GenerationKind == GenerationKind.None.")]
public bool ExplicityIgnored
{
get { return GenerationKind == GenerationKind.None; }
set { if (value) ExplicitlyIgnore(); }
}
[Obsolete("Replace set by ExplicityIgnored. Replace get by IsGenerated, IsInternal or IsDeclared.")] [Obsolete("Replace set by ExplicitlyIgnore(). Replace get by GenerationKind == GenerationKind.None.")]
public virtual bool Ignore public virtual bool Ignore
{ {
get { return GenerationKind == GenerationKind.None; } get { return GenerationKind == GenerationKind.None; }
set { ExplicityIgnored = value; } set { if (value) ExplicitlyIgnore(); }
} }
public AccessSpecifier Access { get; set; } public AccessSpecifier Access { get; set; }

4
src/CppParser/Bindings/ParserGen.cs

@ -150,7 +150,7 @@ namespace CppSharp
if (!IsStdType(field.QualifiedType)) return false; if (!IsStdType(field.QualifiedType)) return false;
field.ExplicityIgnored = true; field.ExplicitlyIgnore();
return true; return true;
} }
@ -161,7 +161,7 @@ namespace CppSharp
if (function.Parameters.Any(param => IsStdType(param.QualifiedType))) if (function.Parameters.Any(param => IsStdType(param.QualifiedType)))
{ {
function.ExplicityIgnored = true; function.ExplicitlyIgnore();
return false; return false;
} }

8
src/Generator.Tests/Passes/TestPasses.cs

@ -55,13 +55,13 @@ namespace CppSharp.Generator.Tests.Passes
{ {
var c = AstContext.Class("Foo"); var c = AstContext.Class("Foo");
Assert.IsFalse(AstContext.Function("FooStart").ExplicityIgnored); Assert.IsTrue(AstContext.Function("FooStart").IsGenerated);
Assert.IsNull(c.Method("Start")); Assert.IsNull(c.Method("Start"));
passBuilder.AddPass(new FunctionToStaticMethodPass()); passBuilder.AddPass(new FunctionToStaticMethodPass());
passBuilder.RunPasses(pass => pass.VisitLibrary(AstContext)); passBuilder.RunPasses(pass => pass.VisitLibrary(AstContext));
Assert.IsTrue(AstContext.Function("FooStart").ExplicityIgnored); Assert.IsFalse(AstContext.Function("FooStart").IsGenerated);
Assert.IsNotNull(c.Method("Start")); Assert.IsNotNull(c.Method("Start"));
} }
@ -105,8 +105,8 @@ namespace CppSharp.Generator.Tests.Passes
public void TestIgnoringMethod() public void TestIgnoringMethod()
{ {
AstContext.IgnoreClassMethodWithName("Foo", "toIgnore"); AstContext.IgnoreClassMethodWithName("Foo", "toIgnore");
Assert.IsTrue(AstContext.FindClass("Foo").First().Methods.Find( Assert.IsFalse(AstContext.FindClass("Foo").First().Methods.Find(
m => m.Name == "toIgnore").ExplicityIgnored); m => m.Name == "toIgnore").IsGenerated);
} }
} }
} }

14
src/Generator/Library.cs

@ -54,7 +54,7 @@ namespace CppSharp
{ {
Enumeration @enum = context.GetEnumWithMatchingItem(pattern); Enumeration @enum = context.GetEnumWithMatchingItem(pattern);
if (@enum != null) if (@enum != null)
@enum.ExplicityIgnored = true; @enum.ExplicitlyIgnore();
} }
public static void SetNameOfEnumWithMatchingItem(this ASTContext context, string pattern, public static void SetNameOfEnumWithMatchingItem(this ASTContext context, string pattern,
@ -184,7 +184,7 @@ namespace CppSharp
public static void IgnoreClassWithName(this ASTContext context, string name) public static void IgnoreClassWithName(this ASTContext context, string name)
{ {
foreach (var @class in context.FindClass(name)) foreach (var @class in context.FindClass(name))
@class.ExplicityIgnored = true; @class.ExplicitlyIgnore();
} }
public static void SetClassAsOpaque(this ASTContext context, string name) public static void SetClassAsOpaque(this ASTContext context, string name)
@ -270,7 +270,7 @@ namespace CppSharp
public static void IgnoreFunctionWithName(this ASTContext context, string name) public static void IgnoreFunctionWithName(this ASTContext context, string name)
{ {
foreach (var function in context.FindFunction(name)) foreach (var function in context.FindFunction(name))
function.ExplicityIgnored = true; function.ExplicitlyIgnore();
} }
public static void IgnoreFunctionWithPattern(this ASTContext context, string pattern) public static void IgnoreFunctionWithPattern(this ASTContext context, string pattern)
@ -280,7 +280,7 @@ namespace CppSharp
foreach (var function in unit.Functions) foreach (var function in unit.Functions)
{ {
if (Regex.Match(function.Name, pattern).Success) if (Regex.Match(function.Name, pattern).Success)
function.ExplicityIgnored = true; function.ExplicitlyIgnore();
} }
} }
} }
@ -299,7 +299,7 @@ namespace CppSharp
where method.Name == name where method.Name == name
select method) select method)
{ {
method.ExplicityIgnored = true; method.ExplicitlyIgnore();
} }
} }
@ -308,7 +308,7 @@ namespace CppSharp
foreach (var @class in context.FindClass(name)) foreach (var @class in context.FindClass(name))
{ {
foreach (var classField in @class.Fields.FindAll(f => f.Name == field)) foreach (var classField in @class.Fields.FindAll(f => f.Name == field))
classField.ExplicityIgnored = true; classField.ExplicitlyIgnore();
} }
} }
@ -334,7 +334,7 @@ namespace CppSharp
foreach (var unit in units) foreach (var unit in units)
{ {
unit.ExplicityIgnored = true; unit.ExplicitlyIgnore();
} }
} }

8
src/Generator/Passes/CheckAmbiguousFunctions.cs

@ -88,9 +88,9 @@ namespace CppSharp.Passes
} }
if (function.Parameters.Count > overload.Parameters.Count) if (function.Parameters.Count > overload.Parameters.Count)
overload.ExplicityIgnored = true; overload.ExplicitlyIgnore();
else else
function.ExplicityIgnored = true; function.ExplicitlyIgnore();
return true; return true;
} }
@ -104,13 +104,13 @@ namespace CppSharp.Passes
if (method1.IsConst && !method2.IsConst) if (method1.IsConst && !method2.IsConst)
{ {
method1.ExplicityIgnored = true; method1.ExplicitlyIgnore();
return false; return false;
} }
if (method2.IsConst && !method1.IsConst) if (method2.IsConst && !method1.IsConst)
{ {
method2.ExplicityIgnored = true; method2.ExplicitlyIgnore();
return false; return false;
} }
} }

4
src/Generator/Passes/CheckDuplicatedNamesPass.cs

@ -72,12 +72,12 @@ namespace CppSharp.Passes
{ {
// TODO: turn into a method; append the original type (say, "signed long") of the last parameter to the type so that the user knows which overload is called // TODO: turn into a method; append the original type (say, "signed long") of the last parameter to the type so that the user knows which overload is called
Driver.Diagnostics.EmitWarning("Duplicate operator {0} ignored", function.Name); Driver.Diagnostics.EmitWarning("Duplicate operator {0} ignored", function.Name);
function.ExplicityIgnored = true; function.ExplicitlyIgnore();
} }
else if (method != null && method.IsConstructor) else if (method != null && method.IsConstructor)
{ {
Driver.Diagnostics.EmitWarning("Duplicate constructor {0} ignored", function.Name); Driver.Diagnostics.EmitWarning("Duplicate constructor {0} ignored", function.Name);
function.ExplicityIgnored = true; function.ExplicitlyIgnore();
} }
else else
function.Name += methodCount.ToString(CultureInfo.InvariantCulture); function.Name += methodCount.ToString(CultureInfo.InvariantCulture);

38
src/Generator/Passes/CheckIgnoredDecls.cs

@ -33,20 +33,20 @@ namespace CppSharp.Passes
if (AlreadyVisited(decl)) if (AlreadyVisited(decl))
return false; return false;
if (decl.ExplicityIgnored) if (decl.GenerationKind == GenerationKind.None)
return true; return true;
if (!CheckDeclarationAccess(decl)) if (!CheckDeclarationAccess(decl))
{ {
Log.Debug("Decl '{0}' was ignored due to invalid access", Log.Debug("Decl '{0}' was ignored due to invalid access",
decl.Name); decl.Name);
decl.ExplicityIgnored = true; decl.ExplicitlyIgnore();
return true; return true;
} }
if (decl.IsDependent) if (decl.IsDependent)
{ {
decl.ExplicityIgnored = true; decl.ExplicitlyIgnore();
Log.Debug("Decl '{0}' was ignored due to dependent context", Log.Debug("Decl '{0}' was ignored due to dependent context",
decl.Name); decl.Name);
return true; return true;
@ -66,7 +66,7 @@ namespace CppSharp.Passes
if (!HasInvalidType(type, out msg)) if (!HasInvalidType(type, out msg))
return false; return false;
field.ExplicityIgnored = true; field.ExplicitlyIgnore();
var @class = (Class)field.Namespace; var @class = (Class)field.Namespace;
@ -89,7 +89,7 @@ namespace CppSharp.Passes
string msg; string msg;
if (HasInvalidType(ret.Type, out msg)) if (HasInvalidType(ret.Type, out msg))
{ {
function.ExplicityIgnored = true; function.ExplicitlyIgnore();
Log.Debug("Function '{0}' was ignored due to {1} return decl", Log.Debug("Function '{0}' was ignored due to {1} return decl",
function.Name, msg); function.Name, msg);
return false; return false;
@ -99,7 +99,7 @@ namespace CppSharp.Passes
{ {
if (HasInvalidDecl(param, out msg)) if (HasInvalidDecl(param, out msg))
{ {
function.ExplicityIgnored = true; function.ExplicitlyIgnore();
Log.Debug("Function '{0}' was ignored due to {1} param", Log.Debug("Function '{0}' was ignored due to {1} param",
function.Name, msg); function.Name, msg);
return false; return false;
@ -107,7 +107,7 @@ namespace CppSharp.Passes
if (HasInvalidType(param.Type, out msg)) if (HasInvalidType(param.Type, out msg))
{ {
function.ExplicityIgnored = true; function.ExplicitlyIgnore();
Log.Debug("Function '{0}' was ignored due to {1} param", Log.Debug("Function '{0}' was ignored due to {1} param",
function.Name, msg); function.Name, msg);
return false; return false;
@ -116,7 +116,7 @@ namespace CppSharp.Passes
var decayedType = param.Type.Desugar() as DecayedType; var decayedType = param.Type.Desugar() as DecayedType;
if (decayedType != null) if (decayedType != null)
{ {
function.ExplicityIgnored = true; function.ExplicitlyIgnore();
Log.Debug("Function '{0}' was ignored due to unsupported decayed type param", Log.Debug("Function '{0}' was ignored due to unsupported decayed type param",
function.Name); function.Name);
return false; return false;
@ -128,7 +128,7 @@ namespace CppSharp.Passes
param.Type.Desugar().IsTagDecl(out retClass); param.Type.Desugar().IsTagDecl(out retClass);
if (retClass == null) if (retClass == null)
{ {
function.ExplicityIgnored = true; function.ExplicitlyIgnore();
Log.Debug( Log.Debug(
"Function '{0}' was ignored due to an indirect return param not of a tag type", "Function '{0}' was ignored due to an indirect return param not of a tag type",
function.Name); function.Name);
@ -161,7 +161,7 @@ namespace CppSharp.Passes
"Virtual method '{0}' was ignored due to ignored base '{1}'", "Virtual method '{0}' was ignored due to ignored base '{1}'",
method.QualifiedOriginalName, ignoredBase.Name); method.QualifiedOriginalName, ignoredBase.Name);
method.ExplicityIgnored = true; method.ExplicitlyIgnore();
return false; return false;
} }
@ -174,7 +174,7 @@ namespace CppSharp.Passes
"Virtual method '{0}' was ignored due to ignored override '{1}'", "Virtual method '{0}' was ignored due to ignored override '{1}'",
method.QualifiedOriginalName, baseOverride.Name); method.QualifiedOriginalName, baseOverride.Name);
method.ExplicityIgnored = true; method.ExplicitlyIgnore();
return false; return false;
} }
} }
@ -217,7 +217,7 @@ namespace CppSharp.Passes
string msg; string msg;
if (HasInvalidType(typedef.Type, out msg)) if (HasInvalidType(typedef.Type, out msg))
{ {
typedef.ExplicityIgnored = true; typedef.ExplicitlyIgnore();
Log.Debug("Typedef '{0}' was ignored due to {1} type", Log.Debug("Typedef '{0}' was ignored due to {1} type",
typedef.Name, msg); typedef.Name, msg);
return false; return false;
@ -234,7 +234,7 @@ namespace CppSharp.Passes
string msg; string msg;
if (HasInvalidDecl(property, out msg)) if (HasInvalidDecl(property, out msg))
{ {
property.ExplicityIgnored = true; property.ExplicitlyIgnore();
Log.Debug("Property '{0}' was ignored due to {1} decl", Log.Debug("Property '{0}' was ignored due to {1} decl",
property.Name, msg); property.Name, msg);
return false; return false;
@ -242,7 +242,7 @@ namespace CppSharp.Passes
if (HasInvalidType(property.Type, out msg)) if (HasInvalidType(property.Type, out msg))
{ {
property.ExplicityIgnored = true; property.ExplicitlyIgnore();
Log.Debug("Property '{0}' was ignored due to {1} type", Log.Debug("Property '{0}' was ignored due to {1} type",
property.Name, msg); property.Name, msg);
return false; return false;
@ -259,7 +259,7 @@ namespace CppSharp.Passes
string msg; string msg;
if (HasInvalidDecl(variable, out msg)) if (HasInvalidDecl(variable, out msg))
{ {
variable.ExplicityIgnored = true; variable.ExplicitlyIgnore();
Log.Debug("Variable '{0}' was ignored due to {1} decl", Log.Debug("Variable '{0}' was ignored due to {1} decl",
variable.Name, msg); variable.Name, msg);
return false; return false;
@ -267,7 +267,7 @@ namespace CppSharp.Passes
if (HasInvalidType(variable.Type, out msg)) if (HasInvalidType(variable.Type, out msg))
{ {
variable.ExplicityIgnored = true; variable.ExplicitlyIgnore();
Log.Debug("Variable '{0}' was ignored due to {1} type", Log.Debug("Variable '{0}' was ignored due to {1} type",
variable.Name, msg); variable.Name, msg);
return false; return false;
@ -284,7 +284,7 @@ namespace CppSharp.Passes
string msg; string msg;
if (HasInvalidDecl(@event, out msg)) if (HasInvalidDecl(@event, out msg))
{ {
@event.ExplicityIgnored = true; @event.ExplicitlyIgnore();
Log.Debug("Event '{0}' was ignored due to {1} decl", Log.Debug("Event '{0}' was ignored due to {1} decl",
@event.Name, msg); @event.Name, msg);
return false; return false;
@ -294,7 +294,7 @@ namespace CppSharp.Passes
{ {
if (HasInvalidDecl(param, out msg)) if (HasInvalidDecl(param, out msg))
{ {
@event.ExplicityIgnored = true; @event.ExplicitlyIgnore();
Log.Debug("Event '{0}' was ignored due to {1} param", Log.Debug("Event '{0}' was ignored due to {1} param",
@event.Name, msg); @event.Name, msg);
return false; return false;
@ -302,7 +302,7 @@ namespace CppSharp.Passes
if (HasInvalidType(param.Type, out msg)) if (HasInvalidType(param.Type, out msg))
{ {
@event.ExplicityIgnored = true; @event.ExplicitlyIgnore();
Log.Debug("Event '{0}' was ignored due to {1} param", Log.Debug("Event '{0}' was ignored due to {1} param",
@event.Name, msg); @event.Name, msg);
return false; return false;

8
src/Generator/Passes/CheckMacrosPass.cs

@ -74,7 +74,7 @@ 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.ExplicityIgnored = true; decl.ExplicitlyIgnore();
if (expansions.Any(e => e.Text == Prefix + "_IGNORE_GEN" && if (expansions.Any(e => e.Text == Prefix + "_IGNORE_GEN" &&
e.Location != MacroLocation.ClassBody && e.Location != MacroLocation.ClassBody &&
@ -89,7 +89,7 @@ namespace CppSharp.Passes
if (expansions.Any(e => e.Text == Prefix + "_IGNORE_FILE")) if (expansions.Any(e => e.Text == Prefix + "_IGNORE_FILE"))
{ {
unit.ExplicityIgnored = true; unit.ExplicitlyIgnore();
} }
return base.VisitTranslationUnit(unit); return base.VisitTranslationUnit(unit);
@ -149,7 +149,7 @@ namespace CppSharp.Passes
if (expansions.Any(e => e.Text == Prefix + "_HASHCODE" if (expansions.Any(e => e.Text == Prefix + "_HASHCODE"
|| e.Text == Prefix + "_EQUALS")) || e.Text == Prefix + "_EQUALS"))
method.ExplicityIgnored = true; method.ExplicitlyIgnore();
return base.VisitMethodDecl(method); return base.VisitMethodDecl(method);
} }
@ -184,7 +184,7 @@ namespace CppSharp.Passes
var setMethod = property.SetMethod; var setMethod = property.SetMethod;
if (setMethod != null) if (setMethod != null)
property.SetMethod.ExplicityIgnored = true; property.SetMethod.ExplicitlyIgnore();
} }
return base.VisitProperty(property); return base.VisitProperty(property);

2
src/Generator/Passes/CheckOperatorsOverloads.cs

@ -54,7 +54,7 @@ namespace CppSharp.Passes
Driver.Diagnostics.Debug(DiagnosticId.InvalidOperatorOverload, Driver.Diagnostics.Debug(DiagnosticId.InvalidOperatorOverload,
"Invalid operator overload {0}::{1}", "Invalid operator overload {0}::{1}",
@class.OriginalName, @operator.OperatorKind); @class.OriginalName, @operator.OperatorKind);
@operator.ExplicityIgnored = true; @operator.ExplicitlyIgnore();
continue; continue;
} }
if (@operator.SynthKind == FunctionSynthKind.NonMemberOperator) if (@operator.SynthKind == FunctionSynthKind.NonMemberOperator)

6
src/Generator/Passes/CleanInvalidDeclNamesPass.cs

@ -36,7 +36,7 @@ namespace CppSharp.Passes
if (decl is Class && string.IsNullOrWhiteSpace(decl.Name)) if (decl is Class && string.IsNullOrWhiteSpace(decl.Name))
{ {
decl.Name = "_"; decl.Name = "_";
decl.ExplicityIgnored = true; decl.ExplicitlyIgnore();
return false; return false;
} }
@ -107,10 +107,10 @@ namespace CppSharp.Passes
// so we ignore the class and process just the typedef. // so we ignore the class and process just the typedef.
if (@class != null) if (@class != null)
typedef.ExplicityIgnored = true; typedef.ExplicitlyIgnore();
if (typedef.Type == null) if (typedef.Type == null)
typedef.ExplicityIgnored = true; typedef.ExplicitlyIgnore();
return base.VisitTypedefDecl(typedef); return base.VisitTypedefDecl(typedef);
} }

2
src/Generator/Passes/FindSymbolsPass.cs

@ -15,7 +15,7 @@ namespace CppSharp.Passes
if (mangledDecl != null && !(method != null && (method.IsPure || method.IsSynthetized)) && if (mangledDecl != null && !(method != null && (method.IsPure || method.IsSynthetized)) &&
!VisitMangledDeclaration(mangledDecl)) !VisitMangledDeclaration(mangledDecl))
{ {
decl.ExplicityIgnored = true; decl.ExplicitlyIgnore();
return false; return false;
} }

2
src/Generator/Passes/FunctionToInstanceMethodPass.cs

@ -39,7 +39,7 @@ namespace CppSharp.Passes
return false; return false;
function.Name = function.Name.Substring(@class.Name.Length); function.Name = function.Name.Substring(@class.Name.Length);
function.ExplicityIgnored = true; function.ExplicitlyIgnore();
// Create a new fake method so it acts as an instance method. // Create a new fake method so it acts as an instance method.
var method = new Method var method = new Method

2
src/Generator/Passes/FunctionToStaticMethodPass.cs

@ -33,7 +33,7 @@ namespace CppSharp.Passes
// Clean up the name of the function now that it will be a static method. // Clean up the name of the function now that it will be a static method.
var name = function.Name.Substring(@class.Name.Length); var name = function.Name.Substring(@class.Name.Length);
function.ExplicityIgnored = true; function.ExplicitlyIgnore();
// Create a new fake method so it acts as a static method. // Create a new fake method so it acts as a static method.
var method = new Method var method = new Method

4
src/Generator/Passes/MoveFunctionToClassPass.cs

@ -24,7 +24,7 @@ namespace CppSharp.Passes
} }
if (function.IsOperator) if (function.IsOperator)
function.ExplicityIgnored = true; function.ExplicitlyIgnore();
return true; return true;
} }
@ -49,7 +49,7 @@ namespace CppSharp.Passes
IsStatic = true IsStatic = true
}; };
function.ExplicityIgnored = true; function.ExplicitlyIgnore();
if (method.OperatorKind != CXXOperatorKind.None) if (method.OperatorKind != CXXOperatorKind.None)
{ {

2
src/Generator/Passes/MoveOperatorToClassPass.cs

@ -38,7 +38,7 @@ namespace CppSharp.Passes
IsStatic = true IsStatic = true
}; };
function.ExplicityIgnored = true; function.ExplicitlyIgnore();
@class.Methods.Add(method); @class.Methods.Add(method);

Loading…
Cancel
Save