diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2017-07-12 08:48:34 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2017-07-12 08:48:37 +0900 |
commit | 01ddc2783a1d721a003f181000e266acde134d19 (patch) | |
tree | 6155250ea95730d62401f9c3fcb3ff421a8512e8 /gi/_gobject | |
parent | 54ced30b5b9a8471d9d7af4dc3e8c2d0f7b013e8 (diff) | |
download | pygobject2-01ddc2783a1d721a003f181000e266acde134d19.tar.gz pygobject2-01ddc2783a1d721a003f181000e266acde134d19.tar.bz2 pygobject2-01ddc2783a1d721a003f181000e266acde134d19.zip |
Imported Upstream version 3.7.5.1
Change-Id: Ia20ac1ff7d37d8b37e621aa7ad28420e18d55d77
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'gi/_gobject')
-rw-r--r-- | gi/_gobject/Makefile.in | 7 | ||||
-rw-r--r-- | gi/_gobject/gobjectmodule.c | 16 | ||||
-rw-r--r-- | gi/_gobject/pygobject.c | 126 | ||||
-rw-r--r-- | gi/_gobject/pygobject.h | 2 |
4 files changed, 46 insertions, 105 deletions
diff --git a/gi/_gobject/Makefile.in b/gi/_gobject/Makefile.in index 8a2353d..e6369f5 100644 --- a/gi/_gobject/Makefile.in +++ b/gi/_gobject/Makefile.in @@ -60,10 +60,8 @@ DIST_COMMON = $(pkginclude_HEADERS) $(pygobject_PYTHON) \ $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/as-ac-expand.m4 \ - $(top_srcdir)/m4/jhflags.m4 $(top_srcdir)/m4/libtool.m4 \ - $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ - $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ - $(top_srcdir)/m4/python.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/jhflags.m4 $(top_srcdir)/m4/python.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d @@ -264,6 +262,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ THREADING_CFLAGS = @THREADING_CFLAGS@ VERSION = @VERSION@ +WARN_CFLAGS = @WARN_CFLAGS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ diff --git a/gi/_gobject/gobjectmodule.c b/gi/_gobject/gobjectmodule.c index 304a041..96b5c94 100644 --- a/gi/_gobject/gobjectmodule.c +++ b/gi/_gobject/gobjectmodule.c @@ -972,18 +972,18 @@ get_type_name_for_class(PyTypeObject *class) } -static GStaticPrivate pygobject_construction_wrapper = G_STATIC_PRIVATE_INIT; +static GPrivate pygobject_construction_wrapper; static inline void pygobject_init_wrapper_set(PyObject *wrapper) { - g_static_private_set(&pygobject_construction_wrapper, wrapper, NULL); + g_private_set(&pygobject_construction_wrapper, wrapper); } static inline PyObject * pygobject_init_wrapper_get(void) { - return (PyObject *) g_static_private_get(&pygobject_construction_wrapper); + return (PyObject *) g_private_get(&pygobject_construction_wrapper); } int @@ -1034,7 +1034,7 @@ pygobject__g_instance_init(GTypeInstance *instance, * now */ PyGILState_STATE state; state = pyglib_gil_state_ensure(); - wrapper = pygobject_new_full(object, FALSE, g_class); + wrapper = pygobject_new_full(object, TRUE, g_class); /* float the wrapper ref here because we are going to orphan it * so we don't destroy the wrapper. The next call to pygobject_new_full @@ -1477,7 +1477,7 @@ pyg_object_new (PyGObject *self, PyObject *args, PyObject *kwargs) if (obj) { pygobject_sink (obj); - self = (PyGObject *) pygobject_new_full((GObject *)obj, FALSE, NULL); + self = (PyGObject *) pygobject_new_full((GObject *)obj, TRUE, NULL); g_object_unref(obj); } else self = NULL; @@ -2117,7 +2117,9 @@ struct _PyGObject_Functions pygobject_api_functions = { pyg_gerror_exception_check, pyglib_option_group_new, - pyg_type_from_object_strict + pyg_type_from_object_strict, + + pygobject_new_full }; /* for addon libraries ... */ @@ -2205,7 +2207,9 @@ PYGLIB_MODULE_START(_gobject, "_gobject") { PyObject *d; +#if !defined(GLIB_VERSION_2_36) g_type_init(); +#endif pyglib_init(); d = PyModule_GetDict(module); diff --git a/gi/_gobject/pygobject.c b/gi/_gobject/pygobject.c index 00444bd..a23d469 100644 --- a/gi/_gobject/pygobject.c +++ b/gi/_gobject/pygobject.c @@ -951,7 +951,7 @@ pygobject_lookup_class(GType gtype) /** * pygobject_new_full: * @obj: a GObject instance. - * @sink: whether to sink any floating reference found on the GObject. DEPRECATED. + * @sink: whether to sink any floating reference found on the GObject. * @g_class: the GObjectClass * * This function gets a reference to a wrapper for the given GObject @@ -1002,7 +1002,10 @@ pygobject_new_full(GObject *obj, gboolean sink, gpointer g_class) self->obj = obj; /* if we are creating a wrapper around a newly created object, it can have a floating ref (e.g. for methods like Gtk.Button.new()). Bug 640868 */ - g_object_ref_sink(obj); + if (sink) + g_object_ref_sink(obj); + else + g_object_ref(obj); pygobject_register_wrapper((PyObject *)self); PyObject_GC_Track((PyObject *)self); } @@ -1371,6 +1374,7 @@ pygobject_set_property(PyGObject *self, PyObject *args) gchar *param_name; GParamSpec *pspec; PyObject *pvalue; + int ret = -1; if (!PyArg_ParseTuple(args, "sO:GObject.set_property", ¶m_name, &pvalue)) @@ -1387,9 +1391,17 @@ pygobject_set_property(PyGObject *self, PyObject *args) return NULL; } + ret = pygi_set_property_value (self, pspec, pvalue); + if (ret == 0) + goto done; + else if (PyErr_Occurred()) + return NULL; + if (!set_property_from_pspec(self->obj, pspec, pvalue)) return NULL; - + +done: + Py_INCREF(Py_None); return Py_None; } @@ -1413,6 +1425,7 @@ pygobject_set_properties(PyGObject *self, PyObject *args, PyObject *kwargs) while (kwargs && PyDict_Next (kwargs, &pos, &key, &value)) { gchar *key_str = PYGLIB_PyUnicode_AsString(key); GParamSpec *pspec; + int ret = -1; pspec = g_object_class_find_property(class, key_str); if (!pspec) { @@ -1425,6 +1438,12 @@ pygobject_set_properties(PyGObject *self, PyObject *args, PyObject *kwargs) goto exit; } + ret = pygi_set_property_value (self, pspec, value); + if (ret == 0) + goto exit; + else if (PyErr_Occurred()) + goto exit; + if (!set_property_from_pspec(G_OBJECT(self->obj), pspec, value)) goto exit; } @@ -1814,62 +1833,6 @@ pygobject_connect_object_after(PyGObject *self, PyObject *args) } static PyObject * -pygobject_disconnect(PyGObject *self, PyObject *args) -{ - gulong handler_id; - - if (!PyArg_ParseTuple(args, "k:GObject.disconnect", &handler_id)) - return NULL; - - CHECK_GOBJECT(self); - - g_signal_handler_disconnect(self->obj, handler_id); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -pygobject_handler_is_connected(PyGObject *self, PyObject *args) -{ - gulong handler_id; - - if (!PyArg_ParseTuple(args, "k:GObject.handler_is_connected", &handler_id)) - return NULL; - - - CHECK_GOBJECT(self); - - return PyBool_FromLong(g_signal_handler_is_connected(self->obj, handler_id)); -} - -static PyObject * -pygobject_handler_block(PyGObject *self, PyObject *args) -{ - gulong handler_id; - - if (!PyArg_ParseTuple(args, "k:GObject.handler_block", &handler_id)) - return NULL; - - CHECK_GOBJECT(self); - - g_signal_handler_block(self->obj, handler_id); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * -pygobject_handler_unblock(PyGObject *self, PyObject *args) -{ - gulong handler_id; - - if (!PyArg_ParseTuple(args, "k:GObject.handler_unblock", &handler_id)) - return NULL; - g_signal_handler_unblock(self->obj, handler_id); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * pygobject_emit(PyGObject *self, PyObject *args) { guint signal_id, i, j; @@ -1961,33 +1924,6 @@ pygobject_emit(PyGObject *self, PyObject *args) } static PyObject * -pygobject_stop_emission(PyGObject *self, PyObject *args) -{ - gchar *signal; - guint signal_id; - GQuark detail; - PyObject *repr = NULL; - - if (!PyArg_ParseTuple(args, "s:GObject.stop_emission", &signal)) - return NULL; - - CHECK_GOBJECT(self); - - if (!g_signal_parse_name(signal, G_OBJECT_TYPE(self->obj), - &signal_id, &detail, TRUE)) { - repr = PyObject_Repr((PyObject*)self); - PyErr_Format(PyExc_TypeError, "%s: unknown signal name: %s", - PYGLIB_PyUnicode_AsString(repr), - signal); - Py_DECREF(repr); - return NULL; - } - g_signal_stop_emission(self->obj, signal_id, detail); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject * pygobject_chain_from_overridden(PyGObject *self, PyObject *args) { GSignalInvocationHint *ihint; @@ -2219,17 +2155,10 @@ static PyMethodDef pygobject_methods[] = { { "connect_after", (PyCFunction)pygobject_connect_after, METH_VARARGS }, { "connect_object", (PyCFunction)pygobject_connect_object, METH_VARARGS }, { "connect_object_after", (PyCFunction)pygobject_connect_object_after, METH_VARARGS }, - { "disconnect", (PyCFunction)pygobject_disconnect, METH_VARARGS }, { "disconnect_by_func", (PyCFunction)pygobject_disconnect_by_func, METH_VARARGS }, - { "handler_disconnect", (PyCFunction)pygobject_disconnect, METH_VARARGS }, - { "handler_is_connected", (PyCFunction)pygobject_handler_is_connected, METH_VARARGS }, - { "handler_block", (PyCFunction)pygobject_handler_block, METH_VARARGS }, - { "handler_unblock", (PyCFunction)pygobject_handler_unblock,METH_VARARGS }, { "handler_block_by_func", (PyCFunction)pygobject_handler_block_by_func, METH_VARARGS }, { "handler_unblock_by_func", (PyCFunction)pygobject_handler_unblock_by_func, METH_VARARGS }, { "emit", (PyCFunction)pygobject_emit, METH_VARARGS }, - { "stop_emission", (PyCFunction)pygobject_stop_emission, METH_VARARGS }, - { "emit_stop_by_name", (PyCFunction)pygobject_stop_emission,METH_VARARGS }, { "chain", (PyCFunction)pygobject_chain_from_overridden,METH_VARARGS }, { "weak_ref", (PyCFunction)pygobject_weak_ref, METH_VARARGS }, { "__copy__", (PyCFunction)pygobject_copy, METH_NOARGS }, @@ -2256,12 +2185,18 @@ static PyObject * pygobject_get_refcount(PyGObject *self, void *closure) { if (self->obj == NULL) { - PyErr_Format(PyExc_TypeError, "GObject instance is not yet created"); - return NULL; + PyErr_Format(PyExc_TypeError, "GObject instance is not yet created"); + return NULL; } return PYGLIB_PyLong_FromLong(self->obj->ref_count); } +static PyObject * +pygobject_get_pointer(PyGObject *self, void *closure) +{ + return PYGLIB_CPointer_WrapPointer (self->obj, NULL); +} + static int pygobject_setattro(PyObject *self, PyObject *name, PyObject *value) { @@ -2280,6 +2215,7 @@ pygobject_setattro(PyObject *self, PyObject *name, PyObject *value) static PyGetSetDef pygobject_getsets[] = { { "__dict__", (getter)pygobject_get_dict, (setter)0 }, { "__grefcount__", (getter)pygobject_get_refcount, (setter)0, }, + { "__gpointer__", (getter)pygobject_get_pointer, (setter)0, }, { NULL, 0, 0 } }; diff --git a/gi/_gobject/pygobject.h b/gi/_gobject/pygobject.h index 8879fd0..ba40986 100644 --- a/gi/_gobject/pygobject.h +++ b/gi/_gobject/pygobject.h @@ -188,6 +188,7 @@ struct _PyGObject_Functions { gboolean (*gerror_exception_check) (GError **error); PyObject* (*option_group_new) (GOptionGroup *group); GType (* type_from_object_strict) (PyObject *obj, gboolean strict); + PyObject *(* newgobj_full)(GObject *obj, gboolean sink, gpointer g_class); }; #ifndef _INSIDE_PYGOBJECT_ @@ -202,6 +203,7 @@ struct _PyGObject_Functions *_PyGObject_API; #define pygobject_register_wrapper (_PyGObject_API->register_wrapper) #define pygobject_lookup_class (_PyGObject_API->lookup_class) #define pygobject_new (_PyGObject_API->newgobj) +#define pygobject_new_full (_PyGObject_API->newgobj_full) #define pyg_closure_new (_PyGObject_API->closure_new) #define pygobject_watch_closure (_PyGObject_API->object_watch_closure) #define pyg_closure_set_exception_handler (_PyGObject_API->closure_set_exception_handler) |