Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/CppObjectMapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,15 @@ struct CppObjectMapper

JSValue CreateFunction(pesapi_callback Callback, void* Data, pesapi_function_finalize Finalize);

JSValue CreateClassByID(const void* typeId);
JSValue FindOrCreateClassByID(const void* typeId);

static JSValue CreateError(JSContext* ctx, const char* message);

JSValue MakeMethod(pesapi_callback Callback, void* Data);
void InitMethod(puerts::JSFunctionInfo* FuncInfo, JSValue Obj);
void InitProperty(puerts::JSPropertyInfo* PropInfo, JSValue Obj);

JSValue CreateClass(const puerts::JSClassDefinition* ClassDefinition);
JSValue FindOrCreateClass(const puerts::JSClassDefinition* ClassDefinition);

void BindAndAddToCache(const puerts::JSClassDefinition* typeInfo, const void* ptr, JSValue value, bool callFinalize);

Expand Down
10 changes: 5 additions & 5 deletions source/CppObjectMapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ JSValue CppObjectMapper::PushNativeObject(const void* TypeId, void* ObjectPtr, b
{
ClassDefinition = &PtrClassDef;
}
JSValue ctor = CreateClass(ClassDefinition);
JSValue ctor = FindOrCreateClass(ClassDefinition);
JSValue proto = JS_GetProperty(ctx, ctor, JS_ATOM_prototype);
JSValue obj = JS_NewObjectProtoClass(ctx, proto, classId);
JS_FreeValue(ctx, proto);
Expand Down Expand Up @@ -224,7 +224,7 @@ void CppObjectMapper::InitProperty(puerts::JSPropertyInfo* PropInfo, JSValue Obj
JS_FreeValue(ctx, setter);
}

JSValue CppObjectMapper::CreateClass(const puerts::JSClassDefinition* ClassDefinition)
JSValue CppObjectMapper::FindOrCreateClass(const puerts::JSClassDefinition* ClassDefinition)
{
auto it = TypeIdToFunctionMap.find(ClassDefinition->TypeId);
if (it == TypeIdToFunctionMap.end())
Expand Down Expand Up @@ -312,7 +312,7 @@ JSValue CppObjectMapper::CreateClass(const puerts::JSClassDefinition* ClassDefin
{
if (auto SuperDefinition = puerts::FindClassByID(ClassDefinition->SuperTypeId))
{
JSValue super_func = CreateClass(SuperDefinition);
JSValue super_func = FindOrCreateClass(SuperDefinition);
JSValue parent_proto = JS_GetProperty(ctx, super_func, JS_ATOM_prototype);
JS_SetPrototype(ctx, proto, parent_proto);
JS_FreeValue(ctx, parent_proto);
Expand All @@ -326,14 +326,14 @@ JSValue CppObjectMapper::CreateClass(const puerts::JSClassDefinition* ClassDefin
return it->second;
}

JSValue CppObjectMapper::CreateClassByID(const void* typeId)
JSValue CppObjectMapper::FindOrCreateClassByID(const void* typeId)
{
auto clsDef = puerts::LoadClassByID(typeId);
if (!clsDef)
{
return JS_UNDEFINED;
}
return CreateClass(clsDef);
return FindOrCreateClass(clsDef);
}

void CppObjectMapper::Initialize(JSContext* ctx_)
Expand Down
2 changes: 1 addition & 1 deletion source/PapiQuickjsImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ pesapi_value pesapi_create_class(pesapi_env env, const void* type_id)
{
auto ctx = qjsContextFromPesapiEnv(env);
auto ret = allocValueInCurrentScope(ctx);
*ret = pesapi::qjsimpl::CppObjectMapper::Get(ctx)->CreateClassByID(type_id);
*ret = pesapi::qjsimpl::CppObjectMapper::Get(ctx)->FindOrCreateClassByID(type_id);
JS_DupValue(ctx, *ret);
return pesapiValueFromQjsValue(ret);
}
Expand Down
Loading