[gobject-introspection] Add support for g[u]intptr in scanner and girwriter.



commit f3f3cb62abec946f82fe44a8382a04b28d6c7313
Author: Pavel Holejsovsky <pavel holejsovsky gmail com>
Date:   Tue Dec 14 16:28:01 2010 +0100

    Add support for g[u]intptr in scanner and girwriter.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=634838

 girepository/girparser.c                  |    8 +++++---
 giscanner/ast.py                          |   15 +++++++++++----
 tests/scanner/Annotation-1.0-expected.gir |    6 +++---
 tests/scanner/Regress-1.0-expected.gir    |    8 ++++----
 tests/scanner/Utility-1.0-expected.gir    |    2 +-
 5 files changed, 24 insertions(+), 15 deletions(-)
---
diff --git a/girepository/girparser.c b/girepository/girparser.c
index 03ab6d2..96761ac 100644
--- a/girepository/girparser.c
+++ b/girepository/girparser.c
@@ -366,8 +366,10 @@ static IntegerAliasInfo integer_aliases[] = {
   { "guint",    SIZEOF_INT,       0 },
   { "glong",    SIZEOF_LONG,      1 },
   { "gulong",   SIZEOF_LONG,      0 },
-  { "gsize",    GLIB_SIZEOF_SIZE_T,    0 },
   { "gssize",   GLIB_SIZEOF_SIZE_T,    1 },
+  { "gsize",    GLIB_SIZEOF_SIZE_T,    0 },
+  { "gintptr",  GLIB_SIZEOF_SIZE_T,    1 },
+  { "guintptr", GLIB_SIZEOF_SIZE_T,    0 },
 };
 
 typedef struct {
@@ -407,12 +409,12 @@ parse_basic (const char *str)
 
   for (i = 0; i < n_basic; i++)
     {
-      if (g_str_has_prefix (str, basic_types[i].str))
+      if (strcmp (str, basic_types[i].str) == 0)
 	return &(basic_types[i]);
     }
   for (i = 0; i < G_N_ELEMENTS (integer_aliases); i++)
     {
-      if (g_str_has_prefix (str, integer_aliases[i].str))
+      if (strcmp (str, integer_aliases[i].str) == 0)
 	{
 	  switch (integer_aliases[i].size)
 	    {
diff --git a/giscanner/ast.py b/giscanner/ast.py
index f7906f2..f5270fc 100644
--- a/giscanner/ast.py
+++ b/giscanner/ast.py
@@ -180,6 +180,10 @@ TYPE_INT = Type(target_fundamental='gint', ctype='gint')
 TYPE_UINT = Type(target_fundamental='guint', ctype='guint')
 TYPE_LONG = Type(target_fundamental='glong', ctype='glong')
 TYPE_ULONG = Type(target_fundamental='gulong', ctype='gulong')
+TYPE_SIZE = Type(target_fundamental='gsize', ctype='gsize')
+TYPE_SSIZE = Type(target_fundamental='gssize', ctype='gssize')
+TYPE_INTPTR = Type(target_fundamental='gintptr', ctype='gintptr')
+TYPE_UINTPTR = Type(target_fundamental='guintptr', ctype='guintptr')
 # C99 types
 TYPE_LONG_LONG = Type(target_fundamental='long long', ctype='long long')
 TYPE_LONG_ULONG = Type(target_fundamental='unsigned long long',
@@ -201,8 +205,9 @@ TYPE_VALIST = Type(target_fundamental='va_list', ctype='va_list')
 BASIC_GIR_TYPES = [TYPE_BOOLEAN, TYPE_INT8, TYPE_UINT8, TYPE_INT16,
                    TYPE_UINT16, TYPE_INT32, TYPE_UINT32, TYPE_INT64,
                    TYPE_UINT64, TYPE_CHAR, TYPE_SHORT, TYPE_USHORT, TYPE_INT,
-                   TYPE_UINT, TYPE_LONG, TYPE_ULONG, TYPE_LONG_LONG,
-                   TYPE_LONG_ULONG, TYPE_FLOAT, TYPE_DOUBLE,
+                   TYPE_UINT, TYPE_LONG, TYPE_ULONG, TYPE_SIZE, TYPE_SSIZE,
+                   TYPE_LONG_LONG, TYPE_LONG_ULONG, TYPE_INTPTR, TYPE_UINTPTR,
+                   TYPE_FLOAT, TYPE_DOUBLE,
                    TYPE_LONG_DOUBLE, TYPE_UNICHAR, TYPE_GTYPE]
 GIR_TYPES = [TYPE_NONE, TYPE_ANY]
 GIR_TYPES.extend(BASIC_GIR_TYPES)
@@ -252,8 +257,10 @@ type_names['gchararray'] = TYPE_STRING
 type_names['gchar*'] = TYPE_STRING
 type_names['goffset'] = TYPE_INT64
 type_names['gunichar2'] = TYPE_UINT16
-type_names['gsize'] = TYPE_ULONG
-type_names['gssize'] = TYPE_LONG
+type_names['gsize'] = TYPE_SIZE
+type_names['gssize'] = TYPE_SSIZE
+type_names['gintptr'] = TYPE_INTPTR
+type_names['guintptr'] = TYPE_UINTPTR
 type_names['gconstpointer'] = TYPE_ANY
 
 # We used to support these; continue to do so
diff --git a/tests/scanner/Annotation-1.0-expected.gir b/tests/scanner/Annotation-1.0-expected.gir
index 2194eee..e47a4b9 100644
--- a/tests/scanner/Annotation-1.0-expected.gir
+++ b/tests/scanner/Annotation-1.0-expected.gir
@@ -397,7 +397,7 @@ each string needs to be freed.</doc>
           </parameter>
           <parameter name="length" transfer-ownership="none">
             <doc xml:whitespace="preserve">Length of the data</doc>
-            <type name="gulong" c:type="gsize"/>
+            <type name="gsize" c:type="gsize"/>
           </parameter>
         </parameters>
       </method>
@@ -415,7 +415,7 @@ each string needs to be freed.</doc>
           </parameter>
           <parameter name="length" transfer-ownership="none">
             <doc xml:whitespace="preserve">Length of the data</doc>
-            <type name="gulong" c:type="gsize"/>
+            <type name="gsize" c:type="gsize"/>
           </parameter>
         </parameters>
       </method>
@@ -434,7 +434,7 @@ type.</doc>
           </parameter>
           <parameter name="length" transfer-ownership="none">
             <doc xml:whitespace="preserve">Length of the data</doc>
-            <type name="gulong" c:type="gsize"/>
+            <type name="gsize" c:type="gsize"/>
           </parameter>
         </parameters>
       </method>
diff --git a/tests/scanner/Regress-1.0-expected.gir b/tests/scanner/Regress-1.0-expected.gir
index 758497e..c7fb783 100644
--- a/tests/scanner/Regress-1.0-expected.gir
+++ b/tests/scanner/Regress-1.0-expected.gir
@@ -2041,21 +2041,21 @@ call and can be released on return.</doc>
     </function>
     <function name="test_size" c:identifier="regress_test_size">
       <return-value transfer-ownership="none">
-        <type name="gulong" c:type="gsize"/>
+        <type name="gsize" c:type="gsize"/>
       </return-value>
       <parameters>
         <parameter name="in" transfer-ownership="none">
-          <type name="gulong" c:type="gsize"/>
+          <type name="gsize" c:type="gsize"/>
         </parameter>
       </parameters>
     </function>
     <function name="test_ssize" c:identifier="regress_test_ssize">
       <return-value transfer-ownership="none">
-        <type name="glong" c:type="gssize"/>
+        <type name="gssize" c:type="gssize"/>
       </return-value>
       <parameters>
         <parameter name="in" transfer-ownership="none">
-          <type name="glong" c:type="gssize"/>
+          <type name="gssize" c:type="gssize"/>
         </parameter>
       </parameters>
     </function>
diff --git a/tests/scanner/Utility-1.0-expected.gir b/tests/scanner/Utility-1.0-expected.gir
index 112fa42..dec7984 100644
--- a/tests/scanner/Utility-1.0-expected.gir
+++ b/tests/scanner/Utility-1.0-expected.gir
@@ -23,7 +23,7 @@ and/or use gtk-doc annotations.  -->
         <type name="gpointer"/>
       </field>
       <field name="length" writable="1">
-        <type name="gulong" c:type="gsize"/>
+        <type name="gsize" c:type="gsize"/>
       </field>
     </record>
     <union name="Byte" c:type="UtilityByte">



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