summaryrefslogtreecommitdiff
path: root/tests/testhelpermodule.c
diff options
context:
space:
mode:
authorChristoph Reiter <reiter.christoph@gmail.com>2020-04-15 20:15:10 +0200
committerChristoph Reiter <reiter.christoph@gmail.com>2020-04-16 18:54:18 +0200
commitf3cb961528e9e913811ed425bd096fd133880683 (patch)
tree5e81a8c02547f46bef080d66e103825311b116f0 /tests/testhelpermodule.c
parenta6799b242c0abd6a9dfbf1e98742b2b922205ebf (diff)
downloadpygobject-f3cb961528e9e913811ed425bd096fd133880683.tar.gz
Remove all Python 2 C code
Diffstat (limited to 'tests/testhelpermodule.c')
-rw-r--r--tests/testhelpermodule.c45
1 files changed, 36 insertions, 9 deletions
diff --git a/tests/testhelpermodule.c b/tests/testhelpermodule.c
index 82b0399e..848d8203 100644
--- a/tests/testhelpermodule.c
+++ b/tests/testhelpermodule.c
@@ -5,7 +5,12 @@
#include "test-unknown.h"
#include "test-floating.h"
-#include "pygi-python-compat.h"
+#define PYGLIB_DEFINE_TYPE(typename, symbol, csymbol) \
+PyTypeObject symbol = { \
+ PyVarObject_HEAD_INIT(NULL, 0) \
+ typename, \
+ sizeof(csymbol) \
+};
static PyObject * _wrap_TestInterface__do_iface_method(PyObject *cls,
PyObject *args,
@@ -82,7 +87,7 @@ _wrap_test_g_object_new (PyObject * self)
PyObject *rv;
obj = g_object_new(g_type_from_name("PyGObject"), NULL);
- rv = PYGLIB_PyLong_FromLong(obj->ref_count); /* should be == 2 at this point */
+ rv = PyLong_FromLong(obj->ref_count); /* should be == 2 at this point */
g_object_unref(obj);
return rv;
}
@@ -583,7 +588,7 @@ _wrap_constant_strip_prefix(PyObject *self, PyObject *args)
return NULL;
result = pyg_constant_strip_prefix (name, strip_prefix);
- return PYGLIB_PyUnicode_FromString (result);
+ return PyUnicode_FromString (result);
}
static PyObject *
@@ -676,7 +681,7 @@ _wrap_test_parse_constructor_args (PyObject *self, PyObject *args)
return NULL;
}
- return PYGLIB_PyLong_FromLong (nparams);
+ return PyLong_FromLong (nparams);
}
G_GNUC_END_IGNORE_DEPRECATIONS
@@ -693,7 +698,7 @@ _wrap_test_to_unichar_conv (PyObject * self, PyObject *args)
if (!pyg_pyobj_to_unichar_conv (obj, &result))
return NULL;
- return PYGLIB_PyLong_FromLong (result);
+ return PyLong_FromLong (result);
}
static PyMethodDef testhelper_functions[] = {
@@ -715,11 +720,32 @@ static PyMethodDef testhelper_functions[] = {
{ NULL, NULL }
};
-PYGLIB_MODULE_START(testhelper, "testhelper")
-{
+static struct PyModuleDef _testhelpermodule = {
+ PyModuleDef_HEAD_INIT,
+ "testhelper",
+ NULL,
+ -1,
+ testhelper_functions,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
+#ifdef __GNUC__
+#define PYGI_MODINIT_FUNC __attribute__((visibility("default"))) PyMODINIT_FUNC
+#else
+#define PYGI_MODINIT_FUNC PyMODINIT_FUNC
+#endif
+
+PYGI_MODINIT_FUNC PyInit_testhelper(void);
+
+PYGI_MODINIT_FUNC PyInit_testhelper(void) {
+ PyObject *module;
PyObject *gobject_module;
PyObject *m, *d;
+ module = PyModule_Create(&_testhelpermodule);
if ((gobject_module = pygobject_init(-1, -1, -1)) == NULL)
return NULL;
@@ -730,7 +756,7 @@ PYGLIB_MODULE_START(testhelper, "testhelper")
if ((m = PyImport_ImportModule("gi.repository.GObject")) == NULL) {
PyErr_SetString(PyExc_ImportError,
"could not import gobject");
- return PYGLIB_MODULE_ERROR_RETURN;
+ return NULL;
}
/* TestInterface */
@@ -779,6 +805,7 @@ PYGLIB_MODULE_START(testhelper, "testhelper")
&PyTestFloatingAndSunk_Type,
Py_BuildValue("(O)",
&PyGObject_Type));
+
+ return module;
}
-PYGLIB_MODULE_END