Browse Source

Added a hard-coded for the time being option indicating whether the wrapped lib is 32-bit and used that option to generate the v-table offsets.

Signed-off-by: Dimitar Dobrev <dpldobrev@yahoo.com>
pull/53/head
Dimitar Dobrev 13 years ago
parent
commit
816c946790
  1. 5
      src/Generator/AST/VTables.cs
  2. 2
      src/Generator/Driver.cs
  3. 2
      src/Generator/Generators/CSharp/CSharpTextTemplate.cs

5
src/Generator/AST/VTables.cs

@ -83,7 +83,8 @@ namespace CppSharp.AST @@ -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 @@ -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";

2
src/Generator/Driver.cs

@ -280,6 +280,8 @@ namespace CppSharp @@ -280,6 +280,8 @@ namespace CppSharp
{
get { return GeneratorKind == LanguageGeneratorKind.CLI; }
}
public bool Is32Bit { get { return true; } }
}
public class InvalidOptionException : Exception

2
src/Generator/Generators/CSharp/CSharpTextTemplate.cs

@ -1574,7 +1574,7 @@ namespace CppSharp.Generators.CSharp @@ -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);
}

Loading…
Cancel
Save