diff --git a/src/Generator/AST/VTables.cs b/src/Generator/AST/VTables.cs index f7e15e76..d3894996 100644 --- a/src/Generator/AST/VTables.cs +++ b/src/Generator/AST/VTables.cs @@ -83,7 +83,8 @@ namespace CppSharp.AST throw new NotSupportedException(); } - public static string GetVirtualCallDelegate(INamedDecl method, Class @class, out string delegateId) + public static string GetVirtualCallDelegate(INamedDecl method, Class @class, + bool is32Bit, out string delegateId) { var virtualCallBuilder = new StringBuilder(); virtualCallBuilder.AppendFormat( @@ -106,7 +107,7 @@ namespace CppSharp.AST } virtualCallBuilder.AppendFormat( - "void* slot = *((void**) vtable + {0} * IntPtr.Size);", i); + "void* slot = *((void**) vtable + {0} * {1});", i, is32Bit ? 4 : 8); virtualCallBuilder.AppendLine(); string @delegate = method.Name + "Delegate"; diff --git a/src/Generator/Driver.cs b/src/Generator/Driver.cs index b57b71e3..1e153420 100644 --- a/src/Generator/Driver.cs +++ b/src/Generator/Driver.cs @@ -280,6 +280,8 @@ namespace CppSharp { get { return GeneratorKind == LanguageGeneratorKind.CLI; } } + + public bool Is32Bit { get { return true; } } } public class InvalidOptionException : Exception diff --git a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs b/src/Generator/Generators/CSharp/CSharpTextTemplate.cs index fa200f82..cfa1821f 100644 --- a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs +++ b/src/Generator/Generators/CSharp/CSharpTextTemplate.cs @@ -1574,7 +1574,7 @@ namespace CppSharp.Generators.CSharp private void GenerateVirtualTableFunctionCall(Function method, Class @class) { string delegateId; - Write(VTables.GetVirtualCallDelegate(method, @class, out delegateId)); + Write(VTables.GetVirtualCallDelegate(method, @class, Driver.Options.Is32Bit, out delegateId)); GenerateFunctionCall(delegateId, method.Parameters, method); }