static JSObject* gjs_lookup_param_prototype(JSContext *context) { JS::RootedId gobject_name(context, gjs_intern_string_to_id(context, "GObject")); JS::RootedObject in_object(context, gjs_lookup_namespace_object_by_name(context, gobject_name)); if (G_UNLIKELY (!in_object)) return NULL; JS::RootedValue value(context); if (!JS_GetProperty(context, in_object, "ParamSpec", &value)) return NULL; if (G_UNLIKELY (!value.isObject())) return NULL; JS::RootedObject constructor(context, &value.toObject()); g_assert(constructor); if (!gjs_object_get_property(context, constructor, GJS_STRING_PROTOTYPE, &value)) return NULL; if (G_UNLIKELY (!value.isObjectOrNull())) return NULL; return value.toObjectOrNull(); }
/* Find the first constructor */ static GIFunctionInfo * find_fundamental_constructor(JSContext *context, GIObjectInfo *info, jsid *constructor_name) { int i, n_methods; n_methods = g_object_info_get_n_methods(info); for (i = 0; i < n_methods; ++i) { GIFunctionInfo *func_info; GIFunctionInfoFlags flags; func_info = g_object_info_get_method(info, i); flags = g_function_info_get_flags(func_info); if ((flags & GI_FUNCTION_IS_CONSTRUCTOR) != 0) { const char *name; name = g_base_info_get_name((GIBaseInfo *) func_info); *constructor_name = gjs_intern_string_to_id(context, name); return func_info; } g_base_info_unref((GIBaseInfo *) func_info); } return NULL; }
static JSObject* gjs_lookup_param_prototype(JSContext *context) { JSObject *in_object; JSObject *constructor; jsid gobject_name; jsval value; gobject_name = gjs_intern_string_to_id(context, "GObject"); in_object = gjs_lookup_namespace_object_by_name(context, gobject_name); if (G_UNLIKELY (!in_object)) return NULL; if (!JS_GetProperty(context, in_object, "ParamSpec", &value)) return NULL; if (G_UNLIKELY (!JSVAL_IS_OBJECT(value) || JSVAL_IS_NULL(value))) return NULL; constructor = JSVAL_TO_OBJECT(value); g_assert(constructor != NULL); if (!gjs_object_get_property_const(context, constructor, GJS_STRING_PROTOTYPE, &value)) return NULL; if (G_UNLIKELY (!JSVAL_IS_OBJECT(value))) return NULL; return JSVAL_TO_OBJECT(value); }