From 6b1bc6800eff97635231139def7b2efb4b393049 Mon Sep 17 00:00:00 2001 From: johnche Date: Tue, 5 Nov 2024 10:52:11 +0800 Subject: [PATCH] =?UTF-8?q?[unity]=E9=87=8D=E6=9E=84pesapi=5Fapis=20->=20p?= =?UTF-8?q?esapi=5Fffi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../puerts/templates/il2cppbridge.tpl.mjs | 2 +- .../templates/il2cppfieldwrapper.tpl.mjs | 4 +- .../puerts/templates/il2cppwrapper.tpl.mjs | 2 +- .../puerts/templates/il2cppwrapperdef.tpl.mjs | 2 +- .../puerts/xil2cpp/Puerts_il2cpp.cpp.txt | 64 +++++------ .../Resources/puerts/xil2cpp/TDataTrans.h.txt | 104 +++++++++--------- .../Resources/puerts/xil2cpp/pesapi.h.txt | 8 +- unity/native_src_il2cpp/Inc/CppObjectMapper.h | 2 +- unity/native_src_il2cpp/Inc/pesapi.h | 8 +- .../native_src_il2cpp/Src/CppObjectMapper.cpp | 12 +- unity/native_src_il2cpp/Src/PesapiV8Impl.cpp | 6 +- unity/native_src_il2cpp/Src/Puerts.cpp | 6 +- 12 files changed, 110 insertions(+), 110 deletions(-) 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 fd9d66258f..e7ac7d7389 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 @@ -52,7 +52,7 @@ static ${il2cpp_snippets.SToCPPType(bridgeInfo.ReturnSignature)} b_${bridgeInfo. `)} PObjectRefInfo* delegateInfo = GetPObjectRefInfo(target); - struct pesapi_apis* apis = delegateInfo->Apis; + struct pesapi_ffi* apis = delegateInfo->Apis; pesapi_env_ref envRef = apis->pesapi_get_ref_associated_env(delegateInfo->ValueRef); AutoValueScope valueScope(apis, envRef); diff --git a/unity/Assets/core/upm/Editor/Resources/puerts/templates/il2cppfieldwrapper.tpl.mjs b/unity/Assets/core/upm/Editor/Resources/puerts/templates/il2cppfieldwrapper.tpl.mjs index b313369b1a..3d967662d0 100644 --- a/unity/Assets/core/upm/Editor/Resources/puerts/templates/il2cppfieldwrapper.tpl.mjs +++ b/unity/Assets/core/upm/Editor/Resources/puerts/templates/il2cppfieldwrapper.tpl.mjs @@ -31,7 +31,7 @@ function genGetField(fieldWrapperInfo) { function genFieldWrapper(fieldWrapperInfo) { return t` -static void ifg_${fieldWrapperInfo.Signature}(struct pesapi_apis* apis, pesapi_callback_info info, FieldInfo* fieldInfo, size_t offset, Il2CppClass* TIret) { +static void ifg_${fieldWrapperInfo.Signature}(struct pesapi_ffi* apis, pesapi_callback_info info, FieldInfo* fieldInfo, size_t offset, Il2CppClass* TIret) { // PLog("Running ifg_${fieldWrapperInfo.Signature}"); pesapi_env env = apis->pesapi_get_env(info); @@ -43,7 +43,7 @@ static void ifg_${fieldWrapperInfo.Signature}(struct pesapi_apis* apis, pesapi_c ${genGetField(fieldWrapperInfo)} } -static void ifs_${fieldWrapperInfo.Signature}(struct pesapi_apis* apis, pesapi_callback_info info, FieldInfo* fieldInfo, size_t offset, Il2CppClass* TIp) { +static void ifs_${fieldWrapperInfo.Signature}(struct pesapi_ffi* apis, pesapi_callback_info info, FieldInfo* fieldInfo, size_t offset, Il2CppClass* TIp) { // PLog("Running ifs_${fieldWrapperInfo.Signature}"); pesapi_env env = apis->pesapi_get_env(info); diff --git a/unity/Assets/core/upm/Editor/Resources/puerts/templates/il2cppwrapper.tpl.mjs b/unity/Assets/core/upm/Editor/Resources/puerts/templates/il2cppwrapper.tpl.mjs index 2cef8d6c0f..bdde222603 100644 --- a/unity/Assets/core/upm/Editor/Resources/puerts/templates/il2cppwrapper.tpl.mjs +++ b/unity/Assets/core/upm/Editor/Resources/puerts/templates/il2cppwrapper.tpl.mjs @@ -24,7 +24,7 @@ export default function Gen(genInfos) { namespace puerts { -${wrapperInfos.map((wrapperInfo) => `bool w_${wrapperInfo.Signature}(struct pesapi_apis* apis, MethodInfo* method, Il2CppMethodPointer methodPointer, pesapi_callback_info info, pesapi_env env, void* self, bool checkJSArgument, WrapData* wrapData);`).join('\n')} +${wrapperInfos.map((wrapperInfo) => `bool w_${wrapperInfo.Signature}(struct pesapi_ffi* apis, MethodInfo* method, Il2CppMethodPointer methodPointer, pesapi_callback_info info, pesapi_env env, void* self, bool checkJSArgument, WrapData* wrapData);`).join('\n')} static WrapFuncInfo g_wrapFuncInfos[] = { ${FOR(wrapperInfos, info => t` diff --git a/unity/Assets/core/upm/Editor/Resources/puerts/templates/il2cppwrapperdef.tpl.mjs b/unity/Assets/core/upm/Editor/Resources/puerts/templates/il2cppwrapperdef.tpl.mjs index 5f8a59c5c2..bfebce0e43 100644 --- a/unity/Assets/core/upm/Editor/Resources/puerts/templates/il2cppwrapperdef.tpl.mjs +++ b/unity/Assets/core/upm/Editor/Resources/puerts/templates/il2cppwrapperdef.tpl.mjs @@ -13,7 +13,7 @@ function genFuncWrapper(wrapperInfo) { return t` // ${wrapperInfo.CsName} -bool w_${wrapperInfo.Signature}(struct pesapi_apis* apis, MethodInfo* method, Il2CppMethodPointer methodPointer, pesapi_callback_info info, pesapi_env env, void* self, bool checkJSArgument, WrapData* wrapData) { +bool w_${wrapperInfo.Signature}(struct pesapi_ffi* apis, MethodInfo* method, Il2CppMethodPointer methodPointer, pesapi_callback_info info, pesapi_env env, void* self, bool checkJSArgument, WrapData* wrapData) { // PLog("Running w_${wrapperInfo.Signature}"); ${il2cpp_snippets.declareTypeInfo(wrapperInfo)} 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 1fb1fec443..53452c8dd9 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 @@ -142,7 +142,7 @@ static void ValueTypeFree(void* ptr) delete [] (uint8_t*)ptr; } -static void PApiFree(struct pesapi_apis* api, void* ptr, void* class_data, void* env_private) +static void PApiFree(struct pesapi_ffi* api, void* ptr, void* class_data, void* env_private) { ValueTypeFree(ptr); //TODO: class_data->IsValueType } @@ -281,7 +281,7 @@ void SetGlobalType_TypedValue(Il2CppReflectionType *type) g_typeofTypedValue = il2cpp_codegen_class_from_type(type->type); } -static void MethodCallback(struct pesapi_apis* apis, pesapi_callback_info info) +static void MethodCallback(struct pesapi_ffi* apis, pesapi_callback_info info) { try { @@ -332,13 +332,13 @@ static void MethodCallback(struct pesapi_apis* apis, pesapi_callback_info info) } } -static void GetterCallback(struct pesapi_apis* apis, pesapi_callback_info info) +static void GetterCallback(struct pesapi_ffi* apis, pesapi_callback_info info) { FieldWrapData* wrapData = static_cast(apis->pesapi_get_userdata(info)); wrapData->Getter(apis, info, wrapData->FieldInfo, wrapData->Offset, wrapData->TypeInfo); } -static void SetterCallback(struct pesapi_apis* apis, pesapi_callback_info info) +static void SetterCallback(struct pesapi_ffi* apis, pesapi_callback_info info) { FieldWrapData* wrapData = static_cast(apis->pesapi_get_userdata(info)); wrapData->Setter(apis, info, wrapData->FieldInfo, wrapData->Offset, wrapData->TypeInfo); @@ -437,7 +437,7 @@ void PLog(const char* Fmt, ...) } } -static void* CtorCallback(struct pesapi_apis* apis, pesapi_callback_info info) +static void* CtorCallback(struct pesapi_ffi* apis, pesapi_callback_info info) { JsClassInfoHeader* classInfo = reinterpret_cast(apis->pesapi_get_userdata(info)); // or will crash in macos. @@ -499,7 +499,7 @@ static void* CtorCallback(struct pesapi_apis* apis, pesapi_callback_info info) return nullptr; } -static void SetPObjectRefInfoValue(struct pesapi_apis* apis, pesapi_env env, PObjectRefInfo* objectInfo, pesapi_value_ref value_ref) +static void SetPObjectRefInfoValue(struct pesapi_ffi* apis, pesapi_env env, PObjectRefInfo* objectInfo, pesapi_value_ref value_ref) { objectInfo->Apis = apis; objectInfo->ValueRef = value_ref; @@ -507,12 +507,12 @@ static void SetPObjectRefInfoValue(struct pesapi_apis* apis, pesapi_env env, POb } -static pesapi_value GetPObjectRefInfoValue(struct pesapi_apis* apis, pesapi_env env, const PObjectRefInfo* objectInfo) +static pesapi_value GetPObjectRefInfoValue(struct pesapi_ffi* apis, pesapi_env env, const PObjectRefInfo* objectInfo) { return apis->pesapi_get_value_from_ref(env, objectInfo->ValueRef); } -static int32_t* FindOrCreateHandleStoreOfValue(struct pesapi_apis* apis, pesapi_env env, pesapi_value value, pesapi_value_ref* out_value_ref, Il2CppObject** out_object) +static int32_t* FindOrCreateHandleStoreOfValue(struct pesapi_ffi* apis, pesapi_env env, pesapi_value value, pesapi_value_ref* out_value_ref, Il2CppObject** out_object) { void* out_ptr; if(!apis->pesapi_get_private(env, value, &out_ptr)) @@ -554,7 +554,7 @@ static int32_t* FindOrCreateHandleStoreOfValue(struct pesapi_apis* apis, pesapi_ return res; } -static Il2CppObject* FunctionToDelegate(struct pesapi_apis* apis, pesapi_env env, pesapi_value jsval, JsClassInfoHeader* classInfo) +static Il2CppObject* FunctionToDelegate(struct pesapi_ffi* apis, pesapi_env env, pesapi_value jsval, JsClassInfoHeader* classInfo) { pesapi_value_ref value_ref; Il2CppObject* ret = nullptr; @@ -573,7 +573,7 @@ static Il2CppObject* FunctionToDelegate(struct pesapi_apis* apis, pesapi_env env return ret; } -static void* DelegateCtorCallback(struct pesapi_apis* apis, pesapi_callback_info info) +static void* DelegateCtorCallback(struct pesapi_ffi* apis, pesapi_callback_info info) { pesapi_env env = apis->pesapi_get_env(info); pesapi_value jsval = apis->pesapi_get_arg(info, 0); @@ -594,7 +594,7 @@ bool IsDelegate(Il2CppClass *klass) static FieldInfo* ArrayBufferCountField = nullptr; static FieldInfo* ArrayBufferBytesField = nullptr; -pesapi_value TryTranslateBuiltin(struct pesapi_apis* apis, pesapi_env env, Il2CppObject* obj) +pesapi_value TryTranslateBuiltin(struct pesapi_ffi* apis, pesapi_env env, Il2CppObject* obj) { if (obj) { @@ -622,7 +622,7 @@ pesapi_value TryTranslateBuiltin(struct pesapi_apis* apis, pesapi_env env, Il2Cp return nullptr; } -static pesapi_value TryTranslatePrimitiveWithClass(struct pesapi_apis* apis, pesapi_env env, Il2CppObject* obj, Il2CppClass *klass = nullptr) +static pesapi_value TryTranslatePrimitiveWithClass(struct pesapi_ffi* apis, pesapi_env env, Il2CppObject* obj, Il2CppClass *klass = nullptr) { if (obj) { @@ -706,7 +706,7 @@ static pesapi_value TryTranslatePrimitiveWithClass(struct pesapi_apis* apis, pes return nullptr; } -pesapi_value TranslateValueType(struct pesapi_apis* apis, pesapi_env env, Il2CppClass* targetClass, Il2CppObject* obj) +pesapi_value TranslateValueType(struct pesapi_ffi* apis, pesapi_env env, Il2CppClass* targetClass, Il2CppObject* obj) { auto len = targetClass->native_size; if (len < 0) @@ -719,7 +719,7 @@ pesapi_value TranslateValueType(struct pesapi_apis* apis, pesapi_env env, Il2Cpp return apis->pesapi_native_object_to_value(env, targetClass, buff, true); } -pesapi_value TryTranslateValueType(struct pesapi_apis* apis, pesapi_env env, Il2CppObject* obj) +pesapi_value TryTranslateValueType(struct pesapi_ffi* apis, pesapi_env env, Il2CppObject* obj) { if (obj && obj->klass) { @@ -747,7 +747,7 @@ union PrimitiveValueType double r8; }; -Il2CppObject* JsValueToCSRef(struct pesapi_apis* apis, Il2CppClass *klass, pesapi_env env, pesapi_value jsval) +Il2CppObject* JsValueToCSRef(struct pesapi_ffi* apis, Il2CppClass *klass, pesapi_env env, pesapi_value jsval) { if (klass == il2cpp_defaults.void_class) return nullptr; @@ -1015,7 +1015,7 @@ handle_underlying: return Object::Box(klass, toBox); } -pesapi_value CSRefToJsValue(struct pesapi_apis* apis, pesapi_env env, Il2CppClass *targetClass, Il2CppObject* obj) +pesapi_value CSRefToJsValue(struct pesapi_ffi* apis, pesapi_env env, Il2CppClass *targetClass, Il2CppObject* obj) { if (targetClass == il2cpp_defaults.void_class ) return apis->pesapi_create_undefined(env); if (!obj) return apis->pesapi_create_null(env); @@ -1063,7 +1063,7 @@ pesapi_value CSRefToJsValue(struct pesapi_apis* apis, pesapi_env env, Il2CppClas return apis->pesapi_native_object_to_value(env, objClass, obj, false); } -static bool GetValueTypeFromJs(struct pesapi_apis* apis, pesapi_env env, pesapi_value jsValue, Il2CppClass* klass, void* storage) +static bool GetValueTypeFromJs(struct pesapi_ffi* apis, pesapi_env env, pesapi_value jsValue, Il2CppClass* klass, void* storage) { bool hasValue = false; uint32_t valueSize = klass->instance_size - sizeof(Il2CppObject); @@ -1222,12 +1222,12 @@ handle_underlying: return hasValue; } -static pesapi_value JsObjectUnRef(struct pesapi_apis* apis, pesapi_env env, pesapi_value jsValue) +static pesapi_value JsObjectUnRef(struct pesapi_ffi* apis, pesapi_env env, pesapi_value jsValue) { return (apis->pesapi_is_object(env, jsValue)) ? apis->pesapi_get_property_uint32(env, jsValue, 0) : nullptr; } -static void JsObjectSetRef(struct pesapi_apis* apis, pesapi_env env, pesapi_value outer, pesapi_value val) +static void JsObjectSetRef(struct pesapi_ffi* apis, pesapi_env env, pesapi_value outer, pesapi_value val) { if (outer && val && apis->pesapi_is_object(env, outer)) { @@ -1235,7 +1235,7 @@ static void JsObjectSetRef(struct pesapi_apis* apis, pesapi_env env, pesapi_valu } } -static bool ReflectionWrapper(struct pesapi_apis* apis, MethodInfo* method, Il2CppMethodPointer methodPointer, pesapi_callback_info info, pesapi_env env, void* self, bool checkJSArgument, WrapData* wrapData) +static bool ReflectionWrapper(struct pesapi_ffi* apis, MethodInfo* method, Il2CppMethodPointer methodPointer, pesapi_callback_info info, pesapi_env env, void* self, bool checkJSArgument, WrapData* wrapData) { int js_args_len = apis->pesapi_get_args_len(info); bool hasParamArray = wrapData->HasParamArray; @@ -1607,7 +1607,7 @@ handle_underlying: return true; } -static void ReflectionGetFieldWrapper(struct pesapi_apis* apis, pesapi_callback_info info, FieldInfo* field, size_t offset, Il2CppClass* fieldType) +static void ReflectionGetFieldWrapper(struct pesapi_ffi* apis, pesapi_callback_info info, FieldInfo* field, size_t offset, Il2CppClass* fieldType) { pesapi_env env = apis->pesapi_get_env(info); pesapi_value jsThis = apis->pesapi_get_holder(info); @@ -1688,7 +1688,7 @@ static void ReflectionGetFieldWrapper(struct pesapi_apis* apis, pesapi_callback_ } } -static void ReflectionSetFieldWrapper(struct pesapi_apis* apis, pesapi_callback_info info, FieldInfo* field, size_t offset, Il2CppClass* fieldType) +static void ReflectionSetFieldWrapper(struct pesapi_ffi* apis, pesapi_callback_info info, FieldInfo* field, size_t offset, Il2CppClass* fieldType) { pesapi_env env = apis->pesapi_get_env(info); pesapi_value jsThis = apis->pesapi_get_holder(info); @@ -1740,7 +1740,7 @@ static void ReflectionSetFieldWrapper(struct pesapi_apis* apis, pesapi_callback_ } } -Il2CppObject* GetJSObjectValue(Il2CppObject* jsObject, struct pesapi_apis* apis, Il2CppString* key, Il2CppReflectionType* rtype) +Il2CppObject* GetJSObjectValue(Il2CppObject* jsObject, struct pesapi_ffi* apis, Il2CppString* key, Il2CppReflectionType* rtype) { PObjectRefInfo* objectInfo = GetPObjectRefInfo(jsObject); @@ -1761,7 +1761,7 @@ Il2CppObject* GetJSObjectValue(Il2CppObject* jsObject, struct pesapi_apis* apis, return JsValueToCSRef(apis, type, env, val); } -Il2CppObject* EvalInternal(struct pesapi_apis* apis, intptr_t ptr, Il2CppArray * __code, Il2CppString* __path, Il2CppReflectionType *__type) +Il2CppObject* EvalInternal(struct pesapi_ffi* apis, intptr_t ptr, Il2CppArray * __code, Il2CppString* __path, Il2CppReflectionType *__type) { pesapi_env_ref envRef = reinterpret_cast(ptr); @@ -1794,7 +1794,7 @@ Il2CppObject* EvalInternal(struct pesapi_apis* apis, intptr_t ptr, Il2CppArray * return nullptr; } -void SetObjectToGlobal(struct pesapi_apis* apis, pesapi_env_ref envRef, Il2CppString* __key, Il2CppObject *obj) +void SetObjectToGlobal(struct pesapi_ffi* apis, pesapi_env_ref envRef, Il2CppString* __key, Il2CppObject *obj) { AutoValueScope ValueScope(apis, envRef); auto env = apis->pesapi_get_env_from_ref(envRef); @@ -1811,7 +1811,7 @@ void SetObjectToGlobal(struct pesapi_apis* apis, pesapi_env_ref envRef, Il2CppSt #define EXECUTEMODULEGLOBANAME "__puertsExecuteModule" -Il2CppObject* GetModuleExecutor(struct pesapi_apis* apis, intptr_t ptr, Il2CppReflectionType* rtype) +Il2CppObject* GetModuleExecutor(struct pesapi_ffi* apis, intptr_t ptr, Il2CppReflectionType* rtype) { pesapi_env_ref envRef = reinterpret_cast(ptr); @@ -1838,14 +1838,14 @@ Il2CppObject* GetModuleExecutor(struct pesapi_apis* apis, intptr_t ptr, Il2CppRe struct JsEnvPrivate { - struct pesapi_apis* apis; + struct pesapi_ffi* apis; pesapi_env_ref envRef; std::mutex pendingKillRefsMutex; std::unordered_set pendingKillRefs; MethodInfoHelper objPoolAdd; MethodInfoHelper objPoolRemove; - JsEnvPrivate(struct pesapi_apis* inApis, pesapi_env_ref inEnvRef, Il2CppObject *objPool, Il2CppReflectionMethod* objPoolAddMethodInfo, Il2CppReflectionMethod* objPoolRemoveMethodInfo) + JsEnvPrivate(struct pesapi_ffi* inApis, pesapi_env_ref inEnvRef, Il2CppObject *objPool, Il2CppReflectionMethod* objPoolAddMethodInfo, Il2CppReflectionMethod* objPoolRemoveMethodInfo) : apis(inApis), envRef(inEnvRef), objPoolAdd(objPoolAddMethodInfo, objPool), objPoolRemove(objPoolRemoveMethodInfo, objPool) { @@ -1920,7 +1920,7 @@ static void OnCsObjectExit(void* ptr, void* class_data, JsEnvPrivate* jsEnvPriva jsEnvPrivate->UnRefCSObject(idx); } -static void LoadTypeWrapper(struct pesapi_apis* apis, pesapi_callback_info info) +static void LoadTypeWrapper(struct pesapi_ffi* apis, pesapi_callback_info info) { pesapi_env env = apis->pesapi_get_env(info); Il2CppObject* type = (Il2CppObject*)apis->pesapi_get_native_object_ptr(env, apis->pesapi_get_arg(info, 0)); @@ -1929,7 +1929,7 @@ static void LoadTypeWrapper(struct pesapi_apis* apis, pesapi_callback_info info) apis->pesapi_add_return(info, ret); } -puerts::JsEnvPrivate* InitialPapiEnvRef(struct pesapi_apis* apis, pesapi_env_ref envRef, Il2CppObject *objPool, Il2CppReflectionMethod* objPoolAddMethodInfo, Il2CppReflectionMethod* objPoolRemoveMethodInfo) +puerts::JsEnvPrivate* InitialPapiEnvRef(struct pesapi_ffi* apis, pesapi_env_ref envRef, Il2CppObject *objPool, Il2CppReflectionMethod* objPoolAddMethodInfo, Il2CppReflectionMethod* objPoolRemoveMethodInfo) { puerts::AutoValueScope ValueScope(apis, envRef); auto env = apis->pesapi_get_env_from_ref(envRef); @@ -1949,7 +1949,7 @@ puerts::JsEnvPrivate* InitialPapiEnvRef(struct pesapi_apis* apis, pesapi_env_ref return nullptr; } -void CleanupPapiEnvRef(struct pesapi_apis* apis, pesapi_env_ref envRef) +void CleanupPapiEnvRef(struct pesapi_ffi* apis, pesapi_env_ref envRef) { puerts::AutoValueScope ValueScope(apis, envRef); auto env = apis->pesapi_get_env_from_ref(envRef); @@ -1990,7 +1990,7 @@ void InitialPuerts(pesapi_func_ptr* func_array) void AddPendingKillScriptObjects(puerts::JsEnvPrivate* jsEnvPrivate, pesapi_value_ref valueRef) { - struct pesapi_apis* apis = jsEnvPrivate->apis; + struct pesapi_ffi* apis = jsEnvPrivate->apis; pesapi_env_ref envRef = apis->pesapi_get_ref_associated_env(valueRef); if (!apis->pesapi_env_ref_is_valid(envRef)) // jsEnv已经释放 { 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 01d1ce359d..4aaa51f869 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 @@ -13,8 +13,8 @@ namespace puerts { -typedef void (*FieldWrapFuncPtr)(struct pesapi_apis* apis, pesapi_callback_info info, FieldInfo* field, size_t offset, Il2CppClass* fieldType); -typedef bool (*WrapFuncPtr)(struct pesapi_apis* apis, MethodInfo* method, Il2CppMethodPointer methodPointer, pesapi_callback_info info, pesapi_env env, void* self, bool checkArgument, struct WrapData* wrapData); +typedef void (*FieldWrapFuncPtr)(struct pesapi_ffi* apis, pesapi_callback_info info, FieldInfo* field, size_t offset, Il2CppClass* fieldType); +typedef bool (*WrapFuncPtr)(struct pesapi_ffi* apis, MethodInfo* method, Il2CppMethodPointer methodPointer, pesapi_callback_info info, pesapi_env env, void* self, bool checkArgument, struct WrapData* wrapData); struct FieldWrapData { @@ -40,7 +40,7 @@ struct WrapData struct PObjectRefInfo { - struct pesapi_apis* Apis; + struct pesapi_ffi* Apis; pesapi_value_ref ValueRef; void* EnvPrivate; }; @@ -49,9 +49,9 @@ struct PObjectRefInfo static_assert(sizeof(PObjectRefInfo) <= sizeof(void*) * 3, "PObjectRefInfo Size invalid"); // begin function in Puerts_il2cpp.cpp -Il2CppObject* JsValueToCSRef(struct pesapi_apis* apis, Il2CppClass *klass, pesapi_env env, pesapi_value jsval); +Il2CppObject* JsValueToCSRef(struct pesapi_ffi* apis, Il2CppClass *klass, pesapi_env env, pesapi_value jsval); -pesapi_value CSRefToJsValue(struct pesapi_apis* apis, pesapi_env env, Il2CppClass *targetClass, Il2CppObject* obj); +pesapi_value CSRefToJsValue(struct pesapi_ffi* apis, pesapi_env env, Il2CppClass *targetClass, Il2CppObject* obj); void* GetDefaultValuePtr(const MethodInfo* method, uint32_t index); @@ -74,7 +74,7 @@ void PLog(const char* Fmt, ...); class AutoValueScope { public: - AutoValueScope(struct pesapi_apis* apis, pesapi_env_ref envRef) + AutoValueScope(struct pesapi_ffi* apis, pesapi_env_ref envRef) { _apis = apis; apis->pesapi_open_scope_placement(envRef, &_mem); @@ -90,7 +90,7 @@ public: return (pesapi_scope)&_mem; } - struct pesapi_apis* _apis; + struct pesapi_ffi* _apis; pesapi_scope_memory _mem; }; @@ -101,7 +101,7 @@ struct DataTransfer return il2cpp::vm::Class::IsAssignableFrom(il2cpp_defaults.delegate_class, klass) && klass != il2cpp_defaults.delegate_class && klass != il2cpp_defaults.multicastdelegate_class; } - static bool IsAssignable(struct pesapi_apis* apis, pesapi_env env, pesapi_value value, Il2CppClass *klass, bool isvaluetype) + static bool IsAssignable(struct pesapi_ffi* apis, pesapi_env env, pesapi_value value, Il2CppClass *klass, bool isvaluetype) { if (!isvaluetype && (apis->pesapi_is_null(env, value) || apis->pesapi_is_undefined(env, value))) { @@ -116,7 +116,7 @@ struct DataTransfer } template - static T* GetPointer(struct pesapi_apis* apis, pesapi_env env, pesapi_value value) + static T* GetPointer(struct pesapi_ffi* apis, pesapi_env env, pesapi_value value) { if (apis->pesapi_is_null(env, value) || apis->pesapi_is_undefined(env, value)) { @@ -126,7 +126,7 @@ struct DataTransfer } template - static pesapi_value CopyValueType(struct pesapi_apis* apis, pesapi_env env, const T &v, const void* type_id) + static pesapi_value CopyValueType(struct pesapi_ffi* apis, pesapi_env env, const T &v, const void* type_id) { T* ret = new T; memcpy(ret, &v, sizeof(T)); @@ -134,7 +134,7 @@ struct DataTransfer } template - static pesapi_value CopyNullableValueType(struct pesapi_apis* apis, pesapi_env env, const T &v, const void* type_id) + static pesapi_value CopyNullableValueType(struct pesapi_ffi* apis, pesapi_env env, const T &v, const void* type_id) { if (!v.hasValue) { @@ -173,17 +173,17 @@ struct Converter; template struct Converter::value && sizeof(T) == 8 && std::is_signed::value>::type> { - static pesapi_value toScript(struct pesapi_apis* apis, pesapi_env env, T value) + static pesapi_value toScript(struct pesapi_ffi* apis, pesapi_env env, T value) { return apis->pesapi_create_int64(env, value); } - static T toCpp(struct pesapi_apis* apis, pesapi_env env, pesapi_value value) + static T toCpp(struct pesapi_ffi* apis, pesapi_env env, pesapi_value value) { return static_cast(apis->pesapi_get_value_int64(env, value)); } - static bool accept(struct pesapi_apis* apis, pesapi_env env, pesapi_value value) + static bool accept(struct pesapi_ffi* apis, pesapi_env env, pesapi_value value) { return apis->pesapi_is_int64(env, value); } @@ -192,17 +192,17 @@ struct Converter::value && sizeof template struct Converter::value && sizeof(T) == 8 && !std::is_signed::value>::type> { - static pesapi_value toScript(struct pesapi_apis* apis, pesapi_env env, T value) + static pesapi_value toScript(struct pesapi_ffi* apis, pesapi_env env, T value) { return apis->pesapi_create_uint64(env, value); } - static T toCpp(struct pesapi_apis* apis, pesapi_env env, pesapi_value value) + static T toCpp(struct pesapi_ffi* apis, pesapi_env env, pesapi_value value) { return static_cast(apis->pesapi_get_value_uint64(env, value)); } - static bool accept(struct pesapi_apis* apis, pesapi_env env, pesapi_value value) + static bool accept(struct pesapi_ffi* apis, pesapi_env env, pesapi_value value) { return apis->pesapi_is_uint64(env, value); } @@ -211,17 +211,17 @@ struct Converter::value && sizeof template struct Converter::value && sizeof(T) < 8 && std::is_signed::value>::type> { - static pesapi_value toScript(struct pesapi_apis* apis, pesapi_env env, T value) + static pesapi_value toScript(struct pesapi_ffi* apis, pesapi_env env, T value) { return apis->pesapi_create_int32(env, value); } - static T toCpp(struct pesapi_apis* apis, pesapi_env env, pesapi_value value) + static T toCpp(struct pesapi_ffi* apis, pesapi_env env, pesapi_value value) { return static_cast(apis->pesapi_get_value_int32(env, value)); } - static bool accept(struct pesapi_apis* apis, pesapi_env env, pesapi_value value) + static bool accept(struct pesapi_ffi* apis, pesapi_env env, pesapi_value value) { return apis->pesapi_is_int32(env, value); } @@ -230,17 +230,17 @@ struct Converter::value && sizeof template struct Converter::value && sizeof(T) < 8 && !std::is_signed::value>::type> { - static pesapi_value toScript(struct pesapi_apis* apis, pesapi_env env, T value) + static pesapi_value toScript(struct pesapi_ffi* apis, pesapi_env env, T value) { return apis->pesapi_create_uint32(env, value); } - static T toCpp(struct pesapi_apis* apis, pesapi_env env, pesapi_value value) + static T toCpp(struct pesapi_ffi* apis, pesapi_env env, pesapi_value value) { return static_cast(apis->pesapi_get_value_uint32(env, value)); } - static bool accept(struct pesapi_apis* apis, pesapi_env env, pesapi_value value) + static bool accept(struct pesapi_ffi* apis, pesapi_env env, pesapi_value value) { return apis->pesapi_is_uint32(env, value); } @@ -249,17 +249,17 @@ struct Converter::value && sizeof template struct Converter::value>::type> { - static pesapi_value toScript(struct pesapi_apis* apis, pesapi_env env, T value) + static pesapi_value toScript(struct pesapi_ffi* apis, pesapi_env env, T value) { return apis->pesapi_create_int32(env, static_cast(value)); } - static T toCpp(struct pesapi_apis* apis, pesapi_env env, pesapi_value value) + static T toCpp(struct pesapi_ffi* apis, pesapi_env env, pesapi_value value) { return static_cast(apis->pesapi_get_value_int32(env, value)); } - static bool accept(struct pesapi_apis* apis, pesapi_env env, pesapi_value value) + static bool accept(struct pesapi_ffi* apis, pesapi_env env, pesapi_value value) { return apis->pesapi_is_int32(env, value); } @@ -268,17 +268,17 @@ struct Converter::value>::type> template struct Converter::value>::type> { - static pesapi_value toScript(struct pesapi_apis* apis, pesapi_env env, T value) + static pesapi_value toScript(struct pesapi_ffi* apis, pesapi_env env, T value) { return apis->pesapi_create_double(env, value); } - static T toCpp(struct pesapi_apis* apis, pesapi_env env, pesapi_value value) + static T toCpp(struct pesapi_ffi* apis, pesapi_env env, pesapi_value value) { return static_cast(apis->pesapi_get_value_double(env, value)); } - static bool accept(struct pesapi_apis* apis, pesapi_env env, pesapi_value value) + static bool accept(struct pesapi_ffi* apis, pesapi_env env, pesapi_value value) { return apis->pesapi_is_double(env, value); } @@ -287,18 +287,18 @@ struct Converter::value>::t template <> struct Converter { - static pesapi_value toScript(struct pesapi_apis* apis, pesapi_env env, void* value) + static pesapi_value toScript(struct pesapi_ffi* apis, pesapi_env env, void* value) { return apis->pesapi_create_binary(env, value, 0); } - static void* toCpp(struct pesapi_apis* apis, pesapi_env env, pesapi_value value) + static void* toCpp(struct pesapi_ffi* apis, pesapi_env env, pesapi_value value) { size_t bufsize; return apis->pesapi_get_value_binary(env, value, &bufsize); } - static bool accept(struct pesapi_apis* apis, pesapi_env env, pesapi_value value) + static bool accept(struct pesapi_ffi* apis, pesapi_env env, pesapi_value value) { return apis->pesapi_is_binary(env, value); } @@ -307,17 +307,17 @@ struct Converter template <> struct Converter { - static pesapi_value toScript(struct pesapi_apis* apis, pesapi_env env, bool value) + static pesapi_value toScript(struct pesapi_ffi* apis, pesapi_env env, bool value) { return apis->pesapi_create_boolean(env, value); } - static bool toCpp(struct pesapi_apis* apis, pesapi_env env, pesapi_value value) + static bool toCpp(struct pesapi_ffi* apis, pesapi_env env, pesapi_value value) { return apis->pesapi_get_value_bool(env, value); } - static bool accept(struct pesapi_apis* apis, pesapi_env env, pesapi_value value) + static bool accept(struct pesapi_ffi* apis, pesapi_env env, pesapi_value value) { return apis->pesapi_is_boolean(env, value); } @@ -326,7 +326,7 @@ struct Converter template <> struct Converter { - static pesapi_value toScript(struct pesapi_apis* apis, pesapi_env env, Il2CppString* value) + static pesapi_value toScript(struct pesapi_ffi* apis, pesapi_env env, Il2CppString* value) { if (value == nullptr) { @@ -337,7 +337,7 @@ struct Converter return apis->pesapi_create_string_utf8(env, str.c_str(), str.size()); } - static Il2CppString* toCpp(struct pesapi_apis* apis, pesapi_env env, pesapi_value value) + static Il2CppString* toCpp(struct pesapi_ffi* apis, pesapi_env env, pesapi_value value) { if (apis->pesapi_is_null(env, value) || apis->pesapi_is_undefined(env, value)) { @@ -360,7 +360,7 @@ struct Converter return nullptr; } - static bool accept(struct pesapi_apis* apis, pesapi_env env, pesapi_value value) + static bool accept(struct pesapi_ffi* apis, pesapi_env env, pesapi_value value) { return apis->pesapi_is_string(env, value) || apis->pesapi_is_null(env, value) || apis->pesapi_is_undefined(env, value); } @@ -369,17 +369,17 @@ struct Converter template struct Converter> { - static pesapi_value toScript(struct pesapi_apis* apis, pesapi_env env, const T& value) + static pesapi_value toScript(struct pesapi_ffi* apis, pesapi_env env, const T& value) { return apis->pesapi_boxing(env, Converter::toScript(apis, env, value)); } - static T toCpp(struct pesapi_apis* apis, pesapi_env env, pesapi_value value) + static T toCpp(struct pesapi_ffi* apis, pesapi_env env, pesapi_value value) { return Converter::toCpp(apis, env, apis->pesapi_unboxing(env, value)); } - static bool accept(struct pesapi_apis* apis, pesapi_env env, pesapi_value value) + static bool accept(struct pesapi_ffi* apis, pesapi_env env, pesapi_value value) { return apis->pesapi_is_boxed_value(env, value); // do not checked inner } @@ -390,7 +390,7 @@ struct Converter> template struct OptionalParameter { - static T GetPrimitive(struct pesapi_apis* apis, pesapi_env env, pesapi_callback_info info, MethodInfo* methodInfo, puerts::WrapData* wrapData, int length, int index) + static T GetPrimitive(struct pesapi_ffi* apis, pesapi_env env, pesapi_callback_info info, MethodInfo* methodInfo, puerts::WrapData* wrapData, int length, int index) { if (index < length) { @@ -408,7 +408,7 @@ struct OptionalParameter } } - static T GetValueType(struct pesapi_apis* apis, pesapi_env env, pesapi_callback_info info, MethodInfo* methodInfo, puerts::WrapData* wrapData, int length, int index) + static T GetValueType(struct pesapi_ffi* apis, pesapi_env env, pesapi_callback_info info, MethodInfo* methodInfo, puerts::WrapData* wrapData, int length, int index) { if (index < length) { @@ -428,7 +428,7 @@ struct OptionalParameter } } - static Il2CppString* GetString(struct pesapi_apis* apis, pesapi_env env, pesapi_callback_info info, MethodInfo* methodInfo, puerts::WrapData* wrapData, int length, int index) + static Il2CppString* GetString(struct pesapi_ffi* apis, pesapi_env env, pesapi_callback_info info, MethodInfo* methodInfo, puerts::WrapData* wrapData, int length, int index) { if (index < length) { @@ -441,7 +441,7 @@ struct OptionalParameter } } - static Il2CppObject* GetRefType(struct pesapi_apis* apis, pesapi_env env, pesapi_callback_info info, MethodInfo* methodInfo, puerts::WrapData* wrapData, int length, int index, Il2CppClass* typeId) + static Il2CppObject* GetRefType(struct pesapi_ffi* apis, pesapi_env env, pesapi_callback_info info, MethodInfo* methodInfo, puerts::WrapData* wrapData, int length, int index, Il2CppClass* typeId) { if (index < length) { @@ -459,7 +459,7 @@ struct OptionalParameter template struct Params { - static Il2CppArray* PackPrimitive(struct pesapi_apis* apis, pesapi_env env, pesapi_callback_info info, Il2CppClass* typeId, int length, int start) + static Il2CppArray* PackPrimitive(struct pesapi_ffi* apis, pesapi_env env, pesapi_callback_info info, Il2CppClass* typeId, int length, int start) { Il2CppArray* ret = il2cpp::vm::Array::NewSpecific(typeId, length - start > 0 ? length - start : 0); T* arr = reinterpret_cast(il2cpp::vm::Array::GetFirstElementAddress(ret)); @@ -470,7 +470,7 @@ struct Params return ret; } - static Il2CppArray* PackString(struct pesapi_apis* apis, pesapi_env env, pesapi_callback_info info, Il2CppClass* typeId, int length, int start) + static Il2CppArray* PackString(struct pesapi_ffi* apis, pesapi_env env, pesapi_callback_info info, Il2CppClass* typeId, int length, int start) { Il2CppArray* ret = il2cpp::vm::Array::NewSpecific(typeId, length - start > 0 ? length - start : 0); for(int i = start; i < length;++i) @@ -480,7 +480,7 @@ struct Params return ret; } - static Il2CppArray* PackRef(struct pesapi_apis* apis, pesapi_env env, pesapi_callback_info info, Il2CppClass* typeId, int length, int start) + static Il2CppArray* PackRef(struct pesapi_ffi* apis, pesapi_env env, pesapi_callback_info info, Il2CppClass* typeId, int length, int start) { Il2CppArray* ret = il2cpp::vm::Array::NewSpecific(typeId, length - start > 0 ? length - start : 0); auto elemTypeId = il2cpp::vm::Class::GetElementClass(typeId); @@ -491,7 +491,7 @@ struct Params return ret; } - static Il2CppArray* PackValueType(struct pesapi_apis* apis, pesapi_env env, pesapi_callback_info info, Il2CppClass* typeId, int length, int start) + static Il2CppArray* PackValueType(struct pesapi_ffi* apis, pesapi_env env, pesapi_callback_info info, Il2CppClass* typeId, int length, int start) { Il2CppArray* ret = il2cpp::vm::Array::NewSpecific(typeId, length - start > 0 ? length - start : 0); T* arr = reinterpret_cast(il2cpp::vm::Array::GetFirstElementAddress(ret)); @@ -505,7 +505,7 @@ struct Params } - static void UnPackPrimitive(struct pesapi_apis* apis, pesapi_env env, Il2CppArray* array, uint32_t arrayLength, Il2CppClass* typeId, pesapi_value* argv) + static void UnPackPrimitive(struct pesapi_ffi* apis, pesapi_env env, Il2CppArray* array, uint32_t arrayLength, Il2CppClass* typeId, pesapi_value* argv) { T* arr = reinterpret_cast(il2cpp::vm::Array::GetFirstElementAddress(array)); for (uint32_t i = 0; i < arrayLength; ++i) @@ -514,7 +514,7 @@ struct Params } } - static void UnPackRefOrBoxedValueType(struct pesapi_apis* apis, pesapi_env env, Il2CppArray* array, uint32_t arrayLength, Il2CppClass* typeId, pesapi_value* argv) + static void UnPackRefOrBoxedValueType(struct pesapi_ffi* apis, pesapi_env env, Il2CppArray* array, uint32_t arrayLength, Il2CppClass* typeId, pesapi_value* argv) { Il2CppObject** arr = reinterpret_cast(il2cpp::vm::Array::GetFirstElementAddress(array)); for (uint32_t i = 0; i < arrayLength; ++i) @@ -523,7 +523,7 @@ struct Params } } - static void UnPackValueType(struct pesapi_apis* apis, pesapi_env env, Il2CppArray* array, uint32_t arrayLength, Il2CppClass* typeId, pesapi_value* argv) + static void UnPackValueType(struct pesapi_ffi* apis, pesapi_env env, Il2CppArray* array, uint32_t arrayLength, Il2CppClass* typeId, pesapi_value* argv) { T* arr = reinterpret_cast(il2cpp::vm::Array::GetFirstElementAddress(array)); auto elemTypeId = il2cpp::vm::Class::GetElementClass(typeId); diff --git a/unity/Assets/core/upm/Editor/Resources/puerts/xil2cpp/pesapi.h.txt b/unity/Assets/core/upm/Editor/Resources/puerts/xil2cpp/pesapi.h.txt index a4d4327f9b..ffb8e7b4c0 100644 --- a/unity/Assets/core/upm/Editor/Resources/puerts/xil2cpp/pesapi.h.txt +++ b/unity/Assets/core/upm/Editor/Resources/puerts/xil2cpp/pesapi.h.txt @@ -124,9 +124,9 @@ typedef struct pesapi_type_info__* pesapi_type_info; typedef struct pesapi_signature_info__* pesapi_signature_info; typedef struct pesapi_property_descriptor__* pesapi_property_descriptor; -typedef void (*pesapi_callback)(struct pesapi_apis* apis, pesapi_callback_info info); -typedef void* (*pesapi_constructor)(struct pesapi_apis* apis, pesapi_callback_info info); -typedef void (*pesapi_finalize)(struct pesapi_apis* apis, void* ptr, void* class_data, void* env_private); +typedef void (*pesapi_callback)(struct pesapi_ffi* apis, pesapi_callback_info info); +typedef void* (*pesapi_constructor)(struct pesapi_ffi* apis, pesapi_callback_info info); +typedef void (*pesapi_finalize)(struct pesapi_ffi* apis, void* ptr, void* class_data, void* env_private); typedef void* (*pesapi_on_native_object_enter)(void* ptr, void* class_data, void* env_private); // userdata: return of pesapi_on_native_object_enter typedef void (*pesapi_on_native_object_exit)(void* ptr, void* class_data, void* env_private, void* userdata); @@ -234,7 +234,7 @@ typedef pesapi_value (*pesapi_global_func)(pesapi_env env); typedef const void* (*pesapi_get_env_private_func)(pesapi_env env); typedef void (*pesapi_set_env_private_func)(pesapi_env env, const void* ptr); -struct pesapi_apis +struct pesapi_ffi { pesapi_create_null_func pesapi_create_null; pesapi_create_undefined_func pesapi_create_undefined; diff --git a/unity/native_src_il2cpp/Inc/CppObjectMapper.h b/unity/native_src_il2cpp/Inc/CppObjectMapper.h index 5fc16d54ea..6e5fdd55d8 100644 --- a/unity/native_src_il2cpp/Inc/CppObjectMapper.h +++ b/unity/native_src_il2cpp/Inc/CppObjectMapper.h @@ -23,7 +23,7 @@ PRAGMA_ENABLE_UNDEFINED_IDENTIFIER_WARNINGS namespace v8impl { -extern pesapi_apis g_pesapi_apis; +extern pesapi_ffi g_pesapi_ffi; } namespace PUERTS_NAMESPACE diff --git a/unity/native_src_il2cpp/Inc/pesapi.h b/unity/native_src_il2cpp/Inc/pesapi.h index a4d4327f9b..ffb8e7b4c0 100644 --- a/unity/native_src_il2cpp/Inc/pesapi.h +++ b/unity/native_src_il2cpp/Inc/pesapi.h @@ -124,9 +124,9 @@ typedef struct pesapi_type_info__* pesapi_type_info; typedef struct pesapi_signature_info__* pesapi_signature_info; typedef struct pesapi_property_descriptor__* pesapi_property_descriptor; -typedef void (*pesapi_callback)(struct pesapi_apis* apis, pesapi_callback_info info); -typedef void* (*pesapi_constructor)(struct pesapi_apis* apis, pesapi_callback_info info); -typedef void (*pesapi_finalize)(struct pesapi_apis* apis, void* ptr, void* class_data, void* env_private); +typedef void (*pesapi_callback)(struct pesapi_ffi* apis, pesapi_callback_info info); +typedef void* (*pesapi_constructor)(struct pesapi_ffi* apis, pesapi_callback_info info); +typedef void (*pesapi_finalize)(struct pesapi_ffi* apis, void* ptr, void* class_data, void* env_private); typedef void* (*pesapi_on_native_object_enter)(void* ptr, void* class_data, void* env_private); // userdata: return of pesapi_on_native_object_enter typedef void (*pesapi_on_native_object_exit)(void* ptr, void* class_data, void* env_private, void* userdata); @@ -234,7 +234,7 @@ typedef pesapi_value (*pesapi_global_func)(pesapi_env env); typedef const void* (*pesapi_get_env_private_func)(pesapi_env env); typedef void (*pesapi_set_env_private_func)(pesapi_env env, const void* ptr); -struct pesapi_apis +struct pesapi_ffi { pesapi_create_null_func pesapi_create_null; pesapi_create_undefined_func pesapi_create_undefined; diff --git a/unity/native_src_il2cpp/Src/CppObjectMapper.cpp b/unity/native_src_il2cpp/Src/CppObjectMapper.cpp index 1264ea66dd..f453e0e997 100644 --- a/unity/native_src_il2cpp/Src/CppObjectMapper.cpp +++ b/unity/native_src_il2cpp/Src/CppObjectMapper.cpp @@ -151,7 +151,7 @@ static void CDataNew(const v8::FunctionCallbackInfo& Info) void* Ptr = nullptr; if (ClassDefinition->Initialize) - Ptr = ClassDefinition->Initialize(&v8impl::g_pesapi_apis, (pesapi_callback_info) &Info); + Ptr = ClassDefinition->Initialize(&v8impl::g_pesapi_ffi, (pesapi_callback_info) &Info); if (Ptr == nullptr) return; @@ -167,21 +167,21 @@ static void PesapiCallbackWrap(const v8::FunctionCallbackInfo& Info) { JSFunctionInfo* FunctionInfo = reinterpret_cast( reinterpret_cast(v8::Local::Cast(Info.Data())->Value()) - offsetof(JSFunctionInfo, Data)); - FunctionInfo->Callback(&v8impl::g_pesapi_apis, (pesapi_callback_info)(&Info)); + FunctionInfo->Callback(&v8impl::g_pesapi_ffi, (pesapi_callback_info)(&Info)); } static void PesapiGetterWrap(const v8::FunctionCallbackInfo& Info) { JSPropertyInfo* PropertyInfo = reinterpret_cast( reinterpret_cast(v8::Local::Cast(Info.Data())->Value()) - offsetof(JSPropertyInfo, GetterData)); - PropertyInfo->Getter(&v8impl::g_pesapi_apis, (pesapi_callback_info)(&Info)); + PropertyInfo->Getter(&v8impl::g_pesapi_ffi, (pesapi_callback_info)(&Info)); } static void PesapiSetterWrap(const v8::FunctionCallbackInfo& Info) { JSPropertyInfo* PropertyInfo = reinterpret_cast( reinterpret_cast(v8::Local::Cast(Info.Data())->Value()) - offsetof(JSPropertyInfo, SetterData)); - PropertyInfo->Setter(&v8impl::g_pesapi_apis, (pesapi_callback_info)(&Info)); + PropertyInfo->Setter(&v8impl::g_pesapi_ffi, (pesapi_callback_info)(&Info)); } v8::Local FCppObjectMapper::GetTemplateOfClass(v8::Isolate* Isolate, const JSClassDefinition* ClassDefinition) @@ -307,7 +307,7 @@ static void CDataGarbageCollectedWithFree(const v8::WeakCallbackInfoFinalize) - ClassDefinition->Finalize(&v8impl::g_pesapi_apis, Ptr, ClassDefinition->Data, DataTransfer::GetIsolatePrivateData(Data.GetIsolate())); + ClassDefinition->Finalize(&v8impl::g_pesapi_ffi, Ptr, ClassDefinition->Data, DataTransfer::GetIsolatePrivateData(Data.GetIsolate())); DataTransfer::IsolateData(Data.GetIsolate())->UnBindCppObject(Data.GetIsolate(), ClassDefinition, Ptr); } @@ -420,7 +420,7 @@ void FCppObjectMapper::UnInitialize(v8::Isolate* InIsolate) { if (ClassDefinition && ClassDefinition->Finalize) { - ClassDefinition->Finalize(&v8impl::g_pesapi_apis, KV.first, ClassDefinition->Data, PData); + ClassDefinition->Finalize(&v8impl::g_pesapi_ffi, KV.first, ClassDefinition->Data, PData); } PNode->MustCallFinalize = false; } diff --git a/unity/native_src_il2cpp/Src/PesapiV8Impl.cpp b/unity/native_src_il2cpp/Src/PesapiV8Impl.cpp index 3ff6c176e0..d02b839fd4 100644 --- a/unity/native_src_il2cpp/Src/PesapiV8Impl.cpp +++ b/unity/native_src_il2cpp/Src/PesapiV8Impl.cpp @@ -168,13 +168,13 @@ struct PesapiCallbackData void* data; }; -extern pesapi_apis g_pesapi_apis; +extern pesapi_ffi g_pesapi_ffi; static void PesapiFunctionCallback(const v8::FunctionCallbackInfo& info) { PesapiCallbackData* FunctionInfo = reinterpret_cast( reinterpret_cast(v8::Local::Cast(info.Data())->Value()) - offsetof(PesapiCallbackData, data)); - FunctionInfo->callback(&g_pesapi_apis, (pesapi_callback_info)(&info)); + FunctionInfo->callback(&g_pesapi_ffi, (pesapi_callback_info)(&info)); } pesapi_value pesapi_create_function(pesapi_env env, pesapi_callback native_impl, void* data) @@ -839,7 +839,7 @@ void pesapi_set_env_private(pesapi_env env, const void* ptr) puerts::DataTransfer::SetIsolatePrivateData(context->GetIsolate(), const_cast(ptr)); } -pesapi_apis g_pesapi_apis { +pesapi_ffi g_pesapi_ffi { &pesapi_create_null, &pesapi_create_undefined, &pesapi_create_boolean, diff --git a/unity/native_src_il2cpp/Src/Puerts.cpp b/unity/native_src_il2cpp/Src/Puerts.cpp index d2dd68d378..b11ec24a4f 100644 --- a/unity/native_src_il2cpp/Src/Puerts.cpp +++ b/unity/native_src_il2cpp/Src/Puerts.cpp @@ -170,7 +170,7 @@ V8_EXPORT pesapi_env_ref GetPapiEnvRef(puerts::JSEnv* jsEnv) v8::Context::Scope ContextScope(Context); auto env = reinterpret_cast(*Context); //TODO: 实现相关 - return v8impl::g_pesapi_apis.pesapi_create_env_ref(env); + return v8impl::g_pesapi_ffi.pesapi_create_env_ref(env); } /*V8_EXPORT void SetObjectPool(puerts::JSEnv* jsEnv, void* ObjectPoolAddMethodInfo, puerts::ObjectPoolAddFunc ObjectPoolAdd, void* ObjectPoolRemoveMethodInfo, puerts::ObjectPoolRemoveFunc ObjectPoolRemove, void* ObjectPoolInstance) @@ -202,9 +202,9 @@ V8_EXPORT void LogicTick(puerts::JSEnv* jsEnv) jsEnv->BackendEnv.LogicTick(); } -V8_EXPORT pesapi_apis* GetPesApi() +V8_EXPORT pesapi_ffi* GetPesApi() { - return &v8impl::g_pesapi_apis; + return &v8impl::g_pesapi_ffi; } #ifdef __cplusplus