| 252 | } |
| 253 | |
| 254 | GJS_JSAPI_RETURN_CONVENTION |
| 255 | static 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 | |
| 285 | GJS_JSAPI_RETURN_CONVENTION |
| 286 | static bool gjs_register_interface_with_class(JSContext* cx, unsigned argc, |
nothing calls this directly
no test coverage detected