瀏覽代碼

Add NOLINT for types that we consider can be used interchangebly.
Fix the rest of the build error by calling constructor explicitly.
Related to commit d6eb307e34c72eeda57095f5d1f1afe9bea6b656

Yao Wei Tjong 姚伟忠 8 年之前
父節點
當前提交
2b493dc3dd

+ 2 - 2
Source/Urho3D/Container/ArrayPtr.h

@@ -126,7 +126,7 @@ public:
     bool operator <(const SharedArrayPtr<T>& rhs) const { return ptr_ < rhs.ptr_; }
 
     /// Convert to a raw pointer.
-    explicit operator T*() const { return ptr_; }
+    operator T*() const { return ptr_; }    // NOLINT
 
     /// Reset to null and release the array reference.
     void Reset() { ReleaseRef(); }
@@ -340,7 +340,7 @@ public:
     bool operator <(const WeakArrayPtr<T>& rhs) const { return ptr_ < rhs.ptr_; }
 
     /// Convert to a raw pointer, null if array is expired.
-    explicit operator T*() const { return Get(); }
+    operator T*() const { return Get(); }       // NOLINT
 
     /// Reset to null and release the weak reference.
     void Reset() { ReleaseRef(); }

+ 1 - 1
Source/Urho3D/Container/HashMap.h

@@ -165,7 +165,7 @@ public:
         }
 
         /// Construct from a non-const iterator.
-        explicit ConstIterator(const Iterator& rhs) :
+        ConstIterator(const Iterator& rhs) :        // NOLINT
             HashIteratorBase(rhs.ptr_)
         {
         }

+ 1 - 1
Source/Urho3D/Container/HashSet.h

@@ -122,7 +122,7 @@ public:
         }
 
         /// Construct from a non-const iterator.
-        explicit ConstIterator(const Iterator& rhs) :
+        ConstIterator(const Iterator& rhs) :    // NOLINT
             HashIteratorBase(rhs.ptr_)
         {
         }

+ 1 - 1
Source/Urho3D/Container/List.h

@@ -116,7 +116,7 @@ public:
         }
 
         /// Construct from a non-const iterator.
-        explicit ConstIterator(const Iterator& rhs) :
+        ConstIterator(const Iterator& rhs) :        // NOLINT
             ListIteratorBase(rhs.ptr_)
         {
         }

+ 4 - 4
Source/Urho3D/Container/Ptr.h

@@ -43,7 +43,7 @@ public:
     }
 
     /// Construct a null shared pointer.
-    explicit SharedPtr(std::nullptr_t) :
+    SharedPtr(std::nullptr_t) :     // NOLINT
         ptr_(0)
     {
     }
@@ -142,7 +142,7 @@ public:
     template <class U> bool operator !=(const SharedPtr<U>& rhs) const { return ptr_ != rhs.ptr_; }
 
     /// Convert to a raw pointer.
-    explicit operator T*() const { return ptr_; }
+    operator T*() const { return ptr_; }    // NOLINT
 
     /// Swap with another SharedPtr.
     void Swap(SharedPtr& rhs) { Urho3D::Swap(ptr_, rhs.ptr_); }
@@ -251,7 +251,7 @@ public:
     }
 
     /// Construct a null weak pointer.
-    explicit WeakPtr(std::nullptr_t) :
+    WeakPtr(std::nullptr_t) :   // NOLINT
         ptr_(0),
         refCount_(nullptr)
     {
@@ -405,7 +405,7 @@ public:
     template <class U> bool operator <(const WeakPtr<U>& rhs) const { return ptr_ < rhs.ptr_; }
 
     /// Convert to a raw pointer, null if the object is expired.
-    explicit operator T*() const { return Get(); }
+    operator T*() const { return Get(); }   // NOLINT
 
     /// Reset to null and release the weak reference.
     void Reset() { ReleaseRef(); }

+ 2 - 2
Source/Urho3D/Container/Str.h

@@ -61,7 +61,7 @@ public:
     }
 
     /// Construct from a C string.
