From bf7ea7d24fe48433c59a35bb3f64d5eb102e0cc8 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 18 Sep 2023 11:05:57 +0200 Subject: Replace typedef by using Change-Id: I23d8ea03ec578a897352c2627417a706ca71ef82 Reviewed-by: Shyamnath Premnadh Reviewed-by: Qt CI Bot (cherry picked from commit d249f2922bcbbca0169faabc5108db5999adaf54) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit 028c18b450d4098b64ab520d5be04325547b12bb) --- sources/pyside6/PySide6/QtQml/typesystem_qml.xml | 4 ++-- sources/pyside6/PySide6/pysidewtypes.h | 12 ++++++------ sources/pyside6/libpyside/class_property.h | 4 ++-- sources/pyside6/libpyside/feature_select.cpp | 6 +++--- sources/pyside6/libpyside/pyside.cpp | 2 +- sources/pyside6/libpyside/pysideslot.cpp | 4 ++-- sources/pyside6/libpyside/pysideweakref.cpp | 4 ++-- sources/pyside6/libpyside/pysideweakref.h | 2 +- sources/pyside6/tests/pysidetest/testobject.h | 8 +++----- sources/shiboken6/libshiboken/basewrapper.h | 18 +++++++++--------- sources/shiboken6/libshiboken/bindingmanager.h | 2 +- sources/shiboken6/libshiboken/bufferprocs_py37.h | 4 ++-- sources/shiboken6/libshiboken/pep384impl.h | 2 +- sources/shiboken6/libshiboken/sbkarrayconverter_p.h | 2 +- sources/shiboken6/libshiboken/sbkconverter.h | 6 +++--- .../libshiboken/signature/signature_globals.cpp | 2 +- sources/shiboken6/libshiboken/signature_p.h | 6 +++--- sources/shiboken6/libshiboken/voidptr.cpp | 4 ++-- sources/shiboken6/tests/libsample/cvlist.h | 2 +- sources/shiboken6/tests/libsample/nontypetemplate.h | 4 ++-- 20 files changed, 48 insertions(+), 50 deletions(-) diff --git a/sources/pyside6/PySide6/QtQml/typesystem_qml.xml b/sources/pyside6/PySide6/QtQml/typesystem_qml.xml index d3ad64bab..b5538dcba 100644 --- a/sources/pyside6/PySide6/QtQml/typesystem_qml.xml +++ b/sources/pyside6/PySide6/QtQml/typesystem_qml.xml @@ -15,10 +15,10 @@ using AtomicBool = std::atomic<bool>; - typedef struct { + struct QtQml_VolatileBoolObject { PyObject_HEAD AtomicBool *flag; - } QtQml_VolatileBoolObject; + }; diff --git a/sources/pyside6/PySide6/pysidewtypes.h b/sources/pyside6/PySide6/pysidewtypes.h index 4e6cf8263..f853949ac 100644 --- a/sources/pyside6/PySide6/pysidewtypes.h +++ b/sources/pyside6/PySide6/pysidewtypes.h @@ -4,12 +4,12 @@ #ifndef __PYSIDEWTYPES__ #define __PYSIDEWTYPES__ -typedef struct HWND__ *HWND; -typedef unsigned UINT; -typedef long LONG; -typedef unsigned long DWORD; -typedef UINT WPARAM; -typedef LONG LPARAM; +using HWND = struct HWND__ *; +using UINT = unsigned; +using LONG = long; +using DWORD = unsigned long; +using WPARAM = UINT; +using LPARAM = LONG; struct POINT { diff --git a/sources/pyside6/libpyside/class_property.h b/sources/pyside6/libpyside/class_property.h index 3f4a6e9e6..d5dc76b57 100644 --- a/sources/pyside6/libpyside/class_property.h +++ b/sources/pyside6/libpyside/class_property.h @@ -9,7 +9,7 @@ extern "C" { -typedef struct { +struct propertyobject { PyObject_HEAD PyObject *prop_get; PyObject *prop_set; @@ -21,7 +21,7 @@ typedef struct { PyObject *prop_name; #endif int getter_doc; -} propertyobject; +}; PYSIDE_API PyTypeObject *PyClassProperty_TypeF(); diff --git a/sources/pyside6/libpyside/feature_select.cpp b/sources/pyside6/libpyside/feature_select.cpp index b3b692578..1c0fb451e 100644 --- a/sources/pyside6/libpyside/feature_select.cpp +++ b/sources/pyside6/libpyside/feature_select.cpp @@ -93,7 +93,7 @@ namespace PySide { namespace Feature { using namespace Shiboken; -typedef bool(*FeatureProc)(PyTypeObject *type, PyObject *prev_dict, int id); +using FeatureProc = bool(*)(PyTypeObject *type, PyObject *prev_dict, int id); static FeatureProc *featurePointer = nullptr; @@ -501,12 +501,12 @@ static bool feature_01_addLowerNames(PyTypeObject *type, PyObject *prev_dict, in // This is the Python 2 version for inspection of m_ml, only. // The actual Python 3 version is larget. -typedef struct { +struct PyCFunctionObject { PyObject_HEAD PyMethodDef *m_ml; /* Description of the C function to call */ PyObject *m_self; /* Passed as 'self' arg to the C func, can be NULL */ PyObject *m_module; /* The __module__ attribute, can be anything */ -} PyCFunctionObject; +}; static PyObject *modifyStaticToClassMethod(PyTypeObject *type, PyObject *sm) { diff --git a/sources/pyside6/libpyside/pyside.cpp b/sources/pyside6/libpyside/pyside.cpp index 33a05cc0d..f2a2f0cb9 100644 --- a/sources/pyside6/libpyside/pyside.cpp +++ b/sources/pyside6/libpyside/pyside.cpp @@ -645,7 +645,7 @@ void setNextQObjectMemoryAddr(void *addr) // A std::shared_ptr is used with a deletion function to invalidate a pointer // when the property value is cleared. This should be a QSharedPointer with // a void *pointer, but that isn't allowed -typedef char any_t; +using any_t = char; Q_DECLARE_METATYPE(std::shared_ptr); diff --git a/sources/pyside6/libpyside/pysideslot.cpp b/sources/pyside6/libpyside/pysideslot.cpp index 9b0f1f4e0..f22e5534e 100644 --- a/sources/pyside6/libpyside/pysideslot.cpp +++ b/sources/pyside6/libpyside/pysideslot.cpp @@ -19,11 +19,11 @@ struct SlotData QByteArray resultType; }; -typedef struct +struct PySideSlot { PyObject_HEAD SlotData *slotData; -} PySideSlot; +}; extern "C" { diff --git a/sources/pyside6/libpyside/pysideweakref.cpp b/sources/pyside6/libpyside/pysideweakref.cpp index 79a19fec8..7a94048bb 100644 --- a/sources/pyside6/libpyside/pysideweakref.cpp +++ b/sources/pyside6/libpyside/pysideweakref.cpp @@ -6,12 +6,12 @@ #include #include -typedef struct { +struct PySideCallableObject { PyObject_HEAD /* Type-specific fields go here. */ PySideWeakRefFunction weakref_func; void *user_data; -} PySideCallableObject; +}; static PyObject *CallableObject_call(PyObject *callable_object, PyObject *args, PyObject *kw); diff --git a/sources/pyside6/libpyside/pysideweakref.h b/sources/pyside6/libpyside/pysideweakref.h index 71386903f..156203cfb 100644 --- a/sources/pyside6/libpyside/pysideweakref.h +++ b/sources/pyside6/libpyside/pysideweakref.h @@ -7,7 +7,7 @@ #include #include -typedef void (*PySideWeakRefFunction)(void* userData); +using PySideWeakRefFunction = void (*)(void *userData); namespace PySide { namespace WeakRef { diff --git a/sources/pyside6/tests/pysidetest/testobject.h b/sources/pyside6/tests/pysidetest/testobject.h index 88652bcca..359387730 100644 --- a/sources/pyside6/tests/pysidetest/testobject.h +++ b/sources/pyside6/tests/pysidetest/testobject.h @@ -23,7 +23,7 @@ public: int value; }; -typedef IntValue TypedefValue; +using TypedefValue = IntValue; class PYSIDETEST_API TestObject : public QObject { @@ -60,8 +60,7 @@ private: PYSIDETEST_API QDebug operator<<(QDebug dbg, TestObject &testObject); -typedef int PySideInt; - +using PySideInt = int; namespace PySideCPP { @@ -100,8 +99,7 @@ namespace PySideCPP2 { enum Enum1 { Option1 = 1, Option2 = 2 }; - -typedef long PySideLong; +using PySideLong = long; class PYSIDETEST_API TestObjectWithoutNamespace : public QObject { diff --git a/sources/shiboken6/libshiboken/basewrapper.h b/sources/shiboken6/libshiboken/basewrapper.h index a57fa06f1..0930830c5 100644 --- a/sources/shiboken6/libshiboken/basewrapper.h +++ b/sources/shiboken6/libshiboken/basewrapper.h @@ -38,27 +38,27 @@ LIBSHIBOKEN_API void SbkDeallocQAppWrapper(PyObject *pyObj); LIBSHIBOKEN_API void SbkDeallocWrapperWithPrivateDtor(PyObject *self); /// Function signature for the multiple inheritance information initializers that should be provided by classes with multiple inheritance. -typedef int *(*MultipleInheritanceInitFunction)(const void *); +using MultipleInheritanceInitFunction = int *(*)(const void *); /** * Special cast function is used to correctly cast an object when it's * part of a multiple inheritance hierarchy. * The implementation of this function is auto generated by the generator and you don't need to care about it. */ -typedef void *(*SpecialCastFunction)(void *, PyTypeObject *); -typedef PyTypeObject *(*TypeDiscoveryFunc)(void *, PyTypeObject *); -typedef void *(*TypeDiscoveryFuncV2)(void *, PyTypeObject *); +using SpecialCastFunction = void *(*)(void *, PyTypeObject *); +using TypeDiscoveryFunc = PyTypeObject *(*)(void *, PyTypeObject *); +using TypeDiscoveryFuncV2 = void *(*)(void *, PyTypeObject *); // Used in userdata dealloc function -typedef void (*DeleteUserDataFunc)(void *); +using DeleteUserDataFunc = void (*)(void *); -typedef void (*ObjectDestructor)(void *); +using ObjectDestructor = void (*)(void *); -typedef void (*SubTypeInitHook)(PyTypeObject *, PyObject *, PyObject *); +using SubTypeInitHook = void (*)(PyTypeObject *, PyObject *, PyObject *); /// PYSIDE-1019: Set the function to select the current feature. /// Return value is the previous content. -typedef void (*SelectableFeatureHook)(PyTypeObject *); +using SelectableFeatureHook = void (*)(PyTypeObject *); LIBSHIBOKEN_API SelectableFeatureHook initSelectableFeature(SelectableFeatureHook func); /// PYSIDE-1626: Enforcing a context switch without further action. @@ -72,7 +72,7 @@ LIBSHIBOKEN_API void SbkObjectType_SetPropertyStrings(PyTypeObject *type, const LIBSHIBOKEN_API void SbkObjectType_SetEnumFlagInfo(PyTypeObject *type, const char **strings); /// PYSIDE-1470: Set the function to kill a Q*Application. -typedef void(*DestroyQAppHook)(); +using DestroyQAppHook = void(*)(); LIBSHIBOKEN_API void setDestroyQApplication(DestroyQAppHook func); /// PYSIDE-535: Use the C API in PyPy instead of `op->ob_dict`, directly (borrowed ref) diff --git a/sources/shiboken6/libshiboken/bindingmanager.h b/sources/shiboken6/libshiboken/bindingmanager.h index 955c0a1f4..4b21ae835 100644 --- a/sources/shiboken6/libshiboken/bindingmanager.h +++ b/sources/shiboken6/libshiboken/bindingmanager.h @@ -15,7 +15,7 @@ namespace Shiboken struct DestructorEntry; -typedef void (*ObjectVisitor)(SbkObject *, void *); +using ObjectVisitor = void (*)(SbkObject *, void *); class LIBSHIBOKEN_API BindingManager { diff --git a/sources/shiboken6/libshiboken/bufferprocs_py37.h b/sources/shiboken6/libshiboken/bufferprocs_py37.h index 06b42cabd..e16194e50 100644 --- a/sources/shiboken6/libshiboken/bufferprocs_py37.h +++ b/sources/shiboken6/libshiboken/bufferprocs_py37.h @@ -67,8 +67,8 @@ typedef struct bufferinfo { void *internal; } Pep_buffer; -typedef int (*getbufferproc)(PyObject *, Pep_buffer *, int); -typedef void (*releasebufferproc)(PyObject *, Pep_buffer *); +using getbufferproc =int (*)(PyObject *, Pep_buffer *, int); +using releasebufferproc = void (*)(PyObject *, Pep_buffer *); /* Maximum number of dimensions */ #define PyBUF_MAX_NDIM 64 diff --git a/sources/shiboken6/libshiboken/pep384impl.h b/sources/shiboken6/libshiboken/pep384impl.h index d57b191a2..daf6b748a 100644 --- a/sources/shiboken6/libshiboken/pep384impl.h +++ b/sources/shiboken6/libshiboken/pep384impl.h @@ -285,7 +285,7 @@ enum PepUnicode_Kind { #ifdef Py_LIMITED_API -typedef struct _pycfunc PyCFunctionObject; +using PyCFunctionObject = struct _pycfunc; #define PyCFunction_GET_FUNCTION(func) PyCFunction_GetFunction((PyObject *)func) #define PyCFunction_GET_SELF(func) PyCFunction_GetSelf((PyObject *)func) #define PyCFunction_GET_FLAGS(func) PyCFunction_GetFlags((PyObject *)func) diff --git a/sources/shiboken6/libshiboken/sbkarrayconverter_p.h b/sources/shiboken6/libshiboken/sbkarrayconverter_p.h index db92e56af..63d03fb12 100644 --- a/sources/shiboken6/libshiboken/sbkarrayconverter_p.h +++ b/sources/shiboken6/libshiboken/sbkarrayconverter_p.h @@ -10,7 +10,7 @@ extern "C" { -typedef PythonToCppFunc (*IsArrayConvertibleToCppFunc)(PyObject *, int dim1, int dim2); +using IsArrayConvertibleToCppFunc = PythonToCppFunc (*)(PyObject *, int dim1, int dim2); /** * \internal * Private structure of SbkArrayConverter. diff --git a/sources/shiboken6/libshiboken/sbkconverter.h b/sources/shiboken6/libshiboken/sbkconverter.h index c4a99a818..9148e7a8a 100644 --- a/sources/shiboken6/libshiboken/sbkconverter.h +++ b/sources/shiboken6/libshiboken/sbkconverter.h @@ -43,7 +43,7 @@ struct SbkArrayConverter; * * C++ -> Python */ -typedef PyObject *(*CppToPythonFunc)(const void *); +using CppToPythonFunc = PyObject *(*)(const void *); /** * This function converts a Python object to a C++ value, it may be @@ -56,7 +56,7 @@ typedef PyObject *(*CppToPythonFunc)(const void *); * * Python -> C++ */ -typedef void (*PythonToCppFunc)(PyObject *,void *); +using PythonToCppFunc = void (*)(PyObject *,void *); /** * Checks if the Python object passed in the argument is convertible to a @@ -67,7 +67,7 @@ typedef void (*PythonToCppFunc)(PyObject *,void *); * * Python -> C++ ? */ -typedef PythonToCppFunc (*IsConvertibleToCppFunc)(PyObject *); +using IsConvertibleToCppFunc = PythonToCppFunc (*)(PyObject *); } // extern "C" diff --git a/sources/shiboken6/libshiboken/signature/signature_globals.cpp b/sources/shiboken6/libshiboken/signature/signature_globals.cpp index d41936126..3a79a12d5 100644 --- a/sources/shiboken6/libshiboken/signature/signature_globals.cpp +++ b/sources/shiboken6/libshiboken/signature/signature_globals.cpp @@ -237,7 +237,7 @@ static void handler(int sig) { //////////////////////////////////////////////////////////////////////////// #endif // _WIN32 -safe_globals pyside_globals = nullptr; +safe_globals_struc *pyside_globals = nullptr; void init_shibokensupport_module(void) { diff --git a/sources/shiboken6/libshiboken/signature_p.h b/sources/shiboken6/libshiboken/signature_p.h index d7e38ed90..d0c4ee537 100644 --- a/sources/shiboken6/libshiboken/signature_p.h +++ b/sources/shiboken6/libshiboken/signature_p.h @@ -10,7 +10,7 @@ extern "C" { // signature_globals.cpp -typedef struct safe_globals_struc { +struct safe_globals_struc { // init part 1: get arg_dict PyObject *helper_module; PyObject *arg_dict; @@ -25,9 +25,9 @@ typedef struct safe_globals_struc { PyObject *finish_import_func; PyObject *feature_import_func; PyObject *feature_imported_func; -} safe_globals_struc, *safe_globals; +}; -extern safe_globals pyside_globals; +extern safe_globals_struc *pyside_globals; extern PyMethodDef signature_methods[]; void init_shibokensupport_module(void); diff --git a/sources/shiboken6/libshiboken/voidptr.cpp b/sources/shiboken6/libshiboken/voidptr.cpp index e768ff608..abfff5831 100644 --- a/sources/shiboken6/libshiboken/voidptr.cpp +++ b/sources/shiboken6/libshiboken/voidptr.cpp @@ -10,12 +10,12 @@ extern "C" { // Void pointer object definition. -typedef struct { +struct SbkVoidPtrObject { PyObject_HEAD void *cptr; Py_ssize_t size; bool isWritable; -} SbkVoidPtrObject; +}; PyObject *SbkVoidPtrObject_new(PyTypeObject *type, PyObject * /* args */, PyObject * /* kwds */) { diff --git a/sources/shiboken6/tests/libsample/cvlist.h b/sources/shiboken6/tests/libsample/cvlist.h index 96eaab35e..e0c6dfeb5 100644 --- a/sources/shiboken6/tests/libsample/cvlist.h +++ b/sources/shiboken6/tests/libsample/cvlist.h @@ -12,7 +12,7 @@ class CVValueType CVValueType(); }; -typedef std::list const_ptr_value_list; +using const_ptr_value_list = std::list; // This tests binding generation for a container of a const value type. The // class doesn't need to do anything; this is just to verify that the generated diff --git a/sources/shiboken6/tests/libsample/nontypetemplate.h b/sources/shiboken6/tests/libsample/nontypetemplate.h index d3bc7fb8a..e41c21604 100644 --- a/sources/shiboken6/tests/libsample/nontypetemplate.h +++ b/sources/shiboken6/tests/libsample/nontypetemplate.h @@ -21,7 +21,7 @@ private: int m_array[Size]; }; -typedef IntArray<2> IntArray2; -typedef IntArray<3> IntArray3; +using IntArray2 = IntArray<2>; +using IntArray3 = IntArray<3>; #endif // NONTYPETEMPLATE_H -- cgit v1.2.3