From 883bb677d6e93c23a12aa8ff5a73b6cb959b7c3d Mon Sep 17 00:00:00 2001 From: Adeel Kazmi Date: Wed, 19 May 2021 12:20:38 +0100 Subject: [PATCH] Remove variable shadowing Change-Id: Ica05b9e265b1907e8798fd110e8410cf00afe7b8 --- examples/bezier-curve/bezier-curve-example.cpp | 18 ++++--------- examples/deferred-shading/deferred-shading.cpp | 8 +++--- .../image-scaling-irregular-grid-example.cpp | 23 ++++++++-------- examples/line-mesh/line-mesh-example.cpp | 2 +- examples/motion-blur/motion-blur-example.cpp | 8 +++--- examples/motion-stretch/motion-stretch-example.cpp | 8 +++--- .../refraction-effect-example.cpp | 31 +++++++--------------- examples/scene-loader/scene-loader-example.cpp | 7 +++-- examples/sparkle/sparkle-effect-example.cpp | 10 +++---- examples/sparkle/sparkle-effect.h | 17 ------------ examples/text-label/text-label-example.cpp | 10 +++---- examples/text-scrolling/text-scrolling-example.cpp | 6 ++--- examples/transitions/shadow-button-impl.cpp | 15 ++++++----- examples/visual-transitions/beat-control-impl.cpp | 8 +++--- 14 files changed, 69 insertions(+), 102 deletions(-) diff --git a/examples/bezier-curve/bezier-curve-example.cpp b/examples/bezier-curve/bezier-curve-example.cpp index 7dc3b8a..3f5425c 100644 --- a/examples/bezier-curve/bezier-curve-example.cpp +++ b/examples/bezier-curve/bezier-curve-example.cpp @@ -53,14 +53,6 @@ inline float Clamp(float v, float min, float max) struct HandlePositionConstraint { - HandlePositionConstraint(float minRelX, float maxRelX, float minRelY, float maxRelY) - : minRelX(minRelX), - maxRelX(maxRelX), - minRelY(minRelY), - maxRelY(maxRelY) - { - } - void operator()(Vector3& current, const PropertyInputContainer& inputs) { Vector3 size(inputs[0]->GetVector3()); @@ -68,10 +60,10 @@ struct HandlePositionConstraint current.y = Clamp(current.y, minRelY * size.y, maxRelY * size.y); } - float minRelX; - float maxRelX; - float minRelY; - float maxRelY; + float minRelX{0.0f}; + float maxRelX{0.0f}; + float minRelY{0.0f}; + float maxRelY{0.0f}; }; void AnimatingPositionConstraint(Vector3& current, const PropertyInputContainer& inputs) @@ -304,7 +296,7 @@ public: positionAnimation.FinishedSignal().Connect(this, &BezierCurveExample::OnAnimationFinished); // Set up constraints for drag/drop - Constraint constraint = Constraint::New(actor, Actor::Property::POSITION, HandlePositionConstraint(-0.5, 0.5, -1, 1)); + Constraint constraint = Constraint::New(actor, Actor::Property::POSITION, HandlePositionConstraint{-0.5, 0.5, -1, 1}); constraint.AddSource(Source(parent, Actor::Property::SIZE)); constraint.Apply(); diff --git a/examples/deferred-shading/deferred-shading.cpp b/examples/deferred-shading/deferred-shading.cpp index 8a2f93b..ae8e849 100644 --- a/examples/deferred-shading/deferred-shading.cpp +++ b/examples/deferred-shading/deferred-shading.cpp @@ -183,8 +183,8 @@ Geometry CreateOctahedron(bool invertNormals) struct Vertex { - Vector3 position; - Vector3 normal; + Vector3 position{}; + Vector3 normal{}; }; Vertex vertexData[] = { {positions[0]}, @@ -624,12 +624,12 @@ private: int DALI_EXPORT_API main(int argc, char** argv) { - const bool showLights = [](int argc, char** argv) { + const bool showLights = [argc, argv]() { auto endArgs = argv + argc; return std::find_if(argv, endArgs, [](const char* arg) { return strcmp(arg, "--show-lights") == 0; }) != endArgs; - }(argc, argv); + }(); Application app = Application::New(&argc, &argv); DeferredShadingExample example(app, (showLights ? DeferredShadingExample::Options::SHOW_LIGHTS : 0)); diff --git a/examples/image-scaling-irregular-grid/image-scaling-irregular-grid-example.cpp b/examples/image-scaling-irregular-grid/image-scaling-irregular-grid-example.cpp index 7fe4b6d..137a02a 100644 --- a/examples/image-scaling-irregular-grid/image-scaling-irregular-grid-example.cpp +++ b/examples/image-scaling-irregular-grid/image-scaling-irregular-grid-example.cpp @@ -222,9 +222,9 @@ Dali::FittingMode::Type NextMode(const Dali::FittingMode::Type oldMode) * */ struct ImageConfiguration { - ImageConfiguration(const char* const path, const Vector2 dimensions) - : path(path), - dimensions(dimensions) + ImageConfiguration(const char* const imagePath, const Vector2 dims) + : path(imagePath), + dimensions(dims) { } const char* path; @@ -236,11 +236,11 @@ struct ImageConfiguration */ struct PositionedImage { - PositionedImage(ImageConfiguration& configuration, unsigned cellX, unsigned cellY, Vector2 imageGridDims) - : configuration(configuration), - cellX(cellX), - cellY(cellY), - imageGridDims(imageGridDims) + PositionedImage(ImageConfiguration& config, unsigned x, unsigned y, Vector2 imageGridDimensions) + : configuration(config), + cellX(x), + cellY(y), + imageGridDims(imageGridDimensions) { } @@ -422,11 +422,10 @@ public: // Place the images in the grid: - std::vector::iterator config, end; - GridFlags grid(gridWidth, maxGridHeight); - std::vector placedImages; + GridFlags grid(gridWidth, maxGridHeight); + std::vector placedImages; - for(config = configurations.begin(), end = configurations.end(); config != end; ++config) + for(std::vector::iterator config = configurations.begin(), end = configurations.end(); config != end; ++config) { unsigned cellX, cellY; Vector2 imageGridDims; diff --git a/examples/line-mesh/line-mesh-example.cpp b/examples/line-mesh/line-mesh-example.cpp index a71ce30..742287b 100644 --- a/examples/line-mesh/line-mesh-example.cpp +++ b/examples/line-mesh/line-mesh-example.cpp @@ -231,7 +231,7 @@ public: mMinusButton.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT); mMinusButton.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT); - Toolkit::PushButton mPlusButton = Toolkit::PushButton::New(); + mPlusButton = Toolkit::PushButton::New(); mPlusButton.SetProperty(Toolkit::Button::Property::LABEL, ">>"); mPlusButton.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT); mPlusButton.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_RIGHT); diff --git a/examples/motion-blur/motion-blur-example.cpp b/examples/motion-blur/motion-blur-example.cpp index e52e2c8..66f4c6e 100644 --- a/examples/motion-blur/motion-blur-example.cpp +++ b/examples/motion-blur/motion-blur-example.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -281,11 +281,11 @@ public: destPos.y = localPoint.y - originOffsetY; destPos.z = 0.0f; - float animDuration = 0.5f; - mActorTapMovementAnimation = Animation::New(animDuration); + float tapMovementAnimDuration = 0.5f; + mActorTapMovementAnimation = Animation::New(tapMovementAnimDuration); if(mMotionBlurImageView) { - mActorTapMovementAnimation.AnimateTo(Property(mMotionBlurImageView, Actor::Property::POSITION), destPos, AlphaFunction::EASE_IN_OUT_SINE, TimePeriod(animDuration)); + mActorTapMovementAnimation.AnimateTo(Property(mMotionBlurImageView, Actor::Property::POSITION), destPos, AlphaFunction::EASE_IN_OUT_SINE, TimePeriod(tapMovementAnimDuration)); } mActorTapMovementAnimation.SetEndAction(Animation::BAKE); mActorTapMovementAnimation.Play(); diff --git a/examples/motion-stretch/motion-stretch-example.cpp b/examples/motion-stretch/motion-stretch-example.cpp index dd55e34..0ecc426 100644 --- a/examples/motion-stretch/motion-stretch-example.cpp +++ b/examples/motion-stretch/motion-stretch-example.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -254,11 +254,11 @@ public: destPos.y = localPoint.y - originOffsetY; destPos.z = 0.0f; - float animDuration = 0.5f; - mActorTapMovementAnimation = Animation::New(animDuration); + float tapMovementAnimDuration = 0.5f; + mActorTapMovementAnimation = Animation::New(tapMovementAnimDuration); if(mMotionStretchImageView) { - mActorTapMovementAnimation.AnimateTo(Property(mMotionStretchImageView, Actor::Property::POSITION), destPos, AlphaFunction::EASE_IN_OUT_SINE, TimePeriod(animDuration)); + mActorTapMovementAnimation.AnimateTo(Property(mMotionStretchImageView, Actor::Property::POSITION), destPos, AlphaFunction::EASE_IN_OUT_SINE, TimePeriod(tapMovementAnimDuration)); } mActorTapMovementAnimation.SetEndAction(Animation::BAKE); mActorTapMovementAnimation.Play(); diff --git a/examples/refraction-effect/refraction-effect-example.cpp b/examples/refraction-effect/refraction-effect-example.cpp index 37e83dd..cd4b682 100644 --- a/examples/refraction-effect/refraction-effect-example.cpp +++ b/examples/refraction-effect/refraction-effect-example.cpp @@ -85,17 +85,6 @@ struct Vertex Vector3 position; Vector3 normal; Vector2 textureCoord; - - Vertex() - { - } - - Vertex(const Vector3& position, const Vector3& normal, const Vector2& textureCoord) - : position(position), - normal(normal), - textureCoord(textureCoord) - { - } }; } // namespace @@ -334,16 +323,16 @@ private: // make sure all the faces are front-facing if(normal.z > 0) { - vertices.push_back(Vertex(vertexPositions[faceIndices[i]], normal, textureCoordinates[faceIndices[i]])); - vertices.push_back(Vertex(vertexPositions[faceIndices[i + 1]], normal, textureCoordinates[faceIndices[i + 1]])); - vertices.push_back(Vertex(vertexPositions[faceIndices[i + 2]], normal, textureCoordinates[faceIndices[i + 2]])); + vertices.push_back(Vertex{vertexPositions[faceIndices[i]], normal, textureCoordinates[faceIndices[i]]}); + vertices.push_back(Vertex{vertexPositions[faceIndices[i + 1]], normal, textureCoordinates[faceIndices[i + 1]]}); + vertices.push_back(Vertex{vertexPositions[faceIndices[i + 2]], normal, textureCoordinates[faceIndices[i + 2]]}); } else { normal *= -1.f; - vertices.push_back(Vertex(vertexPositions[faceIndices[i]], normal, textureCoordinates[faceIndices[i]])); - vertices.push_back(Vertex(vertexPositions[faceIndices[i + 2]], normal, textureCoordinates[faceIndices[i + 2]])); - vertices.push_back(Vertex(vertexPositions[faceIndices[i + 1]], normal, textureCoordinates[faceIndices[i + 1]])); + vertices.push_back(Vertex{vertexPositions[faceIndices[i]], normal, textureCoordinates[faceIndices[i]]}); + vertices.push_back(Vertex{vertexPositions[faceIndices[i + 2]], normal, textureCoordinates[faceIndices[i + 2]]}); + vertices.push_back(Vertex{vertexPositions[faceIndices[i + 1]], normal, textureCoordinates[faceIndices[i + 1]]}); } } @@ -386,10 +375,10 @@ private: { if(line[0] == 'v' && std::isspace(line[1])) // vertex { - std::istringstream iss(line.substr(2), std::istringstream::in); + std::istringstream vertexIss(line.substr(2), std::istringstream::in); unsigned int i = 0; Vector3 vertex; - while(iss >> vertex[i++] && i < 3) + while(vertexIss >> vertex[i++] && i < 3) ; if(vertex.x < boundingBox[0]) boundingBox[0] = vertex.x; if(vertex.x > boundingBox[1]) boundingBox[1] = vertex.x; @@ -413,11 +402,11 @@ private: numOfInt++; } - std::istringstream iss(line.substr(2), std::istringstream::in); + std::istringstream faceIss(line.substr(2), std::istringstream::in); Dali::Vector indices; indices.Resize(numOfInt); unsigned int i = 0; - while(iss >> indices[i++] && i < numOfInt) + while(faceIss >> indices[i++] && i < numOfInt) ; unsigned int step = (i + 1) / 3; faceIndices.PushBack(indices[0] - 1); diff --git a/examples/scene-loader/scene-loader-example.cpp b/examples/scene-loader/scene-loader-example.cpp index 9a1f116..13d7681 100644 --- a/examples/scene-loader/scene-loader-example.cpp +++ b/examples/scene-loader/scene-loader-example.cpp @@ -204,7 +204,7 @@ Actor LoadScene(std::string sceneName, CameraActor camera) {}, {}, nullptr, - }; + {}}; DliLoader::LoadParams loadParams{input, output}; if(!loader.LoadScene(path, loadParams)) { @@ -233,7 +233,10 @@ Actor LoadScene(std::string sceneName, CameraActor camera) viewProjection}; NodeDefinition::CreateParams nodeParams{ resources, - xforms}; + xforms, + {}, + {}, + {}}; Customization::Choices choices; Actor root = Actor::New(); diff --git a/examples/sparkle/sparkle-effect-example.cpp b/examples/sparkle/sparkle-effect-example.cpp index cac0e40..d4060fc 100644 --- a/examples/sparkle/sparkle-effect-example.cpp +++ b/examples/sparkle/sparkle-effect-example.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -226,10 +226,10 @@ private: float particleIdx = static_cast(idx / 4 + 1); // count from 1 float colorIdx = colorIndex + 1.f; // count from 1 - vertices.push_back(Vertex(Vector2(-colorIdx, -particleIdx), particlePath0, particlePath1, particlePath2, particlePath3, particlePath4, particlePath5)); - vertices.push_back(Vertex(Vector2(-colorIdx, particleIdx), particlePath0, particlePath1, particlePath2, particlePath3, particlePath4, particlePath5)); - vertices.push_back(Vertex(Vector2(colorIdx, particleIdx), particlePath0, particlePath1, particlePath2, particlePath3, particlePath4, particlePath5)); - vertices.push_back(Vertex(Vector2(colorIdx, -particleIdx), particlePath0, particlePath1, particlePath2, particlePath3, particlePath4, particlePath5)); + vertices.push_back(Vertex{Vector2(-colorIdx, -particleIdx), particlePath0, particlePath1, particlePath2, particlePath3, particlePath4, particlePath5}); + vertices.push_back(Vertex{Vector2(-colorIdx, particleIdx), particlePath0, particlePath1, particlePath2, particlePath3, particlePath4, particlePath5}); + vertices.push_back(Vertex{Vector2(colorIdx, particleIdx), particlePath0, particlePath1, particlePath2, particlePath3, particlePath4, particlePath5}); + vertices.push_back(Vertex{Vector2(colorIdx, -particleIdx), particlePath0, particlePath1, particlePath2, particlePath3, particlePath4, particlePath5}); faces.push_back(idx); faces.push_back(idx + 1); diff --git a/examples/sparkle/sparkle-effect.h b/examples/sparkle/sparkle-effect.h index e7f9002..acd2d41 100644 --- a/examples/sparkle/sparkle-effect.h +++ b/examples/sparkle/sparkle-effect.h @@ -201,23 +201,6 @@ const int MAXIMUM_ANIMATION_COUNT = 30; // Geometry format used by the SparkeEffect struct Vertex { - Vertex(const Vector2& texCoord, - const Vector2& aParticlePath0, - const Vector2& aParticlePath1, - const Vector2& aParticlePath2, - const Vector2& aParticlePath3, - const Vector2& aParticlePath4, - const Vector2& aParticlePath5) - : aTexCoord(texCoord), - aParticlePath0(aParticlePath0), - aParticlePath1(aParticlePath1), - aParticlePath2(aParticlePath2), - aParticlePath3(aParticlePath3), - aParticlePath4(aParticlePath4), - aParticlePath5(aParticlePath5) - { - } - Vector2 aTexCoord; Vector2 aParticlePath0; Vector2 aParticlePath1; diff --git a/examples/text-label/text-label-example.cpp b/examples/text-label/text-label-example.cpp index ff9db66..83743c7 100644 --- a/examples/text-label/text-label-example.cpp +++ b/examples/text-label/text-label-example.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -105,10 +105,10 @@ int ConvertToEven(int value) struct HSVColorConstraint { - HSVColorConstraint(float hue, float saturation, float value) - : hue(hue), - saturation(saturation), - value(value) + HSVColorConstraint(float hueParam, float saturationParam, float valueParam) + : hue(hueParam), + saturation(saturationParam), + value(valueParam) { } diff --git a/examples/text-scrolling/text-scrolling-example.cpp b/examples/text-scrolling/text-scrolling-example.cpp index 85f92cd..05a2cf2 100644 --- a/examples/text-scrolling/text-scrolling-example.cpp +++ b/examples/text-scrolling/text-scrolling-example.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -131,7 +131,7 @@ public: mAnimation = Animation::New(1.0f); - const Size mTargetActorSize(mWindowSize.width, mWindowSize.height * WINDOW_HEIGHT_MULTIPLIER); + const Size targetActorSize(mWindowSize.width, mWindowSize.height * WINDOW_HEIGHT_MULTIPLIER); // Create Desktop Control desktop = Control::New(); @@ -139,7 +139,7 @@ public: desktop.SetProperty(Dali::Actor::Property::NAME, "desktopActor"); desktop.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); desktop.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS); - desktop.SetProperty(Actor::Property::SIZE, mTargetActorSize); + desktop.SetProperty(Actor::Property::SIZE, targetActorSize); rootActor.Add(desktop); // Add desktop (content) to offscreen actor diff --git a/examples/transitions/shadow-button-impl.cpp b/examples/transitions/shadow-button-impl.cpp index 17cd0f4..77ef9f6 100644 --- a/examples/transitions/shadow-button-impl.cpp +++ b/examples/transitions/shadow-button-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -220,9 +220,10 @@ void ShadowButton::OnRelayout(const Vector2& targetSize, RelayoutContainer& cont void ShadowButton::RelayoutVisuals(const Vector2& targetSize) { - bool transitioning = false; - ShadowButton::Transitions::iterator iter = mTransitions.begin(); - for(; iter != mTransitions.end(); ++iter) + bool transitioning = false; + for(ShadowButton::Transitions::iterator iter = mTransitions.begin(); + iter != mTransitions.end(); + ++iter) { if(iter->mPlaying == true) { @@ -368,10 +369,10 @@ void ShadowButton::ResetVisual( } // Extract transform maps out of the visual definition and store them - Property::Value* value = map->Find(Visual::Property::TRANSFORM, "transform"); - if(value) + Property::Value* transformValue = map->Find(Visual::Property::TRANSFORM, "transform"); + if(transformValue) { - Property::Map* transformMap = value->GetMap(); + Property::Map* transformMap = transformValue->GetMap(); if(transformMap) { ShadowButton::Transforms::iterator iter = FindTransform(index); diff --git a/examples/visual-transitions/beat-control-impl.cpp b/examples/visual-transitions/beat-control-impl.cpp index 9dc35f4..ba2dba8 100644 --- a/examples/visual-transitions/beat-control-impl.cpp +++ b/examples/visual-transitions/beat-control-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -252,10 +252,10 @@ void BeatControl::SetProperty(BaseObject* object, Property::Index index, const P const Property::Map* map = value.GetMap(); if(map) { - Property::Value* value = map->Find(Visual::Property::TRANSFORM, "transform"); - if(value) + Property::Value* transformValue = map->Find(Visual::Property::TRANSFORM, "transform"); + if(transformValue) { - Property::Map* transformMap = value->GetMap(); + Property::Map* transformMap = transformValue->GetMap(); if(transformMap) { // We'll increment this whenever SIZE, ORIGIN or ANCHOR_POINT's are modified as we won't need to create a new visual if only these properties are used -- 2.7.4