Commit 42fc9fa4 authored by Steve Frécinaux's avatar Steve Frécinaux
Browse files

Drop support for old constructor style.

Bindings don't write their own constructors anymore, and the old style
has been deprecated for ages, so let's just drop them now and make
pygobject simpler.

https://bugzilla.gnome.org/show_bug.cgi?id=657413
parent 3961a405
......@@ -1024,10 +1024,6 @@ pygobject__g_instance_init(GTypeInstance *instance,
GObject *object = (GObject *) instance;
PyObject *wrapper, *args, *kwargs;
if (!g_type_get_qdata(G_OBJECT_TYPE(object),
pygobject_has_updated_constructor_key))
return;
wrapper = g_object_get_qdata(object, pygobject_wrapper_key);
if (wrapper == NULL) {
wrapper = pygobject_init_wrapper_get();
......@@ -1135,7 +1131,6 @@ pyg_type_register(PyTypeObject *class, const char *type_name)
guint n_parent_interfaces;
GTypeQuery query;
gpointer gclass;
gpointer has_new_constructor_api;
GTypeInfo type_info = {
0, /* class_size */
......@@ -1201,14 +1196,6 @@ pyg_type_register(PyTypeObject *class, const char *type_name)
PyObject_SetAttrString((PyObject *)class, "__gtype__", gtype);
Py_DECREF(gtype);
/* propagate new constructor API compatility flag from parent to child type */
has_new_constructor_api =
g_type_get_qdata(parent_type,
pygobject_has_updated_constructor_key);
if (has_new_constructor_api != NULL)
g_type_set_qdata(instance_type, pygobject_has_updated_constructor_key,
has_new_constructor_api);
/* if no __doc__, set it to the auto doc descriptor */
if (PyDict_GetItemString(class->tp_dict, "__doc__") == NULL) {
PyDict_SetItemString(class->tp_dict, "__doc__",
......@@ -2313,12 +2300,6 @@ pygobject_construct(PyGObject *self, const char *first_property_name, ...)
return retval;
}
void
pyg_set_object_has_new_constructor(GType type)
{
g_type_set_qdata(type, pygobject_has_updated_constructor_key, GINT_TO_POINTER(1));
}
PyObject *
pyg_integer_richcompare(PyObject *v, PyObject *w, int op)
{
......@@ -2471,7 +2452,6 @@ struct _PyGObject_Functions pygobject_api_functions = {
pyg_closure_set_exception_handler,
pygobject_constructv,
pygobject_construct,
pyg_set_object_has_new_constructor,
add_warning_redirection,
disable_warning_redirections,
......
......@@ -92,7 +92,6 @@ int pygobject_constructv (PyGObject *self,
int pygobject_construct (PyGObject *self,
const char *first_property_name,
...);
void pyg_set_object_has_new_constructor (GType gtype);
PyObject *pyg_integer_richcompare(PyObject *v,
PyObject *w,
......
......@@ -2297,7 +2297,6 @@ pygobject_object_register_types(PyObject *d)
&PyGObject_Type, NULL);
PyDict_SetItemString(PyGObject_Type.tp_dict, "__gdoc__",
pyg_object_descr_doc_get());
pyg_set_object_has_new_constructor(G_TYPE_OBJECT);
/* GProps */
PyGProps_Type.tp_dealloc = (destructor)PyGProps_dealloc;
......
......@@ -186,7 +186,6 @@ struct _PyGObject_Functions {
int (*pygobject_construct) (PyGObject *self,
const char *first_property_name,
...);
void (*set_object_has_new_constructor) (GType type);
void (*add_warning_redirection) (const char *domain,
PyObject *warning);
......@@ -257,7 +256,6 @@ struct _PyGObject_Functions *_PyGObject_API;
#define pyg_register_interface_info (_PyGObject_API->register_interface_info)
#define pygobject_construct (_PyGObject_API->pygobject_construct)
#define pygobject_constructv (_PyGObject_API->pygobject_constructv)
#define pyg_set_object_has_new_constructor (_PyGObject_API->set_object_has_new_constructor)
#define pyg_add_warning_redirection (_PyGObject_API->add_warning_redirection)
#define pyg_disable_warning_redirections (_PyGObject_API->disable_warning_redirections)
#define pyg_type_register_custom_callback (_PyGObject_API->type_register_custom)
......
......@@ -201,33 +201,6 @@ _wrap_pyg_flags_register_new_gtype_and_add (PyObject *self,
return pyg_flags_add (NULL, g_type_name (g_type), NULL, g_type);
}
static PyObject *
_wrap_pyg_set_object_has_new_constructor (PyObject *self,
PyObject *args,
PyObject *kwargs)
{
static char *kwlist[] = { "g_type", NULL };
PyObject *py_g_type;
GType g_type;
if (!PyArg_ParseTupleAndKeywords (args, kwargs,
"O!:set_object_has_new_constructor",
kwlist, &PyGTypeWrapper_Type, &py_g_type)) {
return NULL;
}
g_type = pyg_type_from_object (py_g_type);
if (!g_type_is_a (g_type, G_TYPE_OBJECT)) {
PyErr_SetString (PyExc_TypeError, "must be a subtype of GObject");
return NULL;
}
pyg_set_object_has_new_constructor (g_type);
Py_RETURN_NONE;
}
static void
initialize_interface (GTypeInterface *iface, PyTypeObject *pytype)
{
......@@ -486,7 +459,6 @@ static PyMethodDef _gi_functions[] = {
{ "flags_add", (PyCFunction) _wrap_pyg_flags_add, METH_VARARGS | METH_KEYWORDS },
{ "flags_register_new_gtype_and_add", (PyCFunction) _wrap_pyg_flags_register_new_gtype_and_add, METH_VARARGS | METH_KEYWORDS },
{ "set_object_has_new_constructor", (PyCFunction) _wrap_pyg_set_object_has_new_constructor, METH_VARARGS | METH_KEYWORDS },
{ "register_interface_info", (PyCFunction) _wrap_pyg_register_interface_info, METH_VARARGS },
{ "hook_up_vfunc_implementation", (PyCFunction) _wrap_pyg_hook_up_vfunc_implementation, METH_VARARGS },
{ "variant_new_tuple", (PyCFunction) _wrap_pyg_variant_new_tuple, METH_VARARGS },
......
......@@ -30,7 +30,6 @@ from ._gi import \
ObjectInfo, \
StructInfo, \
VFuncInfo, \
set_object_has_new_constructor, \
register_interface_info, \
hook_up_vfunc_implementation
......@@ -225,7 +224,6 @@ class GObjectMeta(_gobject.GObjectMeta, MetaClassHelper):
if isinstance(cls.__info__, ObjectInfo):
cls._setup_fields()
cls._setup_constructors()
set_object_has_new_constructor(cls.__info__.get_g_type())
elif isinstance(cls.__info__, InterfaceInfo):
register_interface_info(cls.__info__.get_g_type())
......
......@@ -560,8 +560,6 @@ PYGLIB_MODULE_START(testhelper, "testhelper")
Py_BuildValue("(O)",
&PyGObject_Type,
&PyTestInterface_Type));
pyg_set_object_has_new_constructor(TEST_TYPE_UNKNOWN);
//pyg_register_class_init(TEST_TYPE_UNKNOWN, __GtkUIManager_class_init);
/* TestFloating */
PyTestFloating_Type.tp_flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE);
......@@ -571,7 +569,6 @@ PYGLIB_MODULE_START(testhelper, "testhelper")
&PyTestFloating_Type,
Py_BuildValue("(O)",
&PyGObject_Type));
pyg_set_object_has_new_constructor(TEST_TYPE_FLOATING);
/* TestOwnedByLibrary */
PyTestOwnedByLibrary_Type.tp_flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE);
......@@ -582,7 +579,6 @@ PYGLIB_MODULE_START(testhelper, "testhelper")
&PyTestOwnedByLibrary_Type,
Py_BuildValue("(O)",
&PyGObject_Type));
pyg_set_object_has_new_constructor(TEST_TYPE_OWNED_BY_LIBRARY);
/* TestFloatingAndSunk */
PyTestFloatingAndSunk_Type.tp_flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE);
......@@ -593,7 +589,6 @@ PYGLIB_MODULE_START(testhelper, "testhelper")
&PyTestFloatingAndSunk_Type,
Py_BuildValue("(O)",
&PyGObject_Type));
pyg_set_object_has_new_constructor(TEST_TYPE_FLOATING_AND_SUNK);
}
PYGLIB_MODULE_END
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