Skip to content

Commit 2e9251f

Browse files
committed
Support for unary + in PythonQt itself
1 parent 0e69eaa commit 2e9251f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/PythonQtClassWrapper.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,17 @@ static PyObject* PythonQtInstanceWrapper_negative(PythonQtInstanceWrapper* wrapp
7171
return result;
7272
}
7373

74+
static PyObject* PythonQtInstanceWrapper_positive(PythonQtInstanceWrapper* wrapper)
75+
{
76+
PyObject* result = nullptr;
77+
static QByteArray memberName = "__add__";
78+
PythonQtMemberInfo opSlot = wrapper->classInfo()->member(memberName);
79+
if (opSlot._type == PythonQtMemberInfo::Slot) {
80+
result = PythonQtSlotFunction_CallImpl(wrapper->classInfo(), wrapper->_obj, opSlot._slot, nullptr, nullptr, wrapper->_wrappedPtr);
81+
}
82+
return result;
83+
}
84+
7485
static int PythonQtInstanceWrapper_nonzero(PythonQtInstanceWrapper* wrapper)
7586
{
7687
int result = (wrapper->_wrappedPtr == nullptr && wrapper->_obj == nullptr)?0:1;
@@ -239,6 +250,7 @@ static void initializeSlots(PythonQtClassWrapper* wrap)
239250

240251
if (typeSlots & PythonQt::Type_Add) {
241252
wrap->_base.as_number.nb_add = (binaryfunc)PythonQtInstanceWrapper_add;
253+
wrap->_base.as_number.nb_positive = (unaryfunc)PythonQtInstanceWrapper_positive;
242254
}
243255
if (typeSlots & PythonQt::Type_Subtract) {
244256
wrap->_base.as_number.nb_subtract = (binaryfunc)PythonQtInstanceWrapper_sub;

0 commit comments

Comments
 (0)