diff --git a/src/Generator/AST/Utils.cs b/src/Generator/AST/Utils.cs index ffa7c01f..c85c8ab3 100644 --- a/src/Generator/AST/Utils.cs +++ b/src/Generator/AST/Utils.cs @@ -1,9 +1,53 @@ -using System.Collections.Generic; - + namespace CppSharp.AST { public static class Utils { + public static bool CheckIgnoreFunction(Class @class, Function function) + { + if (function.Ignore) return true; + + if (function is Method) + return CheckIgnoreMethod(@class, function as Method); + + return false; + } + + public static bool CheckIgnoreMethod(Class @class, Method method) + { + if (method.Ignore) return true; + + var isEmptyCtor = method.IsConstructor && method.Parameters.Count == 0; + + if (@class.IsValueType && isEmptyCtor) + return true; + + if (method.IsCopyConstructor || method.IsMoveConstructor) + return true; + + if (method.IsDestructor) + return true; + + if (method.OperatorKind == CXXOperatorKind.Equal) + return true; + + if (method.Kind == CXXMethodKind.Conversion) + return true; + + if (method.Access != AccessSpecifier.Public) + return true; + + return false; + } + + public static bool CheckIgnoreField(Class @class, Field field) + { + if (field.Ignore) return true; + + if (field.Access != AccessSpecifier.Public) + return true; + return false; + } } } diff --git a/src/Generator/Generators/Template.cs b/src/Generator/Generators/Template.cs index 47b56ae2..5fc7cd36 100644 --- a/src/Generator/Generators/Template.cs +++ b/src/Generator/Generators/Template.cs @@ -22,52 +22,4 @@ Transform = driver.Transform; TranslationUnit = unit; } - - public static bool CheckIgnoreFunction(Class @class, Function function) - { - if (function.Ignore) return true; - - if (function is Method) - return CheckIgnoreMethod(@class, function as Method); - - return false; - } - - public static bool CheckIgnoreMethod(Class @class, Method method) - { - if (method.Ignore) return true; - - var isEmptyCtor = method.IsConstructor && method.Parameters.Count == 0; - - if (@class.IsValueType && isEmptyCtor) - return true; - - if (method.IsCopyConstructor || method.IsMoveConstructor) - return true; - - if (method.IsDestructor) - return true; - - if (method.OperatorKind == CXXOperatorKind.Equal) - return true; - - if (method.Kind == CXXMethodKind.Conversion) - return true; - - if (method.Access != AccessSpecifier.Public) - return true; - - return false; - } - - public static bool CheckIgnoreField(Class @class, Field field) - { - if (field.Ignore) return true; - - if (field.Access != AccessSpecifier.Public) - return true; - - return false; - } - } } \ No newline at end of file diff --git a/src/Generator/Passes/CheckAmbiguousOverloads.cs b/src/Generator/Passes/CheckAmbiguousOverloads.cs index fa2a64af..6e94bf0a 100644 --- a/src/Generator/Passes/CheckAmbiguousOverloads.cs +++ b/src/Generator/Passes/CheckAmbiguousOverloads.cs @@ -30,10 +30,10 @@ namespace CppSharp.Passes if (overload1.Function == overload2.Function) return false; - if (TextTemplate.CheckIgnoreFunction(@class, overload1.Function)) + if (AST.Utils.CheckIgnoreFunction(@class, overload1.Function)) return false; - if (TextTemplate.CheckIgnoreFunction(@class, overload2.Function)) + if (AST.Utils.CheckIgnoreFunction(@class, overload2.Function)) return false; // TODO: Default parameters?