[fix] 修复ReversePInvokeWrapper生成的bug

main
walon 2022-10-14 16:15:18 +08:00
parent e3095ccc01
commit 4a00e944a6
3 changed files with 4 additions and 12 deletions

View File

@ -5,15 +5,16 @@ namespace hybridclr
{ {
namespace metadata namespace metadata
{ {
//!!!{{REVERSE_PINVOKE_METHOD_STUB
void CallLuaFunction(void* xState, int32_t wrapperIndex) void CallLuaFunction(void* xState, int32_t wrapperIndex)
{ {
const MethodInfo* method = MetadataModule::GetMethodInfoByReversePInvokeWrapperIndex(wrapperIndex); const MethodInfo* method = MetadataModule::GetMethodInfoByReversePInvokeWrapperIndex(wrapperIndex);
typedef void (*Callback)(void* xState, const MethodInfo* method); typedef void (*Callback)(void* xState, const MethodInfo* method);
((Callback)GetInterpreterDirectlyCallMethodPointer(method))(xState, method); ((Callback)(method->methodPointerCallByInterp))(xState, method);
} }
//!!!{{REVERSE_PINVOKE_METHOD_STUB
void __ReversePInvokeMethod_0(void* xState) void __ReversePInvokeMethod_0(void* xState)
{ {
CallLuaFunction(xState, 0); CallLuaFunction(xState, 0);

View File

@ -15,15 +15,6 @@ namespace HybridCLR.Editor.ReversePInvokeWrap
var frr = new FileRegionReplace(template); var frr = new FileRegionReplace(template);
var codes = new List<string>(); var codes = new List<string>();
codes.Add(@"
void CallLuaFunction(void* xState, int32_t wrapperIndex)
{
const MethodInfo* method = MetadataModule::GetMethodInfoByReversePInvokeWrapperIndex(wrapperIndex);
typedef void (*Callback)(void* xState, const MethodInfo* method);
((Callback)GetInterpreterDirectlyCallMethodPointer(method))(xState, method);
}
");
for(int i = 0; i < wrapperCount; i++) for(int i = 0; i < wrapperCount; i++)
{ {
codes.Add($@" codes.Add($@"

View File

@ -1,6 +1,6 @@
{ {
"name": "com.focus-creative-games.hybridclr_unity", "name": "com.focus-creative-games.hybridclr_unity",
"version": "0.4.1", "version": "0.4.2",
"displayName": "HybridCLR", "displayName": "HybridCLR",
"description": "Unity package for HybridCLR. It includes editor and runtime scripts and assets for HybridCLR", "description": "Unity package for HybridCLR. It includes editor and runtime scripts and assets for HybridCLR",
"category": "Runtime", "category": "Runtime",