Skip to content

Commit

Permalink
[pesapi]发现第三方实现pesapi对几个api产生误解,审视名字确实不太恰当,改下名字
Browse files Browse the repository at this point in the history
  • Loading branch information
chexiongsheng committed Oct 20, 2023
1 parent 102c6e6 commit 1cfd902
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 34 deletions.
32 changes: 16 additions & 16 deletions unreal/Puerts/Source/JsEnv/Private/PesapiAddonLoad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,22 @@ static pesapi_func_ptr funcs[] = {(pesapi_func_ptr) &pesapi_create_null, (pesapi
(pesapi_func_ptr) &pesapi_is_double, (pesapi_func_ptr) &pesapi_is_string, (pesapi_func_ptr) &pesapi_is_object,
(pesapi_func_ptr) &pesapi_is_function, (pesapi_func_ptr) &pesapi_is_binary, (pesapi_func_ptr) &pesapi_is_array,
(pesapi_func_ptr) &pesapi_create_native_object, (pesapi_func_ptr) &pesapi_get_native_object_ptr,
(pesapi_func_ptr) &pesapi_get_native_object_typeid, (pesapi_func_ptr) &pesapi_is_native_object,
(pesapi_func_ptr) &pesapi_create_ref, (pesapi_func_ptr) &pesapi_get_value_ref, (pesapi_func_ptr) &pesapi_update_value_ref,
(pesapi_func_ptr) &pesapi_is_ref, (pesapi_func_ptr) &pesapi_get_args_len, (pesapi_func_ptr) &pesapi_get_arg,
(pesapi_func_ptr) &pesapi_get_env, (pesapi_func_ptr) &pesapi_get_this, (pesapi_func_ptr) &pesapi_get_holder,
(pesapi_func_ptr) &pesapi_get_userdata, (pesapi_func_ptr) &pesapi_get_constructor_userdata,
(pesapi_func_ptr) &pesapi_add_return, (pesapi_func_ptr) &pesapi_throw_by_string, (pesapi_func_ptr) &pesapi_hold_env,
(pesapi_func_ptr) &pesapi_get_env_from_holder, (pesapi_func_ptr) &pesapi_duplicate_env_holder,
(pesapi_func_ptr) &pesapi_release_env_holder, (pesapi_func_ptr) &pesapi_open_scope, (pesapi_func_ptr) &pesapi_has_caught,
(pesapi_func_ptr) &pesapi_get_exception_as_string, (pesapi_func_ptr) &pesapi_close_scope, (pesapi_func_ptr) &pesapi_hold_value,
(pesapi_func_ptr) &pesapi_duplicate_value_holder, (pesapi_func_ptr) &pesapi_release_value_holder,
(pesapi_func_ptr) &pesapi_get_value_from_holder, (pesapi_func_ptr) &pesapi_get_property, (pesapi_func_ptr) &pesapi_set_property,
(pesapi_func_ptr) &pesapi_get_property_uint32, (pesapi_func_ptr) &pesapi_set_property_uint32,
(pesapi_func_ptr) &pesapi_call_function, (pesapi_func_ptr) &pesapi_eval, (pesapi_func_ptr) &pesapi_alloc_type_infos,
(pesapi_func_ptr) &pesapi_set_type_info, (pesapi_func_ptr) &pesapi_create_signature_info,
(pesapi_func_ptr) &pesapi_alloc_property_descriptors, (pesapi_func_ptr) &pesapi_set_method_info,
(pesapi_func_ptr) &pesapi_set_property_info, (pesapi_func_ptr) &pesapi_define_class, (pesapi_func_ptr) &pesapi_class_type_info};
(pesapi_func_ptr) &pesapi_get_native_object_typeid, (pesapi_func_ptr) &pesapi_is_instance_of, (pesapi_func_ptr) &pesapi_boxing,
(pesapi_func_ptr) &pesapi_unboxing, (pesapi_func_ptr) &pesapi_update_boxed_value, (pesapi_func_ptr) &pesapi_is_boxed_value,
(pesapi_func_ptr) &pesapi_get_args_len, (pesapi_func_ptr) &pesapi_get_arg, (pesapi_func_ptr) &pesapi_get_env,
(pesapi_func_ptr) &pesapi_get_this, (pesapi_func_ptr) &pesapi_get_holder, (pesapi_func_ptr) &pesapi_get_userdata,
(pesapi_func_ptr) &pesapi_get_constructor_userdata, (pesapi_func_ptr) &pesapi_add_return,
(pesapi_func_ptr) &pesapi_throw_by_string, (pesapi_func_ptr) &pesapi_hold_env, (pesapi_func_ptr) &pesapi_get_env_from_holder,
(pesapi_func_ptr) &pesapi_duplicate_env_holder, (pesapi_func_ptr) &pesapi_release_env_holder,
(pesapi_func_ptr) &pesapi_open_scope, (pesapi_func_ptr) &pesapi_has_caught, (pesapi_func_ptr) &pesapi_get_exception_as_string,
(pesapi_func_ptr) &pesapi_close_scope, (pesapi_func_ptr) &pesapi_hold_value, (pesapi_func_ptr) &pesapi_duplicate_value_holder,
(pesapi_func_ptr) &pesapi_release_value_holder, (pesapi_func_ptr) &pesapi_get_value_from_holder,
(pesapi_func_ptr) &pesapi_get_property, (pesapi_func_ptr) &pesapi_set_property, (pesapi_func_ptr) &pesapi_get_property_uint32,
(pesapi_func_ptr) &pesapi_set_property_uint32, (pesapi_func_ptr) &pesapi_call_function, (pesapi_func_ptr) &pesapi_eval,
(pesapi_func_ptr) &pesapi_alloc_type_infos, (pesapi_func_ptr) &pesapi_set_type_info,
(pesapi_func_ptr) &pesapi_create_signature_info, (pesapi_func_ptr) &pesapi_alloc_property_descriptors,
(pesapi_func_ptr) &pesapi_set_method_info, (pesapi_func_ptr) &pesapi_set_property_info, (pesapi_func_ptr) &pesapi_define_class,
(pesapi_func_ptr) &pesapi_class_type_info};
MSVC_PRAGMA(warning(pop))

