Commit dd43a1e1 authored by Simon Feltman's avatar Simon Feltman
Browse files

Override GValue.set/get_boxed with static C marshaler

Override boxed type get/set methods on GValue to use the static C
GValue marshaler. This works around the inability of the introspection
version of these methods to know what the held GValue type is.
With this, all boxed types will now marshal properly with GValues as
their storage.
parent 2cff4827
......@@ -1658,6 +1658,40 @@ pyg__install_metaclass(PyObject *dummy, PyTypeObject *metaclass)
return Py_None;
static PyObject *
pyg__gvalue_get(PyObject *module, PyObject *pygvalue)
if (!pyg_boxed_check (pygvalue, G_TYPE_VALUE)) {
PyErr_SetString (PyExc_TypeError, "Expected GValue argument.");
return NULL;
return pyg_value_as_pyobject (pyg_boxed_get(pygvalue, GValue),
/*copy_boxed=*/ TRUE);
static PyObject *
pyg__gvalue_set(PyObject *module, PyObject *args)
PyObject *pygvalue;
PyObject *pyobject;
if (!PyArg_ParseTuple (args, "OO:_gobject._gvalue_set",
&pygvalue, &pyobject))
return NULL;
if (!pyg_boxed_check (pygvalue, G_TYPE_VALUE)) {
PyErr_SetString (PyExc_TypeError, "Expected GValue argument.");
return NULL;
if (pyg_value_from_pyobject_with_error (pyg_boxed_get (pygvalue, GValue),
pyobject) == -1)
return NULL;
static PyMethodDef _gobject_functions[] = {
{ "type_name", pyg_type_name, METH_VARARGS },
{ "type_from_name", pyg_type_from_name, METH_VARARGS },
......@@ -1676,6 +1710,10 @@ static PyMethodDef _gobject_functions[] = {
(PyCFunction)pyg_add_emission_hook, METH_VARARGS },
{ "_install_metaclass",
(PyCFunction)pyg__install_metaclass, METH_O },
{ "_gvalue_get",
(PyCFunction)pyg__gvalue_get, METH_O },
{ "_gvalue_set",
(PyCFunction)pyg__gvalue_set, METH_VARARGS },
{ NULL, NULL, 0 }
......@@ -219,6 +219,15 @@ class Value(GObjectModule.Value):
if self._free_on_dealloc and self.g_type != TYPE_INVALID:
def set_boxed(self, boxed):
# Workaround the introspection marshalers inability to know
# these methods should be marshaling boxed types. This is because
# the type information is stored on the GValue.
_gobject._gvalue_set(self, boxed)
def get_boxed(self):
return _gobject._gvalue_get(self)
def set_value(self, py_value):
gtype = self.g_type
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