Created Singal/Slot/Property namespace for pure C structures.
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org>
Lauro Neto <lauro.neto@openbossa.org>
This commit is contained in:
parent
62fd909705
commit
c7945787c5
16 changed files with 278 additions and 227 deletions
|
|
@ -34,7 +34,7 @@ int SbkQCoreApplication_Init(PyObject* self, PyObject* args, PyObject*)
|
||||||
sbkSelf->containsCppWrapper = 1;
|
sbkSelf->containsCppWrapper = 1;
|
||||||
sbkSelf->hasOwnership = 0;
|
sbkSelf->hasOwnership = 0;
|
||||||
Shiboken::BindingManager::instance().registerWrapper(sbkSelf, cptr);
|
Shiboken::BindingManager::instance().registerWrapper(sbkSelf, cptr);
|
||||||
PySide::signalUpdateSource(self);
|
PySide::Signal::updateSourceObject(self);
|
||||||
cptr->metaObject();
|
cptr->metaObject();
|
||||||
|
|
||||||
PySide::registerCleanupFunction(&PySide::destroyQCoreApplication);
|
PySide::registerCleanupFunction(&PySide::destroyQCoreApplication);
|
||||||
|
|
|
||||||
|
|
@ -1957,15 +1957,15 @@
|
||||||
timer->connect(timer, SIGNAL(timeout()), timer, SLOT(deleteLater()));
|
timer->connect(timer, SIGNAL(timeout()), timer, SLOT(deleteLater()));
|
||||||
|
|
||||||
if (PyObject_TypeCheck(%2, &PySideSignalInstanceType)) {
|
if (PyObject_TypeCheck(%2, &PySideSignalInstanceType)) {
|
||||||
PySideSignalInstanceData* signalInstance = reinterpret_cast<PySideSignalInstanceData*>(%2);
|
PySideSignalInstance* signalInstance = reinterpret_cast<PySideSignalInstance*>(%2);
|
||||||
Shiboken::AutoDecRef signalSignature(PyString_FromFormat("2%s", PySide::getSignalSignature(signalInstance)));
|
Shiboken::AutoDecRef signalSignature(PyString_FromFormat("2%s", PySide::Signal::getSignature(signalInstance)));
|
||||||
Shiboken::AutoDecRef result(
|
Shiboken::AutoDecRef result(
|
||||||
PyObject_CallMethod(pyTimer,
|
PyObject_CallMethod(pyTimer,
|
||||||
const_cast<char*>("connect"),
|
const_cast<char*>("connect"),
|
||||||
const_cast<char*>("OsOO"),
|
const_cast<char*>("OsOO"),
|
||||||
pyTimer,
|
pyTimer,
|
||||||
SIGNAL(timeout()),
|
SIGNAL(timeout()),
|
||||||
PySide::getSignalSource(signalInstance),
|
PySide::Signal::getObject(signalInstance),
|
||||||
signalSignature.object())
|
signalSignature.object())
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -2627,11 +2627,11 @@
|
||||||
</modify-argument>
|
</modify-argument>
|
||||||
<inject-code>
|
<inject-code>
|
||||||
if (PyObject_TypeCheck(%1, &PySideSignalInstanceType)) {
|
if (PyObject_TypeCheck(%1, &PySideSignalInstanceType)) {
|
||||||
PyObject* dataSource = PySide::getSignalSource((PySideSignalInstanceData*) %PYARG_1);
|
PyObject* dataSource = PySide::Signal::getObject((PySideSignalInstance*) %PYARG_1);
|
||||||
Shiboken::AutoDecRef obType(PyObject_Type(dataSource));
|
Shiboken::AutoDecRef obType(PyObject_Type(dataSource));
|
||||||
QObject* sender = %CONVERTTOCPP[QObject*](dataSource);
|
QObject* sender = %CONVERTTOCPP[QObject*](dataSource);
|
||||||
if (sender) {
|
if (sender) {
|
||||||
const char* dataSignature = PySide::getSignalSignature((PySideSignalInstanceData*) %PYARG_1);
|
const char* dataSignature = PySide::Signal::getSignature((PySideSignalInstance*) %PYARG_1);
|
||||||
QByteArray signature(dataSignature); // Append SIGNAL flag (2)
|
QByteArray signature(dataSignature); // Append SIGNAL flag (2)
|
||||||
%0 = new QSignalTransitionWrapper(sender, "2" + signature, %2);
|
%0 = new QSignalTransitionWrapper(sender, "2" + signature, %2);
|
||||||
}
|
}
|
||||||
|
|
@ -2681,9 +2681,9 @@
|
||||||
// http://bugs.openbossa.org/show_bug.cgi?id=362
|
// http://bugs.openbossa.org/show_bug.cgi?id=362
|
||||||
if (!PyObject_TypeCheck(%1, &PySideSignalInstanceType))
|
if (!PyObject_TypeCheck(%1, &PySideSignalInstanceType))
|
||||||
goto Sbk%TYPEFunc_%FUNCTION_NAME_TypeError;
|
goto Sbk%TYPEFunc_%FUNCTION_NAME_TypeError;
|
||||||
PySideSignalInstanceData* signalInstance = reinterpret_cast<PySideSignalInstanceData*>(%1);
|
PySideSignalInstance* signalInstance = reinterpret_cast<PySideSignalInstance*>(%1);
|
||||||
QObject* sender = %CONVERTTOCPP[QObject*](PySide::getSignalSource(signalInstance));
|
QObject* sender = %CONVERTTOCPP[QObject*](PySide::Signal::getObject(signalInstance));
|
||||||
%PYARG_0 = %CONVERTTOPYTHON[QSignalTransition*](%CPPSELF->%FUNCTION_NAME(sender, PySide::getSignalSignature(signalInstance), %2));
|
%PYARG_0 = %CONVERTTOPYTHON[QSignalTransition*](%CPPSELF->%FUNCTION_NAME(sender, PySide::Signal::getSignature(signalInstance), %2));
|
||||||
</inject-code>
|
</inject-code>
|
||||||
</add-function>
|
</add-function>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ int SbkQApplication_Init(PyObject* self, PyObject* args, PyObject*)
|
||||||
sbkSelf->containsCppWrapper = 1;
|
sbkSelf->containsCppWrapper = 1;
|
||||||
sbkSelf->hasOwnership = 0;
|
sbkSelf->hasOwnership = 0;
|
||||||
Shiboken::BindingManager::instance().registerWrapper(sbkSelf, cptr);
|
Shiboken::BindingManager::instance().registerWrapper(sbkSelf, cptr);
|
||||||
PySide::signalUpdateSource(self);
|
PySide::Signal::updateSourceObject(self);
|
||||||
cptr->metaObject();
|
cptr->metaObject();
|
||||||
|
|
||||||
// Verify if qApp is in main module
|
// Verify if qApp is in main module
|
||||||
|
|
|
||||||
|
|
@ -83,14 +83,14 @@
|
||||||
<access modifier="private"/>
|
<access modifier="private"/>
|
||||||
</modify-function>
|
</modify-function>
|
||||||
<inject-code class="target" position="end">
|
<inject-code class="target" position="end">
|
||||||
PyObject* signal_item;
|
PySideSignal* signal_item;
|
||||||
|
|
||||||
signal_item = PySide::signalNew("capabilitiesChanged", "void", NULL);
|
signal_item = PySide::Signal::newObject("capabilitiesChanged", "void", NULL);
|
||||||
PyDict_SetItemString(SbkPhonon_BackendCapabilities_NotifierWrapper_Type.super.ht_type.tp_dict, "capabilitiesChanged", signal_item);
|
PyDict_SetItemString(SbkPhonon_BackendCapabilities_NotifierWrapper_Type.super.ht_type.tp_dict, "capabilitiesChanged", (PyObject*)signal_item);
|
||||||
Py_DECREF(signal_item);
|
Py_DECREF(signal_item);
|
||||||
|
|
||||||
signal_item = PySide::signalNew("availableAudioOutputDevicesChanged", "void", NULL);
|
signal_item = PySide::Signal::newObject("availableAudioOutputDevicesChanged", "void", NULL);
|
||||||
PyDict_SetItemString( SbkPhonon_BackendCapabilities_NotifierWrapper_Type.super.ht_type.tp_dict, "availableAudioOutputDevicesChanged", signal_item);
|
PyDict_SetItemString( SbkPhonon_BackendCapabilities_NotifierWrapper_Type.super.ht_type.tp_dict, "availableAudioOutputDevicesChanged", (PyObject*)signal_item);
|
||||||
Py_DECREF(signal_item);
|
Py_DECREF(signal_item);
|
||||||
</inject-code>
|
</inject-code>
|
||||||
</object-type>
|
</object-type>
|
||||||
|
|
|
||||||
|
|
@ -161,39 +161,39 @@ uint PropertyData::flags() const
|
||||||
else if (!isQRealType(typeName))
|
else if (!isQRealType(typeName))
|
||||||
flags |= qvariant_nameToType(typeName) << 24;
|
flags |= qvariant_nameToType(typeName) << 24;
|
||||||
|
|
||||||
if (qpropertyIsReadable(m_data))
|
if (PySide::Property::isReadable(m_data))
|
||||||
flags |= Readable;
|
flags |= Readable;
|
||||||
|
|
||||||
if (qpropertyIsWritable(m_data))
|
if (PySide::Property::isWritable(m_data))
|
||||||
flags |= Writable;
|
flags |= Writable;
|
||||||
|
|
||||||
if (qpropertyHasReset(m_data))
|
if (PySide::Property::hasReset(m_data))
|
||||||
flags |= Resettable;
|
flags |= Resettable;
|
||||||
|
|
||||||
if (!qpropertyIsDesignable(m_data))
|
if (!PySide::Property::isDesignable(m_data))
|
||||||
flags |= ResolveDesignable;
|
flags |= ResolveDesignable;
|
||||||
else
|
else
|
||||||
flags |= Designable;
|
flags |= Designable;
|
||||||
|
|
||||||
if (!qpropertyIsScriptable(m_data))
|
if (!PySide::Property::isScriptable(m_data))
|
||||||
flags |= ResolveScriptable;
|
flags |= ResolveScriptable;
|
||||||
else
|
else
|
||||||
flags |= Scriptable;
|
flags |= Scriptable;
|
||||||
|
|
||||||
if (!qpropertyIsStored(m_data))
|
if (!PySide::Property::isStored(m_data))
|
||||||
flags |= ResolveStored;
|
flags |= ResolveStored;
|
||||||
else
|
else
|
||||||
flags |= Stored;
|
flags |= Stored;
|
||||||
|
|
||||||
if (!qpropertyIsUser(m_data))
|
if (!PySide::Property::isUser(m_data))
|
||||||
flags |= ResolveUser;
|
flags |= ResolveUser;
|
||||||
else
|
else
|
||||||
flags |= User;
|
flags |= User;
|
||||||
|
|
||||||
if (qpropertyIsConstant(m_data))
|
if (PySide::Property::isConstant(m_data))
|
||||||
flags |= Constant;
|
flags |= Constant;
|
||||||
|
|
||||||
if (qpropertyIsFinal(m_data))
|
if (PySide::Property::isFinal(m_data))
|
||||||
flags |= Final;
|
flags |= Final;
|
||||||
|
|
||||||
if (m_notifyId)
|
if (m_notifyId)
|
||||||
|
|
@ -253,14 +253,14 @@ PropertyData::PropertyData()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyData::PropertyData(const char* name, uint notifyId, PySideQProperty* data)
|
PropertyData::PropertyData(const char* name, uint notifyId, PySideProperty* data)
|
||||||
: m_name(name), m_notifyId(notifyId), m_data(data)
|
: m_name(name), m_notifyId(notifyId), m_data(data)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray PropertyData::type() const
|
QByteArray PropertyData::type() const
|
||||||
{
|
{
|
||||||
return QByteArray(qpropertyGetType(m_data));
|
return QByteArray(PySide::Property::getTypeName(m_data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -374,8 +374,8 @@ void DynamicQMetaObject::addProperty(const char* propertyName, PyObject* data)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// retrieve notifyId
|
// retrieve notifyId
|
||||||
PySideQProperty* property = reinterpret_cast<PySideQProperty*>(data);
|
PySideProperty* property = reinterpret_cast<PySideProperty*>(data);
|
||||||
const char* signalNotify = qpropertyGetNotify(property);
|
const char* signalNotify = PySide::Property::getNotifyName(property);
|
||||||
uint notifyId = 0;
|
uint notifyId = 0;
|
||||||
if (signalNotify) {
|
if (signalNotify) {
|
||||||
QByteArray signalSignature(signalNotify);
|
QByteArray signalSignature(signalNotify);
|
||||||
|
|
@ -409,18 +409,18 @@ DynamicQMetaObject* DynamicQMetaObject::createBasedOn(PyObject* pyObj, PyTypeObj
|
||||||
while (PyDict_Next(type->tp_dict, &pos, &key, &value)) {
|
while (PyDict_Next(type->tp_dict, &pos, &key, &value)) {
|
||||||
|
|
||||||
//Leave the properties to be register after signals because of notify object
|
//Leave the properties to be register after signals because of notify object
|
||||||
if (value->ob_type == &PySideQPropertyType)
|
if (value->ob_type == &PySidePropertyType)
|
||||||
properties.append(key);
|
properties.append(key);
|
||||||
|
|
||||||
//Register signals
|
//Register signals
|
||||||
if (value->ob_type == &PySideSignalType) {
|
if (value->ob_type == &PySideSignalType) {
|
||||||
PyObject *attr = PyObject_GetAttr(pyObj, key);
|
PyObject *attr = PyObject_GetAttr(pyObj, key);
|
||||||
PySideSignalInstanceData *data = reinterpret_cast<PySideSignalInstanceData*>(attr);
|
PySideSignalInstance *data = reinterpret_cast<PySideSignalInstance*>(attr);
|
||||||
while(data) {
|
while(data) {
|
||||||
int index = base->indexOfSignal(data->d->signature);
|
int index = base->indexOfSignal(data->d->signature);
|
||||||
if (index == -1)
|
if (index == -1)
|
||||||
mo->addSignal(data->d->signature);
|
mo->addSignal(data->d->signature);
|
||||||
data = reinterpret_cast<PySideSignalInstanceData*>(data->d->next);
|
data = reinterpret_cast<PySideSignalInstance*>(data->d->next);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
#define PYSIDE_SLOT_LIST_ATTR "_slots"
|
#define PYSIDE_SLOT_LIST_ATTR "_slots"
|
||||||
|
|
||||||
struct PySideQProperty;
|
struct PySideProperty;
|
||||||
namespace PySide
|
namespace PySide
|
||||||
{
|
{
|
||||||
class MethodData
|
class MethodData
|
||||||
|
|
@ -54,7 +54,7 @@ namespace PySide
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PropertyData();
|
PropertyData();
|
||||||
PropertyData(const char* name, uint notifyId=0, PySideQProperty* data = 0);
|
PropertyData(const char* name, uint notifyId=0, PySideProperty* data = 0);
|
||||||
QByteArray name() const;
|
QByteArray name() const;
|
||||||
QByteArray type() const;
|
QByteArray type() const;
|
||||||
uint flags() const;
|
uint flags() const;
|
||||||
|
|
@ -66,7 +66,7 @@ namespace PySide
|
||||||
private:
|
private:
|
||||||
QByteArray m_name;
|
QByteArray m_name;
|
||||||
uint m_notifyId;
|
uint m_notifyId;
|
||||||
PySideQProperty* m_data;
|
PySideProperty* m_data;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,9 +43,9 @@ namespace PySide
|
||||||
|
|
||||||
void init(PyObject *module)
|
void init(PyObject *module)
|
||||||
{
|
{
|
||||||
initSignalSupport(module);
|
Signal::init(module);
|
||||||
initSlotSupport(module);
|
Slot::init(module);
|
||||||
initQProperty(module);
|
Property::init(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.
|
||||||
SignalManager::instance();
|
SignalManager::instance();
|
||||||
}
|
}
|
||||||
|
|
@ -69,14 +69,14 @@ bool fillQtProperties(PyObject* qObj, const QMetaObject* metaObj, PyObject* kwds
|
||||||
Shiboken::AutoDecRef retval(PyObject_CallObject(propSetter, args));
|
Shiboken::AutoDecRef retval(PyObject_CallObject(propSetter, args));
|
||||||
} else {
|
} else {
|
||||||
PyObject* attr = PyObject_GenericGetAttr(qObj, key);
|
PyObject* attr = PyObject_GenericGetAttr(qObj, key);
|
||||||
if (isQPropertyType(attr))
|
if (PySide::Property::isPropertyType(attr))
|
||||||
PySide::qpropertySet(reinterpret_cast<PySideQProperty*>(attr), qObj, value);
|
PySide::Property::setValue(reinterpret_cast<PySideProperty*>(attr), qObj, value);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
propName.append("()");
|
propName.append("()");
|
||||||
if (metaObj->indexOfSignal(propName) != -1) {
|
if (metaObj->indexOfSignal(propName) != -1) {
|
||||||
propName.prepend('2');
|
propName.prepend('2');
|
||||||
PySide::signalConnect(qObj, propName, value);
|
PySide::Signal::connect(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;
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
|
|
||||||
struct PySideQPropertyPrivate {
|
struct PySidePropertyPrivate {
|
||||||
char* typeName;
|
char* typeName;
|
||||||
PyObject* type;
|
PyObject* type;
|
||||||
PyObject* fget;
|
PyObject* fget;
|
||||||
|
|
@ -56,11 +56,11 @@ struct PySideQPropertyPrivate {
|
||||||
static int qpropertyTpInit(PyObject*, PyObject*, PyObject*);
|
static int qpropertyTpInit(PyObject*, PyObject*, PyObject*);
|
||||||
static void qpropertyFree(void*);
|
static void qpropertyFree(void*);
|
||||||
|
|
||||||
PyTypeObject PySideQPropertyType = {
|
PyTypeObject PySidePropertyType = {
|
||||||
PyObject_HEAD_INIT(0)
|
PyObject_HEAD_INIT(0)
|
||||||
0, /*ob_size*/
|
0, /*ob_size*/
|
||||||
QPROPERTY_CLASS_NAME, /*tp_name*/
|
QPROPERTY_CLASS_NAME, /*tp_name*/
|
||||||
sizeof(PySideQProperty), /*tp_basicsize*/
|
sizeof(PySideProperty), /*tp_basicsize*/
|
||||||
0, /*tp_itemsize*/
|
0, /*tp_itemsize*/
|
||||||
0, /*tp_dealloc*/
|
0, /*tp_dealloc*/
|
||||||
0, /*tp_print*/
|
0, /*tp_print*/
|
||||||
|
|
@ -109,8 +109,8 @@ PyTypeObject PySideQPropertyType = {
|
||||||
int qpropertyTpInit(PyObject* self, PyObject* args, PyObject* kwds)
|
int qpropertyTpInit(PyObject* self, PyObject* args, PyObject* kwds)
|
||||||
{
|
{
|
||||||
PyObject* type = 0;
|
PyObject* type = 0;
|
||||||
PySideQProperty* data = reinterpret_cast<PySideQProperty*>(self);
|
PySideProperty* data = reinterpret_cast<PySideProperty*>(self);
|
||||||
PySideQPropertyPrivate* pData = (PySideQPropertyPrivate*) malloc(sizeof(PySideQPropertyPrivate));
|
PySidePropertyPrivate* pData = (PySidePropertyPrivate*) malloc(sizeof(PySidePropertyPrivate));
|
||||||
data->d = pData;
|
data->d = pData;
|
||||||
pData->fset = 0;
|
pData->fset = 0;
|
||||||
pData->fget = 0;
|
pData->fget = 0;
|
||||||
|
|
@ -139,14 +139,14 @@ int qpropertyTpInit(PyObject* self, PyObject* args, PyObject* kwds)
|
||||||
if (!pData->fset && pData->fget)
|
if (!pData->fset && pData->fget)
|
||||||
pData->constant = true;
|
pData->constant = true;
|
||||||
|
|
||||||
pData->typeName = PySide::getTypeName(type);
|
pData->typeName = PySide::Signal::getTypeName(type);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void qpropertyFree(void *self)
|
void qpropertyFree(void *self)
|
||||||
{
|
{
|
||||||
PyObject *pySelf = reinterpret_cast<PyObject*>(self);
|
PyObject *pySelf = reinterpret_cast<PyObject*>(self);
|
||||||
PySideQProperty *data = reinterpret_cast<PySideQProperty*>(self);
|
PySideProperty *data = reinterpret_cast<PySideProperty*>(self);
|
||||||
|
|
||||||
free(data->d->typeName);
|
free(data->d->typeName);
|
||||||
free(data->d->doc);
|
free(data->d->doc);
|
||||||
|
|
@ -159,27 +159,26 @@ void qpropertyFree(void *self)
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
|
|
||||||
|
|
||||||
namespace PySide
|
namespace PySide { namespace Property {
|
||||||
{
|
|
||||||
|
|
||||||
void initQProperty(PyObject* module)
|
void init(PyObject* module)
|
||||||
{
|
{
|
||||||
if (PyType_Ready(&PySideQPropertyType) < 0)
|
if (PyType_Ready(&PySidePropertyType) < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Py_INCREF(&PySideQPropertyType);
|
Py_INCREF(&PySidePropertyType);
|
||||||
PyModule_AddObject(module, QPROPERTY_CLASS_NAME, ((PyObject*)&PySideQPropertyType));
|
PyModule_AddObject(module, QPROPERTY_CLASS_NAME, ((PyObject*)&PySidePropertyType));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isQPropertyType(PyObject* pyObj)
|
bool isPropertyType(PyObject* pyObj)
|
||||||
{
|
{
|
||||||
if (pyObj) {
|
if (pyObj) {
|
||||||
return pyObj->ob_type == &PySideQPropertyType;
|
return pyObj->ob_type == &PySidePropertyType;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int qpropertySet(PySideQProperty* self, PyObject* source, PyObject* value)
|
int setValue(PySideProperty* self, PyObject* source, PyObject* value)
|
||||||
{
|
{
|
||||||
PyObject* fset = self->d->fset;
|
PyObject* fset = self->d->fset;
|
||||||
if (fset) {
|
if (fset) {
|
||||||
|
|
@ -196,7 +195,7 @@ int qpropertySet(PySideQProperty* self, PyObject* source, PyObject* value)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject* qpropertyGet(PySideQProperty* self, PyObject* source)
|
PyObject* getValue(PySideProperty* self, PyObject* source)
|
||||||
{
|
{
|
||||||
PyObject* fget = self->d->fget;
|
PyObject* fget = self->d->fget;
|
||||||
if (fget) {
|
if (fget) {
|
||||||
|
|
@ -208,7 +207,7 @@ PyObject* qpropertyGet(PySideQProperty* self, PyObject* source)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int qpropertyReset(PySideQProperty* self, PyObject* source)
|
int reset(PySideProperty* self, PyObject* source)
|
||||||
{
|
{
|
||||||
PyObject* freset = self->d->freset;
|
PyObject* freset = self->d->freset;
|
||||||
if (freset) {
|
if (freset) {
|
||||||
|
|
@ -222,16 +221,16 @@ int qpropertyReset(PySideQProperty* self, PyObject* source)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char* qpropertyGetType(PySideQProperty* self)
|
const char* getTypeName(const PySideProperty* self)
|
||||||
{
|
{
|
||||||
return self->d->typeName;
|
return self->d->typeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
PySideQProperty* qpropertyGetObject(PyObject* source, PyObject* name)
|
PySideProperty* getObject(PyObject* source, PyObject* name)
|
||||||
{
|
{
|
||||||
PyObject* attr = PyObject_GenericGetAttr(source, name);
|
PyObject* attr = PyObject_GenericGetAttr(source, name);
|
||||||
if (attr && isQPropertyType(attr))
|
if (attr && isPropertyType(attr))
|
||||||
return reinterpret_cast<PySideQProperty*>(attr);
|
return reinterpret_cast<PySideProperty*>(attr);
|
||||||
|
|
||||||
if (!attr)
|
if (!attr)
|
||||||
PyErr_Clear(); //Clear possible error caused by PyObject_GenericGetAttr
|
PyErr_Clear(); //Clear possible error caused by PyObject_GenericGetAttr
|
||||||
|
|
@ -240,52 +239,52 @@ PySideQProperty* qpropertyGetObject(PyObject* source, PyObject* name)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool qpropertyIsReadable(PySideQProperty* self)
|
bool isReadable(const PySideProperty* self)
|
||||||
{
|
{
|
||||||
return (self->d->fget != 0);
|
return (self->d->fget != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool qpropertyIsWritable(PySideQProperty* self)
|
bool isWritable(const PySideProperty* self)
|
||||||
{
|
{
|
||||||
return (self->d->fset != 0);
|
return (self->d->fset != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool qpropertyHasReset(PySideQProperty* self)
|
bool hasReset(const PySideProperty* self)
|
||||||
{
|
{
|
||||||
return (self->d->freset != 0);
|
return (self->d->freset != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool qpropertyIsDesignable(PySideQProperty* self)
|
bool isDesignable(const PySideProperty* self)
|
||||||
{
|
{
|
||||||
return self->d->designable;
|
return self->d->designable;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool qpropertyIsScriptable(PySideQProperty* self)
|
bool isScriptable(const PySideProperty* self)
|
||||||
{
|
{
|
||||||
return self->d->scriptable;
|
return self->d->scriptable;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool qpropertyIsStored(PySideQProperty* self)
|
bool isStored(const PySideProperty* self)
|
||||||
{
|
{
|
||||||
return self->d->stored;
|
return self->d->stored;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool qpropertyIsUser(PySideQProperty* self)
|
bool isUser(const PySideProperty* self)
|
||||||
{
|
{
|
||||||
return self->d->user;
|
return self->d->user;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool qpropertyIsConstant(PySideQProperty* self)
|
bool isConstant(const PySideProperty* self)
|
||||||
{
|
{
|
||||||
return self->d->constant;
|
return self->d->constant;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool qpropertyIsFinal(PySideQProperty* self)
|
bool isFinal(const PySideProperty* self)
|
||||||
{
|
{
|
||||||
return self->d->final;
|
return self->d->final;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* qpropertyGetNotify(PySideQProperty* self)
|
const char* getNotifyName(PySideProperty* self)
|
||||||
{
|
{
|
||||||
if (!self->d->notifySignature) {
|
if (!self->d->notifySignature) {
|
||||||
PyObject* str = PyObject_Str(self->d->notify);
|
PyObject* str = PyObject_Str(self->d->notify);
|
||||||
|
|
@ -296,4 +295,5 @@ const char* qpropertyGetNotify(PySideQProperty* self)
|
||||||
return self->d->notifySignature;
|
return self->d->notifySignature;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} //namespace Property
|
||||||
} //namespace PySide
|
} //namespace PySide
|
||||||
|
|
|
||||||
|
|
@ -29,22 +29,19 @@
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
extern PYSIDE_API PyTypeObject PySideQPropertyType;
|
extern PYSIDE_API PyTypeObject PySidePropertyType;
|
||||||
|
|
||||||
struct PySideQPropertyPrivate;
|
struct PySidePropertyPrivate;
|
||||||
struct PYSIDE_API PySideQProperty
|
struct PYSIDE_API PySideProperty
|
||||||
{
|
{
|
||||||
PyObject_HEAD
|
PyObject_HEAD
|
||||||
PySideQPropertyPrivate* d;
|
PySidePropertyPrivate* d;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PySideSignalInstanceData;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace PySide
|
namespace PySide { namespace Property {
|
||||||
{
|
|
||||||
|
|
||||||
PYSIDE_API bool isQPropertyType(PyObject* pyObj);
|
PYSIDE_API bool isPropertyType(PyObject* pyObj);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function call set property function and pass value as arg
|
* This function call set property function and pass value as arg
|
||||||
|
|
@ -55,7 +52,7 @@ PYSIDE_API bool isQPropertyType(PyObject* pyObj);
|
||||||
* @param value The value to set in property
|
* @param value The value to set in property
|
||||||
* @return Return 0 if ok or -1 if this function fail
|
* @return Return 0 if ok or -1 if this function fail
|
||||||
**/
|
**/
|
||||||
PYSIDE_API int qpropertySet(PySideQProperty* self, PyObject* source, PyObject* value);
|
PYSIDE_API int setValue(PySideProperty* self, PyObject* source, PyObject* value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function call get property function
|
* This function call get property function
|
||||||
|
|
@ -65,7 +62,7 @@ PYSIDE_API int qpropertySet(PySideQProperty* self, PyObject* source, PyObject* v
|
||||||
* @param source The QObject witch has the property
|
* @param source The QObject witch has the property
|
||||||
* @return Return the result of property get function or 0 if this fail
|
* @return Return the result of property get function or 0 if this fail
|
||||||
**/
|
**/
|
||||||
PYSIDE_API PyObject* qpropertyGet(PySideQProperty* self, PyObject* source);
|
PYSIDE_API PyObject* getValue(PySideProperty* self, PyObject* source);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function return the notify name used on this property
|
* This function return the notify name used on this property
|
||||||
|
|
@ -73,7 +70,7 @@ PYSIDE_API PyObject* qpropertyGet(PySideQProperty* self, PyObject* source);
|
||||||
* @param self The property object
|
* @param self The property object
|
||||||
* @return Return a const char with the notify name used
|
* @return Return a const char with the notify name used
|
||||||
**/
|
**/
|
||||||
PYSIDE_API const char* qpropertyGetNotify(PySideQProperty* self);
|
PYSIDE_API const char* getNotifyName(PySideProperty* self);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -83,8 +80,9 @@ PYSIDE_API const char* qpropertyGetNotify(PySideQProperty* self);
|
||||||
* @param name The property name
|
* @param name The property name
|
||||||
* @return Return a new reference to property object
|
* @return Return a new reference to property object
|
||||||
**/
|
**/
|
||||||
PYSIDE_API PySideQProperty* qpropertyGetObject(PyObject* source, PyObject* name);
|
PYSIDE_API PySideProperty* getObject(PyObject* source, PyObject* name);
|
||||||
|
|
||||||
|
} //namespace Property
|
||||||
} //namespace PySide
|
} //namespace PySide
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -25,15 +25,14 @@
|
||||||
|
|
||||||
#include <Python.h>
|
#include <Python.h>
|
||||||
|
|
||||||
struct PySideQProperty;
|
struct PySideProperty;
|
||||||
|
|
||||||
namespace PySide
|
namespace PySide { namespace Property {
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init PySide QProperty support system
|
* Init PySide QProperty support system
|
||||||
*/
|
*/
|
||||||
void initQProperty(PyObject* module);
|
void init(PyObject* module);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function call reset property function
|
* This function call reset property function
|
||||||
|
|
@ -43,7 +42,7 @@ void initQProperty(PyObject* module);
|
||||||
* @param source The QObject witch has the property
|
* @param source The QObject witch has the property
|
||||||
* @return Return 0 if ok or -1 if this function fail
|
* @return Return 0 if ok or -1 if this function fail
|
||||||
**/
|
**/
|
||||||
int qpropertyReset(PySideQProperty* self, PyObject* source);
|
int reset(PySideProperty* self, PyObject* source);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -53,7 +52,7 @@ int qpropertyReset(PySideQProperty* self, PyObject* source);
|
||||||
* @param self The property object
|
* @param self The property object
|
||||||
* @return Return the property type name
|
* @return Return the property type name
|
||||||
**/
|
**/
|
||||||
const char* qpropertyGetType(PySideQProperty* self);
|
const char* getTypeName(const PySideProperty* self);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function check if property has read function
|
* This function check if property has read function
|
||||||
|
|
@ -62,7 +61,7 @@ const char* qpropertyGetType(PySideQProperty* self);
|
||||||
* @param self The property object
|
* @param self The property object
|
||||||
* @return Return a boolean value
|
* @return Return a boolean value
|
||||||
**/
|
**/
|
||||||
bool qpropertyIsReadable(PySideQProperty* self);
|
bool isReadable(const PySideProperty* self);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function check if property has write function
|
* This function check if property has write function
|
||||||
|
|
@ -71,7 +70,7 @@ bool qpropertyIsReadable(PySideQProperty* self);
|
||||||
* @param self The property object
|
* @param self The property object
|
||||||
* @return Return a boolean value
|
* @return Return a boolean value
|
||||||
**/
|
**/
|
||||||
bool qpropertyIsWritable(PySideQProperty* self);
|
bool isWritable(const PySideProperty* self);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function check if property has reset function
|
* This function check if property has reset function
|
||||||
|
|
@ -80,7 +79,7 @@ bool qpropertyIsWritable(PySideQProperty* self);
|
||||||
* @param self The property object
|
* @param self The property object
|
||||||
* @return Return a boolean value
|
* @return Return a boolean value
|
||||||
**/
|
**/
|
||||||
bool qpropertyHasReset(PySideQProperty* self);
|
bool hasReset(const PySideProperty* self);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function check if property has the flag DESIGNABLE setted
|
* This function check if property has the flag DESIGNABLE setted
|
||||||
|
|
@ -89,7 +88,7 @@ bool qpropertyHasReset(PySideQProperty* self);
|
||||||
* @param self The property object
|
* @param self The property object
|
||||||
* @return Return a boolean value
|
* @return Return a boolean value
|
||||||
**/
|
**/
|
||||||
bool qpropertyIsDesignable(PySideQProperty* self);
|
bool isDesignable(const PySideProperty* self);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function check if property has the flag SCRIPTABLE setted
|
* This function check if property has the flag SCRIPTABLE setted
|
||||||
|
|
@ -98,7 +97,7 @@ bool qpropertyIsDesignable(PySideQProperty* self);
|
||||||
* @param self The property object
|
* @param self The property object
|
||||||
* @return Return a boolean value
|
* @return Return a boolean value
|
||||||
**/
|
**/
|
||||||
bool qpropertyIsScriptable(PySideQProperty* self);
|
bool isScriptable(const PySideProperty* self);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function check if property has the flag STORED setted
|
* This function check if property has the flag STORED setted
|
||||||
|
|
@ -107,7 +106,7 @@ bool qpropertyIsScriptable(PySideQProperty* self);
|
||||||
* @param self The property object
|
* @param self The property object
|
||||||
* @return Return a boolean value
|
* @return Return a boolean value
|
||||||
**/
|
**/
|
||||||
bool qpropertyIsStored(PySideQProperty* self);
|
bool isStored(const PySideProperty* self);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function check if property has the flag USER setted
|
* This function check if property has the flag USER setted
|
||||||
|
|
@ -116,7 +115,7 @@ bool qpropertyIsStored(PySideQProperty* self);
|
||||||
* @param self The property object
|
* @param self The property object
|
||||||
* @return Return a boolean value
|
* @return Return a boolean value
|
||||||
**/
|
**/
|
||||||
bool qpropertyIsUser(PySideQProperty* self);
|
bool isUser(const PySideProperty* self);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function check if property has the flag CONSTANT setted
|
* This function check if property has the flag CONSTANT setted
|
||||||
|
|
@ -125,7 +124,7 @@ bool qpropertyIsUser(PySideQProperty* self);
|
||||||
* @param self The property object
|
* @param self The property object
|
||||||
* @return Return a boolean value
|
* @return Return a boolean value
|
||||||
**/
|
**/
|
||||||
bool qpropertyIsConstant(PySideQProperty* self);
|
bool isConstant(const PySideProperty* self);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function check if property has the flag FINAL setted
|
* This function check if property has the flag FINAL setted
|
||||||
|
|
@ -134,8 +133,9 @@ bool qpropertyIsConstant(PySideQProperty* self);
|
||||||
* @param self The property object
|
* @param self The property object
|
||||||
* @return Return a boolean value
|
* @return Return a boolean value
|
||||||
**/
|
**/
|
||||||
bool qpropertyIsFinal(PySideQProperty* self);
|
bool isFinal(const PySideProperty* self);
|
||||||
|
|
||||||
|
} // namespace Property
|
||||||
} // namespace PySide
|
} // namespace PySide
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -31,16 +31,15 @@
|
||||||
#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 { namespace Signal {
|
||||||
{
|
|
||||||
//aux
|
//aux
|
||||||
static char* signalBuildSignature(const char*, const char*);
|
static char* buildSignature(const char*, const char*);
|
||||||
static void signalAppendSignature(SignalData*, char*);
|
static void appendSignature(PySideSignal*, char*);
|
||||||
static void signalInstanceInitialize(PySideSignalInstanceData*, PyObject*, SignalData*, PyObject *, int);
|
static void instanceInitialize(PySideSignalInstance*, PyObject*, PySideSignal*, PyObject *, int);
|
||||||
static char* signalParseSignature(PyObject*);
|
static char* parseSignature(PyObject*);
|
||||||
static PyObject* signalBuildQtCompatible(const char*);
|
static PyObject* buildQtCompatible(const char*);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
|
|
@ -73,7 +72,7 @@ PyTypeObject PySideSignalType = {
|
||||||
PyObject_HEAD_INIT(0)
|
PyObject_HEAD_INIT(0)
|
||||||
/*ob_size*/ 0,
|
/*ob_size*/ 0,
|
||||||
/*tp_name*/ "PySide.QtCore."SIGNAL_CLASS_NAME,
|
/*tp_name*/ "PySide.QtCore."SIGNAL_CLASS_NAME,
|
||||||
/*tp_basicsize*/ sizeof(SignalData),
|
/*tp_basicsize*/ sizeof(PySideSignal),
|
||||||
/*tp_itemsize*/ 0,
|
/*tp_itemsize*/ 0,
|
||||||
/*tp_dealloc*/ 0,
|
/*tp_dealloc*/ 0,
|
||||||
/*tp_print*/ 0,
|
/*tp_print*/ 0,
|
||||||
|
|
@ -136,7 +135,7 @@ PyTypeObject PySideSignalInstanceType = {
|
||||||
PyObject_HEAD_INIT(0)
|
PyObject_HEAD_INIT(0)
|
||||||
/*ob_size*/ 0,
|
/*ob_size*/ 0,
|
||||||
/*tp_name*/ "PySide.QtCore."SIGNAL_CLASS_NAME,
|
/*tp_name*/ "PySide.QtCore."SIGNAL_CLASS_NAME,
|
||||||
/*tp_basicsize*/ sizeof(PySideSignalInstanceData),
|
/*tp_basicsize*/ sizeof(PySideSignalInstance),
|
||||||
/*tp_itemsize*/ 0,
|
/*tp_itemsize*/ 0,
|
||||||
/*tp_dealloc*/ 0,
|
/*tp_dealloc*/ 0,
|
||||||
/*tp_print*/ 0,
|
/*tp_print*/ 0,
|
||||||
|
|
@ -196,7 +195,7 @@ int signalTpInit(PyObject* self, PyObject* args, PyObject* kwds)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
bool tupledArgs = false;
|
bool tupledArgs = false;
|
||||||
SignalData *data = reinterpret_cast<SignalData*>(self);
|
PySideSignal *data = reinterpret_cast<PySideSignal*>(self);
|
||||||
if (argName) {
|
if (argName) {
|
||||||
data->signalName = strdup(argName);
|
data->signalName = strdup(argName);
|
||||||
}
|
}
|
||||||
|
|
@ -205,12 +204,12 @@ int signalTpInit(PyObject* self, PyObject* args, PyObject* kwds)
|
||||||
PyObject *arg = PyTuple_GET_ITEM(args, i);
|
PyObject *arg = PyTuple_GET_ITEM(args, i);
|
||||||
if (PySequence_Check(arg) && !PyString_Check(arg)) {
|
if (PySequence_Check(arg) && !PyString_Check(arg)) {
|
||||||
tupledArgs = true;
|
tupledArgs = true;
|
||||||
PySide::signalAppendSignature(data, PySide::signalParseSignature(arg));
|
PySide::Signal::appendSignature(data, PySide::Signal::parseSignature(arg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tupledArgs)
|
if (!tupledArgs)
|
||||||
PySide::signalAppendSignature(data, PySide::signalParseSignature(args));
|
PySide::Signal::appendSignature(data, PySide::Signal::parseSignature(args));
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
@ -218,7 +217,7 @@ int signalTpInit(PyObject* self, PyObject* args, PyObject* kwds)
|
||||||
void signalFree(void *self)
|
void signalFree(void *self)
|
||||||
{
|
{
|
||||||
PyObject *pySelf = reinterpret_cast<PyObject*>(self);
|
PyObject *pySelf = reinterpret_cast<PyObject*>(self);
|
||||||
SignalData *data = reinterpret_cast<SignalData*>(self);
|
PySideSignal *data = reinterpret_cast<PySideSignal*>(self);
|
||||||
|
|
||||||
for(int i = 0, i_max = data->signaturesSize; i < i_max; i++) {
|
for(int i = 0, i_max = data->signaturesSize; i < i_max; i++) {
|
||||||
if (data->signatures[i])
|
if (data->signatures[i])
|
||||||
|
|
@ -237,17 +236,17 @@ void signalFree(void *self)
|
||||||
|
|
||||||
PyObject* signalGetItem(PyObject* self, PyObject* key)
|
PyObject* signalGetItem(PyObject* self, PyObject* key)
|
||||||
{
|
{
|
||||||
SignalData* data = reinterpret_cast<SignalData*>(self);
|
PySideSignal* data = reinterpret_cast<PySideSignal*>(self);
|
||||||
char* sigKey;
|
char* sigKey;
|
||||||
if (key) {
|
if (key) {
|
||||||
sigKey = PySide::signalParseSignature(key);
|
sigKey = PySide::Signal::parseSignature(key);
|
||||||
} else {
|
} else {
|
||||||
if (data->signatures[0])
|
if (data->signatures[0])
|
||||||
sigKey = strdup(data->signatures[0]);
|
sigKey = strdup(data->signatures[0]);
|
||||||
else
|
else
|
||||||
sigKey = strdup("void");
|
sigKey = strdup("void");
|
||||||
}
|
}
|
||||||
char* sig = PySide::signalBuildSignature(data->signalName, sigKey);
|
char* sig = PySide::Signal::buildSignature(data->signalName, sigKey);
|
||||||
free(sigKey);
|
free(sigKey);
|
||||||
PyObject* pySignature = PyString_FromString(sig);
|
PyObject* pySignature = PyString_FromString(sig);
|
||||||
free(sig);
|
free(sig);
|
||||||
|
|
@ -263,9 +262,9 @@ PyObject* signalToString(PyObject* self)
|
||||||
void signalInstanceFree(void* self)
|
void signalInstanceFree(void* self)
|
||||||
{
|
{
|
||||||
PyObject* pySelf = reinterpret_cast<PyObject*>(self);
|
PyObject* pySelf = reinterpret_cast<PyObject*>(self);
|
||||||
PySideSignalInstanceData* data = reinterpret_cast<PySideSignalInstanceData*>(self);
|
PySideSignalInstance* data = reinterpret_cast<PySideSignalInstance*>(self);
|
||||||
|
|
||||||
PySideSignalInstanceDataPrivate* dataPvt = data->d;
|
PySideSignalInstancePrivate* dataPvt = data->d;
|
||||||
free(dataPvt->signalName);
|
free(dataPvt->signalName);
|
||||||
free(dataPvt->signature);
|
free(dataPvt->signature);
|
||||||
|
|
||||||
|
|
@ -290,37 +289,37 @@ PyObject* signalInstanceConnect(PyObject* self, PyObject* args, PyObject* kwds)
|
||||||
"O|O:"SIGNAL_CLASS_NAME, (char**) kwlist, &slot, &type))
|
"O|O:"SIGNAL_CLASS_NAME, (char**) kwlist, &slot, &type))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
PySideSignalInstanceData *source = reinterpret_cast<PySideSignalInstanceData*>(self);
|
PySideSignalInstance *source = reinterpret_cast<PySideSignalInstance*>(self);
|
||||||
Shiboken::AutoDecRef pyArgs(PyList_New(0));
|
Shiboken::AutoDecRef pyArgs(PyList_New(0));
|
||||||
|
|
||||||
bool match = false;
|
bool match = false;
|
||||||
if (slot->ob_type == &PySideSignalInstanceType) {
|
if (slot->ob_type == &PySideSignalInstanceType) {
|
||||||
PySideSignalInstanceData *sourceWalk = source;
|
PySideSignalInstance *sourceWalk = source;
|
||||||
PySideSignalInstanceData *targetWalk;
|
PySideSignalInstance *targetWalk;
|
||||||
|
|
||||||
//find best match
|
//find best match
|
||||||
while(sourceWalk && !match) {
|
while(sourceWalk && !match) {
|
||||||
targetWalk = reinterpret_cast<PySideSignalInstanceData*>(slot);
|
targetWalk = reinterpret_cast<PySideSignalInstance*>(slot);
|
||||||
while(targetWalk && !match) {
|
while(targetWalk && !match) {
|
||||||
if (QMetaObject::checkConnectArgs(sourceWalk->d->signature, targetWalk->d->signature)) {
|
if (QMetaObject::checkConnectArgs(sourceWalk->d->signature, targetWalk->d->signature)) {
|
||||||
PyList_Append(pyArgs, sourceWalk->d->source);
|
PyList_Append(pyArgs, sourceWalk->d->source);
|
||||||
Shiboken::AutoDecRef sourceSignature(PySide::signalBuildQtCompatible(sourceWalk->d->signature));
|
Shiboken::AutoDecRef sourceSignature(PySide::Signal::buildQtCompatible(sourceWalk->d->signature));
|
||||||
PyList_Append(pyArgs, sourceSignature);
|
PyList_Append(pyArgs, sourceSignature);
|
||||||
|
|
||||||
PyList_Append(pyArgs, targetWalk->d->source);
|
PyList_Append(pyArgs, targetWalk->d->source);
|
||||||
Shiboken::AutoDecRef targetSignature(PySide::signalBuildQtCompatible(targetWalk->d->signature));
|
Shiboken::AutoDecRef targetSignature(PySide::Signal::buildQtCompatible(targetWalk->d->signature));
|
||||||
PyList_Append(pyArgs, targetSignature);
|
PyList_Append(pyArgs, targetSignature);
|
||||||
|
|
||||||
match = true;
|
match = true;
|
||||||
}
|
}
|
||||||
targetWalk = reinterpret_cast<PySideSignalInstanceData*>(targetWalk->d->next);
|
targetWalk = reinterpret_cast<PySideSignalInstance*>(targetWalk->d->next);
|
||||||
}
|
}
|
||||||
sourceWalk = reinterpret_cast<PySideSignalInstanceData*>(sourceWalk->d->next);
|
sourceWalk = reinterpret_cast<PySideSignalInstance*>(sourceWalk->d->next);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//try the first signature
|
//try the first signature
|
||||||
PyList_Append(pyArgs, source->d->source);
|
PyList_Append(pyArgs, source->d->source);
|
||||||
Shiboken::AutoDecRef signature(PySide::signalBuildQtCompatible(source->d->signature));
|
Shiboken::AutoDecRef signature(PySide::Signal::buildQtCompatible(source->d->signature));
|
||||||
PyList_Append(pyArgs, signature);
|
PyList_Append(pyArgs, signature);
|
||||||
|
|
||||||
PyList_Append(pyArgs, slot);
|
PyList_Append(pyArgs, slot);
|
||||||
|
|
@ -341,10 +340,10 @@ PyObject* signalInstanceConnect(PyObject* self, PyObject* args, PyObject* kwds)
|
||||||
|
|
||||||
PyObject* signalInstanceEmit(PyObject* self, PyObject* args)
|
PyObject* signalInstanceEmit(PyObject* self, PyObject* args)
|
||||||
{
|
{
|
||||||
PySideSignalInstanceData *source = reinterpret_cast<PySideSignalInstanceData*>(self);
|
PySideSignalInstance *source = reinterpret_cast<PySideSignalInstance*>(self);
|
||||||
|
|
||||||
Shiboken::AutoDecRef pyArgs(PyList_New(0));
|
Shiboken::AutoDecRef pyArgs(PyList_New(0));
|
||||||
Shiboken::AutoDecRef sourceSignature(PySide::signalBuildQtCompatible(source->d->signature));
|
Shiboken::AutoDecRef sourceSignature(PySide::Signal::buildQtCompatible(source->d->signature));
|
||||||
|
|
||||||
PyList_Append(pyArgs, sourceSignature);
|
PyList_Append(pyArgs, sourceSignature);
|
||||||
for(Py_ssize_t i = 0, max = PyTuple_Size(args); i < max; i++)
|
for(Py_ssize_t i = 0, max = PyTuple_Size(args); i < max; i++)
|
||||||
|
|
@ -358,9 +357,9 @@ PyObject* signalInstanceEmit(PyObject* self, PyObject* args)
|
||||||
|
|
||||||
PyObject* signalInstanceGetItem(PyObject* self, PyObject* key)
|
PyObject* signalInstanceGetItem(PyObject* self, PyObject* key)
|
||||||
{
|
{
|
||||||
PySideSignalInstanceData* data = reinterpret_cast<PySideSignalInstanceData*>(self);
|
PySideSignalInstance* data = reinterpret_cast<PySideSignalInstance*>(self);
|
||||||
char* sigKey = PySide::signalParseSignature(key);
|
char* sigKey = PySide::Signal::parseSignature(key);
|
||||||
char* sig = PySide::signalBuildSignature(data->d->signalName, sigKey);
|
char* sig = PySide::Signal::buildSignature(data->d->signalName, sigKey);
|
||||||
free(sigKey);
|
free(sigKey);
|
||||||
const char* sigName = data->d->signalName;
|
const char* sigName = data->d->signalName;
|
||||||
|
|
||||||
|
|
@ -371,7 +370,7 @@ PyObject* signalInstanceGetItem(PyObject* self, PyObject* key)
|
||||||
Py_INCREF(result);
|
Py_INCREF(result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
data = reinterpret_cast<PySideSignalInstanceData*>(data->d->next);
|
data = reinterpret_cast<PySideSignalInstance*>(data->d->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);
|
||||||
|
|
@ -381,7 +380,7 @@ PyObject* signalInstanceGetItem(PyObject* self, PyObject* key)
|
||||||
|
|
||||||
PyObject* signalInstanceDisconnect(PyObject* self, PyObject* args)
|
PyObject* signalInstanceDisconnect(PyObject* self, PyObject* args)
|
||||||
{
|
{
|
||||||
PySideSignalInstanceData *source = reinterpret_cast<PySideSignalInstanceData*>(self);
|
PySideSignalInstance *source = reinterpret_cast<PySideSignalInstance*>(self);
|
||||||
Shiboken::AutoDecRef pyArgs(PyList_New(0));
|
Shiboken::AutoDecRef pyArgs(PyList_New(0));
|
||||||
|
|
||||||
PyObject *slot;
|
PyObject *slot;
|
||||||
|
|
@ -392,21 +391,21 @@ PyObject* signalInstanceDisconnect(PyObject* self, PyObject* args)
|
||||||
|
|
||||||
bool match = false;
|
bool match = false;
|
||||||
if (slot->ob_type == &PySideSignalInstanceType) {
|
if (slot->ob_type == &PySideSignalInstanceType) {
|
||||||
PySideSignalInstanceData *target = reinterpret_cast<PySideSignalInstanceData*>(slot);
|
PySideSignalInstance *target = reinterpret_cast<PySideSignalInstance*>(slot);
|
||||||
if (QMetaObject::checkConnectArgs(source->d->signature, target->d->signature)) {
|
if (QMetaObject::checkConnectArgs(source->d->signature, target->d->signature)) {
|
||||||
PyList_Append(pyArgs, source->d->source);
|
PyList_Append(pyArgs, source->d->source);
|
||||||
Shiboken::AutoDecRef source_signature(PySide::signalBuildQtCompatible(source->d->signature));
|
Shiboken::AutoDecRef source_signature(PySide::Signal::buildQtCompatible(source->d->signature));
|
||||||
PyList_Append(pyArgs, source_signature);
|
PyList_Append(pyArgs, source_signature);
|
||||||
|
|
||||||
PyList_Append(pyArgs, target->d->source);
|
PyList_Append(pyArgs, target->d->source);
|
||||||
Shiboken::AutoDecRef target_signature(PySide::signalBuildQtCompatible(target->d->signature));
|
Shiboken::AutoDecRef target_signature(PySide::Signal::buildQtCompatible(target->d->signature));
|
||||||
PyList_Append(pyArgs, target_signature);
|
PyList_Append(pyArgs, target_signature);
|
||||||
match = true;
|
match = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//try the first signature
|
//try the first signature
|
||||||
PyList_Append(pyArgs, source->d->source);
|
PyList_Append(pyArgs, source->d->source);
|
||||||
Shiboken::AutoDecRef signature(PySide::signalBuildQtCompatible(source->d->signature));
|
Shiboken::AutoDecRef signature(PySide::Signal::buildQtCompatible(source->d->signature));
|
||||||
PyList_Append(pyArgs, signature);
|
PyList_Append(pyArgs, signature);
|
||||||
|
|
||||||
PyList_Append(pyArgs, slot);
|
PyList_Append(pyArgs, slot);
|
||||||
|
|
@ -424,42 +423,41 @@ PyObject* signalInstanceDisconnect(PyObject* self, PyObject* args)
|
||||||
|
|
||||||
PyObject* signalCall(PyObject* self, PyObject* args, PyObject* kw)
|
PyObject* signalCall(PyObject* self, PyObject* args, PyObject* kw)
|
||||||
{
|
{
|
||||||
SignalData* signalData = reinterpret_cast<SignalData*>(self);
|
PySideSignal* signal = reinterpret_cast<PySideSignal*>(self);
|
||||||
|
|
||||||
if (!signalData->homonymousMethod) {
|
if (!signal->homonymousMethod) {
|
||||||
PyErr_SetString(PyExc_TypeError, "native Qt signal is not callable");
|
PyErr_SetString(PyExc_TypeError, "native Qt signal is not callable");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
descrgetfunc getDescriptor = signalData->homonymousMethod->ob_type->tp_descr_get;
|
descrgetfunc getDescriptor = signal->homonymousMethod->ob_type->tp_descr_get;
|
||||||
Shiboken::AutoDecRef homonymousMethod(getDescriptor(signalData->homonymousMethod, 0, 0));
|
Shiboken::AutoDecRef homonymousMethod(getDescriptor(signal->homonymousMethod, 0, 0));
|
||||||
|
|
||||||
if (PyCFunction_GET_FLAGS(homonymousMethod.object()) & METH_STATIC)
|
if (PyCFunction_GET_FLAGS(homonymousMethod.object()) & METH_STATIC)
|
||||||
return PyCFunction_Call(homonymousMethod, args, kw);
|
return PyCFunction_Call(homonymousMethod, args, kw);
|
||||||
|
|
||||||
ternaryfunc callFunc = signalData->homonymousMethod->ob_type->tp_call;
|
ternaryfunc callFunc = signal->homonymousMethod->ob_type->tp_call;
|
||||||
return callFunc(homonymousMethod, args, kw);
|
return callFunc(homonymousMethod, args, kw);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject* signalInstanceCall(PyObject* self, PyObject* args, PyObject* kw)
|
PyObject* signalInstanceCall(PyObject* self, PyObject* args, PyObject* kw)
|
||||||
{
|
{
|
||||||
PySideSignalInstanceData* signalData = reinterpret_cast<PySideSignalInstanceData*>(self);
|
PySideSignalInstance* PySideSignal = reinterpret_cast<PySideSignalInstance*>(self);
|
||||||
if (!signalData->d->homonymousMethod) {
|
if (!PySideSignal->d->homonymousMethod) {
|
||||||
PyErr_SetString(PyExc_TypeError, "native Qt signal is not callable");
|
PyErr_SetString(PyExc_TypeError, "native Qt signal is not callable");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
descrgetfunc getDescriptor = signalData->d->homonymousMethod->ob_type->tp_descr_get;
|
descrgetfunc getDescriptor = PySideSignal->d->homonymousMethod->ob_type->tp_descr_get;
|
||||||
Shiboken::AutoDecRef homonymousMethod(getDescriptor(signalData->d->homonymousMethod, signalData->d->source, 0));
|
Shiboken::AutoDecRef homonymousMethod(getDescriptor(PySideSignal->d->homonymousMethod, PySideSignal->d->source, 0));
|
||||||
return PyCFunction_Call(homonymousMethod, args, kw);
|
return PyCFunction_Call(homonymousMethod, args, kw);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
|
|
||||||
namespace PySide
|
namespace PySide { namespace Signal {
|
||||||
{
|
|
||||||
|
|
||||||
void initSignalSupport(PyObject* module)
|
void init(PyObject* module)
|
||||||
{
|
{
|
||||||
if (PyType_Ready(&PySideSignalType) < 0)
|
if (PyType_Ready(&PySideSignalType) < 0)
|
||||||
return;
|
return;
|
||||||
|
|
@ -473,7 +471,7 @@ void initSignalSupport(PyObject* module)
|
||||||
Py_INCREF(&PySideSignalInstanceType);
|
Py_INCREF(&PySideSignalInstanceType);
|
||||||
}
|
}
|
||||||
|
|
||||||
void signalUpdateSource(PyObject* source)
|
void updateSourceObject(PyObject* source)
|
||||||
{
|
{
|
||||||
PyTypeObject * objType = reinterpret_cast<PyTypeObject *>(PyObject_Type(source));
|
PyTypeObject * objType = reinterpret_cast<PyTypeObject *>(PyObject_Type(source));
|
||||||
|
|
||||||
|
|
@ -483,8 +481,8 @@ void signalUpdateSource(PyObject* source)
|
||||||
|
|
||||||
while (PyDict_Next(objType->tp_dict, &pos, &key, &value)) {
|
while (PyDict_Next(objType->tp_dict, &pos, &key, &value)) {
|
||||||
if (PyObject_TypeCheck(value, &PySideSignalType)) {
|
if (PyObject_TypeCheck(value, &PySideSignalType)) {
|
||||||
Shiboken::AutoDecRef signalInstance((PyObject*)PyObject_New(PySideSignalInstanceData, &PySideSignalInstanceType));
|
Shiboken::AutoDecRef signalInstance((PyObject*)PyObject_New(PySideSignalInstance, &PySideSignalInstanceType));
|
||||||
signalInstanceInitialize(signalInstance.cast<PySideSignalInstanceData*>(), key, reinterpret_cast<SignalData*>(value), source, 0);
|
instanceInitialize(signalInstance.cast<PySideSignalInstance*>(), key, reinterpret_cast<PySideSignal*>(value), source, 0);
|
||||||
PyObject_SetAttr(source, key, signalInstance);
|
PyObject_SetAttr(source, key, signalInstance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -525,14 +523,14 @@ char* getTypeName(PyObject* type)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* signalBuildSignature(const char *name, const char *signature)
|
char* buildSignature(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* signalParseSignature(PyObject *args)
|
char* parseSignature(PyObject *args)
|
||||||
{
|
{
|
||||||
char *signature = 0;
|
char *signature = 0;
|
||||||
if (args && (PyString_Check(args) || !PySequence_Check(args)))
|
if (args && (PyString_Check(args) || !PySequence_Check(args)))
|
||||||
|
|
@ -555,7 +553,7 @@ char* signalParseSignature(PyObject *args)
|
||||||
return signature;
|
return signature;
|
||||||
}
|
}
|
||||||
|
|
||||||
void signalAppendSignature(SignalData* self, char* signature)
|
void appendSignature(PySideSignal* self, char* signature)
|
||||||
{
|
{
|
||||||
self->signaturesSize++;
|
self->signaturesSize++;
|
||||||
|
|
||||||
|
|
@ -567,17 +565,17 @@ void signalAppendSignature(SignalData* self, char* signature)
|
||||||
self->signatures[self->signaturesSize-1] = signature;
|
self->signatures[self->signaturesSize-1] = signature;
|
||||||
}
|
}
|
||||||
|
|
||||||
PySideSignalInstanceData* signalInitialize(PyObject* self, PyObject* name, PyObject *object)
|
PySideSignalInstance* initialize(PySideSignal* self, PyObject* name, PyObject *object)
|
||||||
{
|
{
|
||||||
PySideSignalInstanceData* instance = PyObject_New(PySideSignalInstanceData, &PySideSignalInstanceType);
|
PySideSignalInstance* instance = PyObject_New(PySideSignalInstance, &PySideSignalInstanceType);
|
||||||
signalInstanceInitialize(instance, name, reinterpret_cast<SignalData*>(self), object, 0);
|
instanceInitialize(instance, name, self, object, 0);
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
void signalInstanceInitialize(PySideSignalInstanceData* self, PyObject* name, SignalData* data, PyObject* source, int index)
|
void instanceInitialize(PySideSignalInstance* self, PyObject* name, PySideSignal* data, PyObject* source, int index)
|
||||||
{
|
{
|
||||||
self->d = new PySideSignalInstanceDataPrivate;
|
self->d = new PySideSignalInstancePrivate;
|
||||||
PySideSignalInstanceDataPrivate* selfPvt = self->d;
|
PySideSignalInstancePrivate* selfPvt = self->d;
|
||||||
selfPvt->next = 0;
|
selfPvt->next = 0;
|
||||||
if (data->signalName)
|
if (data->signalName)
|
||||||
selfPvt->signalName = strdup(data->signalName);
|
selfPvt->signalName = strdup(data->signalName);
|
||||||
|
|
@ -587,7 +585,7 @@ void signalInstanceInitialize(PySideSignalInstanceData* self, PyObject* name, Si
|
||||||
}
|
}
|
||||||
|
|
||||||
selfPvt->source = source;
|
selfPvt->source = source;
|
||||||
selfPvt->signature = signalBuildSignature(self->d->signalName, data->signatures[index]);
|
selfPvt->signature = buildSignature(self->d->signalName, data->signatures[index]);
|
||||||
selfPvt->homonymousMethod = 0;
|
selfPvt->homonymousMethod = 0;
|
||||||
if (data->homonymousMethod) {
|
if (data->homonymousMethod) {
|
||||||
selfPvt->homonymousMethod = data->homonymousMethod;
|
selfPvt->homonymousMethod = data->homonymousMethod;
|
||||||
|
|
@ -596,12 +594,12 @@ void signalInstanceInitialize(PySideSignalInstanceData* self, PyObject* name, Si
|
||||||
index++;
|
index++;
|
||||||
|
|
||||||
if (index < data->signaturesSize) {
|
if (index < data->signaturesSize) {
|
||||||
selfPvt->next = PyObject_New(PySideSignalInstanceData, &PySideSignalInstanceType);
|
selfPvt->next = PyObject_New(PySideSignalInstance, &PySideSignalInstanceType);
|
||||||
signalInstanceInitialize(selfPvt->next, name, data, source, index);
|
instanceInitialize(selfPvt->next, name, data, source, index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool signalConnect(PyObject* source, const char* signal, PyObject* callback)
|
bool 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())
|
||||||
|
|
@ -612,20 +610,20 @@ bool signalConnect(PyObject* source, const char* signal, PyObject* callback)
|
||||||
return PyObject_CallObject(pyMethod, pyArgs);
|
return PyObject_CallObject(pyMethod, pyArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject* signalNewFromMethod(PyObject* source, const QList<QMetaMethod>& methodList)
|
PySideSignalInstance* newObjectFromMethod(PyObject* source, const QList<QMetaMethod>& methodList)
|
||||||
{
|
{
|
||||||
PySideSignalInstanceData *root = 0;
|
PySideSignalInstance *root = 0;
|
||||||
PySideSignalInstanceData *previous = 0;
|
PySideSignalInstance *previous = 0;
|
||||||
foreach(QMetaMethod m, methodList) {
|
foreach(QMetaMethod m, methodList) {
|
||||||
PySideSignalInstanceData *item = PyObject_New(PySideSignalInstanceData, &PySideSignalInstanceType);
|
PySideSignalInstance *item = PyObject_New(PySideSignalInstance, &PySideSignalInstanceType);
|
||||||
if (!root)
|
if (!root)
|
||||||
root = item;
|
root = item;
|
||||||
|
|
||||||
if (previous)
|
if (previous)
|
||||||
previous->d->next = item;
|
previous->d->next = item;
|
||||||
|
|
||||||
item->d = new PySideSignalInstanceDataPrivate;
|
item->d = new PySideSignalInstancePrivate;
|
||||||
PySideSignalInstanceDataPrivate* selfPvt = item->d;
|
PySideSignalInstancePrivate* selfPvt = item->d;
|
||||||
selfPvt->source = source;
|
selfPvt->source = source;
|
||||||
QByteArray cppName(m.signature());
|
QByteArray cppName(m.signature());
|
||||||
cppName = cppName.mid(0, cppName.indexOf('('));
|
cppName = cppName.mid(0, cppName.indexOf('('));
|
||||||
|
|
@ -635,14 +633,14 @@ PyObject* signalNewFromMethod(PyObject* source, const QList<QMetaMethod>& method
|
||||||
selfPvt->homonymousMethod = 0;
|
selfPvt->homonymousMethod = 0;
|
||||||
selfPvt->next = 0;
|
selfPvt->next = 0;
|
||||||
}
|
}
|
||||||
return reinterpret_cast<PyObject*>(root);
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject* signalNew(const char* name, ...)
|
PySideSignal* newObject(const char* name, ...)
|
||||||
{
|
{
|
||||||
va_list listSignatures;
|
va_list listSignatures;
|
||||||
char* sig = 0;
|
char* sig = 0;
|
||||||
SignalData* self = PyObject_New(SignalData, &PySideSignalType);
|
PySideSignal* self = PyObject_New(PySideSignal, &PySideSignalType);
|
||||||
self->signalName = strdup(name);
|
self->signalName = strdup(name);
|
||||||
self->signaturesSize = 0;
|
self->signaturesSize = 0;
|
||||||
self->signatures = 0;
|
self->signatures = 0;
|
||||||
|
|
@ -653,17 +651,17 @@ PyObject* signalNew(const char* name, ...)
|
||||||
sig = va_arg(listSignatures, char*);
|
sig = va_arg(listSignatures, char*);
|
||||||
|
|
||||||
while(sig != NULL) {
|
while(sig != NULL) {
|
||||||
signalAppendSignature(self, strdup(sig));
|
appendSignature(self, strdup(sig));
|
||||||
sig = va_arg(listSignatures, char*);
|
sig = va_arg(listSignatures, char*);
|
||||||
}
|
}
|
||||||
|
|
||||||
va_end(listSignatures);
|
va_end(listSignatures);
|
||||||
|
|
||||||
return reinterpret_cast<PyObject*>(self);
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PyObject* signalBuildQtCompatible(const char* signature)
|
PyObject* buildQtCompatible(const char* signature)
|
||||||
{
|
{
|
||||||
char* qtSignature;
|
char* qtSignature;
|
||||||
qtSignature = reinterpret_cast<char*>(malloc(strlen(signature)+2));
|
qtSignature = reinterpret_cast<char*>(malloc(strlen(signature)+2));
|
||||||
|
|
@ -673,33 +671,35 @@ PyObject* signalBuildQtCompatible(const char* signature)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void addSignalToWrapper(Shiboken::SbkBaseWrapperType* wrapperType, const char* signalName, PyObject* signal)
|
void addSignalToWrapper(Shiboken::SbkBaseWrapperType* wrapperType, const char* signalName, PySideSignal* signal)
|
||||||
{
|
{
|
||||||
PyObject* typeDict = wrapperType->super.ht_type.tp_dict;
|
PyObject* typeDict = wrapperType->super.ht_type.tp_dict;
|
||||||
PyObject* homonymousMethod;
|
PyObject* homonymousMethod;
|
||||||
if ((homonymousMethod = PyDict_GetItemString(typeDict, signalName))) {
|
if ((homonymousMethod = PyDict_GetItemString(typeDict, signalName))) {
|
||||||
Py_INCREF(homonymousMethod);
|
Py_INCREF(homonymousMethod);
|
||||||
reinterpret_cast<SignalData*>(signal)->homonymousMethod = homonymousMethod;
|
signal->homonymousMethod = homonymousMethod;
|
||||||
}
|
}
|
||||||
PyDict_SetItemString(typeDict, signalName, signal);
|
PyDict_SetItemString(typeDict, signalName, reinterpret_cast<PyObject*>(signal));
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject* getSignalSource(PySideSignalInstanceData* signal)
|
PyObject* getObject(PySideSignalInstance* signal)
|
||||||
{
|
{
|
||||||
return signal->d->source;
|
return signal->d->source;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* getSignalSignature(PySideSignalInstanceData* signal)
|
const char* getSignature(PySideSignalInstance* signal)
|
||||||
{
|
{
|
||||||
return signal->d->signature;
|
return signal->d->signature;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char** getSignalSignatures(PyObject* signal, int *size)
|
const char** getSignatures(PyObject* signal, int *size)
|
||||||
{
|
{
|
||||||
SignalData *self = reinterpret_cast<SignalData*>(signal);
|
PySideSignal *self = reinterpret_cast<PySideSignal*>(signal);
|
||||||
*size = self->signaturesSize;
|
*size = self->signaturesSize;
|
||||||
return (const char**) self->signatures;
|
return (const char**) self->signatures;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} //namespace Signal
|
||||||
} //namespace PySide
|
} //namespace PySide
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,25 +37,80 @@ extern "C"
|
||||||
extern PYSIDE_API PyTypeObject PySideSignalType;
|
extern PYSIDE_API PyTypeObject PySideSignalType;
|
||||||
extern PYSIDE_API PyTypeObject PySideSignalInstanceType;
|
extern PYSIDE_API PyTypeObject PySideSignalInstanceType;
|
||||||
|
|
||||||
struct PySideSignalInstanceDataPrivate;
|
//Internal object
|
||||||
struct PYSIDE_API PySideSignalInstanceData
|
struct PYSIDE_API PySideSignal;
|
||||||
|
|
||||||
|
struct PySideSignalInstancePrivate;
|
||||||
|
struct PYSIDE_API PySideSignalInstance
|
||||||
{
|
{
|
||||||
PyObject_HEAD
|
PyObject_HEAD
|
||||||
PySideSignalInstanceDataPrivate* d;
|
PySideSignalInstancePrivate* d;
|
||||||
};
|
};
|
||||||
}; //extern "C"
|
}; //extern "C"
|
||||||
|
|
||||||
namespace PySide
|
namespace PySide { namespace Signal {
|
||||||
{
|
|
||||||
|
|
||||||
PYSIDE_API PyObject* signalNew(const char* name, ...);
|
/**
|
||||||
PYSIDE_API PyObject* signalNewFromMethod(PyObject* source, const QList<QMetaMethod>& method);
|
* This function creates a Signal object which stay attached to QObject class
|
||||||
PYSIDE_API PySideSignalInstanceData* signalInitialize(PyObject* self, PyObject* name, PyObject *object);
|
*
|
||||||
|
* @param name of the Signal to be registered on meta object
|
||||||
|
* @param signatures a list of signatures supported by this signal, ended with a NULL pointer
|
||||||
|
* @return Return a new reference to PyObject* of type PySideSignal
|
||||||
|
**/
|
||||||
|
PYSIDE_API PySideSignal* newObject(const char* name, ...);
|
||||||
|
|
||||||
PYSIDE_API void signalUpdateSource(PyObject* source);
|
/**
|
||||||
PYSIDE_API void addSignalToWrapper(Shiboken::SbkBaseWrapperType* wrapperType, const char* signalName, PyObject* signal);
|
* This function creates a Signal object which stay attached to QObject class based on a list of QMetaMethod
|
||||||
PYSIDE_API PyObject* getSignalSource(PySideSignalInstanceData* signal);
|
*
|
||||||
PYSIDE_API const char* getSignalSignature(PySideSignalInstanceData* signal);
|
* @param source of the Signal to be registered on meta object
|
||||||
|
* @param methods a list of QMetaMethod wich contains the supported signature
|
||||||
|
* @return Return a new reference to PyObject* of type PySideSignal
|
||||||
|
**/
|
||||||
|
PYSIDE_API PySideSignalInstance* newObjectFromMethod(PyObject* source, const QList<QMetaMethod>& methods);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function initializes the Signal object creating a PySideSignalInstance
|
||||||
|
*
|
||||||
|
* @param self a Signal object used as base to PySideSignalInstance
|
||||||
|
* @param name the name to be used on PySideSignalInstance
|
||||||
|
* @param object the PyObject where the signal will be attached
|
||||||
|
* @return Return a new reference to PySideSignalInstance
|
||||||
|
**/
|
||||||
|
PYSIDE_API PySideSignalInstance* initialize(PySideSignal* signal, PyObject* name, PyObject *object);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function is used to retrieve the object in which the sigal is attached
|
||||||
|
*
|
||||||
|
* @param self The Signal object
|
||||||
|
* @return Return the internal reference to parent object of the signal
|
||||||
|
**/
|
||||||
|
PYSIDE_API PyObject* getObject(PySideSignalInstance* signal);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function is used to retrieve the signal signature
|
||||||
|
*
|
||||||
|
* @param self The Signal object
|
||||||
|
* @return Return the signal signature
|
||||||
|
**/
|
||||||
|
PYSIDE_API const char* getSignature(PySideSignalInstance* signal);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function is used to retrieve the signal signature
|
||||||
|
*
|
||||||
|
* @param self The Signal object
|
||||||
|
* @return Return the signal signature
|
||||||
|
**/
|
||||||
|
PYSIDE_API void updateSourceObject(PyObject* source);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function is used to retrieve the signal signature
|
||||||
|
*
|
||||||
|
* @param self The Signal object
|
||||||
|
* @return Return the signal signature
|
||||||
|
**/
|
||||||
|
PYSIDE_API void addSignalToWrapper(Shiboken::SbkBaseWrapperType* wrapperType, const char* signalName, PySideSignal* signal);
|
||||||
|
|
||||||
|
} //namespace Signal
|
||||||
} //namespace PySide
|
} //namespace PySide
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ extern "C"
|
||||||
{
|
{
|
||||||
extern PyTypeObject PySideSignalType;
|
extern PyTypeObject PySideSignalType;
|
||||||
|
|
||||||
struct SignalData {
|
struct PySideSignal {
|
||||||
PyObject_HEAD
|
PyObject_HEAD
|
||||||
bool initialized;
|
bool initialized;
|
||||||
char* signalName;
|
char* signalName;
|
||||||
|
|
@ -38,25 +38,24 @@ extern "C"
|
||||||
PyObject* homonymousMethod;
|
PyObject* homonymousMethod;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PySideSignalInstanceData;
|
struct PySideSignalInstance;
|
||||||
struct PySideSignalInstanceDataPrivate {
|
struct PySideSignalInstancePrivate {
|
||||||
char* signalName;
|
char* signalName;
|
||||||
char* signature;
|
char* signature;
|
||||||
PyObject* source;
|
PyObject* source;
|
||||||
PyObject* homonymousMethod;
|
PyObject* homonymousMethod;
|
||||||
PySideSignalInstanceData* next;
|
PySideSignalInstance* next;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
}; //extern "C"
|
}; //extern "C"
|
||||||
|
|
||||||
namespace PySide
|
namespace PySide { namespace Signal {
|
||||||
{
|
void init(PyObject* module);
|
||||||
bool signalConnect(PyObject* source, const char* signal, PyObject* callback);
|
bool connect(PyObject* source, const char* signal, PyObject* callback);
|
||||||
char* getTypeName(PyObject*);
|
char* getTypeName(PyObject*);
|
||||||
void initSignalSupport(PyObject* module);
|
const char** getSignatures(PyObject* self, int *size);
|
||||||
const char** getSignalSignatures(PyObject* self, int *size);
|
|
||||||
|
|
||||||
} //namespace PySide
|
}} //namespace PySide
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ typedef struct
|
||||||
char* slotName;
|
char* slotName;
|
||||||
char* args;
|
char* args;
|
||||||
char* resultType;
|
char* resultType;
|
||||||
} SlotData;
|
} PySideSlot;
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
|
|
@ -46,7 +46,7 @@ static PyTypeObject PySideSlotType = {
|
||||||
PyObject_HEAD_INIT(NULL)
|
PyObject_HEAD_INIT(NULL)
|
||||||
0, /*ob_size*/
|
0, /*ob_size*/
|
||||||
"PySide.QtCore."SLOT_DEC_NAME, /*tp_name*/
|
"PySide.QtCore."SLOT_DEC_NAME, /*tp_name*/
|
||||||
sizeof(SlotData), /*tp_basicsize*/
|
sizeof(PySideSlot), /*tp_basicsize*/
|
||||||
0, /*tp_itemsize*/
|
0, /*tp_itemsize*/
|
||||||
0, /*tp_dealloc*/
|
0, /*tp_dealloc*/
|
||||||
0, /*tp_print*/
|
0, /*tp_print*/
|
||||||
|
|
@ -105,10 +105,10 @@ int slotTpInit(PyObject *self, PyObject *args, PyObject *kw)
|
||||||
if (!PyArg_ParseTupleAndKeywords(emptyTuple, kw, "|sO:QtCore."SLOT_DEC_NAME, (char**) kwlist, &argName, &argResult))
|
if (!PyArg_ParseTupleAndKeywords(emptyTuple, kw, "|sO:QtCore."SLOT_DEC_NAME, (char**) kwlist, &argName, &argResult))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
SlotData *data = reinterpret_cast<SlotData*>(self);
|
PySideSlot *data = reinterpret_cast<PySideSlot*>(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 = PySide::getTypeName(argType);
|
char *typeName = PySide::Signal::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*)));
|
||||||
|
|
@ -125,7 +125,7 @@ int slotTpInit(PyObject *self, PyObject *args, PyObject *kw)
|
||||||
data->slotName = strdup(argName);
|
data->slotName = strdup(argName);
|
||||||
|
|
||||||
if (argResult)
|
if (argResult)
|
||||||
data->resultType = PySide::getTypeName(argResult);
|
data->resultType = PySide::Signal::getTypeName(argResult);
|
||||||
else
|
else
|
||||||
data->resultType = strdup("void");
|
data->resultType = strdup("void");
|
||||||
|
|
||||||
|
|
@ -140,7 +140,7 @@ PyObject* slotCall(PyObject* self, PyObject* args, PyObject* kw)
|
||||||
Py_INCREF(callback);
|
Py_INCREF(callback);
|
||||||
|
|
||||||
if (PyFunction_Check(callback)) {
|
if (PyFunction_Check(callback)) {
|
||||||
SlotData *data = reinterpret_cast<SlotData*>(self);
|
PySideSlot *data = reinterpret_cast<PySideSlot*>(self);
|
||||||
|
|
||||||
if (!data->slotName) {
|
if (!data->slotName) {
|
||||||
PyObject *funcName = reinterpret_cast<PyFunctionObject*>(callback)->func_name;
|
PyObject *funcName = reinterpret_cast<PyFunctionObject*>(callback)->func_name;
|
||||||
|
|
@ -180,10 +180,9 @@ PyObject* slotCall(PyObject* self, PyObject* args, PyObject* kw)
|
||||||
|
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
|
|
||||||
namespace PySide
|
namespace PySide { namespace Slot {
|
||||||
{
|
|
||||||
|
|
||||||
void initSlotSupport(PyObject* module)
|
void init(PyObject* module)
|
||||||
{
|
{
|
||||||
if (PyType_Ready(&PySideSlotType) < 0)
|
if (PyType_Ready(&PySideSlotType) < 0)
|
||||||
return;
|
return;
|
||||||
|
|
@ -192,4 +191,5 @@ void initSlotSupport(PyObject* module)
|
||||||
PyModule_AddObject(module, SLOT_DEC_NAME, ((PyObject*)&PySideSlotType));
|
PyModule_AddObject(module, SLOT_DEC_NAME, ((PyObject*)&PySideSlotType));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace Slot
|
||||||
} // namespace PySide
|
} // namespace PySide
|
||||||
|
|
|
||||||
|
|
@ -24,9 +24,8 @@
|
||||||
|
|
||||||
#include <Python.h>
|
#include <Python.h>
|
||||||
|
|
||||||
namespace PySide
|
namespace PySide { namespace Slot {
|
||||||
{
|
void init(PyObject* module);
|
||||||
void initSlotSupport(PyObject* module);
|
}}
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -355,7 +355,7 @@ bool SignalManager::emitSignal(QObject* source, const char* signal, PyObject* ar
|
||||||
int SignalManager::qt_metacall(QObject* object, QMetaObject::Call call, int id, void** args)
|
int SignalManager::qt_metacall(QObject* object, QMetaObject::Call call, int id, void** args)
|
||||||
{
|
{
|
||||||
const QMetaObject* metaObject = object->metaObject();
|
const QMetaObject* metaObject = object->metaObject();
|
||||||
PySideQProperty* pp = 0;
|
PySideProperty* pp = 0;
|
||||||
PyObject* pp_name = 0;
|
PyObject* pp_name = 0;
|
||||||
QMetaProperty mp;
|
QMetaProperty mp;
|
||||||
Shiboken::TypeResolver* typeResolver = 0;
|
Shiboken::TypeResolver* typeResolver = 0;
|
||||||
|
|
@ -368,7 +368,7 @@ int SignalManager::qt_metacall(QObject* object, QMetaObject::Call call, int id,
|
||||||
return id - metaObject->methodCount();
|
return id - metaObject->methodCount();
|
||||||
|
|
||||||
pp_name = PyString_FromString(mp.name());
|
pp_name = PyString_FromString(mp.name());
|
||||||
pp = qpropertyGetObject(pySelf, pp_name);
|
pp = Property::getObject(pySelf, pp_name);
|
||||||
if (!pp) {
|
if (!pp) {
|
||||||
qWarning("Invalid property.");
|
qWarning("Invalid property.");
|
||||||
Py_XDECREF(pp_name);
|
Py_XDECREF(pp_name);
|
||||||
|
|
@ -382,7 +382,7 @@ int SignalManager::qt_metacall(QObject* object, QMetaObject::Call call, int id,
|
||||||
#ifndef QT_NO_PROPERTIES
|
#ifndef QT_NO_PROPERTIES
|
||||||
case QMetaObject::ReadProperty:
|
case QMetaObject::ReadProperty:
|
||||||
{
|
{
|
||||||
PyObject* value = qpropertyGet(pp, pySelf);
|
PyObject* value = Property::getValue(pp, pySelf);
|
||||||
if (value) {
|
if (value) {
|
||||||
typeResolver->toCpp(value, &args[0]);
|
typeResolver->toCpp(value, &args[0]);
|
||||||
Py_DECREF(value);
|
Py_DECREF(value);
|
||||||
|
|
@ -395,12 +395,12 @@ int SignalManager::qt_metacall(QObject* object, QMetaObject::Call call, int id,
|
||||||
case QMetaObject::WriteProperty:
|
case QMetaObject::WriteProperty:
|
||||||
{
|
{
|
||||||
Shiboken::AutoDecRef value(typeResolver->toPython(args[0]));
|
Shiboken::AutoDecRef value(typeResolver->toPython(args[0]));
|
||||||
qpropertySet(pp, pySelf, value);
|
Property::setValue(pp, pySelf, value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case QMetaObject::ResetProperty:
|
case QMetaObject::ResetProperty:
|
||||||
qpropertyReset(pp, pp_name);
|
Property::reset(pp, pp_name);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QMetaObject::QueryPropertyDesignable:
|
case QMetaObject::QueryPropertyDesignable:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue