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

Method constructor_impl

gi/struct.cpp:86–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84}
85
86bool StructInstance::constructor_impl(JSContext* cx, JS::HandleObject obj,
87 const JS::CallArgs& args) {
88 if (gtype() == G_TYPE_VARIANT) {
89 // Short-circuit construction for GVariants by calling into the JS
90 // packing function
91 const GjsAtoms& atoms = GjsContextPrivate::atoms(cx);
92 if (!invoke_static_method(cx, obj, atoms.new_internal(), args))
93 return false;
94
95 // The return value of GLib.Variant.new_internal() gets its own
96 // BoxedInstance, and the one we're setting up in this constructor is
97 // discarded.
98 debug_lifecycle(
99 "Boxed construction delegated to GVariant constructor, boxed "
100 "object discarded");
101
102 return true;
103 }
104
105 if (!BoxedInstance::constructor_impl(cx, obj, args))
106 return false;
107
108 // Define the expected Error properties
109 if (gtype() == G_TYPE_ERROR) {
110 JS::RootedObject gerror(cx, &args.rval().toObject());
111 if (!gjs_define_error_properties(cx, gerror))
112 return false;
113 }
114
115 return true;
116}
117
118static bool define_extra_error_properties(JSContext* cx, JS::HandleObject obj) {
119 StructBase* priv = StructBase::for_js(cx, obj);

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected