[gjs] Fix ParamSpec constructors for enum/flags
- From: Giovanni Campagna <gcampagna src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs] Fix ParamSpec constructors for enum/flags
- Date: Sat, 28 Sep 2013 16:49:22 +0000 (UTC)
commit 8ee86a3e68bfccc369b7a81f8f1fa872c34bb265
Author: Giovanni Campagna <gcampagn redhat com>
Date: Fri Sep 27 14:03:56 2013 +0200
Fix ParamSpec constructors for enum/flags
Remove the redundancy in the prop_gtype and actual gtype.
https://bugzilla.gnome.org/show_bug.cgi?id=708915
gi/param.c | 28 +++++-----------------------
modules/overrides/GObject.js | 6 ++----
2 files changed, 7 insertions(+), 27 deletions(-)
---
diff --git a/gi/param.c b/gi/param.c
index cb8f530..06bc2db 100644
--- a/gi/param.c
+++ b/gi/param.c
@@ -303,55 +303,37 @@ param_new_internal(JSContext *cx,
break;
case G_TYPE_ENUM:
{
- JSObject *gtype_jsobj;
- GType gtype;
GIEnumInfo *info;
gint64 default_value;
if (!gjs_parse_args(cx, method_name,
"ot", argc, argv,
- "gtype", >ype_jsobj,
"default_value", &default_value))
goto out;
- gtype = gjs_gtype_get_actual_gtype(cx, gtype_jsobj);
- if (gtype == G_TYPE_NONE) {
- gjs_throw(cx, "Passed invalid GType to GParamSpecEnum constructor");
- goto out;
- }
-
- info = g_irepository_find_by_gtype(g_irepository_get_default(), gtype);
+ info = g_irepository_find_by_gtype(g_irepository_get_default(), prop_gtype);
if (!_gjs_enum_value_is_valid(cx, info, default_value))
goto out;
pspec = g_param_spec_enum(prop_name, nick, blurb,
- gtype, default_value, flags);
+ prop_gtype, default_value, flags);
}
break;
case G_TYPE_FLAGS:
{
- JSObject *gtype_jsobj;
- GType gtype;
gint64 default_value;
if (!gjs_parse_args(cx, method_name,
- "ot", argc, argv,
- "gtype", >ype_jsobj,
+ "t", argc, argv,
"default_value", &default_value))
goto out;
- gtype = gjs_gtype_get_actual_gtype(cx, gtype_jsobj);
- if (gtype == G_TYPE_NONE) {
- gjs_throw(cx, "Passed invalid GType to GParamSpecFlags constructor");
- goto out;
- }
-
- if (!_gjs_flags_value_is_valid(cx, gtype, default_value))
+ if (!_gjs_flags_value_is_valid(cx, prop_gtype, default_value))
goto out;
pspec = g_param_spec_flags(prop_name, nick, blurb,
- gtype, default_value, flags);
+ prop_gtype, default_value, flags);
}
break;
case G_TYPE_FLOAT:
diff --git a/modules/overrides/GObject.js b/modules/overrides/GObject.js
index f2450f7..f8f74da 100644
--- a/modules/overrides/GObject.js
+++ b/modules/overrides/GObject.js
@@ -213,13 +213,11 @@ function _init() {
};
this.ParamSpec.flags = function(name, nick, blurb, flags, flags_type, default_value) {
- return GObject.ParamSpec._new_internal(name, GObject.TYPE_FLAGS,
- nick, blurb, flags, flags_type, default_value);
+ return GObject.ParamSpec._new_internal(name, flags_type, nick, blurb, flags, default_value);
};
this.ParamSpec.enum = function(name, nick, blurb, flags, enum_type, default_value) {
- return GObject.ParamSpec._new_internal(name, GObject.TYPE_ENUM,
- nick, blurb, flags, enum_type, default_value);
+ return GObject.ParamSpec._new_internal(name, enum_type, nick, blurb, flags, default_value);
};
this.ParamSpec.double = function(name, nick, blurb, flags, minimum, maximum, default_value) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]