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

Method constructor

gi/cwrapper.h:251–272  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

249template <class Base, typename Wrapped = Base>
250class CWrapper : public CWrapperPointerOps<Base, Wrapped> {
251 GJS_JSAPI_RETURN_CONVENTION
252 static bool constructor(JSContext* cx, unsigned argc, JS::Value* vp) {
253 JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
254
255 if (!args.isConstructing()) {
256 gjs_throw_constructor_error(cx);
257 return false;
258 }
259 JS::RootedObject object(
260 cx, JS_NewObjectForConstructor(cx, &Base::klass, args));
261 if (!object)
262 return false;
263
264 Wrapped* priv = Base::constructor_impl(cx, args);
265 if (!priv)
266 return false;
267 CWrapperPointerOps<Base, Wrapped>::init_private(object, priv);
268
269 Base::add_associated_memory(object, priv);
270 args.rval().setObject(*object);
271 return true;
272 }
273
274 GJS_JSAPI_RETURN_CONVENTION
275 static bool abstract_constructor(JSContext* cx, unsigned argc,

Callers 4

gjs_object_constructorFunction · 0.45
actual_gtype_recurseMethod · 0.45
invoke_static_methodMethod · 0.45

Calls 1

Tested by

no test coverage detected