| 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 | { |
no test coverage detected