MCPcopy Create free account
hub / github.com/Tencent/puerts / FindOrAddObject

Method FindOrAddObject

unity/native_src/Src/JSEngine.cpp:614–632  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

612 }
613
614 v8::Local<v8::Value> JSEngine::FindOrAddObject(v8::Isolate* Isolate, v8::Local<v8::Context> Context, int ClassID, void *Ptr)
615 {
616 if (!Ptr)
617 {
618 return v8::Undefined(Isolate);
619 }
620
621 auto Iter = ObjectMap.find(Ptr);
622 if (Iter == ObjectMap.end())//create and link
623 {
624 auto BindTo = v8::External::New(Context->GetIsolate(), Ptr);
625 v8::Local<v8::Value> Args[] = { BindTo };
626 return Templates[ClassID].Get(Isolate)->GetFunction(Context).ToLocalChecked()->NewInstance(Context, 1, Args).ToLocalChecked();
627 }
628 else
629 {
630 return v8::Local<v8::Value>::New(Isolate, Iter->second);
631 }
632 }
633
634 void JSEngine::BindObject(FLifeCycleInfo* LifeCycleInfo, void* Ptr, v8::Local<v8::Object> JSObject)
635 {

Callers 3

ToV8Function · 0.45
SetObjectToOutValueFunction · 0.45
ReturnObjectFunction · 0.45

Calls 9

NewFunction · 0.85
NewInstanceMethod · 0.80
UndefinedFunction · 0.50
findMethod · 0.45
endMethod · 0.45
GetIsolateMethod · 0.45
ToLocalCheckedMethod · 0.45
GetFunctionMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected