[gobject-introspection] Add support for gunichar in typelib



commit c8940a11562fd7b888595c6298e39836192fa3d7
Author: Colin Walters <walters verbum org>
Date:   Tue Oct 26 11:12:26 2010 -0400

    Add support for gunichar in typelib
    
    Some API such as gtk_text_iter_get_char returns an individual
    "gunichar"; we should support this.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=633197

 girepository/gifieldinfo.c             |    2 ++
 girepository/girepository.c            |    2 ++
 girepository/girffi.c                  |    1 +
 girepository/girnode.c                 |    2 +-
 girepository/girparser.c               |    3 ++-
 girepository/gitypeinfo.h              |    2 +-
 girepository/gitypelib.c               |    4 +++-
 girepository/gitypes.h                 |    9 ++++++---
 giscanner/introspectablepass.py        |    4 ----
 tests/scanner/Regress-1.0-expected.gir |   10 ++++++++++
 tests/scanner/regress.c                |    5 +++++
 tests/scanner/regress.h                |    1 +
 12 files changed, 34 insertions(+), 11 deletions(-)
---
diff --git a/girepository/gifieldinfo.c b/girepository/gifieldinfo.c
index 1a6b688..d4fd14e 100644
--- a/girepository/gifieldinfo.c
+++ b/girepository/gifieldinfo.c
@@ -220,6 +220,7 @@ g_field_info_get_field (GIFieldInfo *field_info,
 	  break;
 	case GI_TYPE_TAG_INT32:
 	case GI_TYPE_TAG_UINT32:
+	case GI_TYPE_TAG_UNICHAR:
 	  value->v_uint32 = G_STRUCT_MEMBER (guint32, mem, offset);
 	  result = TRUE;
 	  break;
@@ -399,6 +400,7 @@ g_field_info_set_field (GIFieldInfo     *field_info,
 	  break;
 	case GI_TYPE_TAG_INT32:
 	case GI_TYPE_TAG_UINT32:
+	case GI_TYPE_TAG_UNICHAR:
 	  G_STRUCT_MEMBER (guint32, mem, offset) = value->v_uint32;
 	  result = TRUE;
 	  break;
diff --git a/girepository/girepository.c b/girepository/girepository.c
index 7ac407a..f7f55e5 100644
--- a/girepository/girepository.c
+++ b/girepository/girepository.c
@@ -1408,6 +1408,8 @@ g_type_tag_to_string (GITypeTag type)
       return "gfloat";
     case GI_TYPE_TAG_DOUBLE:
       return "gdouble";
+    case GI_TYPE_TAG_UNICHAR:
+      return "gunichar";
     case GI_TYPE_TAG_GTYPE:
       return "GType";
     case GI_TYPE_TAG_UTF8:
diff --git a/girepository/girffi.c b/girepository/girffi.c
index c46d3d3..d2afca0 100644
--- a/girepository/girffi.c
+++ b/girepository/girffi.c
@@ -56,6 +56,7 @@ gi_type_tag_get_ffi_type (GITypeTag   tag,
     case GI_TYPE_TAG_INT32:
       return &ffi_type_sint32;
     case GI_TYPE_TAG_UINT32:
+    case GI_TYPE_TAG_UNICHAR:
       return &ffi_type_uint32;
     case GI_TYPE_TAG_INT64:
       return &ffi_type_sint64;
diff --git a/girepository/girnode.c b/girepository/girnode.c
index 5b9df58..b298c95 100644
--- a/girepository/girnode.c
+++ b/girepository/girnode.c
@@ -1415,7 +1415,7 @@ g_ir_node_build_typelib (GIrNode         *node,
 
 	*offset += sizeof (SimpleTypeBlob);
 
-	if (G_TYPE_TAG_IS_BASIC(type->tag))
+	if (G_TYPE_TAG_IS_BASIC (type->tag))
 	  {
 	    blob->flags.reserved = 0;
 	    blob->flags.reserved2 = 0;
diff --git a/girepository/girparser.c b/girepository/girparser.c
index 42525ec..0e31e9f 100644
--- a/girepository/girparser.c
+++ b/girepository/girparser.c
@@ -396,6 +396,7 @@ static BasicTypeInfo basic_types[] = {
     { "GType",     GI_TYPE_TAG_GTYPE,   0 },
     { "utf8",      GI_TYPE_TAG_UTF8,    1 },
     { "filename",  GI_TYPE_TAG_FILENAME,1 },
+    { "gunichar",  GI_TYPE_TAG_UNICHAR, 0 },
 };
 
 static const BasicTypeInfo *
@@ -579,7 +580,7 @@ parse_type_internal (GIrModule *module,
 
   if (next)
     *next = (char*)str;
-  g_assert (type->tag >= 0 && type->tag <= GI_TYPE_TAG_ERROR);
+  g_assert (type->tag >= 0 && type->tag < GI_TYPE_TAG_N_TYPES);
   g_free (temporary_type);
   return type;
 
diff --git a/girepository/gitypeinfo.h b/girepository/gitypeinfo.h
index 39890a7..5c4fc83 100644
--- a/girepository/gitypeinfo.h
+++ b/girepository/gitypeinfo.h
@@ -33,7 +33,7 @@ G_BEGIN_DECLS
 #define GI_IS_TYPE_INFO(info) \
     (g_base_info_get_type((GIBaseInfo*)info) ==  GI_INFO_TYPE_TYPE)
 
-#define G_TYPE_TAG_IS_BASIC(tag) (tag < GI_TYPE_TAG_ARRAY)
+#define G_TYPE_TAG_IS_BASIC(tag) (tag < GI_TYPE_TAG_ARRAY || tag == GI_TYPE_TAG_UNICHAR)
 
 const gchar*           g_type_tag_to_string            (GITypeTag   type);
 const gchar*           g_info_type_to_string           (GIInfoType  type);
diff --git a/girepository/gitypelib.c b/girepository/gitypelib.c
index 4d119b7..e77866a 100644
--- a/girepository/gitypelib.c
+++ b/girepository/gitypelib.c
@@ -652,6 +652,7 @@ validate_type_blob (GITypelib     *typelib,
 	}
 
       if (simple->flags.tag >= GI_TYPE_TAG_UTF8 &&
+	  simple->flags.tag != GI_TYPE_TAG_UNICHAR &&
 	  !simple->flags.pointer)
 	{
 	  g_set_error (error,
@@ -1010,11 +1011,12 @@ validate_constant_blob (GITypelib     *typelib,
     0, /* GSLIST */
     0, /* GHASH */
     0, /* ERROR */
+    4 /* UNICHAR */
   };
   ConstantBlob *blob;
   SimpleTypeBlob *type;
 
-  g_assert (G_N_ELEMENTS (value_size) == GI_TYPE_TAG_ERROR + 1);
+  g_assert (G_N_ELEMENTS (value_size) == GI_TYPE_TAG_N_TYPES);
 
   if (typelib->len < offset + sizeof (ConstantBlob))
     {
diff --git a/girepository/gitypes.h b/girepository/gitypes.h
index a356800..d15b121 100644
--- a/girepository/gitypes.h
+++ b/girepository/gitypes.h
@@ -322,6 +322,7 @@ typedef enum {
  * @GI_TYPE_TAG_UINT64: 64-bit unsigned integer
  * @GI_TYPE_TAG_FLOAT: float
  * @GI_TYPE_TAG_DOUBLE: double floating point
+ * @GI_TYPE_TAG_UNICHAR: Unicode character
  * @GI_TYPE_TAG_GTYPE: a #GType
  * @GI_TYPE_TAG_UTF8: a UTF-8 encoded string
  * @GI_TYPE_TAG_FILENAME: a filename, encoded in the same encoding
@@ -352,18 +353,20 @@ typedef enum {
   GI_TYPE_TAG_GTYPE     = 12,
   GI_TYPE_TAG_UTF8      = 13,
   GI_TYPE_TAG_FILENAME  = 14,
-  /* Non-basic types */
+  /* Non-basic types; compare with G_TYPE_TAG_IS_BASIC */
   GI_TYPE_TAG_ARRAY     = 15,
   GI_TYPE_TAG_INTERFACE = 16,
   GI_TYPE_TAG_GLIST     = 17,
   GI_TYPE_TAG_GSLIST    = 18,
   GI_TYPE_TAG_GHASH     = 19,
-  GI_TYPE_TAG_ERROR     = 20
+  GI_TYPE_TAG_ERROR     = 20,
+  /* Another basic type */
+  GI_TYPE_TAG_UNICHAR   = 21
   /* Note - there is only room currently for 32 tags.
    * See docs/typelib-format.txt SimpleTypeBlob definition */
 } GITypeTag;
 
-#define GI_TYPE_TAG_N_TYPES (GI_TYPE_TAG_ERROR+1)
+#define GI_TYPE_TAG_N_TYPES (GI_TYPE_TAG_UNICHAR+1)
 
 /* These were removed and no longer appear in the typelib;
  * instead, the machine-specific versions like INT32 are
diff --git a/giscanner/introspectablepass.py b/giscanner/introspectablepass.py
index ef2ddf7..8aa7f8d 100644
--- a/giscanner/introspectablepass.py
+++ b/giscanner/introspectablepass.py
@@ -143,10 +143,6 @@ class IntrospectablePass(object):
         if typeval.target_fundamental:
             if typeval.is_equiv(ast.TYPE_VALIST):
                 return False
-            # Mark UCHAR as not introspectable temporarily until
-            # we're ready to land the typelib changes
-            if typeval.is_equiv(ast.TYPE_UNICHAR):
-                return False
             # These are not introspectable pending us adding
             # larger type tags to the typelib (in theory these could
             # be 128 bit or larger)
diff --git a/tests/scanner/Regress-1.0-expected.gir b/tests/scanner/Regress-1.0-expected.gir
index 36a7b0d..9f112f4 100644
--- a/tests/scanner/Regress-1.0-expected.gir
+++ b/tests/scanner/Regress-1.0-expected.gir
@@ -2274,6 +2274,16 @@ call and can be released on return.</doc>
         </parameter>
       </parameters>
     </function>
+    <function name="test_unichar" c:identifier="regress_test_unichar">
+      <return-value transfer-ownership="none">
+        <type name="gunichar" c:type="gunichar"/>
+      </return-value>
+      <parameters>
+        <parameter name="in" transfer-ownership="none">
+          <type name="gunichar" c:type="gunichar"/>
+        </parameter>
+      </parameters>
+    </function>
     <function name="test_ushort" c:identifier="regress_test_ushort">
       <return-value transfer-ownership="none">
         <type name="gushort" c:type="gushort"/>
diff --git a/tests/scanner/regress.c b/tests/scanner/regress.c
index 40562f5..9f22596 100644
--- a/tests/scanner/regress.c
+++ b/tests/scanner/regress.c
@@ -148,6 +148,11 @@ regress_test_double (gdouble in)
   return in;
 }
 
+gunichar
+regress_test_unichar (gunichar in)
+{
+  return in;
+}
 
 time_t
 regress_test_timet (time_t in)
diff --git a/tests/scanner/regress.h b/tests/scanner/regress.h
index 6d729f1..9b39bd3 100644
--- a/tests/scanner/regress.h
+++ b/tests/scanner/regress.h
@@ -30,6 +30,7 @@ gssize regress_test_ssize (gssize in);
 gsize regress_test_size (gsize in);
 gfloat regress_test_float (gfloat in);
 gdouble regress_test_double (gdouble in);
+gunichar regress_test_unichar (gunichar in);
 time_t regress_test_timet (time_t in);
 GType regress_test_gtype (GType in);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]