summaryrefslogtreecommitdiff
path: root/gi
diff options
context:
space:
mode:
authorChristoph Reiter <reiter.christoph@gmail.com>2020-04-15 21:06:17 +0200
committerChristoph Reiter <reiter.christoph@gmail.com>2020-04-16 18:54:23 +0200
commit009cb45c4be1d624a4218587cf0b6f41d5a79f47 (patch)
tree4573f48989e742557277d8d4c743c37952ecd04f /gi
parentf3cb961528e9e913811ed425bd096fd133880683 (diff)
downloadpygobject-009cb45c4be1d624a4218587cf0b6f41d5a79f47.tar.gz
Remove PYGLIB_REGISTER_TYPE
Less macro magic
Diffstat (limited to 'gi')
-rw-r--r--gi/pygi-type.c7
-rw-r--r--gi/pygi-type.h12
-rw-r--r--gi/pygi-util.h9
-rw-r--r--gi/pygoptioncontext.c7
-rw-r--r--gi/pygoptiongroup.c8
-rw-r--r--gi/pygspawn.c7
6 files changed, 34 insertions, 16 deletions
diff --git a/gi/pygi-type.c b/gi/pygi-type.c
index f8913753..5f0e5667 100644
--- a/gi/pygi-type.c
+++ b/gi/pygi-type.c
@@ -1377,7 +1377,12 @@ pygi_type_register_types(PyObject *d)
PyGTypeWrapper_Type.tp_methods = _PyGTypeWrapper_methods;
PyGTypeWrapper_Type.tp_getset = _PyGTypeWrapper_getsets;
PyGTypeWrapper_Type.tp_init = (initproc)pyg_type_wrapper_init;
- PYGLIB_REGISTER_TYPE(d, PyGTypeWrapper_Type, "GType");
+ PyGTypeWrapper_Type.tp_alloc = PyType_GenericAlloc;
+ PyGTypeWrapper_Type.tp_new = PyType_GenericNew;
+ if (PyType_Ready(&PyGTypeWrapper_Type))
+ return -1;
+
+ PyDict_SetItemString(d, "GType", (PyObject *)&PyGTypeWrapper_Type);
/* This type lazily registered in pyg_object_descr_doc_get */
PyGObjectDoc_Type.tp_dealloc = (destructor)object_doc_dealloc;
diff --git a/gi/pygi-type.h b/gi/pygi-type.h
index 94ddc850..8032571d 100644
--- a/gi/pygi-type.h
+++ b/gi/pygi-type.h
@@ -28,10 +28,16 @@
#define PYGOBJECT_REGISTER_GTYPE(d, type, name, gtype) \
{ \
- PyObject *o; \
- PYGLIB_REGISTER_TYPE(d, type, name); \
+ PyObject *o; \
+ if (!type.tp_alloc) \
+ type.tp_alloc = PyType_GenericAlloc; \
+ if (!type.tp_new) \
+ type.tp_new = PyType_GenericNew; \
+ if (PyType_Ready(&type)) \
+ return -1; \
+ PyDict_SetItemString(d, name, (PyObject *)&type); \
PyDict_SetItemString(type.tp_dict, "__gtype__", \
- o=pyg_type_wrapper_new(gtype)); \
+ o=pyg_type_wrapper_new(gtype)); \
Py_DECREF(o); \
}
diff --git a/gi/pygi-util.h b/gi/pygi-util.h
index e16add13..3df2d36d 100644
--- a/gi/pygi-util.h
+++ b/gi/pygi-util.h
@@ -19,15 +19,6 @@ PyTypeObject symbol = { \
sizeof(csymbol) \
};
-#define PYGLIB_REGISTER_TYPE(d, type, name) \
- if (!type.tp_alloc) \
- type.tp_alloc = PyType_GenericAlloc; \
- if (!type.tp_new) \
- type.tp_new = PyType_GenericNew; \
- if (PyType_Ready(&type)) \
- return -1; \
- PyDict_SetItemString(d, name, (PyObject *)&type);
-
#define _PyGI_ERROR_PREFIX(format, ...) G_STMT_START { \
PyObject *py_error_prefix; \
py_error_prefix = PyUnicode_FromFormat(format, ## __VA_ARGS__); \
diff --git a/gi/pygoptioncontext.c b/gi/pygoptioncontext.c
index f9f4a652..ffeeef24 100644
--- a/gi/pygoptioncontext.c
+++ b/gi/pygoptioncontext.c
@@ -368,7 +368,12 @@ pygi_option_context_register_types(PyObject *d)
PyGOptionContext_Type.tp_flags = Py_TPFLAGS_DEFAULT;
PyGOptionContext_Type.tp_methods = pyg_option_context_methods;
PyGOptionContext_Type.tp_init = (initproc)pyg_option_context_init;
- PYGLIB_REGISTER_TYPE(d, PyGOptionContext_Type, "OptionContext");
+ PyGOptionContext_Type.tp_alloc = PyType_GenericAlloc;
+ PyGOptionContext_Type.tp_new = PyType_GenericNew;
+ if (PyType_Ready(&PyGOptionContext_Type))
+ return -1;
+
+ PyDict_SetItemString(d, "OptionContext", (PyObject *)&PyGOptionContext_Type);
return 0;
}
diff --git a/gi/pygoptiongroup.c b/gi/pygoptiongroup.c
index f144d818..72fbe373 100644
--- a/gi/pygoptiongroup.c
+++ b/gi/pygoptiongroup.c
@@ -295,7 +295,13 @@ pygi_option_group_register_types(PyObject *d)
PyGOptionGroup_Type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
PyGOptionGroup_Type.tp_methods = pyg_option_group_methods;
PyGOptionGroup_Type.tp_init = (initproc)pyg_option_group_init;
- PYGLIB_REGISTER_TYPE(d, PyGOptionGroup_Type, "OptionGroup");
+ PyGOptionGroup_Type.tp_alloc = PyType_GenericAlloc;
+ PyGOptionGroup_Type.tp_new = PyType_GenericNew;
+
+ if (PyType_Ready(&PyGOptionGroup_Type))
+ return -1;
+
+ PyDict_SetItemString(d, "OptionGroup", (PyObject *)&PyGOptionGroup_Type);
return 0;
}
diff --git a/gi/pygspawn.c b/gi/pygspawn.c
index b2825637..daa80c5f 100644
--- a/gi/pygspawn.c
+++ b/gi/pygspawn.c
@@ -272,7 +272,12 @@ pygi_spawn_register_types(PyObject *d)
PyGPid_Type.tp_init = pyg_pid_tp_init;
PyGPid_Type.tp_free = (freefunc)pyg_pid_free;
PyGPid_Type.tp_new = PyLong_Type.tp_new;
- PYGLIB_REGISTER_TYPE(d, PyGPid_Type, "Pid");
+ PyGPid_Type.tp_alloc = PyType_GenericAlloc;
+
+ if (PyType_Ready(&PyGPid_Type))
+ return -1;
+
+ PyDict_SetItemString(d, "Pid", (PyObject *)&PyGPid_Type);
return 0;
}