-    explicit String(const char* str) :
+    String(const char* str) :   // NOLINT
         length_(0),
         capacity_(0),
         buffer_(&endZero)
@@ -70,7 +70,7 @@ public:
     }
 
     /// Construct from a C string.
-    explicit String(char* str) :
+    String(char* str) :         // NOLINT
         length_(0),
         capacity_(0),
         buffer_(&endZero)

+ 1 - 1
Source/Urho3D/Container/VectorBase.h

@@ -145,7 +145,7 @@ template <class T> struct RandomAccessConstIterator
     }
 
     /// Construct from a non-const iterator.
-    explicit RandomAccessConstIterator(const RandomAccessIterator<T>& rhs) :
+    RandomAccessConstIterator(const RandomAccessIterator<T>& rhs) :     // NOLINT
         ptr_(rhs.ptr_)
     {
     }

+ 32 - 32
Source/Urho3D/Core/Variant.h

@@ -326,194 +326,194 @@ public:
     Variant() = default;
 
     /// Construct from integer.
-    explicit Variant(int value)
+    Variant(int value)                  // NOLINT
     {
         *this = value;
     }
 
     /// Construct from 64 bit integer.
-    explicit Variant(long long value)
+    Variant(long long value)            // NOLINT
     {
         *this = value;
     }
 
     /// Construct from unsigned integer.
-    explicit Variant(unsigned value)
+    Variant(unsigned value)             // NOLINT
     {
         *this = (int)value;
     }
 
     /// Construct from unsigned integer.
-    explicit Variant(unsigned long long value)
+    Variant(unsigned long long value)   // NOLINT
     {
         *this = (long long)value;
     }
 
     /// Construct from a string hash (convert to integer).
-    explicit Variant(const StringHash& value)
+    Variant(const StringHash& value)    // NOLINT
     {
         *this = (int)value.Value();
     }
 
     /// Construct from a bool.
-    explicit Variant(bool value)
+    Variant(bool value)                 // NOLINT
     {
         *this = value;
     }
 
     /// Construct from a float.
-    explicit Variant(float value)
+    Variant(float value)                // NOLINT
     {
         *this = value;
     }
 
     /// Construct from a double.
-    explicit Variant(double value)
+    Variant(double value)               // NOLINT
     {
         *this = value;
     }
 
     /// Construct from a Vector2.
-    explicit Variant(const Vector2& value)
+    Variant(const Vector2& value)       // NOLINT
     {
         *this = value;
     }
 
     /// Construct from a Vector3.
-    explicit Variant(const Vector3& value)
+    Variant(const Vector3& value)       // NOLINT
     {
         *this = value;
     }
 
     /// Construct from a Vector4.
-    explicit Variant(const Vector4& value)
+    Variant(const Vector4& value)       // NOLINT
     {
         *this = value;
     }
 
     /// Construct from a quaternion.
-    explicit Variant(const Quaternion& value)
+    Variant(const Quaternion& value)    // NOLINT
     {
         *this = value;
     }
 
     /// Construct from a color.
-    explicit Variant(const Color& value)
+    Variant(const Color& value)         // NOLINT
     {
         *this = value;
     }
 
     /// Construct from a string.
-    explicit Variant(const String& value)
+    Variant(const String& value)        // NOLINT
     {
         *this = value;
     }
 
     /// Construct from a C string.
-    explicit Variant(const char* value)
+    Variant(const char* value)          // NOLINT
     {
         *this = value;
     }
 
     /// Construct from a buffer.
-    explicit Variant(const PODVector<unsigned char>& value)
+    Variant(const PODVector<unsigned char>& value)      // NOLINT
     {
         *this = value;
     }
 
     /// Construct from a %VectorBuffer and store as a buffer.
-    explicit Variant(const VectorBuffer& value)
+    Variant(const VectorBuffer& value)  // NOLINT
     {
         *this = value;
     }
 
     /// Construct from a pointer.
