From 6a9e4b7e28f40917896d4f9d04f5a0b7ce3d63d4 Mon Sep 17 00:00:00 2001 From: josetr <37419832+josetr@users.noreply.github.com> Date: Thu, 30 Jun 2022 20:38:52 +0100 Subject: [PATCH] Remove duplicate IsNativeMethod functions --- src/Generator/Generators/C/CppSources.cs | 12 ++---------- src/Generator/Generators/CLI/CLISources.cs | 12 ++---------- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/src/Generator/Generators/C/CppSources.cs b/src/Generator/Generators/C/CppSources.cs index 64619c77..a8e7a013 100644 --- a/src/Generator/Generators/C/CppSources.cs +++ b/src/Generator/Generators/C/CppSources.cs @@ -5,6 +5,7 @@ using System.IO; using System.Linq; using CppSharp.AST; using CppSharp.AST.Extensions; +using CppSharp.Extensions; using CppSharp.Generators.C; using CppSharp.Generators.CLI; using CppSharp.Types; @@ -510,7 +511,7 @@ namespace CppSharp.Generators.Cpp } else { - if (IsNativeMethod(function)) + if (function.IsNativeMethod()) Write($@"(({typePrinter.PrintTag(@class)}::{ @class.QualifiedOriginalName}*){Helpers.InstanceIdentifier})->"); @@ -572,15 +573,6 @@ namespace CppSharp.Generators.Cpp WriteLine($"return {marshal.Context.Return};"); } - public static bool IsNativeMethod(Function function) - { - var method = function as Method; - if (method == null) - return false; - - return method.Conversion == MethodConversionKind.None; - } - public bool IsNativeFunctionOrStaticMethod(Function function) { var method = function as Method; diff --git a/src/Generator/Generators/CLI/CLISources.cs b/src/Generator/Generators/CLI/CLISources.cs index 3be397f7..af55a4cd 100644 --- a/src/Generator/Generators/CLI/CLISources.cs +++ b/src/Generator/Generators/CLI/CLISources.cs @@ -4,6 +4,7 @@ using System.Globalization; using System.Linq; using CppSharp.AST; using CppSharp.AST.Extensions; +using CppSharp.Extensions; using CppSharp.Generators.C; using Type = CppSharp.AST.Type; @@ -1014,7 +1015,7 @@ namespace CppSharp.Generators.CLI { if (isValueType) Write($"{valueMarshalName}."); - else if (IsNativeMethod(function)) + else if (function.IsNativeMethod()) Write($"(({typePrinter.PrintTag(@class)}::{@class.QualifiedOriginalName}*)NativePtr)->"); Write("{0}(", function.OriginalName); } @@ -1109,15 +1110,6 @@ namespace CppSharp.Generators.CLI } } - private static bool IsNativeMethod(Function function) - { - var method = function as Method; - if (method == null) - return false; - - return method.Conversion == MethodConversionKind.None; - } - private static bool IsNativeFunctionOrStaticMethod(Function function) { var method = function as Method;