summaryrefslogtreecommitdiffstats
path: root/dcoppython/shell/pcop.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dcoppython/shell/pcop.cpp')
-rw-r--r--dcoppython/shell/pcop.cpp36
1 files changed, 21 insertions, 15 deletions
diff --git a/dcoppython/shell/pcop.cpp b/dcoppython/shell/pcop.cpp
index 19557a14..01b45c7f 100644
--- a/dcoppython/shell/pcop.cpp
+++ b/dcoppython/shell/pcop.cpp
@@ -188,7 +188,7 @@ namespace PythonDCOP {
it.current(); ++it, ++c) {
PyObject *tuple = PyTuple_New(2);
PyList_SetItem(result, c, tuple);
- PyTuple_SetItem(tuple, 0, PyString_FromString(it.currentKey() ) );
+ PyTuple_SetItem(tuple, 0, PyBytes_FromString(it.currentKey() ) );
PyTuple_SetItem(tuple, 1, it.current()->pythonMethod() );
}
return result;
@@ -593,7 +593,7 @@ namespace PythonDCOP {
QCStringList::ConstIterator end = apps.end();
unsigned int i = 0;
for (; it != end; ++it, i++ )
- PyList_SetItem( l, i, PyString_FromString( (*it).data() ) );
+ PyList_SetItem( l, i, PyBytes_FromString( (*it).data() ) );
return l;
}
@@ -621,7 +621,7 @@ namespace PythonDCOP {
int add_pid = 1;
if (PyArg_ParseTuple(args, (char*)"s|i", &appid, &add_pid)) {
TQCString actual_appid = Client::instance()->dcop()->registerAs(TQCString(appid), add_pid!=0);
- return PyString_FromString(actual_appid.data());
+ return PyBytes_FromString(actual_appid.data());
}
return NULL;
}
@@ -632,7 +632,7 @@ namespace PythonDCOP {
if (PyArg_ParseTuple(args, (char*)"O|s", &py_dcop_object, &objid)) {
Py_INCREF(py_dcop_object);
PCOPObject *obj = objid ? new PCOPObject(py_dcop_object, objid) : new PCOPObject(py_dcop_object);
- return PyCObject_FromVoidPtr( (void*)obj, delete_dcop_object );
+ return PyCapsule_New( (void*)obj, NULL, (PyCapsule_Destructor)delete_dcop_object );
}
return NULL;
}
@@ -646,7 +646,7 @@ namespace PythonDCOP {
PyObject *c_obj;
PyObject *method_list;
if (PyArg_ParseTuple(args, (char*)"OO", &c_obj, &method_list) &&
- PyCObject_Check(c_obj) &&
+ PyCapsule_CheckExact(c_obj) &&
PyList_Check(method_list)) {
// extract each tuple from the list, aborting if any is invalid
@@ -662,7 +662,7 @@ namespace PythonDCOP {
meth_list.insert(method_signature, py_method);
}
- PCOPObject *obj = (PCOPObject*)PyCObject_AsVoidPtr(c_obj);
+ PCOPObject *obj = (PCOPObject*)PyCapsule_GetPointer(c_obj, NULL);
if (obj) {
if (!obj->setMethodList(meth_list)) return NULL;
}
@@ -675,8 +675,8 @@ namespace PythonDCOP {
PyObject *get_method_list(PyObject */*self*/, PyObject *args) {
PyObject *c_obj;
if (PyArg_ParseTuple(args, (char*)"O", &c_obj)) {
- if (PyCObject_Check(c_obj)) {
- PCOPObject *obj = (PCOPObject*)PyCObject_AsVoidPtr(c_obj);
+ if (PyCapsule_CheckExact(c_obj)) {
+ PCOPObject *obj = (PCOPObject*)PyCapsule_GetPointer(c_obj, NULL);
return obj->methodList();
}
}
@@ -736,7 +736,7 @@ namespace PythonDCOP {
for(QCStringList::ConstIterator it = qt_list.begin();
it!=qt_list.end();
++it,c++)
- PyList_SetItem(l, c, PyString_FromString( (*it).data() ) );
+ PyList_SetItem(l, c, PyBytes_FromString( (*it).data() ) );
return l;
}
@@ -757,14 +757,20 @@ PyMethodDef PCOPMethods[] = {
{ NULL, NULL, 0, NULL } /* Sentinel */
};
+static struct PyModuleDef pcopmodule = {
+ PyModuleDef_HEAD_INIT,
+ "pcop",
+ NULL,
+ -1,
+ PCOPMethods
+};
+
extern "C"
{
-
- void initpcop()
- {
- (void) Py_InitModule( (char*)"pcop", PCOPMethods );
- }
-
+ PyMODINIT_FUNC PyInit_pcop(void)
+ {
+ return PyModule_Create(&pcopmodule);
+ }
}