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

Method define

gjs/native.cpp:58–70  ·  view source on GitHub ↗

* define: * @cx: the #JSContext * @id: Name under which the module was registered with add() * @module_out: Return location for a #JSObject * * Loads a builtin native-code module called @name into @module_out by calling * the function to define it. * * Returns: true on success, false if an exception was thrown. */

Source from the content-addressed store, hash-verified

56 * Returns: true on success, false if an exception was thrown.
57 */
58bool Gjs::NativeModuleDefineFuncs::define(
59 JSContext* cx, const char* id, JS::MutableHandleObject module_out) const {
60 gjs_debug(GJS_DEBUG_NATIVE, "Defining native module '%s'", id);
61
62 const auto& iter = m_modules.find(id);
63
64 if (iter == m_modules.end()) {
65 gjs_throw(cx, "No native module '%s' has registered itself", id);
66 return false;
67 }
68
69 return iter->second(cx, module_out);
70}

Callers 3

gjs_import_native_moduleFunction · 0.80
load_native_moduleMethod · 0.80

Calls 3

gjs_debugFunction · 0.85
gjs_throwFunction · 0.85
endMethod · 0.80

Tested by

no test coverage detected