diff --git a/gienuminfo.c b/gienuminfo.c index 9ecbc2aba..062f3abf2 100644 --- a/gienuminfo.c +++ b/gienuminfo.c @@ -127,9 +127,11 @@ g_enum_info_get_storage_type (GIEnumInfo *info) * * Obtain the enumeration value of the #GIValueInfo. * - * Returns: the enumeration value + * Returns: the enumeration value. This will always be representable + * as a 32-bit signed or unsigned value. The use of gint64 as the + * return type is to allow both. */ -glong +gint64 g_value_info_get_value (GIValueInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; @@ -140,6 +142,9 @@ g_value_info_get_value (GIValueInfo *info) blob = (ValueBlob *)&rinfo->typelib->data[rinfo->offset]; - return (glong)blob->value; + if (blob->unsigned_value) + return (gint64)(guint32)blob->value; + else + return (gint64)blob->value; } diff --git a/gienuminfo.h b/gienuminfo.h index 211ea6efb..6b24fe7ef 100644 --- a/gienuminfo.h +++ b/gienuminfo.h @@ -42,7 +42,7 @@ GIValueInfo * g_enum_info_get_value (GIEnumInfo *info, gint n); GITypeTag g_enum_info_get_storage_type (GIEnumInfo *info); -glong g_value_info_get_value (GIValueInfo *info); +gint64 g_value_info_get_value (GIValueInfo *info); G_END_DECLS diff --git a/gifieldinfo.c b/gifieldinfo.c index 21a6db021..1a6b688c3 100644 --- a/gifieldinfo.c +++ b/gifieldinfo.c @@ -269,9 +269,9 @@ g_field_info_get_field (GIFieldInfo *field_info, case GI_INFO_TYPE_FLAGS: { /* FIXME: there's a mismatch here between the value->v_int we use - * here and the glong result returned from g_value_info_get_value(). - * But to switch this to glong, we'd have to make g_function_info_invoke() - * translate value->v_long to the proper ABI for an enum function + * here and the gint64 result returned from g_value_info_get_value(). + * But to switch this to gint64, we'd have to make g_function_info_invoke() + * translate value->v_int64 to the proper ABI for an enum function * call parameter, which will usually be int, and then fix up language * bindings. */ diff --git a/girnode.c b/girnode.c index 46fd3c7d9..5b9df585d 100644 --- a/girnode.c +++ b/girnode.c @@ -2201,8 +2201,9 @@ g_ir_node_build_typelib (GIrNode *node, blob->deprecated = value->deprecated; blob->reserved = 0; + blob->unsigned_value = value->value >= 0 ? 1 : 0; blob->name = write_string (node->name, strings, data, offset2); - blob->value = value->value; + blob->value = (gint32)value->value; } break; diff --git a/girnode.h b/girnode.h index edb94008f..0df100880 100644 --- a/girnode.h +++ b/girnode.h @@ -262,7 +262,7 @@ struct _GIrNodeValue gboolean deprecated; - gint32 value; + gint64 value; }; struct _GIrNodeConstant diff --git a/girparser.c b/girparser.c index 8f8f6f4da..42525ecde 100644 --- a/girparser.c +++ b/girparser.c @@ -1440,7 +1440,7 @@ start_property (GMarkupParseContext *context, return TRUE; } -static gint +static gint64 parse_value (const gchar *str) { gchar *shift_op; @@ -1450,15 +1450,15 @@ parse_value (const gchar *str) if (shift_op) { - gint base, shift; + gint64 base, shift; - base = strtol (str, NULL, 10); - shift = strtol (shift_op + 3, NULL, 10); + base = g_ascii_strtoll (str, NULL, 10); + shift = g_ascii_strtoll (shift_op + 3, NULL, 10); return base << shift; } else - return strtol (str, NULL, 10); + return g_ascii_strtoll (str, NULL, 10); return 0; } diff --git a/girwriter.c b/girwriter.c index 8c4fa2c35..e90799c13 100644 --- a/girwriter.c +++ b/girwriter.c @@ -704,7 +704,8 @@ write_value_info (const gchar *namespace, Xml *file) { const gchar *name; - glong value; + gint64 value; + gchar *value_str; gboolean deprecated; name = g_base_info_get_name ((GIBaseInfo *)info); @@ -712,7 +713,9 @@ write_value_info (const gchar *namespace, deprecated = g_base_info_is_deprecated ((GIBaseInfo *)info); xml_start_element (file, "member"); - xml_printf (file, " name=\"%s\" value=\"%ld\"", name, value); + value_str = g_strdup_printf ("%" G_GINT64_FORMAT, value); + xml_printf (file, " name=\"%s\" value=\"%s\"", name, value_str); + g_free (value_str); if (deprecated) xml_printf (file, " deprecated=\"1\""); diff --git a/gitypelib-internal.h b/gitypelib-internal.h index 26fd6bfbf..de2f131b6 100644 --- a/gitypelib-internal.h +++ b/gitypelib-internal.h @@ -632,6 +632,7 @@ typedef struct { /** * ValueBlob: * @deprecated: Whether this value is deprecated + * @unsigned_value: if set, value is a 32-bit unsigned integer cast to gint32 * @value: The numerical value * @name: Name of blob * @@ -639,8 +640,9 @@ typedef struct { */ typedef struct { guint32 deprecated : 1; + guint32 unsigned_value : 1; /* */ - guint32 reserved :31; + guint32 reserved :30; /* */ guint32 name; gint32 value;