Browse Source

Removed class parameter from CheckIgnoreFunction, CheckIgnoreMethod and CheckIgnoreField.

pull/16/head
marcos henrich 12 years ago
parent
commit
57ce9d449d
  1. 17
      src/Generator/AST/Utils.cs
  2. 7
      src/Generator/Generators/CLI/CLIHeadersTemplate.cs
  3. 9
      src/Generator/Generators/CSharp/CSharpTextTemplate.cs
  4. 4
      src/Generator/Passes/CheckDuplicatedNamesPass.cs
  5. 2
      src/Generator/Passes/FieldToPropertyPass.cs
  6. 2
      src/Generator/Passes/GetterSetterToPropertyPass.cs

17
src/Generator/AST/Utils.cs

@ -3,23 +3,24 @@ namespace CppSharp.AST @@ -3,23 +3,24 @@ namespace CppSharp.AST
{
public static class ASTUtils
{
public static bool CheckIgnoreFunction(Class @class, Function function)
public static bool CheckIgnoreFunction(Function function)
{
if (function.Ignore) return true;
if (function is Method)
return CheckIgnoreMethod(@class, function as Method);
return CheckIgnoreMethod(function as Method);
return false;
}
public static bool CheckIgnoreMethod(Class @class, Method method)
public static bool CheckIgnoreMethod(Method method)
{
if (method.Ignore) return true;
var isEmptyCtor = method.IsConstructor && method.Parameters.Count == 0;
if (@class.IsValueType && isEmptyCtor)
var @class = method.Namespace as Class;
if (@class != null && @class.IsValueType && isEmptyCtor)
return true;
if (method.IsCopyConstructor || method.IsMoveConstructor)
@ -40,14 +41,12 @@ namespace CppSharp.AST @@ -40,14 +41,12 @@ namespace CppSharp.AST
return false;
}
public static bool CheckIgnoreField(Class @class, Field field)
public static bool CheckIgnoreField(Field field)
{
if (field.Ignore) return true;
if (field.Access != AccessSpecifier.Public)
if (field.Access != AccessSpecifier.Public)
return true;
return false;
return field.Ignore;
}
}
}

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

@ -350,7 +350,7 @@ namespace CppSharp.Generators.CLI @@ -350,7 +350,7 @@ namespace CppSharp.Generators.CLI
PushIndent();
foreach (var field in @class.Fields)
{
if (ASTUtils.CheckIgnoreField(@class, field)) continue;
if (ASTUtils.CheckIgnoreField(field)) continue;
GenerateDeclarationCommon(field);
if (@class.IsUnion)
@ -405,7 +405,7 @@ namespace CppSharp.Generators.CLI @@ -405,7 +405,7 @@ namespace CppSharp.Generators.CLI
var staticMethods = new List<Method>();
foreach (var method in @class.Methods)
{
if (ASTUtils.CheckIgnoreMethod(@class, method))
if (ASTUtils.CheckIgnoreMethod(method))
continue;
if (method.IsConstructor)
@ -515,9 +515,8 @@ namespace CppSharp.Generators.CLI @@ -515,9 +515,8 @@ namespace CppSharp.Generators.CLI
public void GenerateMethod(Method method)
{
if (method.Ignore) return;
if (ASTUtils.CheckIgnoreMethod(method)) return;
if (method.Access != AccessSpecifier.Public)
PushBlock(CLIBlockKind.Method, method);
GenerateDeclarationCommon(method);

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

@ -384,7 +384,7 @@ namespace CppSharp.Generators.CSharp @@ -384,7 +384,7 @@ namespace CppSharp.Generators.CSharp
foreach (var method in @class.Methods)
{
if (ASTUtils.CheckIgnoreMethod(@class, method))
if (ASTUtils.CheckIgnoreMethod(method))
continue;
if (method.IsConstructor)
@ -432,7 +432,7 @@ namespace CppSharp.Generators.CSharp @@ -432,7 +432,7 @@ namespace CppSharp.Generators.CSharp
foreach (var field in @class.Fields)
{
if (ASTUtils.CheckIgnoreField(@class, field)) continue;
if (ASTUtils.CheckIgnoreField(field)) continue;
var nativeField = string.Format("{0}->{1}",
Helpers.GeneratedIdentifier("ptr"), field.OriginalName);
@ -582,6 +582,7 @@ namespace CppSharp.Generators.CSharp @@ -582,6 +582,7 @@ namespace CppSharp.Generators.CSharp
foreach (var field in @class.Fields)
{
if (ASTUtils.CheckIgnoreField(field)) continue;
GenerateClassField(@class, isInternal, field);
}
}
@ -794,7 +795,7 @@ namespace CppSharp.Generators.CSharp @@ -794,7 +795,7 @@ namespace CppSharp.Generators.CSharp
var staticMethods = new List<Method>();
foreach (var method in @class.Methods)
{
if (ASTUtils.CheckIgnoreMethod(@class, method))
if (ASTUtils.CheckIgnoreMethod(method))
continue;
if (method.IsConstructor)
@ -985,7 +986,7 @@ namespace CppSharp.Generators.CSharp @@ -985,7 +986,7 @@ namespace CppSharp.Generators.CSharp
foreach (var ctor in @class.Constructors)
{
if (ASTUtils.CheckIgnoreMethod(@class, ctor))
if (ASTUtils.CheckIgnoreMethod(ctor))
continue;
GenerateMethod(ctor, @class);

4
src/Generator/Passes/CheckDuplicatedNamesPass.cs

@ -72,7 +72,7 @@ namespace CppSharp.Passes @@ -72,7 +72,7 @@ namespace CppSharp.Passes
public override bool VisitFieldDecl(Field decl)
{
if (ASTUtils.CheckIgnoreField(null, decl))
if (ASTUtils.CheckIgnoreField(decl))
return false;
if(!AlreadyVisited(decl))
@ -89,7 +89,7 @@ namespace CppSharp.Passes @@ -89,7 +89,7 @@ namespace CppSharp.Passes
public override bool VisitMethodDecl(Method decl)
{
if (ASTUtils.CheckIgnoreMethod(null, decl))
if (ASTUtils.CheckIgnoreMethod(decl))
return false;
if(!AlreadyVisited(decl))

2
src/Generator/Passes/FieldToPropertyPass.cs

@ -13,7 +13,7 @@ namespace CppSharp.Passes @@ -13,7 +13,7 @@ namespace CppSharp.Passes
if (@class.IsValueType)
return false;
if (ASTUtils.CheckIgnoreField(@class,field))
if (ASTUtils.CheckIgnoreField(field))
return false;
var prop = new Property()

2
src/Generator/Passes/GetterSetterToPropertyPass.cs

@ -76,7 +76,7 @@ namespace CppSharp.Passes @@ -76,7 +76,7 @@ namespace CppSharp.Passes
if (AlreadyVisited(method))
return false;
if (ASTUtils.CheckIgnoreMethod(null, method))
if (ASTUtils.CheckIgnoreMethod(method))
return false;
var @class = method.Namespace as Class;

Loading…
Cancel
Save