Skip to content

Commit

Permalink
Move GParamSpec registration together with the other infos
Browse files Browse the repository at this point in the history
Instead of special casing it in ns_new_resolve(), now that it has
correctly a GType, we can handle it together with the other objects.
Also, check that the classes we define inherit from GObject, since
we assume that around the code.
  • Loading branch information
gcampax authored and magcius committed Feb 3, 2012
1 parent 9e64378 commit a207d14
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
16 changes: 0 additions & 16 deletions gi/ns.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,22 +95,6 @@ ns_new_resolve(JSContext *context,

JS_BeginRequest(context);

/* Special-case fallback hack for GParamSpec */
if (strcmp(name, "ParamSpec") == 0 &&
strcmp(priv->namespace, "GObject") == 0) {
if (!gjs_define_param_class(context,
obj,
NULL)) {
JS_EndRequest(context);
goto out;
} else {
*objp = obj; /* we defined the property in this object */
JS_EndRequest(context);
ret = JS_TRUE;
goto out;
}
}

repo = g_irepository_get_default();

info = g_irepository_find_by_name(repo, priv->namespace, name);
Expand Down
18 changes: 15 additions & 3 deletions gi/repo.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "ns.h"
#include "function.h"
#include "object.h"
#include "param.h"
#include "boxed.h"
#include "union.h"
#include "enumeration.h"
Expand Down Expand Up @@ -470,10 +471,21 @@ gjs_define_info(JSContext *context,
GType gtype;
GIBaseInfo *info_for_gtype;
gtype = g_registered_type_info_get_g_type((GIRegisteredTypeInfo*)info);
if (!gjs_define_object_class(context, in_object, gtype, NULL, NULL, &info_for_gtype))

if (g_type_is_a (gtype, G_TYPE_PARAM)) {
if (!gjs_define_param_class(context, in_object, NULL))
return JS_FALSE;
} else if (g_type_is_a (gtype, G_TYPE_OBJECT)) {
if (!gjs_define_object_class(context, in_object, gtype, NULL, NULL, &info_for_gtype))
return JS_FALSE;
g_assert(g_base_info_equal(info, info_for_gtype));
g_base_info_unref(info_for_gtype);
} else {
gjs_throw (context,
"Unsupported type %s, deriving from fundamental %s",
g_type_name(gtype), g_type_name(g_type_fundamental(gtype)));
return JS_FALSE;
g_assert(g_base_info_equal(info, info_for_gtype));
g_base_info_unref(info_for_gtype);
}
}
break;
case GI_INFO_TYPE_STRUCT:
Expand Down

0 comments on commit a207d14

Please sign in to comment.