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

Function gjs_register_interface

gi/private.cpp:254–283  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

252}
253
254GJS_JSAPI_RETURN_CONVENTION
255static bool gjs_register_interface(JSContext* cx, unsigned argc,
256 JS::Value* vp) {
257 JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
258
259 JS::UniqueChars name;
260 JS::RootedObject interfaces(cx), properties(cx);
261 if (!gjs_parse_call_args(cx, "register_interface", args, "soo", "name",
262 &name, "interfaces", &interfaces, "properties",
263 &properties))
264 return false;
265
266 GType interface_type;
267 if (!gjs_register_interface_impl(cx, name.get(), interfaces, properties,
268 &interface_type))
269 return false;
270
271 // create a custom JSClass
272 JS::RootedObject module(cx, gjs_lookup_private_namespace(cx));
273 if (!module)
274 return false; // error will have been thrown already
275
276 JS::RootedObject constructor(cx), ignored_prototype(cx);
277 if (!InterfacePrototype::create_class(cx, module, Nothing{}, interface_type,
278 &constructor, &ignored_prototype))
279 return false;
280
281 args.rval().setObject(*constructor);
282 return true;
283}
284
285GJS_JSAPI_RETURN_CONVENTION
286static bool gjs_register_interface_with_class(JSContext* cx, unsigned argc,

Callers

nothing calls this directly

Calls 4

gjs_parse_call_argsFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected