Example #1
0
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();
}
Example #2
0
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);
}
Example #3
0
File: param.c Project: goizueta/gjs
JSObject*
gjs_lookup_param_prototype(JSContext    *context)
{
    JSObject *ns;
    JSObject *proto;

    ns = gjs_lookup_namespace_object_by_name(context, "GObject");

    if (ns == NULL)
        return NULL;

    if (gjs_define_param_class(context, ns, &proto))
        return proto;
    else
        return NULL;
}