diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-06-25 09:33:27 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-06-25 10:43:56 +0200 |
commit | ddfbbd346b522703a5b6f8d274a7f79983e5f319 (patch) | |
tree | 6ebd312287a1398b4b619b37045370cbeb83e1d1 /sources/shiboken2/tests | |
parent | 2eced73f6b8dd9f568e84e78f786a0ec8d6dd429 (diff) |
shiboken: Introduce nullptr
Apply Fixits by Qt Creator with some amendments.
Change-Id: Ie8300ddb834adb8b649324562f2c912a4e8cf4ce
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken2/tests')
25 files changed, 54 insertions, 54 deletions
diff --git a/sources/shiboken2/tests/libother/otherderived.cpp b/sources/shiboken2/tests/libother/otherderived.cpp index 5b1714f2a..d23f6ad23 100644 --- a/sources/shiboken2/tests/libother/otherderived.cpp +++ b/sources/shiboken2/tests/libother/otherderived.cpp @@ -51,7 +51,7 @@ OtherDerived::pureVirtual() void* OtherDerived::pureVirtualReturningVoidPtr() { - return 0; + return nullptr; } void diff --git a/sources/shiboken2/tests/libother/othermultiplederived.cpp b/sources/shiboken2/tests/libother/othermultiplederived.cpp index 554df3c76..e7ee4f96d 100644 --- a/sources/shiboken2/tests/libother/othermultiplederived.cpp +++ b/sources/shiboken2/tests/libother/othermultiplederived.cpp @@ -45,6 +45,6 @@ Base1* OtherMultipleDerived::createObject(const std::string& objName) return new MDerived3; else if (objName == "OtherMultipleDerived") return new OtherMultipleDerived; - return 0; + return nullptr; } diff --git a/sources/shiboken2/tests/libsample/abstract.cpp b/sources/shiboken2/tests/libsample/abstract.cpp index c4900d0af..e60c792c4 100644 --- a/sources/shiboken2/tests/libsample/abstract.cpp +++ b/sources/shiboken2/tests/libsample/abstract.cpp @@ -38,7 +38,7 @@ Abstract::Abstract(int id) : m_id(id) { primitiveField = 123; valueTypeField = Point(12, 34); - objectTypeField = 0; + objectTypeField = nullptr; bitField = 0; } diff --git a/sources/shiboken2/tests/libsample/abstract.h b/sources/shiboken2/tests/libsample/abstract.h index 9e7cf5a29..09906f1ee 100644 --- a/sources/shiboken2/tests/libsample/abstract.h +++ b/sources/shiboken2/tests/libsample/abstract.h @@ -74,7 +74,7 @@ public: inline int id() { return m_id; } // factory method - inline static Abstract* createObject() { return 0; } + inline static Abstract* createObject() { return nullptr; } // method that receives an Object Type inline static int getObjectId(Abstract* obj) { return obj->id(); } diff --git a/sources/shiboken2/tests/libsample/blackbox.cpp b/sources/shiboken2/tests/libsample/blackbox.cpp index f3dd57e97..0546ba7c2 100644 --- a/sources/shiboken2/tests/libsample/blackbox.cpp +++ b/sources/shiboken2/tests/libsample/blackbox.cpp @@ -49,7 +49,7 @@ BlackBox::keepObjectType(ObjectType* object) m_ticket++; std::pair<int, ObjectType*> item(m_ticket, object); m_objects.insert(item); - object->setParent(0); + object->setParent(nullptr); return m_ticket; } @@ -63,7 +63,7 @@ BlackBox::retrieveObjectType(int ticket) m_objects.erase(it); return second; } - return 0; + return nullptr; } void @@ -93,7 +93,7 @@ BlackBox::retrievePoint(int ticket) m_points.erase(it); return second; } - return 0; + return nullptr; } void diff --git a/sources/shiboken2/tests/libsample/derived.cpp b/sources/shiboken2/tests/libsample/derived.cpp index 4fa3e4081..0dc026876 100644 --- a/sources/shiboken2/tests/libsample/derived.cpp +++ b/sources/shiboken2/tests/libsample/derived.cpp @@ -54,7 +54,7 @@ Derived::pureVirtual() void* Derived::pureVirtualReturningVoidPtr() { - return 0; + return nullptr; } void @@ -100,7 +100,7 @@ Derived::otherOverloaded(int a, double b) struct SecretClass : public Abstract { virtual void pureVirtual() {} - virtual void* pureVirtualReturningVoidPtr() { return 0; } + virtual void *pureVirtualReturningVoidPtr() { return nullptr; } virtual PrintFormat returnAnEnum() { return Short; } void hideFunction(HideType*){}; private: diff --git a/sources/shiboken2/tests/libsample/expression.cpp b/sources/shiboken2/tests/libsample/expression.cpp index a6051306e..0c255a659 100644 --- a/sources/shiboken2/tests/libsample/expression.cpp +++ b/sources/shiboken2/tests/libsample/expression.cpp @@ -30,18 +30,18 @@ #include "expression.h" #include <sstream> -Expression::Expression() : m_value(0), m_operation(None), m_operand1(0), m_operand2(0) +Expression::Expression() : m_value(0), m_operation(None), m_operand1(nullptr), m_operand2(nullptr) { } -Expression::Expression(int number) : m_value(number), m_operation(None), m_operand1(0), m_operand2(0) +Expression::Expression(int number) : m_value(number), m_operation(None), m_operand1(nullptr), m_operand2(nullptr) { } Expression::Expression(const Expression& other) { - m_operand1 = other.m_operand1 ? new Expression(*other.m_operand1) : 0; - m_operand2 = other.m_operand2 ? new Expression(*other.m_operand2) : 0; + m_operand1 = other.m_operand1 ? new Expression(*other.m_operand1) : nullptr; + m_operand2 = other.m_operand2 ? new Expression(*other.m_operand2) : nullptr; m_value = other.m_value; m_operation = other.m_operation; } @@ -50,8 +50,8 @@ Expression& Expression::operator=(const Expression& other) { delete m_operand1; delete m_operand2; - m_operand1 = other.m_operand1 ? new Expression(*other.m_operand1) : 0; - m_operand2 = other.m_operand2 ? new Expression(*other.m_operand2) : 0; + m_operand1 = other.m_operand1 ? new Expression(*other.m_operand1) : nullptr; + m_operand2 = other.m_operand2 ? new Expression(*other.m_operand2) : nullptr; m_operation = other.m_operation; m_value = other.m_value; return *this; diff --git a/sources/shiboken2/tests/libsample/functions.cpp b/sources/shiboken2/tests/libsample/functions.cpp index 5cc9a1c67..288fa96ee 100644 --- a/sources/shiboken2/tests/libsample/functions.cpp +++ b/sources/shiboken2/tests/libsample/functions.cpp @@ -118,19 +118,19 @@ overloadedFunc(double val) char* returnNullPrimitivePointer() { - return 0; + return nullptr; } ObjectType* returnNullObjectTypePointer() { - return 0; + return nullptr; } Event* returnNullValueTypePointer() { - return 0; + return nullptr; } unsigned int diff --git a/sources/shiboken2/tests/libsample/handle.h b/sources/shiboken2/tests/libsample/handle.h index 400a0a3a6..18221c763 100644 --- a/sources/shiboken2/tests/libsample/handle.h +++ b/sources/shiboken2/tests/libsample/handle.h @@ -45,7 +45,7 @@ typedef OBJ* HANDLE; class LIBSAMPLE_API HandleHolder { public: - explicit HandleHolder(HANDLE ptr = 0) : m_handle(ptr) {} + explicit HandleHolder(HANDLE ptr = nullptr) : m_handle(ptr) {} explicit HandleHolder(Foo::HANDLE val): m_handle2(val) {} inline void set(HANDLE ptr) { HANDLE tmp; tmp = m_handle; m_handle = tmp; } diff --git a/sources/shiboken2/tests/libsample/modifications.h b/sources/shiboken2/tests/libsample/modifications.h index 035ec844e..fa32bdec3 100644 --- a/sources/shiboken2/tests/libsample/modifications.h +++ b/sources/shiboken2/tests/libsample/modifications.h @@ -117,7 +117,7 @@ public: double callDifferenceOfPointCoordinates(const Point* pt, bool* ok) { return differenceOfPointCoordinates(pt, ok); } // Sets an ObjectType in the argument and returns true. - bool nonConversionRuleForArgumentWithDefaultValue(ObjectType** object = 0); + bool nonConversionRuleForArgumentWithDefaultValue(ObjectType **object = nullptr); ObjectType* getObject() const { return m_object; } // Inject code with a %CONVERTTOPYTHON that receives an user's primitive type. diff --git a/sources/shiboken2/tests/libsample/objectmodel.h b/sources/shiboken2/tests/libsample/objectmodel.h index e15ce06a4..1890ac47f 100644 --- a/sources/shiboken2/tests/libsample/objectmodel.h +++ b/sources/shiboken2/tests/libsample/objectmodel.h @@ -35,8 +35,8 @@ class LIBSAMPLE_API ObjectModel : public ObjectType { public: - explicit ObjectModel(ObjectType* parent = 0) - : ObjectType(parent), m_data(0) + explicit ObjectModel(ObjectType *parent = nullptr) + : ObjectType(parent), m_data(nullptr) {} void setData(ObjectType* data); diff --git a/sources/shiboken2/tests/libsample/objecttype.cpp b/sources/shiboken2/tests/libsample/objecttype.cpp index f82b7cf0d..855c08611 100644 --- a/sources/shiboken2/tests/libsample/objecttype.cpp +++ b/sources/shiboken2/tests/libsample/objecttype.cpp @@ -35,7 +35,7 @@ using namespace std; -ObjectType::ObjectType(ObjectType* parent) : m_parent(0), m_layout(0), m_call_id(-1) +ObjectType::ObjectType(ObjectType* parent) : m_parent(nullptr), m_layout(nullptr), m_call_id(-1) { setParent(parent); } @@ -66,7 +66,7 @@ ObjectType::removeChild(ObjectType* child) ObjectTypeList::iterator child_iter = std::find(m_children.begin(), m_children.end(), child); if (child_iter != m_children.end()) { m_children.erase(child_iter); - child->m_parent = 0; + child->m_parent = nullptr; } } @@ -74,15 +74,15 @@ ObjectType* ObjectType::takeChild(ObjectType* child) { if (!child) - return 0; + return nullptr; ObjectTypeList::iterator child_iter = std::find(m_children.begin(), m_children.end(), child); if (child_iter != m_children.end()) { m_children.erase(child_iter); - child->m_parent = 0; + child->m_parent = nullptr; return child; } - return 0; + return nullptr; } ObjectType* @@ -101,7 +101,7 @@ ObjectType::findChild(const Str& name) if ((*child_iter)->objectName() == name) return *child_iter; } - return 0; + return nullptr; } void @@ -218,8 +218,8 @@ ObjectTypeLayout* ObjectType::takeLayout() { ObjectTypeLayout* l = layout(); if (!l) - return 0; - m_layout = 0; + return nullptr; + m_layout = nullptr; l->setParent(0); return l; } diff --git a/sources/shiboken2/tests/libsample/objecttype.h b/sources/shiboken2/tests/libsample/objecttype.h index ecd67b684..cb5823c5b 100644 --- a/sources/shiboken2/tests/libsample/objecttype.h +++ b/sources/shiboken2/tests/libsample/objecttype.h @@ -71,7 +71,7 @@ public: // ### Fixme: Use uintptr_t in C++ 11 typedef size_t Identifier; - explicit ObjectType(ObjectType* parent = 0); + explicit ObjectType(ObjectType *parent = nullptr); virtual ~ObjectType(); // factory method diff --git a/sources/shiboken2/tests/libsample/objectview.h b/sources/shiboken2/tests/libsample/objectview.h index 6a54057e9..b68d031e9 100644 --- a/sources/shiboken2/tests/libsample/objectview.h +++ b/sources/shiboken2/tests/libsample/objectview.h @@ -38,7 +38,7 @@ class ObjectModel; class LIBSAMPLE_API ObjectView : public ObjectType { public: - ObjectView(ObjectModel* model = 0, ObjectType* parent = 0) + ObjectView(ObjectModel *model = nullptr, ObjectType *parent = nullptr) : ObjectType(parent), m_model(model) {} diff --git a/sources/shiboken2/tests/libsample/overload.h b/sources/shiboken2/tests/libsample/overload.h index 6d0165619..aa2572d50 100644 --- a/sources/shiboken2/tests/libsample/overload.h +++ b/sources/shiboken2/tests/libsample/overload.h @@ -83,7 +83,7 @@ public: FunctionEnum wrapperIntIntOverloads(const Polygon& arg0, int arg1, int arg2) { return Function1; } // Similar to QImage constructor - FunctionEnum strBufferOverloads(const Str& arg0, const char* arg1 = 0, bool arg2 = true) { return Function0; } + FunctionEnum strBufferOverloads(const Str &arg0, const char *arg1 = nullptr, bool arg2 = true) { return Function0; } FunctionEnum strBufferOverloads(unsigned char* arg0, int arg1) { return Function1; } FunctionEnum strBufferOverloads() { return Function2; } diff --git a/sources/shiboken2/tests/libsample/photon.h b/sources/shiboken2/tests/libsample/photon.h index 2a32d511a..b9fc6532d 100644 --- a/sources/shiboken2/tests/libsample/photon.h +++ b/sources/shiboken2/tests/libsample/photon.h @@ -116,7 +116,7 @@ LIBSAMPLE_API int countValueDuplicators(const std::list<TemplateBase<DuplicatorT class Pointer { public: - Pointer() PHOTON_NOEXCEPT : px(0) {} + Pointer() PHOTON_NOEXCEPT : px(nullptr) {} Pointer(int* p) : px(p) {} void reset() PHOTON_NOEXCEPT { Pointer().swap(*this); } diff --git a/sources/shiboken2/tests/libsample/protected.h b/sources/shiboken2/tests/libsample/protected.h index 6cdc66e2b..0f4fbf299 100644 --- a/sources/shiboken2/tests/libsample/protected.h +++ b/sources/shiboken2/tests/libsample/protected.h @@ -50,7 +50,7 @@ protected: inline int protectedSum(int a0, int a1) { return a0 + a1; } inline int modifiedProtectedSum(int a0, int a1) { return a0 + a1; } inline static const char* protectedStatic() { return "protectedStatic"; } - inline const char* dataTypeName(void *data = 0) const { return "pointer"; } + inline const char* dataTypeName(void *data = nullptr) const { return "pointer"; } inline const char* dataTypeName(int data) const { return "integer"; } private: @@ -130,8 +130,8 @@ public: : protectedValueTypeProperty(Point(0, 0)), protectedProperty(0), protectedEnumProperty(Event::NO_EVENT), - protectedValueTypePointerProperty(0), - protectedObjectTypeProperty(0) + protectedValueTypePointerProperty(nullptr), + protectedObjectTypeProperty(nullptr) {} protected: // This is deliberately the first member to test wrapper registration diff --git a/sources/shiboken2/tests/libsample/samplenamespace.cpp b/sources/shiboken2/tests/libsample/samplenamespace.cpp index e066869d2..fc9f6d395 100644 --- a/sources/shiboken2/tests/libsample/samplenamespace.cpp +++ b/sources/shiboken2/tests/libsample/samplenamespace.cpp @@ -78,7 +78,7 @@ getNumber(Option opt) retval = rand() % 100; break; case UnixTime: - retval = (int) time(0); + retval = (int) time(nullptr); break; default: retval = 0; diff --git a/sources/shiboken2/tests/libsample/samplenamespace.h b/sources/shiboken2/tests/libsample/samplenamespace.h index 27fa11290..6868b5f0a 100644 --- a/sources/shiboken2/tests/libsample/samplenamespace.h +++ b/sources/shiboken2/tests/libsample/samplenamespace.h @@ -92,7 +92,7 @@ inline double powerOfTwo(double num) { return num * num; } -LIBSAMPLE_API void doSomethingWithArray(const unsigned char* data, unsigned int size, const char* format = 0); +LIBSAMPLE_API void doSomethingWithArray(const unsigned char *data, unsigned int size, const char *format = nullptr); LIBSAMPLE_API int enumItemAsDefaultValueToIntArgument(int value = ZeroIn); @@ -145,19 +145,19 @@ public: // enum SampleNamespace { // }; virtual OkThisIsRecursiveEnough* someVirtualMethod(OkThisIsRecursiveEnough* arg) { return arg; } - inline OkThisIsRecursiveEnough* methodReturningTypeFromParentScope() { return 0; } + inline OkThisIsRecursiveEnough *methodReturningTypeFromParentScope() { return nullptr; } }; // The combination of the following two overloaded methods could trigger a // problematic behaviour on the overload decisor, if it isn't working properly. -LIBSAMPLE_API void forceDecisorSideA(ObjectType* object = 0); +LIBSAMPLE_API void forceDecisorSideA(ObjectType *object = nullptr); LIBSAMPLE_API void forceDecisorSideA(const Point& pt, const Str& text, ObjectType* object = 0); // The combination of the following two overloaded methods could trigger a // problematic behaviour on the overload decisor, if it isn't working properly. // This is a variation of forceDecisorSideB. -LIBSAMPLE_API void forceDecisorSideB(int a, ObjectType* object = 0); -LIBSAMPLE_API void forceDecisorSideB(int a, const Point& pt, const Str& text, ObjectType* object = 0); +LIBSAMPLE_API void forceDecisorSideB(int a, ObjectType *object = nullptr); +LIBSAMPLE_API void forceDecisorSideB(int a, const Point &pt, const Str &text, ObjectType *object = nullptr); // Add a new signature on type system with only a Point value as parameter. LIBSAMPLE_API double passReferenceToValueType(const Point& point, double multiplier); diff --git a/sources/shiboken2/tests/libsample/simplefile.cpp b/sources/shiboken2/tests/libsample/simplefile.cpp index a47571a01..3b68e02c3 100644 --- a/sources/shiboken2/tests/libsample/simplefile.cpp +++ b/sources/shiboken2/tests/libsample/simplefile.cpp @@ -34,7 +34,7 @@ class SimpleFile_p { public: - SimpleFile_p(const char* filename) : m_descriptor(0), m_size(0) + SimpleFile_p(const char* filename) : m_descriptor(nullptr), m_size(0) { m_filename = strdup(filename); } @@ -73,7 +73,7 @@ long SimpleFile::size() bool SimpleFile::open() { - if ((p->m_descriptor = fopen(p->m_filename, "rb")) == 0) + if ((p->m_descriptor = fopen(p->m_filename, "rb")) == nullptr) return false; fseek(p->m_descriptor, 0, SEEK_END); @@ -88,7 +88,7 @@ SimpleFile::close() { if (p->m_descriptor) { fclose(p->m_descriptor); - p->m_descriptor = 0; + p->m_descriptor = nullptr; } } diff --git a/sources/shiboken2/tests/libsample/sometime.h b/sources/shiboken2/tests/libsample/sometime.h index 319cd7f8f..ef16efa29 100644 --- a/sources/shiboken2/tests/libsample/sometime.h +++ b/sources/shiboken2/tests/libsample/sometime.h @@ -70,7 +70,7 @@ public: NumArgs somethingCompletelyDifferent(); NumArgs somethingCompletelyDifferent(int h, int m, ImplicitConv ic = ImplicitConv::CtorThree, - ObjectType* type = 0); + ObjectType *type = nullptr); Str toString() const; bool operator==(const Time& other) const; diff --git a/sources/shiboken2/tests/libsample/str.h b/sources/shiboken2/tests/libsample/str.h index d3bcbaafc..4af00e5b6 100644 --- a/sources/shiboken2/tests/libsample/str.h +++ b/sources/shiboken2/tests/libsample/str.h @@ -49,7 +49,7 @@ public: char get_char(int pos) const; bool set_char(int pos, char ch); - int toInt(bool* ok = 0, int base = 10) const; + int toInt(bool *ok = nullptr, int base = 10) const; void show() const; @@ -73,6 +73,6 @@ LIBSAMPLE_API unsigned int strHash(const Str& str); typedef Str PStr; LIBSAMPLE_API void changePStr(PStr* pstr, const char* suffix); -LIBSAMPLE_API void duplicatePStr(PStr* pstr = 0); +LIBSAMPLE_API void duplicatePStr(PStr *pstr = nullptr); #endif // STR_H diff --git a/sources/shiboken2/tests/libsample/virtualmethods.cpp b/sources/shiboken2/tests/libsample/virtualmethods.cpp index 2d26bd7c8..294feca60 100644 --- a/sources/shiboken2/tests/libsample/virtualmethods.cpp +++ b/sources/shiboken2/tests/libsample/virtualmethods.cpp @@ -40,7 +40,7 @@ bool VirtualMethods::createStr(const char* text, Str*& ret) { if (!text) { - ret = 0; + ret = nullptr; return false; } diff --git a/sources/shiboken2/tests/libsample/voidholder.h b/sources/shiboken2/tests/libsample/voidholder.h index 23408fad8..367e99ddf 100644 --- a/sources/shiboken2/tests/libsample/voidholder.h +++ b/sources/shiboken2/tests/libsample/voidholder.h @@ -34,7 +34,7 @@ class VoidHolder { public: - explicit VoidHolder(void* ptr = 0) : m_ptr(ptr) {} + explicit VoidHolder(void *ptr = nullptr) : m_ptr(ptr) {} ~VoidHolder() {} inline void* voidPointer() { return m_ptr; } inline static void* gimmeMeSomeVoidPointer() diff --git a/sources/shiboken2/tests/libsmart/smart.h b/sources/shiboken2/tests/libsmart/smart.h index 2e3c96406..3347b22c1 100644 --- a/sources/shiboken2/tests/libsmart/smart.h +++ b/sources/shiboken2/tests/libsmart/smart.h @@ -81,7 +81,7 @@ public: template <class T> class SharedPtr { public: - SharedPtr() : m_refData(0) { + SharedPtr() : m_refData(nullptr) { if (shouldPrint()) std::cout << "shared_ptr default constructor " << this << "\n"; } @@ -122,7 +122,7 @@ public: { if (m_refData) return m_refData->m_heldPtr; - return 0; + return nullptr; } int useCount() const @@ -147,7 +147,7 @@ public: { if (m_refData) return m_refData->m_heldPtr; - return 0; + return nullptr; } bool operator!() const |