|
|
@ -896,15 +896,19 @@ class BuildKControlModule(Command):
|
|
|
|
#include <tqstring.h>
|
|
|
|
#include <tqstring.h>
|
|
|
|
#include <sip.h>
|
|
|
|
#include <sip.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef _GNU_SOURCE
|
|
|
|
|
|
|
|
#define _GNU_SOURCE
|
|
|
|
|
|
|
|
#endif // _GNU_SOURCE
|
|
|
|
|
|
|
|
#include <dlfcn.h>
|
|
|
|
|
|
|
|
|
|
|
|
#define MODULE_DIR "%(moduledir)s"
|
|
|
|
#define MODULE_DIR "%(moduledir)s"
|
|
|
|
#define EXTRA_MODULE_DIR "%(extramodule)s"
|
|
|
|
#define EXTRA_MODULE_DIR "%(extramodule)s"
|
|
|
|
#define MODULE_NAME "%(modulename)s"
|
|
|
|
#define MODULE_NAME "%(modulename)s"
|
|
|
|
#define FACTORY "%(factoryfunction)s"
|
|
|
|
#define FACTORY "%(factoryfunction)s"
|
|
|
|
#define CPP_FACTORY %(factoryfunction)s
|
|
|
|
#define CPP_FACTORY %(factoryfunction)s
|
|
|
|
#define LIB_PYTHON "libpython%(python_version)s.so"
|
|
|
|
|
|
|
|
#define debug 1
|
|
|
|
#define debug 1
|
|
|
|
|
|
|
|
|
|
|
|
static TDECModule *report_error(char *msg) {
|
|
|
|
static TDECModule *report_error(const char *msg) {
|
|
|
|
if (debug) printf ("error: %%s\n", msg);
|
|
|
|
if (debug) printf ("error: %%s\n", msg);
|
|
|
|
return NULL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -914,15 +918,17 @@ static TDECModule* return_instance( TQWidget *parent, const char *name ) {
|
|
|
|
PyObject *pyTDECModuleTuple;
|
|
|
|
PyObject *pyTDECModuleTuple;
|
|
|
|
PyObject *pyTDECModule;
|
|
|
|
PyObject *pyTDECModule;
|
|
|
|
Pythonize *pyize; // Pythonize object to manage the Python interpreter.
|
|
|
|
Pythonize *pyize; // Pythonize object to manage the Python interpreter.
|
|
|
|
int isErr;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Try to determine what py script we're loading. Note that "name"
|
|
|
|
// Try to determine what py script we're loading. Note that "name"
|
|
|
|
// typically appears to be NULL.
|
|
|
|
// typically appears to be NULL.
|
|
|
|
TQString script(MODULE_NAME);
|
|
|
|
TQString script(MODULE_NAME);
|
|
|
|
|
|
|
|
|
|
|
|
// Reload libpython, but this time tell the runtime linker to make the
|
|
|
|
// Reload this module, but this time tell the runtime linker to make the
|
|
|
|
// symbols global and available for later loaded libraries/module.
|
|
|
|
// symbols global and available for later loaded libraries/module.
|
|
|
|
KLibLoader::self()->globalLibrary(LIB_PYTHON);
|
|
|
|
Dl_info info;
|
|
|
|
|
|
|
|
if (!dladdr((const void *)(&return_instance), &info) || !info.dli_fname || !dlopen(info.dli_fname, RTLD_GLOBAL|RTLD_NOW)) {
|
|
|
|
|
|
|
|
return report_error ("***Unable to export symbols\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Start the interpreter.
|
|
|
|
// Start the interpreter.
|
|
|
|
pyize = initialize();
|
|
|
|
pyize = initialize();
|
|
|
@ -997,7 +1003,6 @@ static TDECModule* return_instance( TQWidget *parent, const char *name ) {
|
|
|
|
Py_INCREF(PyTuple_GET_ITEM(pyTDECModuleTuple,0));
|
|
|
|
Py_INCREF(PyTuple_GET_ITEM(pyTDECModuleTuple,0));
|
|
|
|
|
|
|
|
|
|
|
|
// convert the TDECModule PyObject to a real C++ TDECModule *.
|
|
|
|
// convert the TDECModule PyObject to a real C++ TDECModule *.
|
|
|
|
isErr = 0;
|
|
|
|
|
|
|
|
pyTDECModule = PyTuple_GET_ITEM(pyTDECModuleTuple,1);
|
|
|
|
pyTDECModule = PyTuple_GET_ITEM(pyTDECModuleTuple,1);
|
|
|
|
tdecmodule = (TDECModule *)PyLong_AsVoidPtr(pyTDECModule);
|
|
|
|
tdecmodule = (TDECModule *)PyLong_AsVoidPtr(pyTDECModule);
|
|
|
|
if(!tdecmodule) {
|
|
|
|
if(!tdecmodule) {
|
|
|
|