| 317 | } |
| 318 | |
| 319 | GJS_JSAPI_RETURN_CONVENTION |
| 320 | static bool bootstrap_coverage(GjsCoverage* self) { |
| 321 | auto* priv = static_cast<GjsCoveragePrivate*>( |
| 322 | gjs_coverage_get_instance_private(self)); |
| 323 | |
| 324 | auto* gjs = GjsContextPrivate::from_object(priv->coverage_context); |
| 325 | JSContext* cx = gjs->context(); |
| 326 | |
| 327 | JS::RootedObject debugger_global{ |
| 328 | cx, gjs_create_global_object(cx, GjsGlobalType::DEBUGGER)}; |
| 329 | { |
| 330 | JSAutoRealm ar{cx, debugger_global}; |
| 331 | JS::RootedObject debuggee{cx, gjs->global()}; |
| 332 | if (!JS_WrapObject(cx, &debuggee)) |
| 333 | return false; |
| 334 | |
| 335 | JS::RootedValue v_debuggee{cx, JS::ObjectValue(*debuggee)}; |
| 336 | if (!JS_SetPropertyById(cx, debugger_global, gjs->atoms().debuggee(), |
| 337 | v_debuggee) || |
| 338 | !gjs_define_global_properties(cx, debugger_global, |
| 339 | GjsGlobalType::DEBUGGER, |
| 340 | "GJS coverage", "coverage")) |
| 341 | return false; |
| 342 | |
| 343 | // Add a tracer, as suggested by jdm on #jsapi |
| 344 | JS_AddExtraGCRootsTracer(cx, coverage_tracer, self); |
| 345 | |
| 346 | priv->global = debugger_global; |
| 347 | } |
| 348 | |
| 349 | return true; |
| 350 | } |
| 351 | |
| 352 | static void gjs_coverage_constructed(GObject* object) { |
| 353 | G_OBJECT_CLASS(gjs_coverage_parent_class)->constructed(object); |
no test coverage detected