-    explicit Variant(void* value)
+    Variant(void* value)                // NOLINT
     {
         *this = value;
     }
 
     /// Construct from a resource reference.
-    explicit Variant(const ResourceRef& value)
+    Variant(const ResourceRef& value)   // NOLINT
     {
         *this = value;
     }
 
     /// Construct from a resource reference list.
-    explicit Variant(const ResourceRefList& value)
+    Variant(const ResourceRefList& value)   // NOLINT
     {
         *this = value;
     }
 
     /// Construct from a variant vector.
-    explicit Variant(const VariantVector& value)
+    Variant(const VariantVector& value) // NOLINT
     {
         *this = value;
     }
 
     /// Construct from a variant map.
-    explicit Variant(const VariantMap& value)
+    Variant(const VariantMap& value)    // NOLINT
     {
         *this = value;
     }
 
     /// Construct from a string vector.
-    explicit Variant(const StringVector& value)
+    Variant(const StringVector& value)  // NOLINT
     {
         *this = value;
     }
 
     /// Construct from a rect.
-    explicit Variant(const Rect& value)
+    Variant(const Rect& value)          // NOLINT
     {
         *this = value;
     }
 
     /// Construct from an integer rect.
-    explicit Variant(const IntRect& value)
+    Variant(const IntRect& value)       // NOLINT
     {
         *this = value;
     }
 
     /// Construct from an IntVector2.
-    explicit Variant(const IntVector2& value)
+    Variant(const IntVector2& value)    // NOLINT
     {
         *this = value;
     }
 
     /// Construct from an IntVector3.
-    explicit Variant(const IntVector3& value)
+    Variant(const IntVector3& value)    // NOLINT
     {
         *this = value;
     }
 
     /// Construct from a RefCounted pointer. The object will be stored internally in a WeakPtr so that its expiration can be detected safely.
-    explicit Variant(RefCounted* value)
+    Variant(RefCounted* value)          // NOLINT
     {
         *this = value;
     }
 
     /// Construct from a Matrix3.
-    explicit Variant(const Matrix3& value)
+    Variant(const Matrix3& value)       // NOLINT
     {
         *this = value;
     }
 
     /// Construct from a Matrix3x4.
-    explicit Variant(const Matrix3x4& value)
+    Variant(const Matrix3x4& value)     // NOLINT
     {
         *this = value;
     }
 
     /// Construct from a Matrix4.
-    explicit Variant(const Matrix4& value)
+    Variant(const Matrix4& value)       // NOLINT
     {
         *this = value;
     }
 
     /// Construct from custom value.
     template <class T>
-    explicit Variant(const CustomVariantValueImpl<T>& value)
+    Variant(const CustomVariantValueImpl<T>& value)     // NOLINT
     {
         *this = value;
     }

+ 1 - 1
Source/Urho3D/IO/Deserializer.cpp

@@ -139,7 +139,7 @@ IntRect Deserializer::ReadIntRect()
 {
     int data[4];
     Read(data, sizeof data);
-    return {data};
+    return IntRect(data);
 }
 
 IntVector2 Deserializer::ReadIntVector2()

+ 1 - 1
Source/Urho3D/IO/FileSystem.cpp

@@ -1073,7 +1073,7 @@ String FileSystem::GetTemporaryDir() const
     wchar_t pathName[MAX_PATH];
     pathName[0] = 0;
     GetTempPathW(SDL_arraysize(pathName), pathName);
-    return AddTrailingSlash(pathName);
+    return AddTrailingSlash(String(pathName));
 #else
     if (char* pathName = getenv("TMPDIR"))
         return AddTrailingSlash(pathName);

+ 2 - 2
Source/Urho3D/Math/StringHash.h

@@ -47,9 +47,9 @@ public:
     }
 
     /// Construct from a C string case-insensitively.
-    explicit StringHash(const char* str);
+    StringHash(const char* str);        // NOLINT
     /// Construct from a string case-insensitively.
