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

Function bootstrap_coverage

gjs/coverage.cpp:319–350  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

317}
318
319GJS_JSAPI_RETURN_CONVENTION
320static 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
352static void gjs_coverage_constructed(GObject* object) {
353 G_OBJECT_CLASS(gjs_coverage_parent_class)->constructed(object);

Callers 1

gjs_coverage_constructedFunction · 0.85

Calls 4

gjs_create_global_objectFunction · 0.85
contextMethod · 0.80
globalMethod · 0.80

Tested by

no test coverage detected