[gobject-introspection] girepository: gchar is a signed type
- From: Martin Pitt <martinpitt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] girepository: gchar is a signed type
- Date: Fri, 11 Jan 2013 13:56:16 +0000 (UTC)
commit ee36c78b0c11763a69203e8ef14d74543698473a
Author: Martin Pitt <martinpitt gnome org>
Date: Fri Jan 11 08:42:27 2013 +0100
girepository: gchar is a signed type
gchar is signed, not unsigned. Add "guchar" alias as unsigned for completeness
(but usually it appears as guint8).
https://bugzilla.gnome.org/show_bug.cgi?id=691524
girepository/girparser.c | 3 +-
tests/repository/gitypelibtest.c | 55 ++++++++++++++++++++++++++++++++++++++
2 files changed, 57 insertions(+), 1 deletions(-)
---
diff --git a/girepository/girparser.c b/girepository/girparser.c
index ce88a69..1a83c23 100644
--- a/girepository/girparser.c
+++ b/girepository/girparser.c
@@ -379,7 +379,8 @@ typedef struct {
} IntegerAliasInfo;
static IntegerAliasInfo integer_aliases[] = {
- { "gchar", SIZEOF_CHAR, 0 },
+ { "gchar", SIZEOF_CHAR, 1 },
+ { "guchar", SIZEOF_CHAR, 0 },
{ "gshort", SIZEOF_SHORT, 1 },
{ "gushort", SIZEOF_SHORT, 0 },
{ "gint", SIZEOF_INT, 1 },
diff --git a/tests/repository/gitypelibtest.c b/tests/repository/gitypelibtest.c
index 3677073..54fe523 100644
--- a/tests/repository/gitypelibtest.c
+++ b/tests/repository/gitypelibtest.c
@@ -178,6 +178,60 @@ test_hash_with_cairo_typelib (GIRepository *repo)
g_assert (info == NULL);
}
+static GIPropertyInfo *
+lookup_property (GIObjectInfo *info, const gchar *name)
+{
+ gssize n_props;
+ gssize i;
+ GIPropertyInfo *property_info;
+
+ n_props = g_object_info_get_n_properties (info);
+ for (i = 0; i < n_props; i++) {
+ property_info = g_object_info_get_property (info, i);
+ if (strcmp (name, g_base_info_get_name (property_info)) == 0)
+ return property_info;
+ g_base_info_unref (property_info);
+ }
+
+ return NULL;
+}
+
+static void
+test_char_types (GIRepository *repo)
+{
+ GITypelib *ret;
+ GError *error = NULL;
+ GIBaseInfo *prop_obj;
+ GIPropertyInfo *prop_info;
+ GITypeInfo *type_info;
+
+ ret = g_irepository_require (repo, "GIMarshallingTests", NULL, 0, &error);
+ if (!ret)
+ g_error ("%s", error->message);
+
+ prop_obj = g_irepository_find_by_name (repo, "GIMarshallingTests", "PropertiesObject");
+ g_assert (prop_obj != NULL);
+ g_assert (GI_IS_OBJECT_INFO (prop_obj));
+
+ /* unsigned char */
+ prop_info = lookup_property ((GIObjectInfo *) prop_obj, "some-uchar");
+ g_assert (prop_info != NULL);
+ type_info = g_property_info_get_type (prop_info);
+ g_assert_cmpuint (g_type_info_get_tag (type_info), ==, GI_TYPE_TAG_UINT8);
+ g_base_info_unref (type_info);
+ g_base_info_unref (prop_info);
+
+ /* signed char */
+ prop_info = lookup_property ((GIObjectInfo *) prop_obj, "some-char");
+ g_assert (prop_info != NULL);
+ type_info = g_property_info_get_type (prop_info);
+ g_assert_cmpuint (g_type_info_get_tag (type_info), ==, GI_TYPE_TAG_INT8);
+ g_base_info_unref (type_info);
+ g_base_info_unref (prop_info);
+
+ g_base_info_unref (prop_obj);
+}
+
int
main(int argc, char **argv)
{
@@ -192,6 +246,7 @@ main(int argc, char **argv)
test_is_pointer_for_struct_arg (repo);
test_fundamental_get_ref_function_pointer (repo);
test_hash_with_cairo_typelib (repo);
+ test_char_types (repo);
exit(0);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]