| 89 | } |
| 90 | |
| 91 | GJS_JSAPI_RETURN_CONVENTION |
| 92 | static bool run_bootstrap(JSContext* cx, const char* bootstrap_script, |
| 93 | JS::HandleObject global) { |
| 94 | Gjs::AutoChar uri{g_strdup_printf( |
| 95 | "resource:///org/gnome/gjs/modules/script/_bootstrap/%s.js", |
| 96 | bootstrap_script)}; |
| 97 | |
| 98 | JSAutoRealm ar(cx, global); |
| 99 | |
| 100 | JS::CompileOptions options(cx); |
| 101 | options.setFileAndLine(uri, 1).setSourceIsLazy(true); |
| 102 | |
| 103 | char* script; |
| 104 | size_t script_len; |
| 105 | if (!gjs_load_internal_source(cx, uri, &script, &script_len)) |
| 106 | return false; |
| 107 | |
| 108 | JS::SourceText<mozilla::Utf8Unit> source; |
| 109 | if (!source.init(cx, script, script_len, |
| 110 | JS::SourceOwnership::TakeOwnership)) |
| 111 | return false; |
| 112 | |
| 113 | JS::RootedValue ignored(cx); |
| 114 | return JS::Evaluate(cx, options, source, &ignored); |
| 115 | } |
| 116 | |
| 117 | GJS_JSAPI_RETURN_CONVENTION |
| 118 | static bool load_native_module(JSContext* m_cx, unsigned argc, |
nothing calls this directly
no test coverage detected