EXTERN_C_START
Expand Down
10 changes: 5 additions & 5 deletions unreal/Puerts/Source/JsEnv/Private/PesapiV8Impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,14 +348,14 @@ const void* pesapi_get_native_object_typeid(pesapi_env env, pesapi_value pvalue)
return puerts::DataTransfer::GetPointerFast<void>(value.As<v8::Object>(), 1);
}

bool pesapi_is_native_object(pesapi_env env, const void* class_id, pesapi_value pvalue)
bool pesapi_is_instance_of(pesapi_env env, const void* class_id, pesapi_value pvalue)
{
auto context = v8impl::V8LocalContextFromPesapiEnv(env);
auto value = v8impl::V8LocalValueFromPesapiValue(pvalue);
return ::puerts::DataTransfer::IsInstanceOf(context->GetIsolate(), static_cast<const char*>(class_id), value.As<v8::Object>());
}

pesapi_value pesapi_create_ref(pesapi_env env, pesapi_value pvalue)
pesapi_value pesapi_boxing(pesapi_env env, pesapi_value pvalue)
{
auto context = v8impl::V8LocalContextFromPesapiEnv(env);
auto value = v8impl::V8LocalValueFromPesapiValue(pvalue);
Expand All @@ -365,7 +365,7 @@ pesapi_value pesapi_create_ref(pesapi_env env, pesapi_value pvalue)
return v8impl::PesapiValueFromV8LocalValue(result);
}

pesapi_value pesapi_get_value_ref(pesapi_env env, pesapi_value pvalue)
pesapi_value pesapi_unboxing(pesapi_env env, pesapi_value pvalue)
{
auto context = v8impl::V8LocalContextFromPesapiEnv(env);
auto value = v8impl::V8LocalValueFromPesapiValue(pvalue);
Expand All @@ -375,7 +375,7 @@ pesapi_value pesapi_get_value_ref(pesapi_env env, pesapi_value pvalue)
return v8impl::PesapiValueFromV8LocalValue(realvalue);
}

void pesapi_update_value_ref(pesapi_env env, pesapi_value ref, pesapi_value pvalue)
void pesapi_update_boxed_value(pesapi_env env, pesapi_value ref, pesapi_value pvalue)
{
auto context = v8impl::V8LocalContextFromPesapiEnv(env);
auto holder = v8impl::V8LocalValueFromPesapiValue(ref);
Expand All @@ -387,7 +387,7 @@ void pesapi_update_value_ref(pesapi_env env, pesapi_value ref, pesapi_value pval
}
}

