diff --git a/unity/Assets/core/upm/Editor/Resources/puerts/templates/il2cppbridge.tpl.mjs b/unity/Assets/core/upm/Editor/Resources/puerts/templates/il2cppbridge.tpl.mjs index 5c79794a22..08535a4236 100644 --- a/unity/Assets/core/upm/Editor/Resources/puerts/templates/il2cppbridge.tpl.mjs +++ b/unity/Assets/core/upm/Editor/Resources/puerts/templates/il2cppbridge.tpl.mjs @@ -115,13 +115,13 @@ ${bridgeInfos.map(genBridge).join('\n')} static BridgeFuncInfo g_bridgeFuncInfos[] = { ${FOR(bridgeInfos, info => t` - {"${info.Signature}", (MethodPointer)b_${info.Signature}}, + {"${info.Signature}", (Il2CppMethodPointer)b_${info.Signature}}, `)} {nullptr, nullptr} }; -MethodPointer FindBridgeFunc(const char* signature) +Il2CppMethodPointer FindBridgeFunc(const char* signature) { auto begin = &g_bridgeFuncInfos[0]; auto end = &g_bridgeFuncInfos[sizeof(g_bridgeFuncInfos) / sizeof(BridgeFuncInfo) - 1]; diff --git a/unity/Assets/core/upm/Editor/Resources/puerts/xil2cpp/Puerts_il2cpp.cpp.txt b/unity/Assets/core/upm/Editor/Resources/puerts/xil2cpp/Puerts_il2cpp.cpp.txt index cf0c137abb..0508f16c6a 100644 --- a/unity/Assets/core/upm/Editor/Resources/puerts/xil2cpp/Puerts_il2cpp.cpp.txt +++ b/unity/Assets/core/upm/Editor/Resources/puerts/xil2cpp/Puerts_il2cpp.cpp.txt @@ -43,7 +43,6 @@ using namespace il2cpp::vm; namespace puerts { - struct CSharpMethodInfo { std::string Name; @@ -53,15 +52,6 @@ struct CSharpMethodInfo std::vector OverloadDatas; }; -struct FieldWrapData -{ - FieldWrapFuncPtr Getter; - FieldWrapFuncPtr Setter; - FieldInfo *FieldInfo; - size_t Offset; - Il2CppClass* TypeInfo; -}; - struct CSharpFieldInfo { std::string Name; @@ -69,6 +59,16 @@ struct CSharpFieldInfo FieldWrapData *Data; }; +struct JsClassInfoHeader +{ + const void* TypeId; + const void* SuperTypeId; + Il2CppClass* Class; + bool IsValueType; + Il2CppMethodPointer DelegateBridge; + WrapData** CtorWrapDatas; +}; + struct JsClassInfo : public JsClassInfoHeader { std::string Name; @@ -1741,7 +1741,7 @@ Il2CppObject* GetJSObjectValue(Il2CppObject* jsObject, Il2CppString* key, Il2Cpp WrapFuncPtr FindWrapFunc(const char* signature); struct FieldWrapFuncInfo * FindFieldWrapFuncInfo(const char* signature); -MethodPointer FindBridgeFunc(const char* signature); +Il2CppMethodPointer FindBridgeFunc(const char* signature); puerts::UnityExports* GetUnityExports() { diff --git a/unity/Assets/core/upm/Editor/Resources/puerts/xil2cpp/TDataTrans.h.txt b/unity/Assets/core/upm/Editor/Resources/puerts/xil2cpp/TDataTrans.h.txt index 4c6c8d9892..5059579f63 100644 --- a/unity/Assets/core/upm/Editor/Resources/puerts/xil2cpp/TDataTrans.h.txt +++ b/unity/Assets/core/upm/Editor/Resources/puerts/xil2cpp/TDataTrans.h.txt @@ -10,6 +10,30 @@ namespace puerts { +typedef void (*FieldWrapFuncPtr)(pesapi_callback_info info, FieldInfo* field, size_t offset, Il2CppClass* fieldType); +typedef bool (*WrapFuncPtr)(MethodInfo* method, Il2CppMethodPointer methodPointer, pesapi_callback_info info, bool checkArgument, struct WrapData* wrapData); + +struct FieldWrapData +{ + FieldWrapFuncPtr Getter; + FieldWrapFuncPtr Setter; + FieldInfo *FieldInfo; + size_t Offset; + Il2CppClass* TypeInfo; +}; + +struct WrapData +{ + WrapFuncPtr Wrap; + MethodInfo* Method; + Il2CppMethodPointer MethodPointer; + bool IsStatic; + bool IsExtensionMethod; + bool HasParamArray; + int OptionalNum; + Il2CppClass* TypeInfos[0]; +}; + // begin function in Puerts_il2cpp.cpp Il2CppObject* JsValueToCSRef(Il2CppClass *klass, pesapi_env env, pesapi_value jsval); @@ -108,7 +132,7 @@ struct WrapFuncInfo struct BridgeFuncInfo { const char* Signature; - MethodPointer Method; + Il2CppMethodPointer Method; }; struct FieldWrapFuncInfo diff --git a/unity/Assets/core/upm/Editor/Resources/puerts/xil2cpp/UnityExports4Puerts.h.txt b/unity/Assets/core/upm/Editor/Resources/puerts/xil2cpp/UnityExports4Puerts.h.txt index a90fd92dd1..f2d180bd7d 100644 --- a/unity/Assets/core/upm/Editor/Resources/puerts/xil2cpp/UnityExports4Puerts.h.txt +++ b/unity/Assets/core/upm/Editor/Resources/puerts/xil2cpp/UnityExports4Puerts.h.txt @@ -19,13 +19,7 @@ struct PObjectRefInfo #if defined(USE_OUTSIZE_UNITY) -typedef void (*MethodPointer)(); -typedef void MethodType; -typedef bool (*WrapFuncPtr)(MethodType* method, MethodPointer methodPointer, const v8::FunctionCallbackInfo& info, bool checkArgument, struct WrapData* wrapData); - -typedef void (*FieldWrapFuncPtr)(const v8::FunctionCallbackInfo& info, void* fieldInfo, size_t offset, void* typeInfo); - -typedef void TypeIdType; +typedef void* (*GetJsClassInfoFunc)(const void* TypeId, bool TryLazyLoad); typedef void (*SetNativePtrFunc)(v8::Object* obj, void* ptr, void* type_id); @@ -36,14 +30,8 @@ typedef const void* (*CSharpTypeToTypeIdFunc)(const void *type); typedef v8::Value* (*GetModuleExecutorFunc)(v8::Context* env); #else - -#define MethodPointer Il2CppMethodPointer - -typedef MethodInfo MethodType; -typedef bool (*WrapFuncPtr)(MethodType* method, Il2CppMethodPointer methodPointer, pesapi_callback_info info, bool checkArgument, struct WrapData* wrapData); -typedef void (*FieldWrapFuncPtr)(pesapi_callback_info info, FieldInfo* field, size_t offset, Il2CppClass* fieldType); - -typedef Il2CppClass TypeIdType; + +typedef struct JsClassInfoHeader* (*GetJsClassInfoFunc)(const void* TypeId, bool TryLazyLoad); typedef void (*SetNativePtrFunc)(pesapi_value obj, void* ptr, const void* type_id); @@ -55,7 +43,6 @@ typedef pesapi_value (*GetModuleExecutorFunc)(pesapi_env env); #endif -typedef struct JsClassInfoHeader* (*GetJsClassInfoFunc)(const void* TypeId, bool TryLazyLoad); typedef void* (*GetRuntimeObjectFromPersistentObjectFunc)(pesapi_env env, pesapi_value pvalue); @@ -65,28 +52,6 @@ typedef void(*LogCallbackFunc)(const char* value); typedef void (*SetExtraDataFunc)(pesapi_env env, struct PObjectRefInfo* objectInfo); -struct WrapData -{ - WrapFuncPtr Wrap; - MethodType* Method; - MethodPointer MethodPointer; - bool IsStatic; - bool IsExtensionMethod; - bool HasParamArray; - int OptionalNum; - TypeIdType* TypeInfos[0]; -}; - -struct JsClassInfoHeader -{ - const void* TypeId; - const void* SuperTypeId; - TypeIdType* Class; - bool IsValueType; - MethodPointer DelegateBridge; - WrapData** CtorWrapDatas; -}; - struct UnityExports { //.cpp api diff --git a/unity/cli/UnityExports4Puerts.h b/unity/cli/UnityExports4Puerts.h index fcdfce9d80..453ff20965 100644 --- a/unity/cli/UnityExports4Puerts.h +++ b/unity/cli/UnityExports4Puerts.h @@ -19,13 +19,7 @@ struct PObjectRefInfo #if defined(USE_OUTSIZE_UNITY) -typedef void (*MethodPointer)(); -typedef void MethodType; -typedef bool (*WrapFuncPtr)(MethodType* method, MethodPointer methodPointer, const v8::FunctionCallbackInfo& info, bool checkArgument, struct WrapData* wrapData); - -typedef void (*FieldWrapFuncPtr)(const v8::FunctionCallbackInfo& info, void* fieldInfo, size_t offset, void* typeInfo); - -typedef void TypeIdType; +typedef void* (*GetJsClassInfoFunc)(const void* TypeId, bool TryLazyLoad); typedef void (*SetNativePtrFunc)(v8::Object* obj, void* ptr, void* type_id); @@ -36,14 +30,8 @@ typedef const void* (*CSharpTypeToTypeIdFunc)(const void *type); typedef v8::Value* (*GetModuleExecutorFunc)(v8::Context* env); #else - -#define MethodPointer Il2CppMethodPointer - -typedef MethodInfo MethodType; -typedef bool (*WrapFuncPtr)(MethodType* method, Il2CppMethodPointer methodPointer, pesapi_callback_info info, bool checkArgument, struct WrapData* wrapData); -typedef void (*FieldWrapFuncPtr)(pesapi_callback_info info, FieldInfo* field, size_t offset, Il2CppClass* fieldType); - -typedef Il2CppClass TypeIdType; + +typedef struct JsClassInfoHeader* (*GetJsClassInfoFunc)(const void* TypeId, bool TryLazyLoad); typedef void (*SetNativePtrFunc)(pesapi_value obj, void* ptr, const void* type_id); @@ -55,7 +43,6 @@ typedef pesapi_value (*GetModuleExecutorFunc)(pesapi_env env); #endif -typedef struct JsClassInfoHeader* (*GetJsClassInfoFunc)(const void* TypeId, bool TryLazyLoad); typedef void* (*GetRuntimeObjectFromPersistentObjectFunc)(pesapi_env env, pesapi_value pvalue); @@ -65,28 +52,6 @@ typedef void(*LogCallbackFunc)(const char* value); typedef void (*SetExtraDataFunc)(pesapi_env env, struct PObjectRefInfo* objectInfo); -struct WrapData -{ - WrapFuncPtr Wrap; - MethodType* Method; - MethodPointer MethodPointer; - bool IsStatic; - bool IsExtensionMethod; - bool HasParamArray; - int OptionalNum; - TypeIdType* TypeInfos[0]; -}; - -struct JsClassInfoHeader -{ - const void* TypeId; - const void* SuperTypeId; - TypeIdType* Class; - bool IsValueType; - MethodPointer DelegateBridge; - WrapData** CtorWrapDatas; -}; - struct UnityExports { //.cpp api diff --git a/unity/native_src_il2cpp/Src/Puerts.cpp b/unity/native_src_il2cpp/Src/Puerts.cpp index bd81e62ee6..2ab07e11e0 100644 --- a/unity/native_src_il2cpp/Src/Puerts.cpp +++ b/unity/native_src_il2cpp/Src/Puerts.cpp @@ -127,7 +127,7 @@ static void SetRuntimeObjectToPersistentObject(pesapi_env env, pesapi_value pval } -static JsClassInfoHeader* GetJsClassInfo(const void* TypeId, bool TryLazyLoad) +static void* GetJsClassInfo(const void* TypeId, bool TryLazyLoad) { auto ClassDefinition = FindClassByID(TypeId, TryLazyLoad); if (!ClassDefinition) @@ -135,7 +135,7 @@ static JsClassInfoHeader* GetJsClassInfo(const void* TypeId, bool TryLazyLoad) return nullptr; } - return static_cast(ClassDefinition->Data); + return ClassDefinition->Data; } static v8::Value* GetModuleExecutor(v8::Context* env)