diff options
25 files changed, 74 insertions, 94 deletions
diff --git a/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml b/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml index e74fd8130..53ba2f254 100644 --- a/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml +++ b/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml @@ -187,7 +187,7 @@ <primitive-type name="short"/> <primitive-type name="signed short"/> <primitive-type name="signed short int"/> - <primitive-type name="ushort" target-lang-api-name="PyInt"/> + <primitive-type name="ushort" target-lang-api-name="PyLong"/> <primitive-type name="unsigned short int"/> <primitive-type name="unsigned short"/> <primitive-type name="char"/> @@ -266,7 +266,7 @@ <native-to-target file="../glue/qtcore.cpp" snippet="return-pyunicode-qchar"/> <target-to-native> <add-conversion type="PyString" check="Shiboken::String::checkChar(%in)" file="../glue/qtcore.cpp" snippet="conversion-pystring-char"/> - <add-conversion type="PyInt" file="../glue/qtcore.cpp" snippet="conversion-pyint"/> + <add-conversion type="PyLong" file="../glue/qtcore.cpp" snippet="conversion-pyint"/> <add-conversion type="Py_None" file="../glue/qtcore.cpp" snippet="conversion-pynone"/> </target-to-native> </conversion-rule> @@ -281,8 +281,6 @@ <add-conversion type="QString" check="Shiboken::String::check(%in)" file="../glue/qtcore.cpp" snippet="conversion-qstring"/> <add-conversion type="QByteArray" file="../glue/qtcore.cpp" snippet="conversion-qbytearray"/> <add-conversion type="PyFloat" check="PyFloat_CheckExact(%in)" file="../glue/qtcore.cpp" snippet="conversion-pyfloat"/> - <!-- Using PyLong instead of PyInt to support Python2 and 3--> - <add-conversion type="PyInt" check="PyInt_CheckExact(%in)" file="../glue/qtcore.cpp" snippet="conversion-qlonglong"/> <add-conversion type="PyLong" check="PyLong_CheckExact(%in)" file="../glue/qtcore.cpp" snippet="conversion-qlonglong"/> <add-conversion type="SbkEnumType" file="../glue/qtcore.cpp" snippet="conversion-pyint"/> <add-conversion type="SbkObject" file="../glue/qtcore.cpp" snippet="conversion-sbkobject"/> diff --git a/sources/pyside6/PySide6/QtQml/pysideqmlregistertype.cpp b/sources/pyside6/PySide6/QtQml/pysideqmlregistertype.cpp index 852a15e21..d2b9b689e 100644 --- a/sources/pyside6/PySide6/QtQml/pysideqmlregistertype.cpp +++ b/sources/pyside6/PySide6/QtQml/pysideqmlregistertype.cpp @@ -166,7 +166,7 @@ int PySide::qmlRegisterSingletonType(PyObject *pyObj, const char *uri, int versi AutoDecRef funcCode(PyObject_GetAttrString(callback, "__code__")); AutoDecRef argCount(PyObject_GetAttrString(funcCode, "co_argcount")); - int count = PyInt_AsLong(argCount); + int count = PyLong_AsLong(argCount); if (count != 1) { PyErr_Format(PyExc_TypeError, "Callback has a bad parameter count."); diff --git a/sources/pyside6/PySide6/glue/qtcore.cpp b/sources/pyside6/PySide6/glue/qtcore.cpp index 09e27c027..b683eef54 100644 --- a/sources/pyside6/PySide6/glue/qtcore.cpp +++ b/sources/pyside6/PySide6/glue/qtcore.cpp @@ -316,7 +316,7 @@ qAddPostRoutine(PySide::globalPostRoutineCallback); QList<QByteArray> version = QByteArray(qVersion()).split('.'); PyObject *pyQtVersion = PyTuple_New(3); for (int i = 0; i < 3; ++i) - PyTuple_SET_ITEM(pyQtVersion, i, PyInt_FromLong(version[i].toInt())); + PyTuple_SET_ITEM(pyQtVersion, i, PyLong_FromLong(version[i].toInt())); PyModule_AddObject(module, "__version_info__", pyQtVersion); PyModule_AddStringConstant(module, "__version__", qVersion()); // @snippet qt-version diff --git a/sources/pyside6/PySide6/glue/qtgui.cpp b/sources/pyside6/PySide6/glue/qtgui.cpp index 5b91790cf..5874dc608 100644 --- a/sources/pyside6/PySide6/glue/qtgui.cpp +++ b/sources/pyside6/PySide6/glue/qtgui.cpp @@ -510,8 +510,8 @@ if (PySequence_Check(_key)) { if (PySequence_Fast_GET_SIZE(key.object()) == 2) { PyObject *posx = PySequence_Fast_GET_ITEM(key.object(), 0); PyObject *posy = PySequence_Fast_GET_ITEM(key.object(), 1); - Py_ssize_t x = PyInt_AsSsize_t(posx); - Py_ssize_t y = PyInt_AsSsize_t(posy); + Py_ssize_t x = PyLong_AsSsize_t(posx); + Py_ssize_t y = PyLong_AsSsize_t(posy); float ret = (*%CPPSELF)(x,y); return %CONVERTTOPYTHON[float](ret); } diff --git a/sources/pyside6/PySide6/glue/qtwidgets.cpp b/sources/pyside6/PySide6/glue/qtwidgets.cpp index 0a934710b..d2b7872d4 100644 --- a/sources/pyside6/PySide6/glue/qtwidgets.cpp +++ b/sources/pyside6/PySide6/glue/qtwidgets.cpp @@ -55,7 +55,7 @@ Shiboken::Object::releaseOwnership(%PYARG_0); // @snippet qtreewidgetitemiterator-value // @snippet qgraphicsitem -PyObject *userTypeConstant = PyInt_FromLong(QGraphicsItem::UserType); +PyObject *userTypeConstant = PyLong_FromLong(QGraphicsItem::UserType); PyDict_SetItemString(reinterpret_cast<PyTypeObject *>(Sbk_QGraphicsItem_TypeF())->tp_dict, "UserType", userTypeConstant); // @snippet qgraphicsitem diff --git a/sources/pyside6/PySide6/templates/core_common.xml b/sources/pyside6/PySide6/templates/core_common.xml index 2193e340c..ada2e92d3 100644 --- a/sources/pyside6/PySide6/templates/core_common.xml +++ b/sources/pyside6/PySide6/templates/core_common.xml @@ -193,10 +193,10 @@ PyObject* _obj = %PYARG_0.object(); if (!PySequence_Check(_obj) || PySequence_Fast_GET_SIZE(_obj) != 4 - || !SbkNumber_Check(PySequence_Fast_GET_ITEM(_obj, 0)) - || !SbkNumber_Check(PySequence_Fast_GET_ITEM(_obj, 1)) - || !SbkNumber_Check(PySequence_Fast_GET_ITEM(_obj, 2)) - || !SbkNumber_Check(PySequence_Fast_GET_ITEM(_obj, 3))) { + || !PyNumber_Check(PySequence_Fast_GET_ITEM(_obj, 0)) + || !PyNumber_Check(PySequence_Fast_GET_ITEM(_obj, 1)) + || !PyNumber_Check(PySequence_Fast_GET_ITEM(_obj, 2)) + || !PyNumber_Check(PySequence_Fast_GET_ITEM(_obj, 3))) { PyErr_SetString(PyExc_TypeError, "Sequence of 4 numbers expected"); } else { *%1 = %CONVERTTOCPP[$TYPE](PySequence_Fast_GET_ITEM(_obj, 0)); diff --git a/sources/pyside6/libpyside/dynamicqmetaobject.cpp b/sources/pyside6/libpyside/dynamicqmetaobject.cpp index 39be38b29..b7febf492 100644 --- a/sources/pyside6/libpyside/dynamicqmetaobject.cpp +++ b/sources/pyside6/libpyside/dynamicqmetaobject.cpp @@ -577,7 +577,7 @@ void MetaObjectBuilderPrivate::parsePythonType(PyTypeObject *type) AutoDecRef member(PySequence_GetItem(item, 1)); AutoDecRef value(PyObject_GetAttr(member, Shiboken::PyName::value())); auto ckey = String::toCString(key); - auto ivalue = PyInt_AsSsize_t(value); // int/long cheating + auto ivalue = PyLong_AsSsize_t(value); auto thing = QPair<QByteArray, int>(ckey, int(ivalue)); entries.push_back(thing); } diff --git a/sources/pyside6/libpyside/feature_select.cpp b/sources/pyside6/libpyside/feature_select.cpp index 648ec96a3..492e30c28 100644 --- a/sources/pyside6/libpyside/feature_select.cpp +++ b/sources/pyside6/libpyside/feature_select.cpp @@ -187,7 +187,7 @@ static inline PyObject *getSelectId(PyObject *dict) static inline void setCurrentSelectId(PyTypeObject *type, PyObject *select_id) { - SbkObjectType_SetReserved(type, PyInt_AsSsize_t(select_id)); // int/long cheating + SbkObjectType_SetReserved(type, PyLong_AsSsize_t(select_id)); // int/long cheating } static inline void setCurrentSelectId(PyTypeObject *type, int id) @@ -217,7 +217,7 @@ static bool replaceClassDict(PyTypeObject *type) if (new_dict == nullptr || PyDict_Update(new_dict, dict) < 0) return false; // Insert the default id. Cannot fail for small numbers. - AutoDecRef select_id(PyInt_FromLong(0)); + AutoDecRef select_id(PyLong_FromLong(0)); setSelectId(new_dict, select_id); // insert the dict into itself as ring setNextDict(new_dict, new_dict); @@ -283,9 +283,9 @@ static bool createNewFeatureSet(PyTypeObject *type, PyObject *select_id) * content in `prev_dict`. It is responsible of filling `type->tp_dict` * with modified content. */ - static auto small_1 = PyInt_FromLong(255); + static auto small_1 = PyLong_FromLong(255); Q_UNUSED(small_1); - static auto small_2 = PyInt_FromLong(255); + static auto small_2 = PyLong_FromLong(255); Q_UNUSED(small_2); // make sure that small integers are cached assert(small_1 != nullptr && small_1 == small_2); @@ -299,7 +299,7 @@ static bool createNewFeatureSet(PyTypeObject *type, PyObject *select_id) Py_INCREF(prev_dict); // keep the first ref unchanged if (!addNewDict(type, select_id)) return false; - auto id = PyInt_AsSsize_t(select_id); // int/long cheating + auto id = PyLong_AsSsize_t(select_id); // int/long cheating if (id == -1) return false; setCurrentSelectId(type, id); @@ -434,7 +434,7 @@ void init() if (!is_initialized) { fast_id_array = &_fast_id_array[1]; for (int idx = -1; idx < 256; ++idx) - fast_id_array[idx] = PyInt_FromLong(idx); + fast_id_array[idx] = PyLong_FromLong(idx); featurePointer = featureProcArray; initSelectableFeature(SelectFeatureSet); registerCleanupFunction(finalize); diff --git a/sources/pyside6/libpyside/pysideqenum.cpp b/sources/pyside6/libpyside/pysideqenum.cpp index 07a548cb6..8abf19313 100644 --- a/sources/pyside6/libpyside/pysideqenum.cpp +++ b/sources/pyside6/libpyside/pysideqenum.cpp @@ -99,7 +99,7 @@ static PyObject *analyzePyEnum(PyObject *pyenum, PyObject *container = nullptr) AutoDecRef value(PyObject_GetAttr(member, Shiboken::PyName::value())); if (value.isNull()) return nullptr; - if (!PyInt_Check(value)) { // int/long cheating + if (!PyLong_Check(value)) { PyErr_Format(PyExc_TypeError, "QEnum expected an int value as '%.200s', got '%.200s'", Shiboken::String::toCString(key), Py_TYPE(value)->tp_name); @@ -113,9 +113,9 @@ static Py_ssize_t get_lineno() { PyObject *frame = reinterpret_cast<PyObject *>(PyEval_GetFrame()); // borrowed ref AutoDecRef ob_lineno(PyObject_GetAttr(frame, Shiboken::PyName::f_lineno())); - if (ob_lineno.isNull() || !PyInt_Check(ob_lineno)) // int/long cheating + if (ob_lineno.isNull() || !PyLong_Check(ob_lineno)) return -1; - return PyInt_AsSsize_t(ob_lineno); // int/long cheating + return PyLong_AsSsize_t(ob_lineno); } static bool is_module_code() diff --git a/sources/pyside6/libpyside/pysideqflags.cpp b/sources/pyside6/libpyside/pysideqflags.cpp index 3252aa9e6..eb4e0e7bb 100644 --- a/sources/pyside6/libpyside/pysideqflags.cpp +++ b/sources/pyside6/libpyside/pysideqflags.cpp @@ -156,7 +156,7 @@ namespace QFlags "missing QFlags name", // to be inserted later sizeof(PySideQFlagsObject), 0, - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES, + Py_TPFLAGS_DEFAULT, SbkNewQFlagsType_slots, }; diff --git a/sources/pyside6/libpyside/pysidesignal.cpp b/sources/pyside6/libpyside/pysidesignal.cpp index 276da1cad..c2a0e31f5 100644 --- a/sources/pyside6/libpyside/pysidesignal.cpp +++ b/sources/pyside6/libpyside/pysidesignal.cpp @@ -770,7 +770,7 @@ QByteArray getTypeName(PyObject *type) auto objType = reinterpret_cast<PyTypeObject *>(type); if (Shiboken::String::checkType(objType)) return QByteArrayLiteral("QString"); - if (objType == &PyInt_Type) + if (objType == &PyLong_Type) return QByteArrayLiteral("int"); if (objType == &PyLong_Type) return QByteArrayLiteral("long"); diff --git a/sources/shiboken6/doc/typesystem_converters.rst b/sources/shiboken6/doc/typesystem_converters.rst index 7858eb6a9..2e41758cd 100644 --- a/sources/shiboken6/doc/typesystem_converters.rst +++ b/sources/shiboken6/doc/typesystem_converters.rst @@ -86,10 +86,10 @@ Here's how to do it: if (!PySequence_Check(pyIn) || !(PySequence_Size(pyIn) == 2)) return false; Shiboken::AutoDecRef pyReal(PySequence_GetItem(pyIn, 0)); - if (!SbkNumber_Check(pyReal)) + if (!PyNumber_Check(pyReal)) return false; Shiboken::AutoDecRef pyImag(PySequence_GetItem(pyIn, 1)); - if (!SbkNumber_Check(pyImag)) + if (!PyNumber_Check(pyImag)) return false; return true; } diff --git a/sources/shiboken6/doc/typesystem_variables.rst b/sources/shiboken6/doc/typesystem_variables.rst index 3d4638253..c6564513b 100644 --- a/sources/shiboken6/doc/typesystem_variables.rst +++ b/sources/shiboken6/doc/typesystem_variables.rst @@ -230,14 +230,14 @@ Variables .. code-block:: c++ - long a = PyInt_AS_LONG(%PYARG_1); + long a = PyLong_AS_LONG(%PYARG_1); is equivalent of .. code-block:: c++ - long a = PyInt_AS_LONG(PyTuple_GET_ITEM(%PYTHON_ARGUMENTS, 0)); + long a = PyLong_AS_LONG(PyTuple_GET_ITEM(%PYTHON_ARGUMENTS, 0)); The generator tries to be smart with attributions, but it will work for the @@ -248,7 +248,7 @@ Variables .. code-block:: c++ Py_DECREF(%PYARG_1); - %PYARG_1 = PyInt_FromLong(10); + %PYARG_1 = PyLong_FromLong(10); is equivalent of @@ -256,7 +256,7 @@ Variables .. code-block:: c++ Py_DECREF(PyTuple_GET_ITEM(%PYTHON_ARGUMENTS, 0)); - PyTuple_SET_ITEM(%PYTHON_ARGUMENTS, 0, PyInt_FromLong(10)); + PyTuple_SET_ITEM(%PYTHON_ARGUMENTS, 0, PyLong_FromLong(10)); .. _pyself: diff --git a/sources/shiboken6/generator/shiboken/cppgenerator.cpp b/sources/shiboken6/generator/shiboken/cppgenerator.cpp index cc5fb20fb..e84f29303 100644 --- a/sources/shiboken6/generator/shiboken/cppgenerator.cpp +++ b/sources/shiboken6/generator/shiboken/cppgenerator.cpp @@ -2469,7 +2469,7 @@ void CppGenerator::writeTypeCheck(TextStream &s, const OverloadData *overloadDat } // This condition trusts that the OverloadData object will arrange for - // PyInt type to come after the more precise numeric types (e.g. float and bool) + // PyLong type to come after the more precise numeric types (e.g. float and bool) AbstractMetaType argType = overloadData->argType(); if (auto viewOn = argType.viewOn()) argType = *viewOn; @@ -4242,7 +4242,7 @@ void CppGenerator::writeClassDefinition(TextStream &s, const AbstractMetaClass *qCoreApp = AbstractMetaClass::findClass(api().classes(), QLatin1String("QCoreApplication")); const bool isQApp = qCoreApp != Q_NULLPTR && metaClass->inheritsFrom(qCoreApp); - tp_flags = QLatin1String("Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_CHECKTYPES"); + tp_flags = QLatin1String("Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE"); if (metaClass->isNamespace() || metaClass->hasPrivateDestructor()) { tp_dealloc = metaClass->hasPrivateDestructor() ? QLatin1String("SbkDeallocWrapperWithPrivateDtor") : @@ -4262,7 +4262,7 @@ void CppGenerator::writeClassDefinition(TextStream &s, ? cpythonSetattroFunctionName(metaClass) : QString(); if (metaClass->hasPrivateDestructor() || onlyPrivCtor) { - // tp_flags = QLatin1String("Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES"); + // tp_flags = QLatin1String("Py_TPFLAGS_DEFAULT"); // This is not generally possible, because PySide does not care about // privacy the same way. This worked before the heap types were used, // because inheritance is not really checked for static types. @@ -5189,7 +5189,7 @@ void CppGenerator::writeEnumInitialization(TextStream &s, const AbstractMetaEnum s << "{\n"; { Indentation indent(s); - s << "PyObject *anonEnumItem = PyInt_FromLong(" << enumValueText << ");\n" + s << "PyObject *anonEnumItem = PyLong_FromLong(" << enumValueText << ");\n" << "if (PyDict_SetItemString(reinterpret_cast<PyTypeObject *>(reinterpret_cast<SbkObjectType *>(" << enclosingObjectVariable << "))->tp_dict, \"" << mangledName << "\", anonEnumItem) < 0)\n"; @@ -5900,7 +5900,7 @@ void CppGenerator::writeGetattroFunction(TextStream &s, AttroCheck attroCheck, Indentation indent(s); s << "return Py_TYPE(meth)->tp_descr_get(meth, self, nullptr);\n"; } - s << "return PyFunction_Check(meth) ? SBK_PyMethod_New(meth, self)\n" + s << "return PyFunction_Check(meth) ? PyMethod_New(meth, self)\n" << " : " << getattrFunc << ";\n"; } s << "}\n"; diff --git a/sources/shiboken6/generator/shiboken/pytypenames.h b/sources/shiboken6/generator/shiboken/pytypenames.h index 779f67f2f..d3b1fdbe9 100644 --- a/sources/shiboken6/generator/shiboken/pytypenames.h +++ b/sources/shiboken6/generator/shiboken/pytypenames.h @@ -33,7 +33,7 @@ static inline QString pyBoolT() { return QStringLiteral("PyBool"); } static inline QString pyFloatT() { return QStringLiteral("PyFloat"); } -static inline QString pyIntT() { return QStringLiteral("PyInt"); } +static inline QString pyIntT() { return QStringLiteral("PyLong"); } static inline QString pyLongT() { return QStringLiteral("PyLong"); } static inline QString pyObjectT() { return QStringLiteral("object"); } static inline QString pyStrT() { return QStringLiteral("str"); } diff --git a/sources/shiboken6/generator/shiboken/shibokengenerator.cpp b/sources/shiboken6/generator/shiboken/shibokengenerator.cpp index 920c668c1..9a2588e33 100644 --- a/sources/shiboken6/generator/shiboken/shibokengenerator.cpp +++ b/sources/shiboken6/generator/shiboken/shibokengenerator.cpp @@ -977,7 +977,7 @@ bool ShibokenGenerator::isPyInt(const TypeEntry *type) if (!type->isPrimitive()) return false; return pythonPrimitiveTypeName(static_cast<const PrimitiveTypeEntry *>(type)) - == QLatin1String("PyInt"); + == QLatin1String("PyLong"); } bool ShibokenGenerator::isPyInt(const AbstractMetaType &type) diff --git a/sources/shiboken6/libshiboken/helper.cpp b/sources/shiboken6/libshiboken/helper.cpp index 02f8177f3..aa8d28c38 100644 --- a/sources/shiboken6/libshiboken/helper.cpp +++ b/sources/shiboken6/libshiboken/helper.cpp @@ -255,12 +255,12 @@ int *sequenceToIntArray(PyObject *obj, bool zeroTerminated) for (int i = 0; i < size; i++) { PyObject *item = PySequence_Fast_GET_ITEM(seq.object(), i); - if (!PyInt_Check(item)) { + if (!PyLong_Check(item)) { PyErr_SetString(PyExc_TypeError, "Sequence of ints expected"); delete[] array; return nullptr; } - array[i] = PyInt_AsLong(item); + array[i] = PyLong_AsLong(item); } if (zeroTerminated) diff --git a/sources/shiboken6/libshiboken/sbkconverter.h b/sources/shiboken6/libshiboken/sbkconverter.h index 6c7a29300..00d18f935 100644 --- a/sources/shiboken6/libshiboken/sbkconverter.h +++ b/sources/shiboken6/libshiboken/sbkconverter.h @@ -376,18 +376,18 @@ template<typename T> PyTypeObject *SbkType() { return nullptr; } // Below are the template specializations for C++ primitive types. template<> inline PyTypeObject *SbkType<PY_LONG_LONG>() { return &PyLong_Type; } template<> inline PyTypeObject *SbkType<bool>() { return &PyBool_Type; } -template<> inline PyTypeObject *SbkType<char>() { return &PyInt_Type; } +template<> inline PyTypeObject *SbkType<char>() { return &PyLong_Type; } template<> inline PyTypeObject *SbkType<double>() { return &PyFloat_Type; } template<> inline PyTypeObject *SbkType<float>() { return &PyFloat_Type; } -template<> inline PyTypeObject *SbkType<int>() { return &PyInt_Type; } +template<> inline PyTypeObject *SbkType<int>() { return &PyLong_Type; } template<> inline PyTypeObject *SbkType<long>() { return &PyLong_Type; } -template<> inline PyTypeObject *SbkType<short>() { return &PyInt_Type; } -template<> inline PyTypeObject *SbkType<signed char>() { return &PyInt_Type; } +template<> inline PyTypeObject *SbkType<short>() { return &PyLong_Type; } +template<> inline PyTypeObject *SbkType<signed char>() { return &PyLong_Type; } template<> inline PyTypeObject *SbkType<unsigned PY_LONG_LONG>() { return &PyLong_Type; } -template<> inline PyTypeObject *SbkType<unsigned char>() { return &PyInt_Type; } +template<> inline PyTypeObject *SbkType<unsigned char>() { return &PyLong_Type; } template<> inline PyTypeObject *SbkType<unsigned int>() { return &PyLong_Type; } template<> inline PyTypeObject *SbkType<unsigned long>() { return &PyLong_Type; } -template<> inline PyTypeObject *SbkType<unsigned short>() { return &PyInt_Type; } +template<> inline PyTypeObject *SbkType<unsigned short>() { return &PyLong_Type; } template<> inline PyTypeObject *SbkType<std::nullptr_t>() { return Py_TYPE(&_Py_NoneStruct); } } // namespace Shiboken @@ -395,7 +395,7 @@ template<> inline PyTypeObject *SbkType<std::nullptr_t>() { return Py_TYPE(&_Py_ // When the user adds a function with an argument unknown for the typesystem, the generator writes type checks as // TYPENAME_Check, so this macro allows users to add PyObject arguments to their added functions. #define PyObject_Check(X) true -#define SbkChar_Check(X) (SbkNumber_Check(X) || Shiboken::String::checkChar(X)) +#define SbkChar_Check(X) (PyNumber_Check(X) || Shiboken::String::checkChar(X)) struct _SbkGenericTypePrivate { SbkConverter **converter; diff --git a/sources/shiboken6/libshiboken/sbkconverter_p.h b/sources/shiboken6/libshiboken/sbkconverter_p.h index 9e23fa54c..98f39bfea 100644 --- a/sources/shiboken6/libshiboken/sbkconverter_p.h +++ b/sources/shiboken6/libshiboken/sbkconverter_p.h @@ -252,7 +252,7 @@ struct IntPrimitive : TwoPrimitive<INT> { static PyObject *toPython(const void *cppIn) { - return PyInt_FromLong(*reinterpret_cast<const INT *>(cppIn)); + return PyLong_FromLong(*reinterpret_cast<const INT *>(cppIn)); } static void toCpp(PyObject *pyIn, void *cppOut) { @@ -277,7 +277,7 @@ struct IntPrimitive : TwoPrimitive<INT> } static PythonToCppFunc isOtherConvertible(PyObject *pyIn) { - if (SbkNumber_Check(pyIn)) + if (PyNumber_Check(pyIn)) return otherToCpp; return nullptr; } @@ -318,7 +318,7 @@ struct Primitive<PY_LONG_LONG> : OnePrimitive<PY_LONG_LONG> } static PythonToCppFunc isConvertible(PyObject *pyIn) { - if (SbkNumber_Check(pyIn)) + if (PyNumber_Check(pyIn)) return toCpp; return nullptr; } @@ -345,7 +345,7 @@ struct Primitive<unsigned PY_LONG_LONG> : OnePrimitive<unsigned PY_LONG_LONG> } static PythonToCppFunc isConvertible(PyObject *pyIn) { - if (SbkNumber_Check(pyIn)) + if (PyNumber_Check(pyIn)) return toCpp; return nullptr; } @@ -366,7 +366,7 @@ struct FloatPrimitive : TwoPrimitive<FLOAT> } static PythonToCppFunc isConvertible(PyObject *pyIn) { - if (PyInt_Check(pyIn) || PyLong_Check(pyIn)) + if (PyLong_Check(pyIn) || PyLong_Check(pyIn)) return toCpp; return nullptr; } @@ -376,7 +376,7 @@ struct FloatPrimitive : TwoPrimitive<FLOAT> } static PythonToCppFunc isOtherConvertible(PyObject *pyIn) { - if (SbkNumber_Check(pyIn)) + if (PyNumber_Check(pyIn)) return otherToCpp; return nullptr; } @@ -395,13 +395,13 @@ struct Primitive<bool> : OnePrimitive<bool> } static PythonToCppFunc isConvertible(PyObject *pyIn) { - if (SbkNumber_Check(pyIn)) + if (PyNumber_Check(pyIn)) return toCpp; return nullptr; } static void toCpp(PyObject *pyIn, void *cppOut) { - *reinterpret_cast<bool *>(cppOut) = PyInt_AS_LONG(pyIn) != 0; + *reinterpret_cast<bool *>(cppOut) = PyLong_AS_LONG(pyIn) != 0; } }; @@ -429,7 +429,7 @@ struct CharPrimitive : IntPrimitive<CHAR> } static PythonToCppFunc isOtherConvertible(PyObject *pyIn) { - if (SbkNumber_Check(pyIn)) + if (PyNumber_Check(pyIn)) return otherToCpp; return nullptr; } diff --git a/sources/shiboken6/libshiboken/sbkenum.cpp b/sources/shiboken6/libshiboken/sbkenum.cpp index a3d17ea2e..c30c3597a 100644 --- a/sources/shiboken6/libshiboken/sbkenum.cpp +++ b/sources/shiboken6/libshiboken/sbkenum.cpp @@ -171,12 +171,12 @@ static PyObject *_enum_op(enum_func f, PyObject *a, PyObject *b) { * versions of Python (version 2) we need to convert it to int type, * respectively. * - * Thus calling PyInt_FromLong() will result in calling PyLong_FromLong in + * Thus calling PyLong_FromLong() will result in calling PyLong_FromLong in * Py3k. */ static PyObject *enum_int(PyObject *v) { - return PyInt_FromLong(reinterpret_cast<SbkEnumObject *>(v)->ob_value); + return PyLong_FromLong(reinterpret_cast<SbkEnumObject *>(v)->ob_value); } static PyObject *enum_and(PyObject *self, PyObject *b) @@ -280,7 +280,7 @@ static PyType_Spec SbkEnumType_Type_spec = { "1:Shiboken.EnumMeta", 0, // filled in later sizeof(PyMemberDef), - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_CHECKTYPES, + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, SbkEnumType_Type_slots, }; @@ -344,7 +344,7 @@ static PyObject *enum___reduce__(PyObject *obj) return Py_BuildValue("O(Ni)", enum_unpickler, Py_BuildValue("s", Py_TYPE(obj)->tp_name), - PyInt_AS_LONG(obj)); + PyLong_AS_LONG(obj)); } } // extern "C" @@ -611,7 +611,7 @@ static PyType_Spec SbkNewEnum_spec = { "1:Shiboken.Enum", sizeof(SbkEnumObject), 0, - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_CHECKTYPES, + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, SbkNewEnum_slots, }; diff --git a/sources/shiboken6/libshiboken/sbkfeature_base.cpp b/sources/shiboken6/libshiboken/sbkfeature_base.cpp index 0cbaf46be..679cf1fe4 100644 --- a/sources/shiboken6/libshiboken/sbkfeature_base.cpp +++ b/sources/shiboken6/libshiboken/sbkfeature_base.cpp @@ -78,13 +78,13 @@ PyObject *getFeatureSelectId() PyObject *select_id = PyDict_GetItem(feature_dict, modname); if (select_id == nullptr - || !PyInt_Check(select_id) // int/long cheating + || !PyLong_Check(select_id) // int/long cheating || select_id == undef) return last_select_id; cached_globals = globals; last_select_id = select_id; - assert(PyInt_AsSsize_t(select_id) >= 0); + assert(PyLong_AsSsize_t(select_id) >= 0); return select_id; } diff --git a/sources/shiboken6/libshiboken/sbkpython.h b/sources/shiboken6/libshiboken/sbkpython.h index 772fe76ac..60997814f 100644 --- a/sources/shiboken6/libshiboken/sbkpython.h +++ b/sources/shiboken6/libshiboken/sbkpython.h @@ -101,24 +101,6 @@ extern "C" { # include "pep384impl.h" #endif -#define PyInt_Type PyLong_Type -#define PyInt_Check PyLong_Check -#define PyInt_CheckExact PyLong_CheckExact -#define PyInt_FromString PyLong_FromString -#define PyInt_FromSsize_t PyLong_FromSsize_t -#define PyInt_FromSize_t PyLong_FromSize_t -#define PyInt_AS_LONG PyLong_AS_LONG -#define PyInt_AsUnsignedLongLongMask PyLong_AsLongLong -#define PyInt_FromLong PyLong_FromLong -#define PyInt_AsLong PyLong_AsLong -#define SbkNumber_Check PyNumber_Check -#define Py_TPFLAGS_CHECKTYPES 0 - -#define SBK_NB_BOOL(x) (x).nb_bool -#define SBK_PyMethod_New PyMethod_New -#define PyInt_AsSsize_t(x) PyLong_AsSsize_t(x) -#define PyString_Type PyUnicode_Type - // In Python 3, Py_TPFLAGS_DEFAULT contains Py_TPFLAGS_HAVE_VERSION_TAG, // which will trigger the attribute cache, which is not intended in Qt for Python. // Use a customized Py_TPFLAGS_DEFAULT by defining Py_TPFLAGS_HAVE_VERSION_TAG = 0. diff --git a/sources/shiboken6/libshiboken/signature/signature_extend.cpp b/sources/shiboken6/libshiboken/signature/signature_extend.cpp index 43a78ed21..528c7c87a 100644 --- a/sources/shiboken6/libshiboken/signature/signature_extend.cpp +++ b/sources/shiboken6/libshiboken/signature/signature_extend.cpp @@ -272,7 +272,7 @@ int PySide_PatchTypes(void) if (!init_done) { AutoDecRef meth_descr(PyObject_GetAttrString( - reinterpret_cast<PyObject *>(&PyString_Type), "split")); + reinterpret_cast<PyObject *>(&PyUnicode_Type), "split")); AutoDecRef wrap_descr(PyObject_GetAttrString( reinterpret_cast<PyObject *>(Py_TYPE(Py_True)), "__add__")); // abbreviations for readability diff --git a/sources/shiboken6/shibokenmodule/typesystem_shiboken.xml b/sources/shiboken6/shibokenmodule/typesystem_shiboken.xml index 7ebc990e1..741826bff 100644 --- a/sources/shiboken6/shibokenmodule/typesystem_shiboken.xml +++ b/sources/shiboken6/shibokenmodule/typesystem_shiboken.xml @@ -116,11 +116,11 @@ <inject-code position="end"> // Add __version__ and __version_info__ attributes to the module PyObject* version = PyTuple_New(5); - PyTuple_SET_ITEM(version, 0, PyInt_FromLong(SHIBOKEN_MAJOR_VERSION)); - PyTuple_SET_ITEM(version, 1, PyInt_FromLong(SHIBOKEN_MINOR_VERSION)); - PyTuple_SET_ITEM(version, 2, PyInt_FromLong(SHIBOKEN_MICRO_VERSION)); + PyTuple_SET_ITEM(version, 0, PyLong_FromLong(SHIBOKEN_MAJOR_VERSION)); + PyTuple_SET_ITEM(version, 1, PyLong_FromLong(SHIBOKEN_MINOR_VERSION)); + PyTuple_SET_ITEM(version, 2, PyLong_FromLong(SHIBOKEN_MICRO_VERSION)); PyTuple_SET_ITEM(version, 3, Shiboken::String::fromCString(SHIBOKEN_RELEASE_LEVEL)); - PyTuple_SET_ITEM(version, 4, PyInt_FromLong(SHIBOKEN_SERIAL)); + PyTuple_SET_ITEM(version, 4, PyLong_FromLong(SHIBOKEN_SERIAL)); PyModule_AddObject(module, "__version_info__", version); PyModule_AddStringConstant(module, "__version__", SHIBOKEN_VERSION); diff --git a/sources/shiboken6/tests/samplebinding/typesystem_sample.xml b/sources/shiboken6/tests/samplebinding/typesystem_sample.xml index fe5e4343c..f2f437184 100644 --- a/sources/shiboken6/tests/samplebinding/typesystem_sample.xml +++ b/sources/shiboken6/tests/samplebinding/typesystem_sample.xml @@ -48,10 +48,10 @@ if (!PySequence_Check(pyIn) || !(PySequence_Size(pyIn) == 2)) return false; Shiboken::AutoDecRef pyReal(PySequence_GetItem(pyIn, 0)); - if (!SbkNumber_Check(pyReal)) + if (!PyNumber_Check(pyReal)) return false; Shiboken::AutoDecRef pyImag(PySequence_GetItem(pyIn, 1)); - if (!SbkNumber_Check(pyImag)) + if (!PyNumber_Check(pyImag)) return false; return true; } @@ -1374,7 +1374,7 @@ <replace-default-expression with="3000"/> </modify-argument> <inject-code class="native" position="beginning"> - PyObject* new_arg0 = PyInt_FromLong(PyInt_AS_LONG(%PYARG_1) - %2); + PyObject* new_arg0 = PyLong_FromLong(PyLong_AS_LONG(%PYARG_1) - %2); Py_DECREF(%PYARG_1); %PYARG_1 = new_arg0; </inject-code> @@ -1448,10 +1448,10 @@ PyObject* _obj = %PYARG_0.object(); if (!PySequence_Check(_obj) || PySequence_Fast_GET_SIZE(_obj) != 4 - || !SbkNumber_Check(PySequence_Fast_GET_ITEM(_obj, 0)) - || !SbkNumber_Check(PySequence_Fast_GET_ITEM(_obj, 1)) - || !SbkNumber_Check(PySequence_Fast_GET_ITEM(_obj, 2)) - || !SbkNumber_Check(PySequence_Fast_GET_ITEM(_obj, 3))) { + || !PyNumber_Check(PySequence_Fast_GET_ITEM(_obj, 0)) + || !PyNumber_Check(PySequence_Fast_GET_ITEM(_obj, 1)) + || !PyNumber_Check(PySequence_Fast_GET_ITEM(_obj, 2)) + || !PyNumber_Check(PySequence_Fast_GET_ITEM(_obj, 3))) { PyErr_SetString(PyExc_TypeError, "Sequence of 4 numbers expected"); } else { *%1 = %CONVERTTOCPP[int](PySequence_Fast_GET_ITEM(_obj, 0)); @@ -2337,7 +2337,7 @@ <conversion-rule class="native"> // Does nothing really, just test the code generation // of constructors whose arguments where - long %out = PyInt_AS_LONG(%PYARG_1) + 1; + long %out = PyLong_AS_LONG(%PYARG_1) + 1; </conversion-rule> </modify-argument> </modify-function> |