-    explicit StringHash(const String& str);
+    StringHash(const String& str);      // NOLINT
 
     /// Assign from another hash.
     StringHash& operator =(const StringHash& rhs) = default;

+ 9 - 9
Source/Urho3D/Resource/JSONValue.h

@@ -78,55 +78,55 @@ public:
     {
     }
     /// Construct with a boolean.
-    explicit JSONValue(bool value) :
+    JSONValue(bool value) :         // NOLINT
         type_(0)
     {
         *this = value;
     }
     /// Construct with a integer.
-    explicit JSONValue(int value) :
+    JSONValue(int value) :          // NOLINT
         type_(0)
     {
         *this = value;
     }
     /// Construct with a unsigned integer.
-    explicit JSONValue(unsigned value) :
+    JSONValue(unsigned value) :     // NOLINT
         type_(0)
     {
         *this = value;
     }
     /// Construct with a float.
-    explicit JSONValue(float value) :
+    JSONValue(float value) :        // NOLINT
         type_(0)
     {
         *this = value;
     }
     /// Construct with a double.
-    explicit JSONValue(double value) :
+    JSONValue(double value) :       // NOLINT
         type_(0)
     {
         *this = value;
     }
     /// Construct with a string.
-    explicit JSONValue(const String& value) :
+    JSONValue(const String& value) :    // NOLINT
         type_(0)
     {
         *this = value;
     }
     /// Construct with a C string.
-    explicit JSONValue(const char* value) :
+    JSONValue(const char* value) :      // NOLINT
         type_(0)
     {
         *this = value;
     }
     /// Construct with a JSON array.
-    explicit JSONValue(const JSONArray& value) :
+    JSONValue(const JSONArray& value) :     // NOLINT
         type_(0)
     {
         *this = value;
     }
     /// Construct with a JSON object.
-    explicit JSONValue(const JSONObject& value) :
+    JSONValue(const JSONObject& value) :    // NOLINT
         type_(0)
     {
         *this = value;

+ 2 - 2
Source/Urho3D/Urho2D/SpriterData2D.cpp

@@ -562,9 +562,9 @@ void SpatialInfo::Interpolate(const SpatialInfo& other, float t)
 }
 
 SpatialTimelineKey::SpatialTimelineKey(Timeline* timeline) :
-    TimelineKey(timeline)
+    TimelineKey(timeline),
+    info_(0.f, 0.f, 0.f, 1.f, 1.f)
 {
-
 }
 
 SpatialTimelineKey::~SpatialTimelineKey() = default;

+ 1 - 1
Source/Urho3D/Urho2D/SpriterData2D.h

@@ -250,7 +250,7 @@ struct SpatialInfo
     float alpha_;
     int spin;
 
-    explicit SpatialInfo(float x = 0.0f, float y = 0.0f, float angle = 0.0f, float scale_x = 1, float scale_y = 1, float a = 1, int spin = 1);
+    SpatialInfo(float x, float y, float angle, float scale_x, float scale_y, float a = 1, int spin = 1);
     SpatialInfo UnmapFromParent(const SpatialInfo& parentInfo) const;
     void Interpolate(const SpatialInfo& other, float t);
 };

+ 2 - 1
Source/Urho3D/Urho2D/SpriterInstance2D.cpp

@@ -39,7 +39,8 @@ SpriterInstance::SpriterInstance(Component* owner, SpriterData* spriteData) :
     owner_(owner),
     spriterData_(spriteData),
     entity_(nullptr),
-    animation_(nullptr)
+    animation_(nullptr),
+    spatialInfo_(0.f, 0.f, 0.f, 1.f, 1.f)
 {
 }
 

+ 16 - 8
Source/Urho3D/Urho2D/TileMap2D.cpp

@@ -74,17 +74,25 @@ void TileMap2D::DrawDebugGeometry(DebugRenderer* debug, bool depthTest)
     case O_ORTHOGONAL:
     case O_STAGGERED:
     case O_HEXAGONAL:
