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

Method Invoke

unity/native_src/Src/JSFunction.cpp:89–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87 }*/
88
89 bool JSFunction::Invoke(bool HasResult)
90 {
91 v8::Isolate* Isolate = ResultInfo.Isolate;
92 v8::Isolate::Scope IsolateScope(Isolate);
93 v8::HandleScope HandleScope(Isolate);
94 v8::Local<v8::Context> Context = ResultInfo.Context.Get(Isolate);
95 v8::Context::Scope ContextScope(Context);
96
97 V8Arguments.clear();
98 for (int i = 0; i < Arguments.size(); ++i)
99 {
100 V8Arguments.push_back(ToV8(Isolate, Context, Arguments[i]));
101 }
102 v8::TryCatch TryCatch(Isolate);
103 auto maybeValue = GFunction.Get(Isolate)->Call(Context, Context->Global(), static_cast<int>(V8Arguments.size()), V8Arguments.data());
104 Arguments.clear();
105
106 if (TryCatch.HasCaught())
107 {
108 LastExceptionInfo = FV8Utils::ExceptionToString(Isolate, TryCatch);
109 return false;
110 }
111 else
112 {
113 if (HasResult && !maybeValue.IsEmpty())
114 {
115 ResultInfo.Result.Reset(Isolate, maybeValue.ToLocalChecked());
116 }
117 return true;
118 }
119 }
120}

Callers 1

Puerts.cppFile · 0.45

Calls 11

ToV8Function · 0.85
HasCaughtMethod · 0.80
GetMethod · 0.45
clearMethod · 0.45
sizeMethod · 0.45
CallMethod · 0.45
GlobalMethod · 0.45
dataMethod · 0.45
IsEmptyMethod · 0.45
ResetMethod · 0.45
ToLocalCheckedMethod · 0.45

Tested by

no test coverage detected