aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/libshiboken/sbkconverter_p.h
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2019-06-16 12:05:39 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2019-06-24 11:25:31 +0200
commit380c65e62de0e60da667dc0d87935171b91b9c6c (patch)
tree480c872f247316a66e446ba196a5bd1a339a0bcd /sources/shiboken2/libshiboken/sbkconverter_p.h
parent992ff1f7925009b7ead6d6f005cafcf2e57ed44e (diff)
Cleanup pointer whitespace everywhere
Among other files to fix, basewrapper.(cpp|h) was full of uncommon pointer whitespace. After fixing that, I could not resist and fixed also libshiboken, generators, and after acceptance also PySide. Most of the time, this regex worked fine (\w\w+)([*&]+)[ ]*(?![&*]*[/=]) replaced with \1 \2 but everything was checked by hand. I did not touch the shiboken tests which are quite hairy. It turned out that inserting a space between a variable and asterisk causes a crash of shiboken, if the same line contains "CONVERTTOCPP". This was temporarily fixed by adding another space after it. Example.. sources/pyside2/PySide2/glue/qtcore.cpp line 977 QByteArray * cppSelf = %CONVERTTOCPP[QByteArray *](obj); //XXX /|\ omitting this space crashes shiboken! cppgenerator.cpp was special, since it was modified to _generate_ correct pointer whitespace. This caused a few testcases to fail, which had to be adjusted, again. This was difficult since some internal names must end on "*" and generated code normally not. Removing the last errors involved binary search on path sets... Apply C++ 11 fixits to the changed code, where applicable. Done-with: Friedemann.Kleint@qt.io Task-number: PYSIDE-1037 Change-Id: I4ac070f52c5efb296c05d581c9d46e6f397a6c81 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources/shiboken2/libshiboken/sbkconverter_p.h')
-rw-r--r--sources/shiboken2/libshiboken/sbkconverter_p.h140
1 files changed, 70 insertions, 70 deletions
diff --git a/sources/shiboken2/libshiboken/sbkconverter_p.h b/sources/shiboken2/libshiboken/sbkconverter_p.h
index cb968ed89..aa90094af 100644
--- a/sources/shiboken2/libshiboken/sbkconverter_p.h
+++ b/sources/shiboken2/libshiboken/sbkconverter_p.h
@@ -69,7 +69,7 @@ struct SbkConverter
* Python type to which the C++ value will be converted (note that the
* C++ type could be produced from various Python types).
*/
- PyTypeObject* pythonType;
+ PyTypeObject *pythonType;
/**
* This function converts a C++ object to a Python object of the type
* indicated in pythonType. The identity of the C++ object is kept,
@@ -77,7 +77,7 @@ struct SbkConverter
* with the C++ instance.
* It is used to convert C++ pointers and references to Python objects.
*/
- CppToPythonFunc pointerToPython;
+ CppToPythonFunc pointerToPython;
/**
* This function converts a C++ object to a Python object of the type
* indicated in pythonType. The identity of the object is not kept,
@@ -86,17 +86,17 @@ struct SbkConverter
* reference can't be traced to an object that already has a Python
* wrapper assigned for it.
*/
- CppToPythonFunc copyToPython;
+ CppToPythonFunc copyToPython;
/**
* This is a special case of a Python to C++ conversion. It returns
* the underlying C++ pointer of a Python wrapper passed as parameter
* or NULL if the Python object is a None value.
* It comes separated from the other toCppConversions because if you
* have a Python object representing a Value Type the type checking
- * for both ValueType and ValueType* would be the same, thus the first
+ * for both ValueType and ValueType *would be the same, thus the first
* check would be true and the second would never be reached.
*/
- ToCppConversion toCppPointerConversion;
+ ToCppConversion toCppPointerConversion;
/**
* This is a list of type checking functions that return the
* proper Python to C++ conversion function, for the given Python
@@ -104,14 +104,14 @@ struct SbkConverter
* For Object Types, that never have implicit conversions, this
* list is always empty.
*/
- ToCppConversionVector toCppConversions;
+ ToCppConversionVector toCppConversions;
};
} // extern "C"
template<typename T, typename MaxLimitType, bool isSigned>
struct OverFlowCheckerBase {
- static void formatOverFlowMessage(const MaxLimitType& value,
+ static void formatOverFlowMessage(const MaxLimitType &value,
const std::string *valueAsString = 0)
{
std::ostringstream str;
@@ -157,7 +157,7 @@ struct OverFlowChecker;
template<typename T, typename MaxLimitType>
struct OverFlowChecker<T, MaxLimitType, true> :
public OverFlowCheckerBase<T, MaxLimitType, true> {
- static bool check(const MaxLimitType& value, PyObject *pyIn)
+ static bool check(const MaxLimitType &value, PyObject *pyIn)
{
std::string valueAsString;
const bool isOverflow =
@@ -173,7 +173,7 @@ struct OverFlowChecker<T, MaxLimitType, true> :
template<typename T, typename MaxLimitType>
struct OverFlowChecker<T, MaxLimitType, false>
: public OverFlowCheckerBase<T, MaxLimitType, false> {
- static bool check(const MaxLimitType& value, PyObject *pyIn)
+ static bool check(const MaxLimitType &value, PyObject *pyIn)
{
std::string valueAsString;
const bool isOverflow =
@@ -204,7 +204,7 @@ struct OverFlowChecker<double, PY_LONG_LONG, true> {
template<>
struct OverFlowChecker<float, PY_LONG_LONG, true> :
public OverFlowCheckerBase<float, PY_LONG_LONG, true> {
- static bool check(const double& value, PyObject *)
+ static bool check(const double &value, PyObject *)
{
const bool result = value < std::numeric_limits<float>::min()
|| value > std::numeric_limits<float>::max();
@@ -221,12 +221,12 @@ template <typename T> struct Primitive {};
template <typename T>
struct OnePrimitive
{
- static PyObject* toPython(const void*) { return 0; }
- static PythonToCppFunc isConvertible(PyObject*) { return 0; }
- static void toCpp(PyObject*, void*) {}
- static SbkConverter* createConverter()
+ static PyObject *toPython(const void *) { return nullptr; }
+ static PythonToCppFunc isConvertible(PyObject *) { return nullptr; }
+ static void toCpp(PyObject *, void *) {}
+ static SbkConverter *createConverter()
{
- SbkConverter* converter = Shiboken::Conversions::createConverter(Shiboken::SbkType<T>(),
+ SbkConverter *converter = Shiboken::Conversions::createConverter(Shiboken::SbkType<T>(),
Primitive<T>::toPython);
Shiboken::Conversions::addPythonToCppValueConversion(converter,
Primitive<T>::toCpp,
@@ -237,11 +237,11 @@ struct OnePrimitive
template <typename T>
struct TwoPrimitive : OnePrimitive<T>
{
- static PythonToCppFunc isOtherConvertible(PyObject*) { return 0; }
- static void otherToCpp(PyObject*, void*) {}
- static SbkConverter* createConverter()
+ static PythonToCppFunc isOtherConvertible(PyObject *) { return nullptr; }
+ static void otherToCpp(PyObject *, void *) {}
+ static SbkConverter *createConverter()
{
- SbkConverter* converter = OnePrimitive<T>::createConverter();
+ SbkConverter *converter = OnePrimitive<T>::createConverter();
Shiboken::Conversions::addPythonToCppValueConversion(converter, Primitive<T>::otherToCpp, Primitive<T>::isOtherConvertible);
return converter;
}
@@ -252,11 +252,11 @@ struct TwoPrimitive : OnePrimitive<T>
template <typename INT>
struct IntPrimitive : TwoPrimitive<INT>
{
- static PyObject* toPython(const void* cppIn)
+ static PyObject *toPython(const void *cppIn)
{
return PyInt_FromLong(*reinterpret_cast<const INT *>(cppIn));
}
- static void toCpp(PyObject* pyIn, void* cppOut)
+ static void toCpp(PyObject *pyIn, void *cppOut)
{
double result = PyFloat_AS_DOUBLE(pyIn);
// If cast to long directly it could overflow silently.
@@ -264,20 +264,20 @@ struct IntPrimitive : TwoPrimitive<INT>
PyErr_SetObject(PyExc_OverflowError, 0);
*reinterpret_cast<INT * >(cppOut) = static_cast<INT>(result);
}
- static PythonToCppFunc isConvertible(PyObject* pyIn)
+ static PythonToCppFunc isConvertible(PyObject *pyIn)
{
if (PyFloat_Check(pyIn))
return toCpp;
return 0;
}
- static void otherToCpp(PyObject* pyIn, void* cppOut)
+ static void otherToCpp(PyObject *pyIn, void *cppOut)
{
PY_LONG_LONG result = PyLong_AsLongLong(pyIn);
if (OverFlowChecker<INT>::check(result, pyIn))
PyErr_SetObject(PyExc_OverflowError, 0);
*reinterpret_cast<INT * >(cppOut) = static_cast<INT>(result);
}
- static PythonToCppFunc isOtherConvertible(PyObject* pyIn)
+ static PythonToCppFunc isOtherConvertible(PyObject *pyIn)
{
if (SbkNumber_Check(pyIn))
return otherToCpp;
@@ -294,7 +294,7 @@ template <> struct Primitive<unsigned short> : IntPrimitive<unsigned short> {};
template <typename LONG>
struct UnsignedLongPrimitive : IntPrimitive<LONG>
{
- static PyObject* toPython(const void* cppIn)
+ static PyObject *toPython(const void *cppIn)
{
return PyLong_FromUnsignedLong(*reinterpret_cast<const LONG *>(cppIn));
}
@@ -307,18 +307,18 @@ template <> struct Primitive<unsigned long> : UnsignedLongPrimitive<unsigned lon
template <>
struct Primitive<PY_LONG_LONG> : OnePrimitive<PY_LONG_LONG>
{
- static PyObject* toPython(const void* cppIn)
+ static PyObject *toPython(const void *cppIn)
{
- return PyLong_FromLongLong(*((PY_LONG_LONG*)cppIn));
+ return PyLong_FromLongLong(*reinterpret_cast<const PY_LONG_LONG *>(cppIn));
}
- static void toCpp(PyObject* pyIn, void* cppOut)
+ static void toCpp(PyObject *pyIn, void *cppOut)
{
PY_LONG_LONG result = PyLong_AsLongLong(pyIn);
if (OverFlowChecker<PY_LONG_LONG>::check(result, pyIn))
PyErr_SetObject(PyExc_OverflowError, 0);
*reinterpret_cast<PY_LONG_LONG * >(cppOut) = result;
}
- static PythonToCppFunc isConvertible(PyObject* pyIn)
+ static PythonToCppFunc isConvertible(PyObject *pyIn)
{
if (SbkNumber_Check(pyIn))
return toCpp;
@@ -329,11 +329,11 @@ struct Primitive<PY_LONG_LONG> : OnePrimitive<PY_LONG_LONG>
template <>
struct Primitive<unsigned PY_LONG_LONG> : OnePrimitive<unsigned PY_LONG_LONG>
{
- static PyObject* toPython(const void* cppIn)
+ static PyObject *toPython(const void *cppIn)
{
- return PyLong_FromUnsignedLongLong(*((unsigned PY_LONG_LONG*)cppIn));
+ return PyLong_FromUnsignedLongLong(*reinterpret_cast<const unsigned PY_LONG_LONG *>(cppIn));
}
- static void toCpp(PyObject* pyIn, void* cppOut)
+ static void toCpp(PyObject *pyIn, void *cppOut)
{
#if PY_MAJOR_VERSION >= 3
if (PyLong_Check(pyIn)) {
@@ -362,7 +362,7 @@ struct Primitive<unsigned PY_LONG_LONG> : OnePrimitive<unsigned PY_LONG_LONG>
}
#endif // Python 2
}
- static PythonToCppFunc isConvertible(PyObject* pyIn)
+ static PythonToCppFunc isConvertible(PyObject *pyIn)
{
if (SbkNumber_Check(pyIn))
return toCpp;
@@ -375,25 +375,25 @@ struct Primitive<unsigned PY_LONG_LONG> : OnePrimitive<unsigned PY_LONG_LONG>
template <typename FLOAT>
struct FloatPrimitive : TwoPrimitive<FLOAT>
{
- static PyObject* toPython(const void* cppIn)
+ static PyObject *toPython(const void *cppIn)
{
return PyFloat_FromDouble(*reinterpret_cast<const FLOAT *>(cppIn));
}
- static void toCpp(PyObject* pyIn, void* cppOut)
+ static void toCpp(PyObject *pyIn, void *cppOut)
{
*reinterpret_cast<FLOAT *>(cppOut) = FLOAT(PyLong_AsLong(pyIn));
}
- static PythonToCppFunc isConvertible(PyObject* pyIn)
+ static PythonToCppFunc isConvertible(PyObject *pyIn)
{
if (PyInt_Check(pyIn) || PyLong_Check(pyIn))
return toCpp;
return 0;
}
- static void otherToCpp(PyObject* pyIn, void* cppOut)
+ static void otherToCpp(PyObject *pyIn, void *cppOut)
{
*reinterpret_cast<FLOAT *>(cppOut) = FLOAT(PyFloat_AsDouble(pyIn));
}
- static PythonToCppFunc isOtherConvertible(PyObject* pyIn)
+ static PythonToCppFunc isOtherConvertible(PyObject *pyIn)
{
if (SbkNumber_Check(pyIn))
return otherToCpp;
@@ -408,17 +408,17 @@ template <> struct Primitive<double> : FloatPrimitive<double> {};
template <>
struct Primitive<bool> : OnePrimitive<bool>
{
- static PyObject* toPython(const void* cppIn)
+ static PyObject *toPython(const void *cppIn)
{
return PyBool_FromLong(*reinterpret_cast<const bool *>(cppIn));
}
- static PythonToCppFunc isConvertible(PyObject* pyIn)
+ static PythonToCppFunc isConvertible(PyObject *pyIn)
{
if (SbkNumber_Check(pyIn))
return toCpp;
return 0;
}
- static void toCpp(PyObject* pyIn, void* cppOut)
+ static void toCpp(PyObject *pyIn, void *cppOut)
{
*reinterpret_cast<bool *>(cppOut) = PyInt_AS_LONG(pyIn) != 0;
}
@@ -429,32 +429,32 @@ struct Primitive<bool> : OnePrimitive<bool>
template <typename CHAR>
struct CharPrimitive : IntPrimitive<CHAR>
{
- static void toCpp(PyObject* pyIn, void* cppOut)
+ static void toCpp(PyObject *pyIn, void *cppOut)
{
*reinterpret_cast<CHAR *>(cppOut) = CHAR(Shiboken::String::toCString(pyIn)[0]);
}
- static PythonToCppFunc isConvertible(PyObject* pyIn)
+ static PythonToCppFunc isConvertible(PyObject *pyIn)
{
if (Shiboken::String::checkChar(pyIn))
return toCpp;
return 0;
}
- static void otherToCpp(PyObject* pyIn, void* cppOut)
+ static void otherToCpp(PyObject *pyIn, void *cppOut)
{
PY_LONG_LONG result = PyLong_AsLongLong(pyIn);
if (OverFlowChecker<CHAR>::check(result, pyIn))
PyErr_SetObject(PyExc_OverflowError, 0);
*reinterpret_cast<CHAR *>(cppOut) = CHAR(result);
}
- static PythonToCppFunc isOtherConvertible(PyObject* pyIn)
+ static PythonToCppFunc isOtherConvertible(PyObject *pyIn)
{
if (SbkNumber_Check(pyIn))
return otherToCpp;
return 0;
}
- static SbkConverter* createConverter()
+ static SbkConverter *createConverter()
{
- SbkConverter* converter = IntPrimitive<CHAR>::createConverter();
+ SbkConverter *converter = IntPrimitive<CHAR>::createConverter();
Shiboken::Conversions::addPythonToCppValueConversion(converter, CharPrimitive<CHAR>::otherToCpp, CharPrimitive<CHAR>::isOtherConvertible);
return converter;
}
@@ -464,8 +464,8 @@ template <> struct Primitive<signed char> : CharPrimitive<signed char> {};
template <> struct Primitive<unsigned char> : CharPrimitive<unsigned char> {};
template <> struct Primitive<char> : CharPrimitive<char> {
using CharPrimitive<char>::toPython;
- static PyObject* toPython(const void* cppIn) {
- return Shiboken::String::fromCString((const char*)cppIn, 1);
+ static PyObject *toPython(const void *cppIn) {
+ return Shiboken::String::fromCString(reinterpret_cast<const char *>(cppIn), 1);
}
};
@@ -474,29 +474,29 @@ template <> struct Primitive<char> : CharPrimitive<char> {
// Strings ---------------------------------------------------------------------------------
template <>
-struct Primitive<const char*> : TwoPrimitive<const char*>
+struct Primitive<const char *> : TwoPrimitive<const char *>
{
- static PyObject* toPython(const void* cppIn)
+ static PyObject *toPython(const void *cppIn)
{
if (!cppIn)
Py_RETURN_NONE;
- return Shiboken::String::fromCString((const char*)cppIn);
+ return Shiboken::String::fromCString(reinterpret_cast<const char *>(cppIn));
}
static void toCpp(PyObject *, void *cppOut)
{
- *((const char**)cppOut) = 0;
+ *((const char **)cppOut) = 0;
}
- static PythonToCppFunc isConvertible(PyObject* pyIn)
+ static PythonToCppFunc isConvertible(PyObject *pyIn)
{
if (pyIn == Py_None)
return toCpp;
return 0;
}
- static void otherToCpp(PyObject* pyIn, void* cppOut)
+ static void otherToCpp(PyObject *pyIn, void *cppOut)
{
- *((const char**)cppOut) = (const char*) Shiboken::String::toCString(pyIn);
+ *reinterpret_cast<const char **>(cppOut) = Shiboken::String::toCString(pyIn);
}
- static PythonToCppFunc isOtherConvertible(PyObject* pyIn)
+ static PythonToCppFunc isOtherConvertible(PyObject *pyIn)
{
if (Shiboken::String::check(pyIn))
return otherToCpp;
@@ -507,25 +507,25 @@ struct Primitive<const char*> : TwoPrimitive<const char*>
template <>
struct Primitive<std::string> : TwoPrimitive<std::string>
{
- static PyObject* toPython(const void* cppIn)
+ static PyObject *toPython(const void *cppIn)
{
- return Shiboken::String::fromCString(((std::string*)cppIn)->c_str());
+ return Shiboken::String::fromCString(reinterpret_cast<const std::string *>(cppIn)->c_str());
}
static void toCpp(PyObject *, void *cppOut)
{
- *((std::string*)cppOut) = std::string();
+ reinterpret_cast<std::string *>(cppOut)->clear();
}
- static PythonToCppFunc isConvertible(PyObject* pyIn)
+ static PythonToCppFunc isConvertible(PyObject *pyIn)
{
if (pyIn == Py_None)
return toCpp;
return 0;
}
- static void otherToCpp(PyObject* pyIn, void* cppOut)
+ static void otherToCpp(PyObject *pyIn, void *cppOut)
{
- *((std::string*)cppOut) = Shiboken::String::toCString(pyIn);
+ reinterpret_cast<std::string *>(cppOut)->assign(Shiboken::String::toCString(pyIn));
}
- static PythonToCppFunc isOtherConvertible(PyObject* pyIn)
+ static PythonToCppFunc isOtherConvertible(PyObject *pyIn)
{
if (Shiboken::String::check(pyIn))
return otherToCpp;
@@ -537,25 +537,25 @@ struct Primitive<std::string> : TwoPrimitive<std::string>
template <>
struct Primitive<std::nullptr_t> : TwoPrimitive<std::nullptr_t>
{
- static PyObject* toPython(const void* cppIn)
+ static PyObject *toPython(const void *cppIn)
{
return Py_None;
}
static void toCpp(PyObject *, void *cppOut)
{
- *reinterpret_cast<std::nullptr_t*>(cppOut) = nullptr;
+ *reinterpret_cast<std::nullptr_t *>(cppOut) = nullptr;
}
- static PythonToCppFunc isConvertible(PyObject* pyIn)
+ static PythonToCppFunc isConvertible(PyObject *pyIn)
{
if (pyIn == Py_None)
return toCpp;
return nullptr;
}
- static void otherToCpp(PyObject* pyIn, void* cppOut)
+ static void otherToCpp(PyObject *pyIn, void *cppOut)
{
- *reinterpret_cast<std::nullptr_t*>(cppOut) = nullptr;
+ *reinterpret_cast<std::nullptr_t *>(cppOut) = nullptr;
}
- static PythonToCppFunc isOtherConvertible(PyObject* pyIn)
+ static PythonToCppFunc isOtherConvertible(PyObject *pyIn)
{
if (pyIn == nullptr)
return otherToCpp;