bool pesapi_is_ref(pesapi_env env, pesapi_value value)
bool pesapi_is_boxed_value(pesapi_env env, pesapi_value value)
{
return pesapi_is_object(env, value);
}
Expand Down
16 changes: 8 additions & 8 deletions unreal/Puerts/Source/JsEnv/Public/PesapiBackend.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ struct API
{
if (pesapi_is_object(env, holder))
{
pesapi_update_value_ref(env, holder, value);
pesapi_update_boxed_value(env, holder, value);
}
}

Expand Down Expand Up @@ -485,17 +485,17 @@ struct Converter<std::reference_wrapper<T>, typename std::enable_if<!is_objectty
{
static pesapi_value toScript(pesapi_env env, const T& value)
{
return pesapi_create_ref(env, Converter<T>::toScript(env, value));
return pesapi_boxing(env, Converter<T>::toScript(env, value));
}

static T toCpp(pesapi_env env, pesapi_value value)
{
return Converter<T>::toCpp(env, pesapi_get_value_ref(env, value));
return Converter<T>::toCpp(env, pesapi_unboxing(env, value));
}

static bool accept(pesapi_env env, pesapi_value value)
{
return pesapi_is_ref(env, value); // do not checked inner
return pesapi_is_boxed_value(env, value); // do not checked inner
}
};

Expand All @@ -504,21 +504,21 @@ struct Converter<std::reference_wrapper<T>, typename std::enable_if<is_objecttyp
{
static pesapi_value toScript(pesapi_env env, const T& value)
{
return pesapi_create_ref(env, Converter<T>::toScript(env, value));
return pesapi_boxing(env, Converter<T>::toScript(env, value));
}

static T* toCpp(pesapi_env env, pesapi_value value)
{
if (pesapi_is_object(env, value))
{
return Converter<T*>::toCpp(env, pesapi_get_value_ref(env, value));
return Converter<T*>::toCpp(env, pesapi_unboxing(env, value));
}
return nullptr;
}

static bool accept(pesapi_env env, pesapi_value value)
{
return pesapi_is_ref(env, value); // do not checked inner
return pesapi_is_boxed_value(env, value); // do not checked inner
}
};

Expand Down Expand Up @@ -573,7 +573,7 @@ struct Converter<T, typename std::enable_if<std::is_copy_constructible<T>::value
}
static bool accept(pesapi_env env, pesapi_value value)
{
return pesapi_is_native_object(env, StaticTypeId<T>::get(), value);
return pesapi_is_instance_of(env, StaticTypeId<T>::get(), value);
}
};

Expand Down
10 changes: 5 additions & 5 deletions unreal/Puerts/Source/JsEnv/Public/pesapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,12 @@ PESAPI_EXTERN bool pesapi_is_array(pesapi_env env, pesapi_value value);
PESAPI_EXTERN pesapi_value pesapi_create_native_object(pesapi_env env, const void* class_id, void* object_ptr, bool copy);
PESAPI_EXTERN void* pesapi_get_native_object_ptr(pesapi_env env, pesapi_value value);
PESAPI_EXTERN const void* pesapi_get_native_object_typeid(pesapi_env env, pesapi_value value);
PESAPI_EXTERN bool pesapi_is_native_object(pesapi_env env, const void* class_id, pesapi_value value);
PESAPI_EXTERN bool pesapi_is_instance_of(pesapi_env env, const void* class_id, pesapi_value value);

PESAPI_EXTERN pesapi_value pesapi_create_ref(pesapi_env env, pesapi_value value);
PESAPI_EXTERN pesapi_value pesapi_get_value_ref(pesapi_env env, pesapi_value value);
PESAPI_EXTERN void pesapi_update_value_ref(pesapi_env env, pesapi_value ref, pesapi_value value);
PESAPI_EXTERN bool pesapi_is_ref(pesapi_env env, pesapi_value value);
PESAPI_EXTERN pesapi_value pesapi_boxing(pesapi_env env, pesapi_value value);
PESAPI_EXTERN pesapi_value pesapi_unboxing(pesapi_env env, pesapi_value value);
PESAPI_EXTERN void pesapi_update_boxed_value(pesapi_env env, pesapi_value ref, pesapi_value value);
PESAPI_EXTERN bool pesapi_is_boxed_value(pesapi_env env, pesapi_value value);

PESAPI_EXTERN int pesapi_get_args_len(pesapi_callback_info info);
PESAPI_EXTERN pesapi_value pesapi_get_arg(pesapi_callback_info info, int index);
Expand Down

0 comments on commit 1cfd902

Please sign in to comment.