Browse Source

Remove duplicate IsNativeMethod functions

refactor
josetr 3 years ago
parent
commit
27d9adb20c
  1. 12
      src/Generator/Generators/C/CppSources.cs
  2. 12
      src/Generator/Generators/CLI/CLISources.cs

12
src/Generator/Generators/C/CppSources.cs

@ -5,6 +5,7 @@ using System.IO;
using System.Linq; using System.Linq;
using CppSharp.AST; using CppSharp.AST;
using CppSharp.AST.Extensions; using CppSharp.AST.Extensions;
using CppSharp.Extensions;
using CppSharp.Generators.C; using CppSharp.Generators.C;
using CppSharp.Generators.CLI; using CppSharp.Generators.CLI;
using CppSharp.Types; using CppSharp.Types;
@ -510,7 +511,7 @@ namespace CppSharp.Generators.Cpp
} }
else else
{ {
if (IsNativeMethod(function)) if (function.IsNativeMethod())
Write($@"(({typePrinter.PrintTag(@class)}::{ Write($@"(({typePrinter.PrintTag(@class)}::{
@class.QualifiedOriginalName}*){Helpers.InstanceIdentifier})->"); @class.QualifiedOriginalName}*){Helpers.InstanceIdentifier})->");
@ -572,15 +573,6 @@ namespace CppSharp.Generators.Cpp
WriteLine($"return {marshal.Context.Return};"); 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) public bool IsNativeFunctionOrStaticMethod(Function function)
{ {
var method = function as Method; var method = function as Method;

12
src/Generator/Generators/CLI/CLISources.cs

@ -4,6 +4,7 @@ using System.Globalization;
using System.Linq; using System.Linq;
using CppSharp.AST; using CppSharp.AST;
using CppSharp.AST.Extensions; using CppSharp.AST.Extensions;
using CppSharp.Extensions;
using CppSharp.Generators.C; using CppSharp.Generators.C;
using Type = CppSharp.AST.Type; using Type = CppSharp.AST.Type;
@ -1014,7 +1015,7 @@ namespace CppSharp.Generators.CLI
{ {
if (isValueType) if (isValueType)
Write($"{valueMarshalName}."); Write($"{valueMarshalName}.");
else if (IsNativeMethod(function)) else if (function.IsNativeMethod())
Write($"(({typePrinter.PrintTag(@class)}::{@class.QualifiedOriginalName}*)NativePtr)->"); Write($"(({typePrinter.PrintTag(@class)}::{@class.QualifiedOriginalName}*)NativePtr)->");
Write("{0}(", function.OriginalName); 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) private static bool IsNativeFunctionOrStaticMethod(Function function)
{ {
var method = function as Method; var method = function as Method;

Loading…
Cancel
Save