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

Function gjs_define_function

gi/function.cpp:1384–1409  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1382} // namespace Gjs
1383
1384GJS_JSAPI_RETURN_CONVENTION
1385JSObject* gjs_define_function(JSContext* cx, JS::HandleObject in_object,
1386 GType gtype, const GI::CallableInfo& info) {
1387 using std::string_literals::operator""s;
1388 std::string name;
1389
1390 JS::RootedObject function{cx, Gjs::Function::create(cx, gtype, info)};
1391 if (!function)
1392 return nullptr;
1393
1394 if (info.is_function()) {
1395 name = info.name();
1396 } else if (info.is_vfunc()) {
1397 name = "vfunc_"s + info.name();
1398 } else {
1399 g_assert_not_reached();
1400 }
1401
1402 if (!JS_DefineProperty(cx, in_object, name.c_str(), function,
1403 GJS_MODULE_PROP_FLAGS)) {
1404 gjs_debug(GJS_DEBUG_GFUNCTION, "Failed to define function");
1405 function = nullptr;
1406 }
1407
1408 return function;
1409}
1410
1411bool gjs_invoke_constructor_from_c(JSContext* cx, const GI::FunctionInfo& info,
1412 JS::HandleObject obj,

Callers 9

resolve_interfaceMethod · 0.85
resolve_implMethod · 0.85
param_resolveFunction · 0.85
gjs_define_infoFunction · 0.85
resolve_no_infoMethod · 0.85
uncached_resolveMethod · 0.85
resolve_implMethod · 0.85
resolve_implMethod · 0.85

Calls 4

gjs_debugFunction · 0.85
is_functionMethod · 0.80
is_vfuncMethod · 0.80
nameMethod · 0.45

Tested by

no test coverage detected