[pygobject] Add support for PyBytes with int8 and uint8 from Python marshaler



commit f517bfbc134b78a23b754332e59b9bb67bb68e98
Author: Simon Feltman <sfeltman src gnome org>
Date:   Mon Jul 22 23:24:13 2013 -0700

    Add support for PyBytes with int8 and uint8 from Python marshaler
    
    This additional type marshaling is necessary for unifying marhalers
    due to the same feature being available with cached argument marshaling.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=693405

 gi/pygi-marshal-from-py.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/gi/pygi-marshal-from-py.c b/gi/pygi-marshal-from-py.c
index fdf13af..5f360bd 100644
--- a/gi/pygi-marshal-from-py.c
+++ b/gi/pygi-marshal-from-py.c
@@ -1015,6 +1015,20 @@ _pygi_marshal_from_py_basic_type (PyObject   *object,   /* in */
             break;
         case GI_TYPE_TAG_INT8:
         case GI_TYPE_TAG_UINT8:
+            if (PYGLIB_PyBytes_Check (object)) {
+                if (PYGLIB_PyBytes_Size (object) != 1) {
+                    PyErr_Format (PyExc_TypeError, "Must be a single character");
+                    return FALSE;
+                }
+                if (type_tag == GI_TYPE_TAG_INT8) {
+                    arg->v_int8 = (gint8)(PYGLIB_PyBytes_AsString (object)[0]);
+                } else {
+                    arg->v_uint8 = (guint8)(PYGLIB_PyBytes_AsString (object)[0]);
+                }
+            } else {
+                return _pygi_marshal_from_py_long (object, arg, type_tag, transfer);
+            }
+            break;
         case GI_TYPE_TAG_INT16:
         case GI_TYPE_TAG_UINT16:
         case GI_TYPE_TAG_INT32:


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