[pygobject] argument: Fix 64bit integer convertion from GValue



commit 4e4c87e3868948743e0446abe2ba0cf5626374c4
Author: Nicolas Dufresne <nicolas dufresne collabora com>
Date:   Fri Sep 7 17:17:09 2012 -0400

    argument: Fix 64bit integer convertion from GValue
    
    Trying to get a 64bit integer using the wrong getter was resulting in an
    assertion and 0 being returned.
    
    Co-Authored-By: Martin Pitt <martinpitt gnome org>
    
    https://bugzilla.gnome.org/show_bug.cgi?id=683596

 gi/pygi-argument.c       |    8 +++++-
 tests/test_everything.py |   52 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 58 insertions(+), 2 deletions(-)
---
diff --git a/gi/pygi-argument.c b/gi/pygi-argument.c
index 234a229..5fd633a 100644
--- a/gi/pygi-argument.c
+++ b/gi/pygi-argument.c
@@ -1998,15 +1998,19 @@ _pygi_argument_from_g_value(const GValue *value,
         case GI_TYPE_TAG_INT8:
         case GI_TYPE_TAG_INT16:
         case GI_TYPE_TAG_INT32:
-        case GI_TYPE_TAG_INT64:
             arg.v_int = g_value_get_int (value);
             break;
+        case GI_TYPE_TAG_INT64:
+            arg.v_int64 = g_value_get_int64 (value);
+            break;
         case GI_TYPE_TAG_UINT8:
         case GI_TYPE_TAG_UINT16:
         case GI_TYPE_TAG_UINT32:
-        case GI_TYPE_TAG_UINT64:
             arg.v_uint = g_value_get_uint (value);
             break;
+        case GI_TYPE_TAG_UINT64:
+            arg.v_uint64 = g_value_get_uint64 (value);
+            break;
         case GI_TYPE_TAG_UNICHAR:
             arg.v_uint32 = g_value_get_schar (value);
             break;
diff --git a/tests/test_everything.py b/tests/test_everything.py
index c5140ed..25d3868 100644
--- a/tests/test_everything.py
+++ b/tests/test_everything.py
@@ -694,6 +694,58 @@ class TestSignals(unittest.TestCase):
         obj.connect('sig-with-obj', callback)
         obj.emit_sig_with_obj()
 
+    def test_int64_param_from_py(self):
+        obj = Everything.TestObj()
+
+        def callback(obj, i):
+            obj.callback_i = i
+            return i
+
+        obj.callback_i = None
+        obj.connect('sig-with-int64-prop', callback)
+        rv = obj.emit('sig-with-int64-prop', GObject.G_MAXINT64)
+        self.assertEqual(rv, GObject.G_MAXINT64)
+        self.assertEqual(obj.callback_i, GObject.G_MAXINT64)
+
+    def test_uint64_param_from_py(self):
+        obj = Everything.TestObj()
+
+        def callback(obj, i):
+            obj.callback_i = i
+            return i
+
+        obj.callback_i = None
+        obj.connect('sig-with-uint64-prop', callback)
+        rv = obj.emit('sig-with-uint64-prop', GObject.G_MAXUINT64)
+        self.assertEqual(rv, GObject.G_MAXUINT64)
+        self.assertEqual(obj.callback_i, GObject.G_MAXUINT64)
+
+    def test_int64_param_from_c(self):
+        obj = Everything.TestObj()
+
+        def callback(obj, i):
+            obj.callback_i = i
+            return i
+
+        obj.callback_i = None
+
+        obj.connect('sig-with-int64-prop', callback)
+        obj.emit_sig_with_int64()
+        self.assertEqual(obj.callback_i, GObject.G_MAXINT64)
+
+    def test_uint64_param_from_c(self):
+        obj = Everything.TestObj()
+
+        def callback(obj, i):
+            obj.callback_i = i
+            return i
+
+        obj.callback_i = None
+
+        obj.connect('sig-with-uint64-prop', callback)
+        obj.emit_sig_with_uint64()
+        self.assertEqual(obj.callback_i, GObject.G_MAXUINT64)
+
 
 class TestPango(unittest.TestCase):
     @unittest.skipUnless(Gtk, 'Gtk not available')



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