Permalink
Browse files

Move GParamSpec registration together with the other infos

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 Dec 9, 2011
1 parent 9e64378 commit a207d14cb704f5d30e1cffbab009b8013d40ae38
Showing with 15 additions and 19 deletions.
  1. +0 −16 gi/ns.c
  2. +15 −3 gi/repo.c
View
16 gi/ns.c
@@ -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);
View
@@ -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"
@@ -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:

0 comments on commit a207d14

Please sign in to comment.