-        debug->AddLine(TransformNode2D(transform, Vector2(0.0f, 0.0f)), TransformNode2D(transform, Vector2(mapW, 0.0f)), color);
-        debug->AddLine(TransformNode2D(transform, Vector2(mapW, 0.0f)), TransformNode2D(transform, Vector2(mapW, mapH)), color);
-        debug->AddLine(TransformNode2D(transform, Vector2(mapW, mapH)), TransformNode2D(transform, Vector2(0.0f, mapH)), color);
-        debug->AddLine(TransformNode2D(transform, Vector2(0.0f, mapH)), TransformNode2D(transform, Vector2(0.0f, 0.0f)), color);
+        debug->AddLine(Vector3(TransformNode2D(transform, Vector2(0.0f, 0.0f))),
+            Vector3(TransformNode2D(transform, Vector2(mapW, 0.0f))), color);
+        debug->AddLine(Vector3(TransformNode2D(transform, Vector2(mapW, 0.0f))),
+            Vector3(TransformNode2D(transform, Vector2(mapW, mapH))), color);
+        debug->AddLine(Vector3(TransformNode2D(transform, Vector2(mapW, mapH))),
+            Vector3(TransformNode2D(transform, Vector2(0.0f, mapH))), color);
+        debug->AddLine(Vector3(TransformNode2D(transform, Vector2(0.0f, mapH))),
+            Vector3(TransformNode2D(transform, Vector2(0.0f, 0.0f))), color);
         break;
 
     case O_ISOMETRIC:
-        debug->AddLine(TransformNode2D(transform, Vector2(0.0f, mapH * 0.5f)), TransformNode2D(transform, Vector2(mapW * 0.5f, 0.0f)), color);
-        debug->AddLine(TransformNode2D(transform, Vector2(mapW * 0.5f, 0.0f)), TransformNode2D(transform, Vector2(mapW, mapH * 0.5f)), color);
-        debug->AddLine(TransformNode2D(transform, Vector2(mapW, mapH * 0.5f)), TransformNode2D(transform, Vector2(mapW * 0.5f, mapH)), color);
-        debug->AddLine(TransformNode2D(transform, Vector2(mapW * 0.5f, mapH)), TransformNode2D(transform, Vector2(0.0f, mapH * 0.5f)), color);
+        debug->AddLine(Vector3(TransformNode2D(transform, Vector2(0.0f, mapH * 0.5f))),
+            Vector3(TransformNode2D(transform, Vector2(mapW * 0.5f, 0.0f))), color);
+        debug->AddLine(Vector3(TransformNode2D(transform, Vector2(mapW * 0.5f, 0.0f))),
+            Vector3(TransformNode2D(transform, Vector2(mapW, mapH * 0.5f))), color);
+        debug->AddLine(Vector3(TransformNode2D(transform, Vector2(mapW, mapH * 0.5f))),
+            Vector3(TransformNode2D(transform, Vector2(mapW * 0.5f, mapH))), color);
+        debug->AddLine(Vector3(TransformNode2D(transform, Vector2(mapW * 0.5f, mapH))),
+            Vector3(TransformNode2D(transform, Vector2(0.0f, mapH * 0.5f))), color);
         break;
     }
 

+ 14 - 11
Source/Urho3D/Urho2D/TileMapLayer2D.cpp

@@ -104,8 +104,9 @@ void TileMapLayer2D::DrawDebugGeometry(DebugRenderer* debug, bool depthTest)
                     }
 
                     for (unsigned j = 0; j < points.Size(); ++j)
-                        debug->AddLine(TransformNode2D(transform, points[j] + object->GetPosition()),
-                                       TransformNode2D(transform, points[(j + 1) % points.Size()] + object->GetPosition()), color, depthTest);
+                        debug->AddLine(Vector3(TransformNode2D(transform, points[j] + object->GetPosition())),
+                            Vector3(TransformNode2D(transform, points[(j + 1) % points.Size()] + object->GetPosition())), color,
+                            depthTest);
                 }
                 break;
 
