3.2.2-4: update endianness patch for rhbz#841596 (to attachment 603367)

This commit is contained in:
David Malcolm 2012-08-09 20:44:27 -04:00
parent b8bc71f0f6
commit 1b9be32b73
2 changed files with 286 additions and 124 deletions

View File

@ -1,3 +1,134 @@
Index: pygobject-3.2.2/gi/pygi-argument.c
===================================================================
--- pygobject-3.2.2.orig/gi/pygi-argument.c
+++ pygobject-3.2.2/gi/pygi-argument.c
@@ -31,6 +31,56 @@
#include <pyglib-python-compat.h>
#include <pyglib.h>
+void
+_pygi_hash_pointer_to_arg (GIArgument *arg,
+ GITypeTag type_tag)
+{
+ switch (type_tag) {
+ case GI_TYPE_TAG_INT8:
+ arg->v_int8 = GPOINTER_TO_INT(arg->v_pointer);
+ break;
+ case GI_TYPE_TAG_INT16:
+ arg->v_int16 = GPOINTER_TO_INT(arg->v_pointer);
+ break;
+ case GI_TYPE_TAG_INT32:
+ arg->v_int32 = GPOINTER_TO_INT(arg->v_pointer);
+ break;
+ case GI_TYPE_TAG_UTF8:
+ case GI_TYPE_TAG_FILENAME:
+ case GI_TYPE_TAG_INTERFACE:
+ break;
+ default:
+ g_critical("Unsupported type %s", g_type_tag_to_string(type_tag));
+ }
+}
+
+gpointer
+_pygi_arg_to_hash_pointer (const GIArgument *arg,
+ GITypeTag type_tag)
+{
+ switch (type_tag) {
+ case GI_TYPE_TAG_INT8:
+ return GINT_TO_POINTER(arg->v_int8);
+ case GI_TYPE_TAG_UINT8:
+ return GINT_TO_POINTER(arg->v_uint8);
+ case GI_TYPE_TAG_INT16:
+ return GINT_TO_POINTER(arg->v_int16);
+ case GI_TYPE_TAG_UINT16:
+ return GINT_TO_POINTER(arg->v_uint16);
+ case GI_TYPE_TAG_INT32:
+ return GINT_TO_POINTER(arg->v_int32);
+ case GI_TYPE_TAG_UINT32:
+ return GINT_TO_POINTER(arg->v_uint32);
+ case GI_TYPE_TAG_UTF8:
+ case GI_TYPE_TAG_FILENAME:
+ case GI_TYPE_TAG_INTERFACE:
+ return arg->v_pointer;
+ default:
+ g_critical("Unsupported type %s", g_type_tag_to_string(type_tag));
+ return arg->v_pointer;
+ }
+}
+
static void
_pygi_g_type_tag_py_bounds (GITypeTag type_tag,
PyObject **lower,
@@ -1122,7 +1172,7 @@ array_success:
break;
}
- arg.v_long = PYGLIB_PyLong_AsLong (int_);
+ arg.v_int = PYGLIB_PyLong_AsLong (int_);
Py_DECREF (int_);
@@ -1295,7 +1345,8 @@ list_item_error:
goto hash_table_item_error;
}
- g_hash_table_insert (hash_table, key.v_pointer, value.v_pointer);
+ g_hash_table_insert (hash_table, key.v_pointer,
+ _pygi_arg_to_hash_pointer(&value, g_type_info_get_tag (value_type_info)));
continue;
hash_table_item_error:
@@ -1644,21 +1695,21 @@ _pygi_argument_to_object (GIArgument *a
return NULL;
py_args = PyTuple_New (1);
- if (PyTuple_SetItem (py_args, 0, PyLong_FromLong (arg->v_long)) != 0) {
+ if (PyTuple_SetItem (py_args, 0, PyLong_FromLong (arg->v_int)) != 0) {
Py_DECREF (py_args);
Py_DECREF (py_type);
return NULL;
}
- object = PyObject_CallFunction (py_type, "l", arg->v_long);
+ object = PyObject_CallFunction (py_type, "i", arg->v_int);
Py_DECREF (py_args);
Py_DECREF (py_type);
} else if (info_type == GI_INFO_TYPE_ENUM) {
- object = pyg_enum_from_gtype (type, arg->v_long);
+ object = pyg_enum_from_gtype (type, arg->v_int);
} else {
- object = pyg_flags_from_gtype (type, arg->v_long);
+ object = pyg_flags_from_gtype (type, arg->v_int);
}
break;
@@ -1771,6 +1822,7 @@ _pygi_argument_to_object (GIArgument *a
break;
}
+ _pygi_hash_pointer_to_arg(&value, g_type_info_get_tag (value_type_info));
py_value = _pygi_argument_to_object (&value, value_type_info, item_transfer);
if (py_value == NULL) {
Py_DECREF (py_key);
Index: pygobject-3.2.2/gi/pygi-argument.h
===================================================================
--- pygobject-3.2.2.orig/gi/pygi-argument.h
+++ pygobject-3.2.2/gi/pygi-argument.h
@@ -30,6 +30,12 @@ G_BEGIN_DECLS
/* Private */
+gpointer _pygi_arg_to_hash_pointer (const GIArgument *arg,
+ GITypeTag type_tag);
+
+void _pygi_hash_pointer_to_arg (GIArgument *arg,
+ GITypeTag type_tag);
+
gint _pygi_g_type_interface_check_object (GIBaseInfo *info,
PyObject *object);
Index: pygobject-3.2.2/gi/pygi-cache.c
===================================================================
--- pygobject-3.2.2.orig/gi/pygi-cache.c
@ -11,6 +142,81 @@ Index: pygobject-3.2.2/gi/pygi-cache.c
g_base_info_unref ( (GIBaseInfo *)arg_info);
continue;
}
Index: pygobject-3.2.2/gi/pygi-closure.c
===================================================================
--- pygobject-3.2.2.orig/gi/pygi-closure.c
+++ pygobject-3.2.2/gi/pygi-closure.c
@@ -28,6 +28,57 @@
static GSList* async_free_list;
static void
+_pygi_closure_assign_pyobj_to_retval (gpointer retval, PyObject *object,
+ GITypeInfo *type_info,
+ GITransfer transfer)
+{
+ GIArgument arg = _pygi_argument_from_object (object, type_info, transfer);
+ GITypeTag type_tag = g_type_info_get_tag (type_info);
+
+ if (retval == NULL)
+ return;
+
+ switch (type_tag) {
+ case GI_TYPE_TAG_BOOLEAN:
+ *((ffi_sarg *) retval) = arg.v_boolean;
+ break;
+ case GI_TYPE_TAG_INT8:
+ *((ffi_sarg *) retval) = arg.v_int8;
+ break;
+ case GI_TYPE_TAG_UINT8:
+ *((ffi_arg *) retval) = arg.v_uint8;
+ break;
+ case GI_TYPE_TAG_INT16:
+ *((ffi_sarg *) retval) = arg.v_int16;
+ break;
+ case GI_TYPE_TAG_UINT16:
+ *((ffi_arg *) retval) = arg.v_uint16;
+ break;
+ case GI_TYPE_TAG_INT32:
+ *((ffi_sarg *) retval) = arg.v_int32;
+ break;
+ case GI_TYPE_TAG_UINT32:
+ *((ffi_arg *) retval) = arg.v_uint32;
+ break;
+ case GI_TYPE_TAG_INT64:
+ *((ffi_sarg *) retval) = arg.v_int64;
+ break;
+ case GI_TYPE_TAG_UINT64:
+ *((ffi_arg *) retval) = arg.v_uint64;
+ break;
+ case GI_TYPE_TAG_FLOAT:
+ *((gfloat *) retval) = arg.v_float;
+ break;
+ case GI_TYPE_TAG_DOUBLE:
+ *((gdouble *) retval) = arg.v_double;
+ break;
+ default:
+ *((GIArgument *) retval) = arg;
+ break;
+ }
+}
+
+static void
_pygi_closure_assign_pyobj_to_out_argument (gpointer out_arg, PyObject *object,
GITypeInfo *type_info,
GITransfer transfer)
@@ -278,10 +329,10 @@ _pygi_closure_set_out_arguments (GICalla
GITransfer transfer = g_callable_info_get_caller_owns (callable_info);
if (PyTuple_Check (py_retval)) {
PyObject *item = PyTuple_GET_ITEM (py_retval, 0);
- _pygi_closure_assign_pyobj_to_out_argument (resp, item,
+ _pygi_closure_assign_pyobj_to_retval (resp, item,
return_type_info, transfer);
} else {
- _pygi_closure_assign_pyobj_to_out_argument (resp, py_retval,
+ _pygi_closure_assign_pyobj_to_retval (resp, py_retval,
return_type_info, transfer);
}
i_py_retval++;
Index: pygobject-3.2.2/gi/pygi-marshal-from-py.c
===================================================================
--- pygobject-3.2.2.orig/gi/pygi-marshal-from-py.c
@ -135,7 +341,41 @@ Index: pygobject-3.2.2/gi/pygi-marshal-from-py.c
/*
* _is_union_member - check to see if the py_arg is actually a member of the
* expected C union
@@ -929,12 +1042,21 @@ array_success:
@@ -733,33 +846,6 @@ _pygi_marshal_from_py_filename (PyGIInvo
return TRUE;
}
-static gpointer
-_pygi_arg_to_hash_pointer (const GIArgument *arg,
- GITypeTag type_tag)
-{
- switch (type_tag) {
- case GI_TYPE_TAG_INT8:
- return GINT_TO_POINTER(arg->v_int8);
- case GI_TYPE_TAG_UINT8:
- return GINT_TO_POINTER(arg->v_uint8);
- case GI_TYPE_TAG_INT16:
- return GINT_TO_POINTER(arg->v_int16);
- case GI_TYPE_TAG_UINT16:
- return GINT_TO_POINTER(arg->v_uint16);
- case GI_TYPE_TAG_INT32:
- return GINT_TO_POINTER(arg->v_int32);
- case GI_TYPE_TAG_UINT32:
- return GINT_TO_POINTER(arg->v_uint32);
- case GI_TYPE_TAG_UTF8:
- case GI_TYPE_TAG_FILENAME:
- case GI_TYPE_TAG_INTERFACE:
- return arg->v_pointer;
- default:
- g_critical("Unsupported type %s", g_type_tag_to_string(type_tag));
- return arg->v_pointer;
- }
-}
-
gboolean
_pygi_marshal_from_py_array (PyGIInvokeState *state,
PyGICallableCache *callable_cache,
@@ -929,12 +1015,21 @@ array_success:
if (child_cache->direction == PYGI_DIRECTION_BIDIRECTIONAL) {
gint *len_arg = (gint *)state->in_args[child_cache->c_arg_index].v_pointer;
/* if we are not setup yet just set the in arg */
@ -161,7 +401,7 @@ Index: pygobject-3.2.2/gi/pygi-marshal-from-py.c
}
}
@@ -1278,20 +1400,32 @@ _pygi_marshal_from_py_interface_enum (Py
@@ -1278,20 +1373,32 @@ _pygi_marshal_from_py_interface_enum (Py
PyObject *py_arg,
GIArgument *arg)
{
@ -199,7 +439,7 @@ Index: pygobject-3.2.2/gi/pygi-marshal-from-py.c
/* If this is not an instance of the Enum type that we want
* we need to check if the value is equivilant to one of the
@@ -1305,7 +1439,7 @@ _pygi_marshal_from_py_interface_enum (Py
@@ -1305,7 +1412,7 @@ _pygi_marshal_from_py_interface_enum (Py
g_enum_info_get_value (iface_cache->interface_info, i);
glong enum_value = g_value_info_get_value (value_info);
g_base_info_unref ( (GIBaseInfo *)value_info);
@ -208,7 +448,7 @@ Index: pygobject-3.2.2/gi/pygi-marshal-from-py.c
is_found = TRUE;
break;
}
@@ -1330,25 +1464,35 @@ _pygi_marshal_from_py_interface_flags (P
@@ -1330,25 +1437,35 @@ _pygi_marshal_from_py_interface_flags (P
PyObject *py_arg,
GIArgument *arg)
{
@ -366,7 +606,37 @@ Index: pygobject-3.2.2/gi/pygi-marshal-to-py.c
}
array_ = g_array_new (FALSE,
@@ -664,11 +746,21 @@ _pygi_marshal_to_py_interface_enum (PyGI
@@ -415,29 +497,6 @@ err:
return NULL;
}
-static void
-_pygi_hash_pointer_to_arg (GIArgument *arg,
- GITypeTag type_tag)
-{
- switch (type_tag) {
- case GI_TYPE_TAG_INT8:
- arg->v_int8 = GPOINTER_TO_INT(arg->v_pointer);
- break;
- case GI_TYPE_TAG_INT16:
- arg->v_int16 = GPOINTER_TO_INT(arg->v_pointer);
- break;
- case GI_TYPE_TAG_INT32:
- arg->v_int32 = GPOINTER_TO_INT(arg->v_pointer);
- break;
- case GI_TYPE_TAG_UTF8:
- case GI_TYPE_TAG_FILENAME:
- case GI_TYPE_TAG_INTERFACE:
- break;
- default:
- g_critical("Unsupported type %s", g_type_tag_to_string(type_tag));
- }
-}
-
PyObject *
_pygi_marshal_to_py_glist (PyGIInvokeState *state,
PyGICallableCache *callable_cache,
@@ -664,11 +723,21 @@ _pygi_marshal_to_py_interface_enum (PyGI
{
PyObject *py_obj = NULL;
PyGIInterfaceCache *iface_cache = (PyGIInterfaceCache *)arg_cache;
@ -390,7 +660,7 @@ Index: pygobject-3.2.2/gi/pygi-marshal-to-py.c
}
return py_obj;
}
@@ -681,6 +773,16 @@ _pygi_marshal_to_py_interface_flags (PyG
@@ -681,6 +750,16 @@ _pygi_marshal_to_py_interface_flags (PyG
{
PyObject *py_obj = NULL;
PyGIInterfaceCache *iface_cache = (PyGIInterfaceCache *)arg_cache;
@ -407,7 +677,7 @@ Index: pygobject-3.2.2/gi/pygi-marshal-to-py.c
if (iface_cache->g_type == G_TYPE_NONE) {
/* An enum with a GType of None is an enum without GType */
@@ -692,18 +794,18 @@ _pygi_marshal_to_py_interface_flags (PyG
@@ -692,18 +771,18 @@ _pygi_marshal_to_py_interface_flags (PyG
return NULL;
py_args = PyTuple_New (1);
@ -429,117 +699,3 @@ Index: pygobject-3.2.2/gi/pygi-marshal-to-py.c
}
return py_obj;
Index: pygobject-3.2.2/gi/pygi-argument.c
===================================================================
--- pygobject-3.2.2.orig/gi/pygi-argument.c
+++ pygobject-3.2.2/gi/pygi-argument.c
@@ -1122,7 +1122,7 @@ array_success:
break;
}
- arg.v_long = PYGLIB_PyLong_AsLong (int_);
+ arg.v_int = PYGLIB_PyLong_AsLong (int_);
Py_DECREF (int_);
@@ -1644,21 +1644,21 @@ _pygi_argument_to_object (GIArgument *a
return NULL;
py_args = PyTuple_New (1);
- if (PyTuple_SetItem (py_args, 0, PyLong_FromLong (arg->v_long)) != 0) {
+ if (PyTuple_SetItem (py_args, 0, PyLong_FromLong (arg->v_int)) != 0) {
Py_DECREF (py_args);
Py_DECREF (py_type);
return NULL;
}
- object = PyObject_CallFunction (py_type, "l", arg->v_long);
+ object = PyObject_CallFunction (py_type, "i", arg->v_int);
Py_DECREF (py_args);
Py_DECREF (py_type);
} else if (info_type == GI_INFO_TYPE_ENUM) {
- object = pyg_enum_from_gtype (type, arg->v_long);
+ object = pyg_enum_from_gtype (type, arg->v_int);
} else {
- object = pyg_flags_from_gtype (type, arg->v_long);
+ object = pyg_flags_from_gtype (type, arg->v_int);
}
break;
Index: pygobject-3.2.2/gi/pygi-closure.c
===================================================================
--- pygobject-3.2.2.orig/gi/pygi-closure.c
+++ pygobject-3.2.2/gi/pygi-closure.c
@@ -28,6 +28,57 @@
static GSList* async_free_list;
static void
+_pygi_closure_assign_pyobj_to_retval (gpointer retval, PyObject *object,
+ GITypeInfo *type_info,
+ GITransfer transfer)
+{
+ GIArgument arg = _pygi_argument_from_object (object, type_info, transfer);
+ GITypeTag type_tag = g_type_info_get_tag (type_info);
+
+ if (retval == NULL)
+ return;
+
+ switch (type_tag) {
+ case GI_TYPE_TAG_BOOLEAN:
+ *((ffi_sarg *) retval) = arg.v_boolean;
+ break;
+ case GI_TYPE_TAG_INT8:
+ *((ffi_sarg *) retval) = arg.v_int8;
+ break;
+ case GI_TYPE_TAG_UINT8:
+ *((ffi_arg *) retval) = arg.v_uint8;
+ break;
+ case GI_TYPE_TAG_INT16:
+ *((ffi_sarg *) retval) = arg.v_int16;
+ break;
+ case GI_TYPE_TAG_UINT16:
+ *((ffi_arg *) retval) = arg.v_uint16;
+ break;
+ case GI_TYPE_TAG_INT32:
+ *((ffi_sarg *) retval) = arg.v_int32;
+ break;
+ case GI_TYPE_TAG_UINT32:
+ *((ffi_arg *) retval) = arg.v_uint32;
+ break;
+ case GI_TYPE_TAG_INT64:
+ *((ffi_sarg *) retval) = arg.v_int64;
+ break;
+ case GI_TYPE_TAG_UINT64:
+ *((ffi_arg *) retval) = arg.v_uint64;
+ break;
+ case GI_TYPE_TAG_FLOAT:
+ *((gfloat *) retval) = arg.v_float;
+ break;
+ case GI_TYPE_TAG_DOUBLE:
+ *((gdouble *) retval) = arg.v_double;
+ break;
+ default:
+ *((GIArgument *) retval) = arg;
+ break;
+ }
+}
+
+static void
_pygi_closure_assign_pyobj_to_out_argument (gpointer out_arg, PyObject *object,
GITypeInfo *type_info,
GITransfer transfer)
@@ -278,10 +329,10 @@ _pygi_closure_set_out_arguments (GICalla
GITransfer transfer = g_callable_info_get_caller_owns (callable_info);
if (PyTuple_Check (py_retval)) {
PyObject *item = PyTuple_GET_ITEM (py_retval, 0);
- _pygi_closure_assign_pyobj_to_out_argument (resp, item,
+ _pygi_closure_assign_pyobj_to_retval (resp, item,
return_type_info, transfer);
} else {
- _pygi_closure_assign_pyobj_to_out_argument (resp, py_retval,
+ _pygi_closure_assign_pyobj_to_retval (resp, py_retval,
return_type_info, transfer);
}
i_py_retval++;

View File

@ -22,7 +22,7 @@
Name: pygobject3
Version: 3.2.2
Release: 3%{?dist}
Release: 4%{?dist}
License: LGPLv2+ and MIT
Group: Development/Languages
Summary: Python 2 bindings for GObject Introspection
@ -49,7 +49,7 @@ Patch0: lm.patch
Patch2: pygobject-3.2.2-known-failures.patch
# Fix various endianness issues that broke things on big-endian 64 bit boxes
# (rhbz#841596; attachment 603090):
# (rhbz#841596; attachment 603367):
Patch3: endianness-fixes.patch
# Cherrypick fix from upstream (in 3.3.5 onwards; rhbz#842880):
@ -127,8 +127,11 @@ for use in Python 3 programs.
%setup -q -n pygobject-%{version}
%patch0 -p1 -b .lm
%patch2 -p1 -b .known-failures
%patch3 -p1 -b .endianness-fixes
# Patch 3 now partly undoes part of patch 4, so they're in reverse order:
%patch4 -p1 -b .fix-list-marshalling-on-big-endian-machines
%patch3 -p1 -b .endianness-fixes
%patch5 -p1 -b .test-list-marshalling
autoreconf
@ -228,6 +231,9 @@ xvfb-run make DESTDIR=$RPM_BUILD_ROOT check %{verbosity}
%endif # with_python3
%changelog
* Mon Aug 13 2012 David Malcolm <dmalcolm@redhat.com> - 3.2.2-4
- update endianness patch for rhbz#841596 (to attachment 603367)
* Mon Aug 13 2012 David Malcolm <dmalcolm@redhat.com> - 3.2.2-3
- fix issues on big-endian 64-bit machines (rhbz#841596, rhbz#842880)