[PATCH] gjs: Use enum info from GI, to support unregistered enums
Johan Bilien <[email protected]> Tue, 21 Oct 2008 12:53:21 +0200
| Newsgroups | gmane.comp.gnome.language-bindings |
|---|---|
| Message-ID | <[email protected]> |
--x+6KMIRAuhnl3hBn Content-Type: text/plain; charset=us-ascii Content-Disposition: inline -- Johan Bilien <[email protected]> --x+6KMIRAuhnl3hBn Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="use_enum_info.diff" Index: gi/arg.c =================================================================== --- gi/arg.c (revision 32) +++ gi/arg.c (working copy) @@ -354,24 +354,20 @@ } else if (JSVAL_IS_NUMBER(value)) { nullable_type = FALSE; - if (g_type_is_a(gtype, G_TYPE_ENUM)) { + + if (g_base_info_get_type(symbol_info) == GI_INFO_TYPE_ENUM) { if (!JS_ValueToInt32(context, value, &arg->v_int)) { wrong = TRUE; } else { - GEnumValue *v; - void *klass; + int n_values; - klass = g_type_class_ref(gtype); + n_values = g_enum_info_get_n_values((GIEnumInfo *)symbol_info); - v = g_enum_get_value(G_ENUM_CLASS(klass), - arg->v_int); - - g_type_class_unref(klass); - - if (v == NULL) { + if (arg->v_int < g_value_info_get_value(g_enum_info_get_value((GIEnumInfo *)symbol_info, 0)) || + arg->v_int > g_value_info_get_value(g_enum_info_get_value((GIEnumInfo *)symbol_info, n_values - 1))) { gjs_throw(context, "%d is not a valid value for enumeration %s", - arg->v_int, g_type_name(gtype)); + arg->v_int, g_base_info_get_name(symbol_info)); wrong = TRUE; } } --x+6KMIRAuhnl3hBn Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ language-bindings mailing list [email protected] http://mail.gnome.org/mailman/listinfo/language-bindings --x+6KMIRAuhnl3hBn--