MCPcopy Create free account
hub / github.com/GNOME/gjs / gjs_create_global_object

Function gjs_create_global_object

gjs/global.cpp:373–400  ·  view source on GitHub ↗

* gjs_create_global_object: * @cx: a #JSContext * * Creates a global object, and initializes it with the default API. * * Returns: the created global object on success, nullptr otherwise, in which * case an exception is pending on @cx */

Source from the content-addressed store, hash-verified

371 * case an exception is pending on @cx
372 */
373JSObject* gjs_create_global_object(JSContext* cx, GjsGlobalType global_type,
374 JS::HandleObject current_global) {
375 if (current_global) {
376 switch (global_type) {
377 case GjsGlobalType::DEFAULT:
378 return GjsGlobal::create_with_compartment(cx, current_global);
379 case GjsGlobalType::DEBUGGER:
380 return GjsDebuggerGlobal::create_with_compartment(
381 cx, current_global);
382 case GjsGlobalType::INTERNAL:
383 return GjsInternalGlobal::create_with_compartment(
384 cx, current_global);
385 default:
386 return nullptr;
387 }
388 }
389
390 switch (global_type) {
391 case GjsGlobalType::DEFAULT:
392 return GjsGlobal::create(cx);
393 case GjsGlobalType::DEBUGGER:
394 return GjsDebuggerGlobal::create(cx);
395 case GjsGlobalType::INTERNAL:
396 return GjsInternalGlobal::create(cx);
397 default:
398 return nullptr;
399 }
400}
401
402/**
403 * gjs_global_is_type:

Callers 3

GjsContextPrivateMethod · 0.85
bootstrap_coverageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected