Don't export symbols that don't need to be exported and rename many functions.
This commit is contained in:
parent
1a10971865
commit
a43eafaae4
7 changed files with 319 additions and 284 deletions
|
|
@ -1793,7 +1793,7 @@
|
||||||
<!-- Second argument is a PySide.QtCore.Signal. See bug #362. -->
|
<!-- Second argument is a PySide.QtCore.Signal. See bug #362. -->
|
||||||
<add-function signature="singleShot(int, PyObject*)" static="yes">
|
<add-function signature="singleShot(int, PyObject*)" static="yes">
|
||||||
<inject-code class="target" position="beginning">
|
<inject-code class="target" position="beginning">
|
||||||
if (!PyObject_TypeCheck(%2, &PySide::SignalInstance_Type))
|
if (!PyObject_TypeCheck(%2, &PySideSignalInstanceType))
|
||||||
goto Sbk%TYPEFunc_%FUNCTION_NAME_TypeError;
|
goto Sbk%TYPEFunc_%FUNCTION_NAME_TypeError;
|
||||||
|
|
||||||
// %FUNCTION_NAME() - disable generation of c++ function call
|
// %FUNCTION_NAME() - disable generation of c++ function call
|
||||||
|
|
@ -1803,7 +1803,7 @@
|
||||||
QTimer* timer = Converter<QTimer*>::toCpp(pyTimer);
|
QTimer* timer = Converter<QTimer*>::toCpp(pyTimer);
|
||||||
timer->setSingleShot(true);
|
timer->setSingleShot(true);
|
||||||
timer->connect(timer, SIGNAL(timeout()), timer, SLOT(deleteLater()));
|
timer->connect(timer, SIGNAL(timeout()), timer, SLOT(deleteLater()));
|
||||||
PySide::SignalInstanceData* signalInstance = reinterpret_cast<PySide::SignalInstanceData*>(%2);
|
PySideSignalInstanceData* signalInstance = reinterpret_cast<PySideSignalInstanceData*>(%2);
|
||||||
Shiboken::AutoDecRef signalSignature(PyString_FromFormat("2%s", signalInstance->signature));
|
Shiboken::AutoDecRef signalSignature(PyString_FromFormat("2%s", signalInstance->signature));
|
||||||
Shiboken::AutoDecRef result(
|
Shiboken::AutoDecRef result(
|
||||||
PyObject_CallMethod(pyTimer,
|
PyObject_CallMethod(pyTimer,
|
||||||
|
|
@ -2498,9 +2498,9 @@
|
||||||
// since it refers to a name very tied to the generator implementation.
|
// since it refers to a name very tied to the generator implementation.
|
||||||
// Check bug #362 for more information on this
|
// Check bug #362 for more information on this
|
||||||
// http://bugs.openbossa.org/show_bug.cgi?id=362
|
// http://bugs.openbossa.org/show_bug.cgi?id=362
|
||||||
if (!PyObject_TypeCheck(%1, &PySide::SignalInstance_Type))
|
if (!PyObject_TypeCheck(%1, &PySideSignalInstanceType))
|
||||||
goto Sbk%TYPEFunc_%FUNCTION_NAME_TypeError;
|
goto Sbk%TYPEFunc_%FUNCTION_NAME_TypeError;
|
||||||
PySide::SignalInstanceData* signalInstance = reinterpret_cast<PySide::SignalInstanceData*>(%1);
|
PySideSignalInstanceData* signalInstance = reinterpret_cast<PySideSignalInstanceData*>(%1);
|
||||||
QObject* sender = %CONVERTTOCPP[QObject*](signalInstance->source);
|
QObject* sender = %CONVERTTOCPP[QObject*](signalInstance->source);
|
||||||
%PYARG_0 = %CONVERTTOPYTHON[QSignalTransition*](%CPPSELF->%FUNCTION_NAME(sender, signalInstance->signature, %2));
|
%PYARG_0 = %CONVERTTOPYTHON[QSignalTransition*](%CPPSELF->%FUNCTION_NAME(sender, signalInstance->signature, %2));
|
||||||
</inject-code>
|
</inject-code>
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@
|
||||||
#include <QMetaMethod>
|
#include <QMetaMethod>
|
||||||
|
|
||||||
#include "qsignal.h"
|
#include "qsignal.h"
|
||||||
|
#include "qsignal_p.h"
|
||||||
#include "qproperty.h"
|
#include "qproperty.h"
|
||||||
#include "qproperty_p.h"
|
#include "qproperty_p.h"
|
||||||
|
|
||||||
|
|
@ -393,14 +394,14 @@ DynamicQMetaObject* DynamicQMetaObject::createBasedOn(PyObject* pyObj, PyTypeObj
|
||||||
}
|
}
|
||||||
|
|
||||||
//Register signals
|
//Register signals
|
||||||
if (value->ob_type == &Signal_Type) {
|
if (value->ob_type == &PySideSignalType) {
|
||||||
PyObject *attr = PyObject_GetAttr(pyObj, key);
|
PyObject *attr = PyObject_GetAttr(pyObj, key);
|
||||||
SignalInstanceData *data = reinterpret_cast<SignalInstanceData*>(attr);
|
PySideSignalInstanceData *data = reinterpret_cast<PySideSignalInstanceData*>(attr);
|
||||||
while(data) {
|
while(data) {
|
||||||
int index = base->indexOfSignal(data->signature);
|
int index = base->indexOfSignal(data->signature);
|
||||||
if (index == -1)
|
if (index == -1)
|
||||||
mo->addSignal(data->signature);
|
mo->addSignal(data->signature);
|
||||||
data = reinterpret_cast<SignalInstanceData*>(data->next);
|
data = reinterpret_cast<PySideSignalInstanceData*>(data->next);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,13 +26,13 @@
|
||||||
#include "qproperty_p.h"
|
#include "qproperty_p.h"
|
||||||
#include "qproperty.h"
|
#include "qproperty.h"
|
||||||
#include "qsignal.h"
|
#include "qsignal.h"
|
||||||
|
#include "qsignal_p.h"
|
||||||
#include <basewrapper.h>
|
#include <basewrapper.h>
|
||||||
#include <conversions.h>
|
#include <conversions.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <QStack>
|
#include <QStack>
|
||||||
|
|
||||||
extern "C" void init_signal(PyObject* module);
|
|
||||||
extern "C" void init_slot(PyObject* module);
|
extern "C" void init_slot(PyObject* module);
|
||||||
|
|
||||||
static QStack<PySide::CleanupFunction> cleanupFunctionList;
|
static QStack<PySide::CleanupFunction> cleanupFunctionList;
|
||||||
|
|
@ -42,7 +42,7 @@ namespace PySide
|
||||||
|
|
||||||
void init(PyObject *module)
|
void init(PyObject *module)
|
||||||
{
|
{
|
||||||
init_signal(module);
|
initSignalSupport(module);
|
||||||
init_slot(module);
|
init_slot(module);
|
||||||
initQProperty(module);
|
initQProperty(module);
|
||||||
// Init signal manager, so it will register some meta types used by QVariant.
|
// Init signal manager, so it will register some meta types used by QVariant.
|
||||||
|
|
@ -75,7 +75,7 @@ bool fillQtProperties(PyObject* qObj, const QMetaObject* metaObj, PyObject* kwds
|
||||||
propName.append("()");
|
propName.append("()");
|
||||||
if (metaObj->indexOfSignal(propName) != -1) {
|
if (metaObj->indexOfSignal(propName) != -1) {
|
||||||
propName.prepend('2');
|
propName.prepend('2');
|
||||||
PySide::signal_connect(qObj, propName, value);
|
PySide::signalConnect(qObj, propName, value);
|
||||||
} else {
|
} else {
|
||||||
PyErr_Format(PyExc_AttributeError, "'%s' is not a Qt property or a signal", propName.constData());
|
PyErr_Format(PyExc_AttributeError, "'%s' is not a Qt property or a signal", propName.constData());
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -25,45 +25,46 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include "qsignal.h"
|
#include "qsignal.h"
|
||||||
|
#include "qsignal_p.h"
|
||||||
#include "signalmanager.h"
|
#include "signalmanager.h"
|
||||||
|
|
||||||
#define SIGNAL_CLASS_NAME "Signal"
|
#define SIGNAL_CLASS_NAME "Signal"
|
||||||
#define QT_SIGNAL_SENTINEL "2"
|
#define QT_SIGNAL_SENTINEL "2"
|
||||||
|
|
||||||
|
struct SignalData;
|
||||||
|
|
||||||
namespace PySide
|
namespace PySide
|
||||||
{
|
{
|
||||||
|
//aux
|
||||||
|
static char* signalBuildSignature(const char*, const char*);
|
||||||
|
static void signalAppendSignature(SignalData*, char*);
|
||||||
|
static void signalInstanceInitialize(PyObject*, PyObject*, SignalData*, PyObject *, int);
|
||||||
|
static char* signalParseSignature(PyObject*);
|
||||||
|
static PyObject* signalBuildQtCompatible(const char*);
|
||||||
|
}
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
|
|
||||||
char* get_type_name(PyObject*);
|
struct SignalData {
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
PyObject_HEAD
|
PyObject_HEAD
|
||||||
bool initialized;
|
bool initialized;
|
||||||
char* signalName;
|
char* signalName;
|
||||||
char** signatures;
|
char** signatures;
|
||||||
int signaturesSize;
|
int signaturesSize;
|
||||||
} SignalData;
|
};
|
||||||
|
|
||||||
static int signal_init(PyObject*, PyObject*, PyObject*);
|
static int signalTpInit(PyObject*, PyObject*, PyObject*);
|
||||||
static void signal_free(void*);
|
static void signalFree(void*);
|
||||||
static void signal_instance_free(void*);
|
static void signalInstanceFree(void*);
|
||||||
|
|
||||||
//methods
|
//methods
|
||||||
static PyObject* signal_instance_connect(PyObject*, PyObject*, PyObject*);
|
static PyObject* signalInstanceConnect(PyObject*, PyObject*, PyObject*);
|
||||||
static PyObject* signal_instance_disconnect(PyObject*, PyObject*);
|
static PyObject* signalInstanceDisconnect(PyObject*, PyObject*);
|
||||||
static PyObject* signal_instance_emit(PyObject*, PyObject*);
|
static PyObject* signalInstanceEmit(PyObject*, PyObject*);
|
||||||
static PyObject* signal_instance_get_item(PyObject*, PyObject*);
|
static PyObject* signalInstanceGetItem(PyObject*, PyObject*);
|
||||||
|
|
||||||
//aux
|
PyTypeObject PySideSignalType = {
|
||||||
static char* signal_build_signature(const char*, const char*);
|
|
||||||
static void signal_append_signature(SignalData*, char*);
|
|
||||||
static void signal_instance_initialize(PyObject*, PyObject*, SignalData*, PyObject *, int);
|
|
||||||
static char* signal_parse_signature(PyObject*);
|
|
||||||
static PyObject* signal_build_qt_compatible(const char*);
|
|
||||||
|
|
||||||
PyTypeObject Signal_Type = {
|
|
||||||
PyObject_HEAD_INIT(0)
|
PyObject_HEAD_INIT(0)
|
||||||
0, /*ob_size*/
|
0, /*ob_size*/
|
||||||
"PySide.QtCore."SIGNAL_CLASS_NAME, /*tp_name*/
|
"PySide.QtCore."SIGNAL_CLASS_NAME, /*tp_name*/
|
||||||
|
|
@ -100,10 +101,10 @@ PyTypeObject Signal_Type = {
|
||||||
0, /*tp_descr_get */
|
0, /*tp_descr_get */
|
||||||
0, /*tp_descr_set */
|
0, /*tp_descr_set */
|
||||||
0, /*tp_dictoffset */
|
0, /*tp_dictoffset */
|
||||||
signal_init, /*tp_init */
|
signalTpInit, /*tp_init */
|
||||||
0, /*tp_alloc */
|
0, /*tp_alloc */
|
||||||
PyType_GenericNew, /*tp_new */
|
PyType_GenericNew, /*tp_new */
|
||||||
signal_free, /*tp_free */
|
signalFree, /*tp_free */
|
||||||
0, /*tp_is_gc */
|
0, /*tp_is_gc */
|
||||||
0, /*tp_bases */
|
0, /*tp_bases */
|
||||||
0, /*tp_mro */
|
0, /*tp_mro */
|
||||||
|
|
@ -114,23 +115,23 @@ PyTypeObject Signal_Type = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static PyMethodDef SignalInstance_methods[] = {
|
static PyMethodDef SignalInstance_methods[] = {
|
||||||
{"connect", (PyCFunction)signal_instance_connect, METH_VARARGS|METH_KEYWORDS, 0},
|
{"connect", (PyCFunction)signalInstanceConnect, METH_VARARGS|METH_KEYWORDS, 0},
|
||||||
{"disconnect", signal_instance_disconnect, METH_VARARGS, 0},
|
{"disconnect", signalInstanceDisconnect, METH_VARARGS, 0},
|
||||||
{"emit", signal_instance_emit, METH_VARARGS, 0},
|
{"emit", signalInstanceEmit, METH_VARARGS, 0},
|
||||||
{0} /* Sentinel */
|
{0} /* Sentinel */
|
||||||
};
|
};
|
||||||
|
|
||||||
static PyMappingMethods SignalInstance_as_mapping = {
|
static PyMappingMethods SignalInstance_as_mapping = {
|
||||||
0,
|
0,
|
||||||
signal_instance_get_item,
|
signalInstanceGetItem,
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
PyTypeObject SignalInstance_Type = {
|
PyTypeObject PySideSignalInstanceType = {
|
||||||
PyObject_HEAD_INIT(0)
|
PyObject_HEAD_INIT(0)
|
||||||
0, /*ob_size*/
|
0, /*ob_size*/
|
||||||
"PySide.QtCore."SIGNAL_CLASS_NAME, /*tp_name*/
|
"PySide.QtCore."SIGNAL_CLASS_NAME, /*tp_name*/
|
||||||
sizeof(SignalInstanceData),/*tp_basicsize*/
|
sizeof(PySideSignalInstanceData),/*tp_basicsize*/
|
||||||
0, /*tp_itemsize*/
|
0, /*tp_itemsize*/
|
||||||
0, /*tp_dealloc*/
|
0, /*tp_dealloc*/
|
||||||
0, /*tp_print*/
|
0, /*tp_print*/
|
||||||
|
|
@ -166,7 +167,7 @@ PyTypeObject SignalInstance_Type = {
|
||||||
0, /*tp_init */
|
0, /*tp_init */
|
||||||
0, /*tp_alloc */
|
0, /*tp_alloc */
|
||||||
PyType_GenericNew, /*tp_new */
|
PyType_GenericNew, /*tp_new */
|
||||||
signal_instance_free, /*tp_free */
|
signalInstanceFree, /*tp_free */
|
||||||
0, /*tp_is_gc */
|
0, /*tp_is_gc */
|
||||||
0, /*tp_bases */
|
0, /*tp_bases */
|
||||||
0, /*tp_mro */
|
0, /*tp_mro */
|
||||||
|
|
@ -176,30 +177,153 @@ PyTypeObject SignalInstance_Type = {
|
||||||
0, /*tp_del */
|
0, /*tp_del */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int signalTpInit(PyObject* self, PyObject* args, PyObject* kwds)
|
||||||
void init_signal(PyObject* module)
|
|
||||||
{
|
{
|
||||||
if (PyType_Ready(&Signal_Type) < 0)
|
static PyObject *emptyTuple = 0;
|
||||||
return;
|
static const char *kwlist[] = {"name", 0};
|
||||||
|
char* argName = 0;
|
||||||
|
|
||||||
Py_INCREF(&Signal_Type);
|
if (emptyTuple == 0)
|
||||||
PyModule_AddObject(module, SIGNAL_CLASS_NAME, ((PyObject*)&Signal_Type));
|
emptyTuple = PyTuple_New(0);
|
||||||
|
|
||||||
if (PyType_Ready(&SignalInstance_Type) < 0)
|
if (!PyArg_ParseTupleAndKeywords(emptyTuple, kwds,
|
||||||
return;
|
"|s:QtCore."SIGNAL_CLASS_NAME, (char**) kwlist, &argName))
|
||||||
|
return 0;
|
||||||
|
|
||||||
Py_INCREF(&SignalInstance_Type);
|
bool tupledArgs = false;
|
||||||
|
SignalData *data = reinterpret_cast<SignalData*>(self);
|
||||||
|
if (argName) {
|
||||||
|
data->signalName = strdup(argName);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(Py_ssize_t i = 0, i_max = PyTuple_Size(args); i < i_max; i++) {
|
||||||
|
PyObject *arg = PyTuple_GET_ITEM(args, i);
|
||||||
|
if (PySequence_Check(arg) && !PyString_Check(arg)) {
|
||||||
|
tupledArgs = true;
|
||||||
|
PySide::signalAppendSignature(data, PySide::signalParseSignature(arg));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!tupledArgs)
|
||||||
|
PySide::signalAppendSignature(data, PySide::signalParseSignature(args));
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void signalFree(void *self)
|
||||||
} // extern "C"
|
|
||||||
|
|
||||||
|
|
||||||
PyObject* signal_instance_get_item(PyObject* self, PyObject* key)
|
|
||||||
{
|
{
|
||||||
SignalInstanceData* data = reinterpret_cast<SignalInstanceData*>(self);
|
PyObject *pySelf = reinterpret_cast<PyObject*>(self);
|
||||||
char* sigKey = signal_parse_signature(key);
|
SignalData *data = reinterpret_cast<SignalData*>(self);
|
||||||
char* sig = signal_build_signature(data->signalName, sigKey);
|
|
||||||
|
for(int i = 0, i_max = data->signaturesSize; i < i_max; i++) {
|
||||||
|
if (data->signatures[i])
|
||||||
|
free(data->signatures[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(data->signatures);
|
||||||
|
free(data->signalName);
|
||||||
|
data->initialized = 0;
|
||||||
|
data->signaturesSize = 0;
|
||||||
|
|
||||||
|
pySelf->ob_type->tp_base->tp_free(self);
|
||||||
|
}
|
||||||
|
|
||||||
|
void signalInstanceFree(void* self)
|
||||||
|
{
|
||||||
|
PyObject *pySelf = reinterpret_cast<PyObject*>(self);
|
||||||
|
PySideSignalInstanceData *data = reinterpret_cast<PySideSignalInstanceData*>(self);
|
||||||
|
|
||||||
|
free(data->signalName);
|
||||||
|
free(data->signature);
|
||||||
|
|
||||||
|
if (data->next) {
|
||||||
|
Py_XDECREF(data->next);
|
||||||
|
data->next = 0;
|
||||||
|
}
|
||||||
|
pySelf->ob_type->tp_base->tp_free(self);
|
||||||
|
}
|
||||||
|
|
||||||
|
PyObject* signalInstanceConnect(PyObject* self, PyObject* args, PyObject* kwds)
|
||||||
|
{
|
||||||
|
PyObject *slot = 0;
|
||||||
|
PyObject *type = 0;
|
||||||
|
static const char *kwlist[] = {"slot", "type", 0};
|
||||||
|
|
||||||
|
if (!PyArg_ParseTupleAndKeywords(args, kwds,
|
||||||
|
"O|O:"SIGNAL_CLASS_NAME, (char**) kwlist, &slot, &type))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
PySideSignalInstanceData *source = reinterpret_cast<PySideSignalInstanceData*>(self);
|
||||||
|
Shiboken::AutoDecRef pyArgs(PyList_New(0));
|
||||||
|
|
||||||
|
bool match = false;
|
||||||
|
if (slot->ob_type == &PySideSignalInstanceType) {
|
||||||
|
PySideSignalInstanceData *sourceWalk = source;
|
||||||
|
PySideSignalInstanceData *targetWalk;
|
||||||
|
|
||||||
|
//find best match
|
||||||
|
while(sourceWalk && !match) {
|
||||||
|
targetWalk = reinterpret_cast<PySideSignalInstanceData*>(slot);
|
||||||
|
while(targetWalk && !match) {
|
||||||
|
if (QMetaObject::checkConnectArgs(sourceWalk->signature, targetWalk->signature)) {
|
||||||
|
PyList_Append(pyArgs, sourceWalk->source);
|
||||||
|
Shiboken::AutoDecRef sourceSignature(PySide::signalBuildQtCompatible(sourceWalk->signature));
|
||||||
|
PyList_Append(pyArgs, sourceSignature);
|
||||||
|
|
||||||
|
PyList_Append(pyArgs, targetWalk->source);
|
||||||
|
Shiboken::AutoDecRef targetSignature(PySide::signalBuildQtCompatible(targetWalk->signature));
|
||||||
|
PyList_Append(pyArgs, targetSignature);
|
||||||
|
|
||||||
|
match = true;
|
||||||
|
}
|
||||||
|
targetWalk = reinterpret_cast<PySideSignalInstanceData*>(targetWalk->next);
|
||||||
|
}
|
||||||
|
sourceWalk = reinterpret_cast<PySideSignalInstanceData*>(sourceWalk->next);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//try the first signature
|
||||||
|
PyList_Append(pyArgs, source->source);
|
||||||
|
Shiboken::AutoDecRef signature(PySide::signalBuildQtCompatible(source->signature));
|
||||||
|
PyList_Append(pyArgs, signature);
|
||||||
|
|
||||||
|
PyList_Append(pyArgs, slot);
|
||||||
|
match = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type)
|
||||||
|
PyList_Append(pyArgs, type);
|
||||||
|
|
||||||
|
if (match) {
|
||||||
|
Shiboken::AutoDecRef tupleArgs(PyList_AsTuple(pyArgs));
|
||||||
|
Shiboken::AutoDecRef pyMethod(PyObject_GetAttrString(source->source, "connect"));
|
||||||
|
return PyObject_CallObject(pyMethod, tupleArgs);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
PyObject* signalInstanceEmit(PyObject* self, PyObject* args)
|
||||||
|
{
|
||||||
|
PySideSignalInstanceData *source = reinterpret_cast<PySideSignalInstanceData*>(self);
|
||||||
|
|
||||||
|
Shiboken::AutoDecRef pyArgs(PyList_New(0));
|
||||||
|
Shiboken::AutoDecRef sourceSignature(PySide::signalBuildQtCompatible(source->signature));
|
||||||
|
|
||||||
|
PyList_Append(pyArgs, sourceSignature);
|
||||||
|
for(Py_ssize_t i = 0, max = PyTuple_Size(args); i < max; i++)
|
||||||
|
PyList_Append(pyArgs, PyTuple_GetItem(args, i));
|
||||||
|
|
||||||
|
Shiboken::AutoDecRef pyMethod(PyObject_GetAttrString(source->source, "emit"));
|
||||||
|
|
||||||
|
Shiboken::AutoDecRef tupleArgs(PyList_AsTuple(pyArgs));
|
||||||
|
return PyObject_CallObject(pyMethod, tupleArgs);
|
||||||
|
}
|
||||||
|
|
||||||
|
PyObject* signalInstanceGetItem(PyObject* self, PyObject* key)
|
||||||
|
{
|
||||||
|
PySideSignalInstanceData* data = reinterpret_cast<PySideSignalInstanceData*>(self);
|
||||||
|
char* sigKey = PySide::signalParseSignature(key);
|
||||||
|
char* sig = PySide::signalBuildSignature(data->signalName, sigKey);
|
||||||
free(sigKey);
|
free(sigKey);
|
||||||
const char* sigName = data->signalName;
|
const char* sigName = data->signalName;
|
||||||
|
|
||||||
|
|
@ -210,7 +334,7 @@ PyObject* signal_instance_get_item(PyObject* self, PyObject* key)
|
||||||
Py_INCREF(result);
|
Py_INCREF(result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
data = reinterpret_cast<SignalInstanceData*>(data->next);
|
data = reinterpret_cast<PySideSignalInstanceData*>(data->next);
|
||||||
}
|
}
|
||||||
PyErr_Format(PyExc_IndexError, "Signature %s not found for signal: %s", sig, sigName);
|
PyErr_Format(PyExc_IndexError, "Signature %s not found for signal: %s", sig, sigName);
|
||||||
free(sig);
|
free(sig);
|
||||||
|
|
@ -218,6 +342,68 @@ PyObject* signal_instance_get_item(PyObject* self, PyObject* key)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PyObject* signalInstanceDisconnect(PyObject* self, PyObject* args)
|
||||||
|
{
|
||||||
|
PySideSignalInstanceData *source = reinterpret_cast<PySideSignalInstanceData*>(self);
|
||||||
|
Shiboken::AutoDecRef pyArgs(PyList_New(0));
|
||||||
|
|
||||||
|
PyObject *slot;
|
||||||
|
if PyTuple_Check(args)
|
||||||
|
slot = PyTuple_GET_ITEM(args, 0);
|
||||||
|
else
|
||||||
|
slot = args;
|
||||||
|
|
||||||
|
bool match = false;
|
||||||
|
if (slot->ob_type == &PySideSignalInstanceType) {
|
||||||
|
PySideSignalInstanceData *target = reinterpret_cast<PySideSignalInstanceData*>(slot);
|
||||||
|
if (QMetaObject::checkConnectArgs(source->signature, target->signature)) {
|
||||||
|
PyList_Append(pyArgs, source->source);
|
||||||
|
Shiboken::AutoDecRef source_signature(PySide::signalBuildQtCompatible(source->signature));
|
||||||
|
PyList_Append(pyArgs, source_signature);
|
||||||
|
|
||||||
|
PyList_Append(pyArgs, target->source);
|
||||||
|
Shiboken::AutoDecRef target_signature(PySide::signalBuildQtCompatible(target->signature));
|
||||||
|
PyList_Append(pyArgs, target_signature);
|
||||||
|
match = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//try the first signature
|
||||||
|
PyList_Append(pyArgs, source->source);
|
||||||
|
Shiboken::AutoDecRef signature(PySide::signalBuildQtCompatible(source->signature));
|
||||||
|
PyList_Append(pyArgs, signature);
|
||||||
|
|
||||||
|
PyList_Append(pyArgs, slot);
|
||||||
|
match = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match) {
|
||||||
|
Shiboken::AutoDecRef tupleArgs(PyList_AsTuple(pyArgs));
|
||||||
|
Shiboken::AutoDecRef pyMethod(PyObject_GetAttrString(source->source, "disconnect"));
|
||||||
|
return PyObject_CallObject(pyMethod, tupleArgs);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // extern "C"
|
||||||
|
|
||||||
|
namespace PySide
|
||||||
|
{
|
||||||
|
|
||||||
|
void initSignalSupport(PyObject* module)
|
||||||
|
{
|
||||||
|
if (PyType_Ready(&PySideSignalType) < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Py_INCREF(&PySideSignalType);
|
||||||
|
PyModule_AddObject(module, SIGNAL_CLASS_NAME, ((PyObject*)&PySideSignalType));
|
||||||
|
|
||||||
|
if (PyType_Ready(&PySideSignalInstanceType) < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Py_INCREF(&PySideSignalInstanceType);
|
||||||
|
}
|
||||||
|
|
||||||
void signalUpdateSource(PyObject* source)
|
void signalUpdateSource(PyObject* source)
|
||||||
{
|
{
|
||||||
Shiboken::AutoDecRef attrs(PyObject_Dir(source));
|
Shiboken::AutoDecRef attrs(PyObject_Dir(source));
|
||||||
|
|
@ -225,15 +411,15 @@ void signalUpdateSource(PyObject* source)
|
||||||
for(int i = 0, iMax = PyList_GET_SIZE(attrs.object()); i < iMax; ++i) {
|
for(int i = 0, iMax = PyList_GET_SIZE(attrs.object()); i < iMax; ++i) {
|
||||||
PyObject *attrName = PyList_GET_ITEM(attrs.object(), i);
|
PyObject *attrName = PyList_GET_ITEM(attrs.object(), i);
|
||||||
Shiboken::AutoDecRef attr(PyObject_GetAttr(reinterpret_cast<PyObject*>(source->ob_type), attrName));
|
Shiboken::AutoDecRef attr(PyObject_GetAttr(reinterpret_cast<PyObject*>(source->ob_type), attrName));
|
||||||
if (!attr.isNull() && attr->ob_type == &Signal_Type) {
|
if (!attr.isNull() && attr->ob_type == &PySideSignalType) {
|
||||||
Shiboken::AutoDecRef signalInstance((PyObject*)PyObject_New(SignalInstanceData, &SignalInstance_Type));
|
Shiboken::AutoDecRef signalInstance((PyObject*)PyObject_New(PySideSignalInstanceData, &PySideSignalInstanceType));
|
||||||
signal_instance_initialize(signalInstance, attrName, reinterpret_cast<SignalData*>(attr.object()), source, 0);
|
signalInstanceInitialize(signalInstance, attrName, reinterpret_cast<SignalData*>(attr.object()), source, 0);
|
||||||
PyObject_SetAttr(source, attrName, signalInstance);
|
PyObject_SetAttr(source, attrName, signalInstance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char* get_type_name(PyObject* type)
|
char* getTypeName(PyObject* type)
|
||||||
{
|
{
|
||||||
if (PyType_Check(type)) {
|
if (PyType_Check(type)) {
|
||||||
char *typeName = NULL;
|
char *typeName = NULL;
|
||||||
|
|
@ -264,22 +450,22 @@ char* get_type_name(PyObject* type)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* signal_build_signature(const char *name, const char *signature)
|
char* signalBuildSignature(const char *name, const char *signature)
|
||||||
{
|
{
|
||||||
QString signal;
|
QString signal;
|
||||||
signal.sprintf("%s(%s)", name, signature);
|
signal.sprintf("%s(%s)", name, signature);
|
||||||
return strdup(QMetaObject::normalizedSignature(signal.toAscii()));
|
return strdup(QMetaObject::normalizedSignature(signal.toAscii()));
|
||||||
}
|
}
|
||||||
|
|
||||||
char* signal_parse_signature(PyObject *args)
|
char* signalParseSignature(PyObject *args)
|
||||||
{
|
{
|
||||||
char *signature = 0;
|
char *signature = 0;
|
||||||
if (args && (PyString_Check(args) || (!PySequence_Check(args) && (args != Py_None))))
|
if (args && (PyString_Check(args) || (!PySequence_Check(args) && (args != Py_None))))
|
||||||
return get_type_name(args);
|
return getTypeName(args);
|
||||||
|
|
||||||
for(Py_ssize_t i = 0, i_max = PySequence_Size(args); i < i_max; i++) {
|
for(Py_ssize_t i = 0, i_max = PySequence_Size(args); i < i_max; i++) {
|
||||||
Shiboken::AutoDecRef arg(PySequence_ITEM(args, i));
|
Shiboken::AutoDecRef arg(PySequence_ITEM(args, i));
|
||||||
char* typeName = get_type_name(arg);
|
char* typeName = getTypeName(arg);
|
||||||
if (typeName) {
|
if (typeName) {
|
||||||
if (signature) {
|
if (signature) {
|
||||||
signature = reinterpret_cast<char*>(realloc(signature, (strlen(signature) + 1 + strlen(typeName)) * sizeof(char*)));
|
signature = reinterpret_cast<char*>(realloc(signature, (strlen(signature) + 1 + strlen(typeName)) * sizeof(char*)));
|
||||||
|
|
@ -294,7 +480,7 @@ char* signal_parse_signature(PyObject *args)
|
||||||
return signature;
|
return signature;
|
||||||
}
|
}
|
||||||
|
|
||||||
void signal_append_signature(SignalData* self, char* signature)
|
void signalAppendSignature(SignalData* self, char* signature)
|
||||||
{
|
{
|
||||||
self->signaturesSize++;
|
self->signaturesSize++;
|
||||||
|
|
||||||
|
|
@ -306,75 +492,9 @@ void signal_append_signature(SignalData* self, char* signature)
|
||||||
self->signatures[self->signaturesSize-1] = signature;
|
self->signatures[self->signaturesSize-1] = signature;
|
||||||
}
|
}
|
||||||
|
|
||||||
int signal_init(PyObject* self, PyObject* args, PyObject* kwds)
|
void signalInstanceInitialize(PyObject* instance, PyObject* name, SignalData* data, PyObject* source, int index)
|
||||||
{
|
{
|
||||||
static PyObject *emptyTuple = 0;
|
PySideSignalInstanceData *self = reinterpret_cast<PySideSignalInstanceData*>(instance);
|
||||||
static const char *kwlist[] = {"name", 0};
|
|
||||||
char* argName = 0;
|
|
||||||
|
|
||||||
if (emptyTuple == 0)
|
|
||||||
emptyTuple = PyTuple_New(0);
|
|
||||||
|
|
||||||
if (!PyArg_ParseTupleAndKeywords(emptyTuple, kwds,
|
|
||||||
"|s:QtCore."SIGNAL_CLASS_NAME, (char**) kwlist, &argName))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
bool tupledArgs = false;
|
|
||||||
SignalData *data = reinterpret_cast<SignalData*>(self);
|
|
||||||
if (argName) {
|
|
||||||
data->signalName = strdup(argName);
|
|
||||||
}
|
|
||||||
|
|
||||||
for(Py_ssize_t i = 0, i_max = PyTuple_Size(args); i < i_max; i++) {
|
|
||||||
PyObject *arg = PyTuple_GET_ITEM(args, i);
|
|
||||||
if (PySequence_Check(arg) && !PyString_Check(arg)) {
|
|
||||||
tupledArgs = true;
|
|
||||||
signal_append_signature(data, signal_parse_signature(arg));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!tupledArgs)
|
|
||||||
signal_append_signature(data, signal_parse_signature(args));
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void signal_free(void *self)
|
|
||||||
{
|
|
||||||
PyObject *pySelf = reinterpret_cast<PyObject*>(self);
|
|
||||||
SignalData *data = reinterpret_cast<SignalData*>(self);
|
|
||||||
|
|
||||||
for(int i = 0, i_max = data->signaturesSize; i < i_max; i++) {
|
|
||||||
if (data->signatures[i])
|
|
||||||
free(data->signatures[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
free(data->signatures);
|
|
||||||
free(data->signalName);
|
|
||||||
data->initialized = 0;
|
|
||||||
data->signaturesSize = 0;
|
|
||||||
|
|
||||||
pySelf->ob_type->tp_base->tp_free(self);
|
|
||||||
}
|
|
||||||
|
|
||||||
void signal_instance_free(void* self)
|
|
||||||
{
|
|
||||||
PyObject *pySelf = reinterpret_cast<PyObject*>(self);
|
|
||||||
SignalInstanceData *data = reinterpret_cast<SignalInstanceData*>(self);
|
|
||||||
|
|
||||||
free(data->signalName);
|
|
||||||
free(data->signature);
|
|
||||||
|
|
||||||
if (data->next) {
|
|
||||||
Py_XDECREF(data->next);
|
|
||||||
data->next = 0;
|
|
||||||
}
|
|
||||||
pySelf->ob_type->tp_base->tp_free(self);
|
|
||||||
}
|
|
||||||
|
|
||||||
void signal_instance_initialize(PyObject* instance, PyObject* name, SignalData* data, PyObject* source, int index)
|
|
||||||
{
|
|
||||||
SignalInstanceData *self = reinterpret_cast<SignalInstanceData*>(instance);
|
|
||||||
self->next = 0;
|
self->next = 0;
|
||||||
if (data->signalName)
|
if (data->signalName)
|
||||||
self->signalName = strdup(data->signalName);
|
self->signalName = strdup(data->signalName);
|
||||||
|
|
@ -382,75 +502,16 @@ void signal_instance_initialize(PyObject* instance, PyObject* name, SignalData*
|
||||||
self->signalName = strdup(PyString_AsString(name));
|
self->signalName = strdup(PyString_AsString(name));
|
||||||
|
|
||||||
self->source = source;
|
self->source = source;
|
||||||
self->signature = signal_build_signature(self->signalName, data->signatures[index]);
|
self->signature = signalBuildSignature(self->signalName, data->signatures[index]);
|
||||||
index++;
|
index++;
|
||||||
|
|
||||||
if (index < data->signaturesSize) {
|
if (index < data->signaturesSize) {
|
||||||
self->next = reinterpret_cast<PyObject*>(PyObject_New(SignalInstanceData, &SignalInstance_Type));
|
self->next = reinterpret_cast<PyObject*>(PyObject_New(PySideSignalInstanceData, &PySideSignalInstanceType));
|
||||||
signal_instance_initialize(self->next, name, data, source, index);
|
signalInstanceInitialize(self->next, name, data, source, index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject* signal_instance_connect(PyObject* self, PyObject* args, PyObject* kwds)
|
bool signalConnect(PyObject* source, const char* signal, PyObject* callback)
|
||||||
{
|
|
||||||
PyObject *slot = 0;
|
|
||||||
PyObject *type = 0;
|
|
||||||
static const char *kwlist[] = {"slot", "type", 0};
|
|
||||||
|
|
||||||
if (!PyArg_ParseTupleAndKeywords(args, kwds,
|
|
||||||
"O|O:"SIGNAL_CLASS_NAME, (char**) kwlist, &slot, &type))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
SignalInstanceData *source = reinterpret_cast<SignalInstanceData*>(self);
|
|
||||||
Shiboken::AutoDecRef pyArgs(PyList_New(0));
|
|
||||||
|
|
||||||
bool match = false;
|
|
||||||
if (slot->ob_type == &SignalInstance_Type) {
|
|
||||||
SignalInstanceData *sourceWalk = source;
|
|
||||||
SignalInstanceData *targetWalk;
|
|
||||||
|
|
||||||
//find best match
|
|
||||||
while(sourceWalk && !match) {
|
|
||||||
targetWalk = reinterpret_cast<SignalInstanceData*>(slot);
|
|
||||||
while(targetWalk && !match) {
|
|
||||||
if (QMetaObject::checkConnectArgs(sourceWalk->signature, targetWalk->signature)) {
|
|
||||||
PyList_Append(pyArgs, sourceWalk->source);
|
|
||||||
Shiboken::AutoDecRef sourceSignature(signal_build_qt_compatible(sourceWalk->signature));
|
|
||||||
PyList_Append(pyArgs, sourceSignature);
|
|
||||||
|
|
||||||
PyList_Append(pyArgs, targetWalk->source);
|
|
||||||
Shiboken::AutoDecRef targetSignature(signal_build_qt_compatible(targetWalk->signature));
|
|
||||||
PyList_Append(pyArgs, targetSignature);
|
|
||||||
|
|
||||||
match = true;
|
|
||||||
}
|
|
||||||
targetWalk = reinterpret_cast<SignalInstanceData*>(targetWalk->next);
|
|
||||||
}
|
|
||||||
sourceWalk = reinterpret_cast<SignalInstanceData*>(sourceWalk->next);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//try the first signature
|
|
||||||
PyList_Append(pyArgs, source->source);
|
|
||||||
Shiboken::AutoDecRef signature(signal_build_qt_compatible(source->signature));
|
|
||||||
PyList_Append(pyArgs, signature);
|
|
||||||
|
|
||||||
PyList_Append(pyArgs, slot);
|
|
||||||
match = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type)
|
|
||||||
PyList_Append(pyArgs, type);
|
|
||||||
|
|
||||||
if (match) {
|
|
||||||
Shiboken::AutoDecRef tupleArgs(PyList_AsTuple(pyArgs));
|
|
||||||
Shiboken::AutoDecRef pyMethod(PyObject_GetAttrString(source->source, "connect"));
|
|
||||||
return PyObject_CallObject(pyMethod, tupleArgs);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool signal_connect(PyObject* source, const char* signal, PyObject* callback)
|
|
||||||
{
|
{
|
||||||
Shiboken::AutoDecRef pyMethod(PyObject_GetAttrString(source, "connect"));
|
Shiboken::AutoDecRef pyMethod(PyObject_GetAttrString(source, "connect"));
|
||||||
if (pyMethod.isNull())
|
if (pyMethod.isNull())
|
||||||
|
|
@ -461,71 +522,11 @@ bool signal_connect(PyObject* source, const char* signal, PyObject* callback)
|
||||||
return PyObject_CallObject(pyMethod, pyArgs);
|
return PyObject_CallObject(pyMethod, pyArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject* signal_instance_disconnect(PyObject* self, PyObject* args)
|
|
||||||
{
|
|
||||||
SignalInstanceData *source = reinterpret_cast<SignalInstanceData*>(self);
|
|
||||||
Shiboken::AutoDecRef pyArgs(PyList_New(0));
|
|
||||||
|
|
||||||
PyObject *slot;
|
|
||||||
if PyTuple_Check(args)
|
|
||||||
slot = PyTuple_GET_ITEM(args, 0);
|
|
||||||
else
|
|
||||||
slot = args;
|
|
||||||
|
|
||||||
bool match = false;
|
|
||||||
if (slot->ob_type == &SignalInstance_Type) {
|
|
||||||
SignalInstanceData *target = reinterpret_cast<SignalInstanceData*>(slot);
|
|
||||||
if (QMetaObject::checkConnectArgs(source->signature, target->signature)) {
|
|
||||||
PyList_Append(pyArgs, source->source);
|
|
||||||
Shiboken::AutoDecRef source_signature(signal_build_qt_compatible(source->signature));
|
|
||||||
PyList_Append(pyArgs, source_signature);
|
|
||||||
|
|
||||||
PyList_Append(pyArgs, target->source);
|
|
||||||
Shiboken::AutoDecRef target_signature(signal_build_qt_compatible(target->signature));
|
|
||||||
PyList_Append(pyArgs, target_signature);
|
|
||||||
match = true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//try the first signature
|
|
||||||
PyList_Append(pyArgs, source->source);
|
|
||||||
Shiboken::AutoDecRef signature(signal_build_qt_compatible(source->signature));
|
|
||||||
PyList_Append(pyArgs, signature);
|
|
||||||
|
|
||||||
PyList_Append(pyArgs, slot);
|
|
||||||
match = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (match) {
|
|
||||||
Shiboken::AutoDecRef tupleArgs(PyList_AsTuple(pyArgs));
|
|
||||||
Shiboken::AutoDecRef pyMethod(PyObject_GetAttrString(source->source, "disconnect"));
|
|
||||||
return PyObject_CallObject(pyMethod, tupleArgs);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
PyObject* signal_instance_emit(PyObject* self, PyObject* args)
|
|
||||||
{
|
|
||||||
SignalInstanceData *source = reinterpret_cast<SignalInstanceData*>(self);
|
|
||||||
|
|
||||||
Shiboken::AutoDecRef pyArgs(PyList_New(0));
|
|
||||||
Shiboken::AutoDecRef source_signature(signal_build_qt_compatible(source->signature));
|
|
||||||
|
|
||||||
PyList_Append(pyArgs, source_signature);
|
|
||||||
for(Py_ssize_t i=0, i_max=PyTuple_Size(args); i < i_max; i++)
|
|
||||||
PyList_Append(pyArgs, PyTuple_GetItem(args, i));
|
|
||||||
|
|
||||||
Shiboken::AutoDecRef pyMethod(PyObject_GetAttrString(source->source, "emit"));
|
|
||||||
|
|
||||||
Shiboken::AutoDecRef tupleArgs(PyList_AsTuple(pyArgs));
|
|
||||||
return PyObject_CallObject(pyMethod, tupleArgs);
|
|
||||||
}
|
|
||||||
|
|
||||||
PyObject* signalNew(const char* name, ...)
|
PyObject* signalNew(const char* name, ...)
|
||||||
{
|
{
|
||||||
va_list listSignatures;
|
va_list listSignatures;
|
||||||
char* sig = 0;
|
char* sig = 0;
|
||||||
SignalData* self = PyObject_New(SignalData, &Signal_Type);
|
SignalData* self = PyObject_New(SignalData, &PySideSignalType);
|
||||||
self->signalName = strdup(name);
|
self->signalName = strdup(name);
|
||||||
self->signaturesSize = 0;
|
self->signaturesSize = 0;
|
||||||
self->signatures = 0;
|
self->signatures = 0;
|
||||||
|
|
@ -535,7 +536,7 @@ PyObject* signalNew(const char* name, ...)
|
||||||
sig = va_arg(listSignatures, char*);
|
sig = va_arg(listSignatures, char*);
|
||||||
|
|
||||||
while(sig != NULL) {
|
while(sig != NULL) {
|
||||||
signal_append_signature(self, strdup(sig));
|
signalAppendSignature(self, strdup(sig));
|
||||||
sig = va_arg(listSignatures, char*);
|
sig = va_arg(listSignatures, char*);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -545,7 +546,7 @@ PyObject* signalNew(const char* name, ...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PyObject* signal_build_qt_compatible(const char* signature)
|
PyObject* signalBuildQtCompatible(const char* signature)
|
||||||
{
|
{
|
||||||
char* qtSignature;
|
char* qtSignature;
|
||||||
qtSignature = reinterpret_cast<char*>(malloc(strlen(signature)+2));
|
qtSignature = reinterpret_cast<char*>(malloc(strlen(signature)+2));
|
||||||
|
|
|
||||||
|
|
@ -27,28 +27,25 @@
|
||||||
#include <Python.h>
|
#include <Python.h>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
namespace PySide
|
extern "C"
|
||||||
{
|
{
|
||||||
|
extern PYSIDE_API PyTypeObject PySideSignalInstanceType;
|
||||||
|
|
||||||
struct SignalInstanceData
|
struct PySideSignalInstanceData
|
||||||
{
|
{
|
||||||
PyObject_HEAD
|
PyObject_HEAD
|
||||||
char* signalName;
|
char* signalName;
|
||||||
char* signature;
|
char* signature;
|
||||||
PyObject* source;
|
PyObject* source;
|
||||||
PyObject* next;
|
PyObject* next;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
extern PYSIDE_API PyTypeObject Signal_Type;
|
|
||||||
extern PYSIDE_API PyTypeObject SignalInstance_Type;
|
|
||||||
}; //extern "C"
|
}; //extern "C"
|
||||||
|
|
||||||
|
namespace PySide
|
||||||
|
{
|
||||||
|
|
||||||
PYSIDE_API PyObject* signalNew(const char* name, ...);
|
PYSIDE_API PyObject* signalNew(const char* name, ...);
|
||||||
PYSIDE_API void signalUpdateSource(PyObject* source);
|
PYSIDE_API void signalUpdateSource(PyObject* source);
|
||||||
PYSIDE_API bool signal_connect(PyObject* source, const char* signal, PyObject* callback);
|
|
||||||
|
|
||||||
} //namespace PySide
|
} //namespace PySide
|
||||||
|
|
||||||
|
|
|
||||||
40
libpyside/qsignal_p.h
Normal file
40
libpyside/qsignal_p.h
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the PySide project.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
*
|
||||||
|
* Contact: PySide team <contact@pyside.org>
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PYSIDE_QSIGNAL_P_H
|
||||||
|
#define PYSIDE_QSIGNAL_P_H
|
||||||
|
|
||||||
|
#include <Python.h>
|
||||||
|
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
extern PyTypeObject PySideSignalType;
|
||||||
|
}; //extern "C"
|
||||||
|
|
||||||
|
namespace PySide
|
||||||
|
{
|
||||||
|
bool signalConnect(PyObject* source, const char* signal, PyObject* callback);
|
||||||
|
char* getTypeName(PyObject*);
|
||||||
|
void initSignalSupport(PyObject* module);
|
||||||
|
} //namespace PySide
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -21,9 +21,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <shiboken.h>
|
#include <shiboken.h>
|
||||||
#include "dynamicqmetaobject_p.h"
|
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include "dynamicqmetaobject_p.h"
|
||||||
|
#include "qsignal_p.h"
|
||||||
|
|
||||||
#define SLOT_DEC_NAME "Slot"
|
#define SLOT_DEC_NAME "Slot"
|
||||||
|
|
||||||
|
|
@ -41,10 +41,6 @@ extern "C"
|
||||||
static int slot_init(PyObject*, PyObject*, PyObject*);
|
static int slot_init(PyObject*, PyObject*, PyObject*);
|
||||||
static PyObject* slot_call(PyObject*, PyObject*, PyObject*);
|
static PyObject* slot_call(PyObject*, PyObject*, PyObject*);
|
||||||
|
|
||||||
//external qsignal.cpp
|
|
||||||
extern char* get_type_name(PyObject*);
|
|
||||||
|
|
||||||
|
|
||||||
// Class Definition -----------------------------------------------
|
// Class Definition -----------------------------------------------
|
||||||
static PyTypeObject Slot_Type = {
|
static PyTypeObject Slot_Type = {
|
||||||
PyObject_HEAD_INIT(NULL)
|
PyObject_HEAD_INIT(NULL)
|
||||||
|
|
@ -124,7 +120,7 @@ int slot_init(PyObject *self, PyObject *args, PyObject *kw)
|
||||||
SlotData *data = reinterpret_cast<SlotData*>(self);
|
SlotData *data = reinterpret_cast<SlotData*>(self);
|
||||||
for(Py_ssize_t i = 0, i_max = PyTuple_Size(args); i < i_max; i++) {
|
for(Py_ssize_t i = 0, i_max = PyTuple_Size(args); i < i_max; i++) {
|
||||||
PyObject *argType = PyTuple_GET_ITEM(args, i);
|
PyObject *argType = PyTuple_GET_ITEM(args, i);
|
||||||
char *typeName = get_type_name(argType);
|
char *typeName = PySide::getTypeName(argType);
|
||||||
if (typeName) {
|
if (typeName) {
|
||||||
if (data->args) {
|
if (data->args) {
|
||||||
data->args = reinterpret_cast<char*>(realloc(data->args, (strlen(data->args) + 1 + strlen(typeName)) * sizeof(char*)));
|
data->args = reinterpret_cast<char*>(realloc(data->args, (strlen(data->args) + 1 + strlen(typeName)) * sizeof(char*)));
|
||||||
|
|
@ -141,7 +137,7 @@ int slot_init(PyObject *self, PyObject *args, PyObject *kw)
|
||||||
data->slotName = strdup(argName);
|
data->slotName = strdup(argName);
|
||||||
|
|
||||||
if (argResult)
|
if (argResult)
|
||||||
data->resultType = get_type_name(argResult);
|
data->resultType = PySide::getTypeName(argResult);
|
||||||
else
|
else
|
||||||
data->resultType = strdup("void");
|
data->resultType = strdup("void");
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue