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

Function gjs_param_from_g_param

gi/param.cpp:223–250  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

221}
222
223JSObject* gjs_param_from_g_param(JSContext* cx, GParamSpec* gparam) {
224 if (!gparam)
225 return nullptr;
226
227 gjs_debug(GJS_DEBUG_GPARAM,
228 "Wrapping %s '%s' on %s with JSObject",
229 g_type_name(G_TYPE_FROM_INSTANCE((GTypeInstance*) gparam)),
230 gparam->name,
231 g_type_name(gparam->owner_type));
232
233 JS::RootedObject proto{cx, gjs_lookup_param_prototype(cx)};
234 if (!proto)
235 return nullptr;
236
237 JSObject* obj = JS_NewObjectWithGivenProto(cx, JS::GetClass(proto), proto);
238 if (!obj)
239 return nullptr;
240
241 GJS_INC_COUNTER(param);
242 auto* priv = new Param(gparam);
243 JS::SetReservedSlot(obj, POINTER, JS::PrivateValue(priv));
244
245 gjs_debug(GJS_DEBUG_GPARAM,
246 "JSObject created with param instance %p type %s", gparam,
247 g_type_name(G_TYPE_FROM_INSTANCE(gparam)));
248
249 return obj;
250}
251
252GParamSpec* gjs_g_param_from_param(JSContext* cx, JS::HandleObject obj) {
253 if (!obj)

Callers 3

gjs_override_propertyFunction · 0.85

Calls 2

gjs_debugFunction · 0.85

Tested by

no test coverage detected