diff --git a/src/Generator/AST/Utils.cs b/src/Generator/AST/Utils.cs index 2f8c2b48..ed454281 100644 --- a/src/Generator/AST/Utils.cs +++ b/src/Generator/AST/Utils.cs @@ -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 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; } } } diff --git a/src/Generator/Generators/CLI/CLIHeadersTemplate.cs b/src/Generator/Generators/CLI/CLIHeadersTemplate.cs index 0bafd45d..5d4dcd96 100644 --- a/src/Generator/Generators/CLI/CLIHeadersTemplate.cs +++ b/src/Generator/Generators/CLI/CLIHeadersTemplate.cs @@ -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 var staticMethods = new List(); 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 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); diff --git a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs b/src/Generator/Generators/CSharp/CSharpTextTemplate.cs index e55bde5d..06426324 100644 --- a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs +++ b/src/Generator/Generators/CSharp/CSharpTextTemplate.cs @@ -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 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 foreach (var field in @class.Fields) { + if (ASTUtils.CheckIgnoreField(field)) continue; GenerateClassField(@class, isInternal, field); } } @@ -794,7 +795,7 @@ namespace CppSharp.Generators.CSharp var staticMethods = new List(); 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 foreach (var ctor in @class.Constructors) { - if (ASTUtils.CheckIgnoreMethod(@class, ctor)) + if (ASTUtils.CheckIgnoreMethod(ctor)) continue; GenerateMethod(ctor, @class); diff --git a/src/Generator/Passes/CheckDuplicatedNamesPass.cs b/src/Generator/Passes/CheckDuplicatedNamesPass.cs index 6453ec67..cfb86ea4 100644 --- a/src/Generator/Passes/CheckDuplicatedNamesPass.cs +++ b/src/Generator/Passes/CheckDuplicatedNamesPass.cs @@ -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 public override bool VisitMethodDecl(Method decl) { - if (ASTUtils.CheckIgnoreMethod(null, decl)) + if (ASTUtils.CheckIgnoreMethod(decl)) return false; if(!AlreadyVisited(decl)) diff --git a/src/Generator/Passes/FieldToPropertyPass.cs b/src/Generator/Passes/FieldToPropertyPass.cs index f2151256..2997e1d6 100644 --- a/src/Generator/Passes/FieldToPropertyPass.cs +++ b/src/Generator/Passes/FieldToPropertyPass.cs @@ -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() diff --git a/src/Generator/Passes/GetterSetterToPropertyPass.cs b/src/Generator/Passes/GetterSetterToPropertyPass.cs index a3c26349..8039611f 100644 --- a/src/Generator/Passes/GetterSetterToPropertyPass.cs +++ b/src/Generator/Passes/GetterSetterToPropertyPass.cs @@ -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;