Commit fa568949 authored by Martin Pitt's avatar Martin Pitt
Browse files

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.
parent 5a5940a0
......@@ -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:
......
......@@ -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):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment