[glib/mjog/2104-short-gtypes: 6/7] gio: Update GDBus and gdbus-codegen to handle G_TYPE_(U)SHORT



commit b9cee7bbfb27d62a578b642ff2aad2dbb161a5f3
Author: Michael Gratton <mike vee net>
Date:   Mon May 11 21:31:45 2020 +1000

    gio: Update GDBus and gdbus-codegen to handle G_TYPE_(U)SHORT

 gio/gdbus-2.0/codegen/codegen.py   | 10 ++++++++--
 gio/gdbus-2.0/codegen/dbustypes.py | 12 ++++++------
 gio/gdbusutils.c                   | 18 ++++++++++--------
 gio/gmarshal-internal.c            |  4 ++++
 gio/tests/codegen.py               |  6 ++++++
 gio/tests/gdbus-test-codegen.c     |  4 ++--
 6 files changed, 36 insertions(+), 18 deletions(-)
---
diff --git a/gio/gdbus-2.0/codegen/codegen.py b/gio/gdbus-2.0/codegen/codegen.py
index d71299ebe..248385d4f 100644
--- a/gio/gdbus-2.0/codegen/codegen.py
+++ b/gio/gdbus-2.0/codegen/codegen.py
@@ -1049,6 +1049,12 @@ class CodeGenerator:
                            '      case G_TYPE_UCHAR:\n'
                            '        ret = (g_value_get_uchar (a) == g_value_get_uchar (b));\n'
                            '        break;\n'
+                           '      case G_TYPE_SHORT:\n'
+                           '        ret = (g_value_get_short (a) == g_value_get_short (b));\n'
+                           '        break;\n'
+                           '      case G_TYPE_USHORT:\n'
+                           '        ret = (g_value_get_ushort (a) == g_value_get_ushort (b));\n'
+                           '        break;\n'
                            '      case G_TYPE_INT:\n'
                            '        ret = (g_value_get_int (a) == g_value_get_int (b));\n'
                            '        break;\n'
@@ -1506,9 +1512,9 @@ class CodeGenerator:
                 elif p.arg.signature == 'y':
                     s = 'g_param_spec_uchar ("%s", "%s", "%s", 0, 255, 0'%(p.name_hyphen, p.name, p.name)
                 elif p.arg.signature == 'n':
-                    s = 'g_param_spec_int ("%s", "%s", "%s", G_MININT16, G_MAXINT16, 0'%(p.name_hyphen, 
p.name, p.name)
+                    s = 'g_param_spec_short ("%s", "%s", "%s", G_MININT16, G_MAXINT16, 0'%(p.name_hyphen, 
p.name, p.name)
                 elif p.arg.signature == 'q':
-                    s = 'g_param_spec_uint ("%s", "%s", "%s", 0, G_MAXUINT16, 0'%(p.name_hyphen, p.name, 
p.name)
+                    s = 'g_param_spec_ushort ("%s", "%s", "%s", 0, G_MAXUINT16, 0'%(p.name_hyphen, p.name, 
p.name)
                 elif p.arg.signature == 'i':
                     s = 'g_param_spec_int ("%s", "%s", "%s", G_MININT32, G_MAXINT32, 0'%(p.name_hyphen, 
p.name, p.name)
                 elif p.arg.signature == 'u':
diff --git a/gio/gdbus-2.0/codegen/dbustypes.py b/gio/gdbus-2.0/codegen/dbustypes.py
index 415a5cc7a..811169e22 100644
--- a/gio/gdbus-2.0/codegen/dbustypes.py
+++ b/gio/gdbus-2.0/codegen/dbustypes.py
@@ -98,25 +98,25 @@ class Arg:
                 self.gvariant_get = 'g_variant_get_byte'
                 self.gvalue_get = 'g_value_get_uchar'
             elif self.signature == 'n':
-                self.ctype_in_g  = 'gint '
+                self.ctype_in_g  = 'gshort '
                 self.ctype_in  = 'gint16 '
                 self.ctype_out = 'gint16 *'
-                self.gtype = 'G_TYPE_INT'
+                self.gtype = 'G_TYPE_SHORT'
                 self.free_func = None
                 self.format_in = 'n'
                 self.format_out = 'n'
                 self.gvariant_get = 'g_variant_get_int16'
-                self.gvalue_get = 'g_value_get_int'
+                self.gvalue_get = 'g_value_get_short'
             elif self.signature == 'q':
-                self.ctype_in_g  = 'guint '
+                self.ctype_in_g  = 'gushort '
                 self.ctype_in  = 'guint16 '
                 self.ctype_out = 'guint16 *'
-                self.gtype = 'G_TYPE_UINT'
+                self.gtype = 'G_TYPE_USHORT'
                 self.free_func = None
                 self.format_in = 'q'
                 self.format_out = 'q'
                 self.gvariant_get = 'g_variant_get_uint16'
-                self.gvalue_get = 'g_value_get_uint'
+                self.gvalue_get = 'g_value_get_ushort'
             elif self.signature == 'i':
                 self.ctype_in_g  = 'gint '
                 self.ctype_in  = 'gint '
diff --git a/gio/gdbusutils.c b/gio/gdbusutils.c
index ff9b44117..8691f3656 100644
--- a/gio/gdbusutils.c
+++ b/gio/gdbusutils.c
@@ -394,13 +394,13 @@ g_dbus_gvariant_to_gvalue (GVariant  *value,
       break;
 
     case G_VARIANT_CLASS_INT16:
-      g_value_init (out_gvalue, G_TYPE_INT);
-      g_value_set_int (out_gvalue, g_variant_get_int16 (value));
+      g_value_init (out_gvalue, G_TYPE_SHORT);
+      g_value_set_short (out_gvalue, g_variant_get_int16 (value));
       break;
 
     case G_VARIANT_CLASS_UINT16:
-      g_value_init (out_gvalue, G_TYPE_UINT);
-      g_value_set_uint (out_gvalue, g_variant_get_uint16 (value));
+      g_value_init (out_gvalue, G_TYPE_USHORT);
+      g_value_set_ushort (out_gvalue, g_variant_get_uint16 (value));
       break;
 
     case G_VARIANT_CLASS_INT32:
@@ -513,8 +513,10 @@ g_dbus_gvariant_to_gvalue (GVariant  *value,
  * - #G_TYPE_STRV: 'as', 'ao' or 'aay'
  * - #G_TYPE_BOOLEAN: 'b'
  * - #G_TYPE_UCHAR: 'y'
- * - #G_TYPE_INT: 'i', 'n'
- * - #G_TYPE_UINT: 'u', 'q'
+ * - #G_TYPE_SHORT: 'n'
+ * - #G_TYPE_SHORT: 'q'
+ * - #G_TYPE_INT: 'i'
+ * - #G_TYPE_UINT: 'u'
  * - #G_TYPE_INT64 'x'
  * - #G_TYPE_UINT64: 't'
  * - #G_TYPE_DOUBLE: 'd'
@@ -574,11 +576,11 @@ g_dbus_gvalue_to_gvariant (const GValue       *gvalue,
           break;
 
         case G_VARIANT_CLASS_INT16:
-          ret = g_variant_ref_sink (g_variant_new_int16 (g_value_get_int (gvalue)));
+          ret = g_variant_ref_sink (g_variant_new_int16 (g_value_get_short (gvalue)));
           break;
 
         case G_VARIANT_CLASS_UINT16:
-          ret = g_variant_ref_sink (g_variant_new_uint16 (g_value_get_uint (gvalue)));
+          ret = g_variant_ref_sink (g_variant_new_uint16 (g_value_get_ushort (gvalue)));
           break;
 
         case G_VARIANT_CLASS_INT32:
diff --git a/gio/gmarshal-internal.c b/gio/gmarshal-internal.c
index f9571c42e..4cba1aa74 100644
--- a/gio/gmarshal-internal.c
+++ b/gio/gmarshal-internal.c
@@ -39,6 +39,8 @@
 #define g_marshal_value_peek_pointer(v)  g_value_get_pointer (v)
 #define g_marshal_value_peek_object(v)   g_value_get_object (v)
 #define g_marshal_value_peek_variant(v)  g_value_get_variant (v)
+#define g_marshal_value_peek_short(v)    g_value_get_int (v)
+#define g_marshal_value_peek_ushort(v)   g_value_get_uint (v)
 #else /* !G_ENABLE_DEBUG */
 /* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
  *          Do not access GValues directly in your code. Instead, use the
@@ -63,6 +65,8 @@
 #define g_marshal_value_peek_pointer(v)  (v)->data[0].v_pointer
 #define g_marshal_value_peek_object(v)   (v)->data[0].v_pointer
 #define g_marshal_value_peek_variant(v)  (v)->data[0].v_pointer
+#define g_marshal_value_peek_short(v)    (v)->data[0].v_int
+#define g_marshal_value_peek_ushort(v)   (v)->data[0].v_uint
 #endif /* !G_ENABLE_DEBUG */
 
 /* BOOLEAN:OBJECT */
diff --git a/gio/tests/codegen.py b/gio/tests/codegen.py
index 51de0ede4..11b3ba31c 100644
--- a/gio/tests/codegen.py
+++ b/gio/tests/codegen.py
@@ -211,6 +211,12 @@ class TestCodegen(unittest.TestCase):
                 '      case G_TYPE_UCHAR:\n'
                 '        ret = (g_value_get_uchar (a) == g_value_get_uchar (b));\n'
                 '        break;\n'
+                '      case G_TYPE_SHORT:\n'
+                '        ret = (g_value_get_short (a) == g_value_get_short (b));\n'
+                '        break;\n'
+                '      case G_TYPE_USHORT:\n'
+                '        ret = (g_value_get_ushort (a) == g_value_get_ushort (b));\n'
+                '        break;\n'
                 '      case G_TYPE_INT:\n'
                 '        ret = (g_value_get_int (a) == g_value_get_int (b));\n'
                 '        break;\n'
diff --git a/gio/tests/gdbus-test-codegen.c b/gio/tests/gdbus-test-codegen.c
index 691506f0f..55aa89c45 100644
--- a/gio/tests/gdbus-test-codegen.c
+++ b/gio/tests/gdbus-test-codegen.c
@@ -733,8 +733,8 @@ check_bar_proxy (FooiGenBar *proxy,
   ClientData *data;
   guchar val_y;
   gboolean val_b;
-  gint val_n;
-  guint val_q;
+  gshort val_n;
+  gushort val_q;
   gint val_i;
   guint val_u;
   gint64 val_x;


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