See GIWrapperBase::constructor()
| 2719 | |
| 2720 | // See GIWrapperBase::constructor() |
| 2721 | bool ObjectInstance::constructor_impl(JSContext* cx, JS::HandleObject object, |
| 2722 | const JS::CallArgs& args) { |
| 2723 | JS::RootedValue initer{cx}; |
| 2724 | GjsContextPrivate* gjs = GjsContextPrivate::from_cx(cx); |
| 2725 | const JS::MutableHandleValue& new_target = args.newTarget(); |
| 2726 | bool has_gtype; |
| 2727 | |
| 2728 | g_assert(new_target.isObject() && "new.target needs to be an object"); |
| 2729 | JS::RootedObject rooted_target{cx, &new_target.toObject()}; |
| 2730 | if (!JS_HasOwnPropertyById(cx, rooted_target, gjs->atoms().gtype(), |
| 2731 | &has_gtype)) |
| 2732 | return false; |
| 2733 | |
| 2734 | if (!has_gtype) { |
| 2735 | gjs_throw(cx, |
| 2736 | "Tried to construct an object without a GType; are " |
| 2737 | "you using GObject.registerClass() when inheriting " |
| 2738 | "from a GObject type?"); |
| 2739 | return false; |
| 2740 | } |
| 2741 | |
| 2742 | return gjs_object_require_property(cx, object, "GObject instance", |
| 2743 | gjs->atoms().init(), &initer) && |
| 2744 | gjs->call_function(object, initer, args, args.rval()); |
| 2745 | } |
| 2746 | |
| 2747 | void ObjectInstance::trace_impl(JSTracer* tracer) { |
| 2748 | for (GClosure* closure : m_closures) |
nothing calls this directly
no test coverage detected