@@ -140,7 +141,8 @@ void TileMapLayer2D::DrawDebugGeometry(DebugRenderer* debug, bool depthTest)
                             point2 = Vector2((point2.x_ + point2.y_) * ratio, (point2.y_ - point2.x_) * 0.5f);
                         }
 
-                        debug->AddLine(TransformNode2D(transform, pivot + point1), TransformNode2D(transform, pivot + point2), color, depthTest);
+                        debug->AddLine(Vector3(TransformNode2D(transform, pivot + point1)),
+                            Vector3(TransformNode2D(transform, pivot + point2)), color, depthTest);
                     }
                 }
                 break;
@@ -149,15 +151,16 @@ void TileMapLayer2D::DrawDebugGeometry(DebugRenderer* debug, bool depthTest)
             case OT_POLYLINE:
                 {
                     for (unsigned j = 0; j < object->GetNumPoints() - 1; ++j)
-                        debug->AddLine(TransformNode2D(transform, object->GetPoint(j)),
-                                       TransformNode2D(transform, object->GetPoint(j + 1)), color, depthTest);
+                        debug->AddLine(Vector3(TransformNode2D(transform, object->GetPoint(j))),
+                            Vector3(TransformNode2D(transform, object->GetPoint(j + 1))), color, depthTest);
 
                     if (object->GetObjectType() == OT_POLYGON)
-                        debug->AddLine(TransformNode2D(transform, object->GetPoint(0)),
-                                       TransformNode2D(transform, object->GetPoint(object->GetNumPoints() - 1)), color, depthTest);
+                        debug->AddLine(Vector3(TransformNode2D(transform, object->GetPoint(0))),
+                            Vector3(TransformNode2D(transform, object->GetPoint(object->GetNumPoints() - 1))), color, depthTest);
                     // Also draw a circle at origin to indicate direction
                     else
-                        debug->AddCircle(TransformNode2D(transform, object->GetPoint(0)), Vector3::FORWARD, 0.05f, color, 64, depthTest);
+                        debug->AddCircle(Vector3(TransformNode2D(transform, object->GetPoint(0))), Vector3::FORWARD, 0.05f, color,
+                            64, depthTest);
                 }
                 break;
 
@@ -353,7 +356,7 @@ void TileMapLayer2D::SetTileLayer(const TmxTileLayer2D* tileLayer)
                 continue;
 
             SharedPtr<Node> tileNode(GetNode()->CreateTemporaryChild("Tile"));
-            tileNode->SetPosition(info.TileIndexToPosition(x, y));
+            tileNode->SetPosition(Vector3(info.TileIndexToPosition(x, y)));
 
             auto* staticSprite = tileNode->CreateComponent<StaticSprite2D>();
             staticSprite->SetSprite(tile->GetSprite());
@@ -378,7 +381,7 @@ void TileMapLayer2D::SetObjectGroup(const TmxObjectGroup2D* objectGroup)
 
         // Create dummy node for all object
         SharedPtr<Node> objectNode(GetNode()->CreateTemporaryChild("Object"));
-        objectNode->SetPosition(object->GetPosition());
+        objectNode->SetPosition(Vector3(object->GetPosition()));
 
         // If object is tile, create static sprite component
         if (object->GetObjectType() == OT_TILE && object->GetTileGid() && object->GetTileSprite())
@@ -407,7 +410,7 @@ void TileMapLayer2D::SetImageLayer(const TmxImageLayer2D* imageLayer)
         return;
 
     SharedPtr<Node> imageNode(GetNode()->CreateTemporaryChild("Tile"));
-    imageNode->SetPosition(imageLayer->GetPosition());
+    imageNode->SetPosition(Vector3(imageLayer->GetPosition()));
 
     auto* staticSprite = imageNode->CreateComponent<StaticSprite2D>();
     staticSprite->SetSprite(imageLayer->GetSprite());