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
{ {
public static class ASTUtils 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.Ignore) return true;
if (function is Method) if (function is Method)
return CheckIgnoreMethod(@class, function as Method); return CheckIgnoreMethod(function as Method);
return false; return false;
} }
public static bool CheckIgnoreMethod(Class @class, Method method) public static bool CheckIgnoreMethod(Method method)
{ {
if (method.Ignore) return true; if (method.Ignore) return true;
var isEmptyCtor = method.IsConstructor && method.Parameters.Count == 0; 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; return true;
if (method.IsCopyConstructor || method.IsMoveConstructor) if (method.IsCopyConstructor || method.IsMoveConstructor)
@ -40,14 +41,12 @@ namespace CppSharp.AST
return false; 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 true;
return false; return field.Ignore;
} }
} }
} }

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

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

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

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

4
src/Generator/Passes/CheckDuplicatedNamesPass.cs

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

2
src/Generator/Passes/FieldToPropertyPass.cs

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

2
src/Generator/Passes/GetterSetterToPropertyPass.cs

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

Loading…
Cancel
Save