diff options
Diffstat (limited to 'gobject')
| -rw-r--r-- | gobject/gobjectmodule.c | 2 | ||||
| -rw-r--r-- | gobject/pygobject-private.h | 2 | ||||
| -rw-r--r-- | gobject/pygobject.c | 6 | ||||
| -rw-r--r-- | gobject/pygobject.h | 2 | ||||
| -rw-r--r-- | gobject/pygtype.c | 29 |
5 files changed, 28 insertions, 13 deletions
diff --git a/gobject/gobjectmodule.c b/gobject/gobjectmodule.c index 8238f7c..2e6b471 100644 --- a/gobject/gobjectmodule.c +++ b/gobject/gobjectmodule.c @@ -385,7 +385,7 @@ pyg_object_set_property (GObject *object, guint property_id, g_return_if_fail(object_wrapper != NULL); py_pspec = pyg_param_spec_new(pspec); - py_value = pyg_value_as_pyobject (value); + py_value = pyg_value_as_pyobject (value, TRUE); retval = PyObject_CallMethod(object_wrapper, "do_set_property", "OO", py_pspec, py_value); if (retval) { diff --git a/gobject/pygobject-private.h b/gobject/pygobject-private.h index acf13b0..e8b768d 100644 --- a/gobject/pygobject-private.h +++ b/gobject/pygobject-private.h @@ -50,7 +50,7 @@ void pyg_register_boxed_custom(GType boxed_type, fromvaluefunc from_func, tovaluefunc to_func); int pyg_value_from_pyobject(GValue *value, PyObject *obj); -PyObject *pyg_value_as_pyobject(const GValue *value); +PyObject *pyg_value_as_pyobject(const GValue *value, gboolean copy_boxed); GClosure *pyg_closure_new(PyObject *callback, PyObject *extra_args, PyObject *swap_data); GClosure *pyg_signal_class_closure_get(void); diff --git a/gobject/pygobject.c b/gobject/pygobject.c index d54b5b3..1c99deb 100644 --- a/gobject/pygobject.c +++ b/gobject/pygobject.c @@ -279,7 +279,7 @@ pygobject_get_property(PyGObject *self, PyObject *args) } g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE(pspec)); g_object_get_property(self->obj, param_name, &value); - ret = pyg_value_as_pyobject(&value); + ret = pyg_value_as_pyobject(&value, TRUE); g_value_unset(&value); return ret; } @@ -633,7 +633,7 @@ pygobject_emit(PyGObject *self, PyObject *args) g_value_unset(¶ms[i]); g_free(params); if ((query.return_type & ~G_SIGNAL_TYPE_STATIC_SCOPE) != G_TYPE_NONE) { - py_ret = pyg_value_as_pyobject(&ret); + py_ret = pyg_value_as_pyobject(&ret, TRUE); g_value_unset(&ret); } else { Py_INCREF(Py_None); @@ -721,7 +721,7 @@ pygobject_chain_from_overridden(PyGObject *self, PyObject *args) g_value_unset(¶ms[i]); g_free(params); if ((query.return_type & ~G_SIGNAL_TYPE_STATIC_SCOPE) != G_TYPE_NONE) { - py_ret = pyg_value_as_pyobject(&ret); + py_ret = pyg_value_as_pyobject(&ret, TRUE); g_value_unset(&ret); } else { Py_INCREF(Py_None); diff --git a/gobject/pygobject.h b/gobject/pygobject.h index 69af1af..5cc4f49 100644 --- a/gobject/pygobject.h +++ b/gobject/pygobject.h @@ -60,7 +60,7 @@ struct _PyGObject_Functions { PyObject *(* from_func)(const GValue *value), int (* to_func)(GValue *value, PyObject *obj)); int (* value_from_pyobject)(GValue *value, PyObject *obj); - PyObject *(* value_as_pyobject)(const GValue *value); + PyObject *(* value_as_pyobject)(const GValue *value, gboolean copy_boxed); void (* register_interface)(PyObject *dict, const gchar *class_name, GType gtype, PyTypeObject *type); diff --git a/gobject/pygtype.c b/gobject/pygtype.c index d03f7f6..36256b7 100644 --- a/gobject/pygtype.c +++ b/gobject/pygtype.c @@ -476,8 +476,18 @@ pyg_value_from_pyobject(GValue *value, PyObject *obj) return 0; } +/** + * pyg_value_as_pyobject: + * @value: the GValue object. + * @copy_boxed: true if boxed values should be copied. + * + * This function creates/returns a Python wrapper object that + * represents the GValue passed as an argument. + * + * Returns: a PyObject representing the value. + */ PyObject * -pyg_value_as_pyobject(const GValue *value) +pyg_value_as_pyobject(const GValue *value, gboolean copy_boxed) { gchar buf[128]; @@ -575,11 +585,16 @@ pyg_value_as_pyobject(const GValue *value) } bm = pyg_boxed_lookup(G_VALUE_TYPE(value)); - if (bm) + if (bm) { return bm->fromvalue(value); - else - return pyg_boxed_new(G_VALUE_TYPE(value), - g_value_get_boxed(value), TRUE, TRUE); + } else { + if (copy_boxed) + return pyg_boxed_new(G_VALUE_TYPE(value), + g_value_get_boxed(value), TRUE, TRUE); + else + return pyg_boxed_new(G_VALUE_TYPE(value), + g_value_get_boxed(value),FALSE,FALSE); + } } case G_TYPE_PARAM: return pyg_param_spec_new(g_value_get_param(value)); @@ -639,7 +654,7 @@ pyg_closure_marshal(GClosure *closure, Py_INCREF(pc->swap_data); PyTuple_SetItem(params, 0, pc->swap_data); } else { - PyObject *item = pyg_value_as_pyobject(¶m_values[i]); + PyObject *item = pyg_value_as_pyobject(¶m_values[i], FALSE); /* error condition */ if (!item) { @@ -758,7 +773,7 @@ pyg_signal_class_closure_marshal(GClosure *closure, /* construct Python tuple for the parameter values */ params = PyTuple_New(n_param_values - 1); for (i = 1; i < n_param_values; i++) { - PyObject *item = pyg_value_as_pyobject(¶m_values[i]); + PyObject *item = pyg_value_as_pyobject(¶m_values[i], TRUE); /* error condition */ if (!item) { |
