| 221 | } |
| 222 | |
| 223 | JSObject* 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 | |
| 252 | GParamSpec* gjs_g_param_from_param(JSContext* cx, JS::HandleObject obj) { |
| 253 | if (!obj) |
no test coverage detected