* 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 */
| 371 | * case an exception is pending on @cx |
| 372 | */ |
| 373 | JSObject* 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: |
no outgoing calls
no test coverage detected