MCPcopy Create free account
hub / github.com/Tracktion/choc / callback

Method callback

choc/javascript/choc_javascript_V8.h:276–300  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

274 }
275
276 void callback (const v8::FunctionCallbackInfo<v8::Value>& info)
277 {
278 v8::HandleScope handleScope (isolate);
279 auto localContext = context.Get (isolate);
280 v8::Context::Scope contextScope (localContext);
281 auto data = info.Data()->Int32Value (localContext);
282
283 if (data.IsJust())
284 {
285 if (auto fn = nativeFunctions.find (data.ToChecked()); fn != nativeFunctions.end())
286 {
287 auto numArgs = info.Length();
288 std::vector<choc::value::Value> args;
289 args.reserve (static_cast<size_t> (numArgs));
290
291 for (int i = 0; i < numArgs; ++i)
292 args.emplace_back (v8ToChoc (localContext, info[i]));
293
294 auto result = fn->second (ArgumentList { args.data(), args.size() });
295
296 if (! result.isVoid())
297 info.GetReturnValue().Set (chocToV8 (localContext, result));
298 }
299 }
300 }
301
302 choc::value::Value v8ToChoc (v8::Local<v8::Context> c, const v8::Local<v8::Value>& value)
303 {

Callers 2

staticCallbackMethod · 0.45
invokeIfStillAliveMethod · 0.45

Calls 7

findMethod · 0.80
emplace_backMethod · 0.80
endMethod · 0.45
reserveMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
isVoidMethod · 0.45

Tested by

no test coverage detected