[pygobject] Fix marshalling of ssize_t to smaller ints
- From: Martin Pitt <martinpitt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] Fix marshalling of ssize_t to smaller ints
- Date: Fri, 9 Nov 2012 14:24:38 +0000 (UTC)
commit fa568949c46dd4b537357f1af74d1f675294b760
Author: Martin Pitt <martinpitt gnome org>
Date: Fri Nov 9 15:23:37 2012 +0100
Fix marshalling of ssize_t to smaller ints
Add missing marshalling cases for (u)int8 and (u)int16. This fixes the
TestArray.test_array_in test, so drop the expected failure.
gi/pygi-marshal-from-py.c | 30 +++++++++++++++++++++++++++++-
tests/test_gi.py | 2 --
2 files changed, 29 insertions(+), 3 deletions(-)
---
diff --git a/gi/pygi-marshal-from-py.c b/gi/pygi-marshal-from-py.c
index b4c9fa0..d0e96db 100644
--- a/gi/pygi-marshal-from-py.c
+++ b/gi/pygi-marshal-from-py.c
@@ -40,11 +40,39 @@ gi_argument_from_py_ssize_t (GIArgument *arg_out,
switch (type_tag) {
case GI_TYPE_TAG_VOID:
case GI_TYPE_TAG_BOOLEAN:
+ goto unhandled_type;
+
case GI_TYPE_TAG_INT8:
+ if (size_in >= G_MININT8 && size_in <= G_MAXINT8) {
+ arg_out->v_int8 = size_in;
+ return TRUE;
+ } else {
+ goto overflow;
+ }
+
case GI_TYPE_TAG_UINT8:
+ if (size_in >= 0 && size_in <= G_MAXUINT8) {
+ arg_out->v_uint8 = size_in;
+ return TRUE;
+ } else {
+ goto overflow;
+ }
+
case GI_TYPE_TAG_INT16:
+ if (size_in >= G_MININT16 && size_in <= G_MAXINT16) {
+ arg_out->v_int16 = size_in;
+ return TRUE;
+ } else {
+ goto overflow;
+ }
+
case GI_TYPE_TAG_UINT16:
- goto unhandled_type;
+ if (size_in >= 0 && size_in <= G_MAXUINT16) {
+ arg_out->v_uint16 = size_in;
+ return TRUE;
+ } else {
+ goto overflow;
+ }
/* Ranges assume two's complement */
case GI_TYPE_TAG_INT32:
diff --git a/tests/test_gi.py b/tests/test_gi.py
index ac81fc9..843a6b6 100644
--- a/tests/test_gi.py
+++ b/tests/test_gi.py
@@ -718,11 +718,9 @@ class TestArray(unittest.TestCase):
def test_array_return_etc(self):
self.assertEqual(([5, 0, 1, 9], 14), GIMarshallingTests.array_return_etc(5, 9))
- @unittest.expectedFailure
def test_array_in(self):
GIMarshallingTests.array_in(Sequence([-1, 0, 1, 2]))
GIMarshallingTests.array_in_guint64_len(Sequence([-1, 0, 1, 2]))
- # FIXME: This does not currently work
GIMarshallingTests.array_in_guint8_len(Sequence([-1, 0, 1, 2]))
def test_array_in_len_before(self):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]