|
|
|
@ -1528,7 +1528,7 @@ namespace CppSharp.Generators.CSharp |
|
|
|
} |
|
|
|
} |
|
|
|
else if (method.IsOverride && method.IsSynthetized) |
|
|
|
else if (method.IsOverride && method.IsSynthetized) |
|
|
|
{ |
|
|
|
{ |
|
|
|
GenerateVirtualTableMethodCall(method, @class); |
|
|
|
GenerateVirtualTableFunctionCall(method, @class); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
@ -1557,7 +1557,7 @@ namespace CppSharp.Generators.CSharp |
|
|
|
PopBlock(NewLineKind.BeforeNextBlock); |
|
|
|
PopBlock(NewLineKind.BeforeNextBlock); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void GenerateVirtualTableMethodCall(Method method, Class @class) |
|
|
|
private void GenerateVirtualTableFunctionCall(Method method, Class @class) |
|
|
|
{ |
|
|
|
{ |
|
|
|
WriteLine("void* vtable = *((void**) __Instance.ToPointer());"); |
|
|
|
WriteLine("void* vtable = *((void**) __Instance.ToPointer());"); |
|
|
|
int i; |
|
|
|
int i; |
|
|
|
@ -1573,15 +1573,12 @@ namespace CppSharp.Generators.CSharp |
|
|
|
i = @class.Layout.Layout.Components.FindIndex(m => m.Method == method); |
|
|
|
i = @class.Layout.Layout.Components.FindIndex(m => m.Method == method); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
WriteLine("void* slot = *((void**) vtable + {0} * sizeof(IntPtr));", i); |
|
|
|
WriteLine("void* slot = *((void**) vtable + {0} * IntPtr.Size);", i); |
|
|
|
string @delegate = method.Name + "Delegate"; |
|
|
|
string @delegate = method.Name + "Delegate"; |
|
|
|
string delegateId = GeneratedIdentifier(@delegate); |
|
|
|
string delegateId = GeneratedIdentifier(@delegate); |
|
|
|
WriteLine("{0} {1} = ({0}) Marshal.GetDelegateForFunctionPointer(new IntPtr(slot), typeof({0}));", |
|
|
|
WriteLine("var {1} = ({0}) Marshal.GetDelegateForFunctionPointer(new IntPtr(slot), typeof({0}));", |
|
|
|
@delegate, delegateId); |
|
|
|
@delegate, delegateId); |
|
|
|
if (!method.OriginalReturnType.Type.IsPrimitiveType(PrimitiveType.Void)) |
|
|
|
GenerateFunctionCall(delegateId, method.Parameters, method); |
|
|
|
Write("return "); |
|
|
|
|
|
|
|
WriteLine("{0}({1});", delegateId, string.Join(", ", method.Parameters.Where( |
|
|
|
|
|
|
|
p => p.Kind != ParameterKind.IndirectReturnType).Select(p => Helpers.SafeIdentifier(p.Name)))); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void GenerateOperator(Method method, Class @class) |
|
|
|
private void GenerateOperator(Method method, Class @class) |
|
|
|
@ -1937,9 +1934,11 @@ namespace CppSharp.Generators.CSharp |
|
|
|
PushBlock(CSharpBlockKind.Typedef); |
|
|
|
PushBlock(CSharpBlockKind.Typedef); |
|
|
|
WriteLine("[UnmanagedFunctionPointerAttribute(CallingConvention.{0})]", |
|
|
|
WriteLine("[UnmanagedFunctionPointerAttribute(CallingConvention.{0})]", |
|
|
|
Helpers.ToCSharpCallConv(functionType.CallingConvention)); |
|
|
|
Helpers.ToCSharpCallConv(functionType.CallingConvention)); |
|
|
|
|
|
|
|
TypePrinter.PushContext(CSharpTypePrinterContextKind.Native); |
|
|
|
WriteLine("public {0};", |
|
|
|
WriteLine("public {0};", |
|
|
|
string.Format(TypePrinter.VisitDelegate(functionType).Type, |
|
|
|
string.Format(TypePrinter.VisitDelegate(functionType).Type, |
|
|
|
SafeIdentifier(typedef.Name))); |
|
|
|
SafeIdentifier(typedef.Name))); |
|
|
|
|
|
|
|
TypePrinter.PopContext(); |
|
|
|
PopBlock(NewLineKind.BeforeNextBlock); |
|
|
|
PopBlock(NewLineKind.BeforeNextBlock); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (typedef.Type.IsEnumType()) |
|
|
|
else if (typedef.Type.IsEnumType()) |
|
|
|
|