From: György Straub Date: Mon, 28 Sep 2020 12:28:53 +0000 (+0100) Subject: Const correctness improvements for Property::Value. X-Git-Tag: dali_1.9.32~2^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F75%2F244975%2F2;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git Const correctness improvements for Property::Value. - instead of using its parameter as in-out (and perhaps erroneously modifying the original), TextVisual returns the new map, which is then merged with the existing properties in ButtonImpl::SetProperty(); Change-Id: I974535fd017416dc60225a1f511e71d81a2a86de Signed-off-by: György Straub --- diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp index a7ccfba..7d0c661 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp @@ -174,7 +174,7 @@ void DummyControlImpl::SetProperty( BaseObject* object, Dali::Property::Index in case Toolkit::DummyControl::Property::FOCUS_VISUAL: case Toolkit::DummyControl::Property::LABEL_VISUAL: { - Property::Map* map = value.GetMap(); + const Property::Map* map = value.GetMap(); if( map != NULL ) { VisualFactory visualFactory = VisualFactory::Get(); diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-animation-data.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-animation-data.cpp index 57c1e41..6702798 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-animation-data.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-animation-data.cpp @@ -156,7 +156,7 @@ void NewAnimator( const Property::Map& map, TestAnimationData::AnimationDataElem { if( value.GetType() == Property::MAP ) { - Property::Map* map = value.GetMap(); + const Property::Map* map = value.GetMap(); const Property::Map& mapref = *map; NewAnimator( mapref, element ); // Merge the map into element } @@ -180,7 +180,7 @@ void NewAnimation( const Property::Array& array, TestAnimationData& outputAnimat const Property::Value& value = array.GetElementAt(i); if( value.GetType() == Property::MAP ) { - Property::Map* map = value.GetMap(); + const Property::Map* map = value.GetMap(); NewAnimator( *map, *element ); outputAnimationData.Add( element ); } diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-button.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-button.cpp index 3b5f451..ff5e1dc 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-button.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-button.cpp @@ -78,13 +78,13 @@ void TestButton::SetProperty( BaseObject* object, Property::Index index, const P { if( value.GetType() == Property::MAP ) { - Property::Map* valueMap = value.GetMap(); + const Property::Map* valueMap = value.GetMap(); buttonImpl.mPressTransitionData.Clear(); NewAnimation( *valueMap, buttonImpl.mPressTransitionData ); } else if( value.GetType() == Property::ARRAY ) { - Property::Array* valueArray = value.GetArray(); + const Property::Array* valueArray = value.GetArray(); buttonImpl.mPressTransitionData.Clear(); NewAnimation( *valueArray, buttonImpl.mPressTransitionData ); } diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Tooltip.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Tooltip.cpp index b1cf510..3d68d5a 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Tooltip.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Tooltip.cpp @@ -272,7 +272,7 @@ int UtcDaliTooltipCreateWithArray(void) tet_infoline( "Ensure first value is a map and contains the right item" ); const Property::Value mapValue1 = contentArray->GetElementAt( 0 ); - Property::Map* map1 = mapValue1.GetMap(); + const Property::Map* map1 = mapValue1.GetMap(); DALI_TEST_CHECK( map1 ); Property::Value* urlValue = map1->Find( ImageVisual::Property::URL ); DALI_TEST_CHECK( urlValue ); @@ -280,7 +280,7 @@ int UtcDaliTooltipCreateWithArray(void) tet_infoline( "Ensure second value is a map and contains the right item" ); const Property::Value mapValue2 = contentArray->GetElementAt( 1 ); - Property::Map* map2 = mapValue2.GetMap(); + const Property::Map* map2 = mapValue2.GetMap(); DALI_TEST_CHECK( map2 ); Property::Value* textValue = map2->Find( TextVisual::Property::TEXT ); DALI_TEST_CHECK( textValue ); diff --git a/dali-toolkit/devel-api/builder/base64-encoding.cpp b/dali-toolkit/devel-api/builder/base64-encoding.cpp index f95dde8..024c1b5 100644 --- a/dali-toolkit/devel-api/builder/base64-encoding.cpp +++ b/dali-toolkit/devel-api/builder/base64-encoding.cpp @@ -41,7 +41,7 @@ bool GetStringFromProperty(const Property::Value& value, std::string& output) } else { - Property::Array* array = value.GetArray(); + const Property::Array* array = value.GetArray(); if(array) { const unsigned int arraySize = array->Size(); diff --git a/dali-toolkit/internal/controls/buttons/button-impl.cpp b/dali-toolkit/internal/controls/buttons/button-impl.cpp index 6d45eed..d840e96 100644 --- a/dali-toolkit/internal/controls/buttons/button-impl.cpp +++ b/dali-toolkit/internal/controls/buttons/button-impl.cpp @@ -379,7 +379,7 @@ void Button::CreateVisualsForComponent( Property::Index index, const Property::V else { // if its not a string then get a Property::Map from the property if possible. - Property::Map *map = value.GetMap(); + const Property::Map *map = value.GetMap(); if( map && !map->Empty() ) // Empty map results in current visual removal. { DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "CreateVisualsForComponent Using Map(%d)\n", index ); @@ -1151,11 +1151,11 @@ void Button::SetProperty( BaseObject* object, Property::Index index, const Prope else { // Get a Property::Map from the property if possible. - Property::Map* setPropertyMap = value.GetMap(); + const Property::Map* setPropertyMap = value.GetMap(); if( setPropertyMap ) { - TextVisual::ConvertStringKeysToIndexKeys( *setPropertyMap ); - GetImplementation( button ).MergeWithExistingLabelProperties( *setPropertyMap, outTextVisualProperties ); + Property::Map indexKeys = TextVisual::ConvertStringKeysToIndexKeys( *setPropertyMap ); + GetImplementation( button ).MergeWithExistingLabelProperties( indexKeys, outTextVisualProperties ); } } diff --git a/dali-toolkit/internal/controls/buttons/toggle-button-impl.cpp b/dali-toolkit/internal/controls/buttons/toggle-button-impl.cpp index e6c0ab7..b1808f5 100755 --- a/dali-toolkit/internal/controls/buttons/toggle-button-impl.cpp +++ b/dali-toolkit/internal/controls/buttons/toggle-button-impl.cpp @@ -136,7 +136,7 @@ void ToggleButton::SetProperty( BaseObject* object, Property::Index propertyInde } case Toolkit::ToggleButton::Property::TOOLTIPS: { - Property::Array* tipArray = value.GetArray(); + const Property::Array* tipArray = value.GetArray(); if( tipArray ) { std::vector tips; diff --git a/dali-toolkit/internal/controls/control/control-data-impl.cpp b/dali-toolkit/internal/controls/control/control-data-impl.cpp index 46a1972..8a2dfd7 100755 --- a/dali-toolkit/internal/controls/control/control-data-impl.cpp +++ b/dali-toolkit/internal/controls/control/control-data-impl.cpp @@ -835,7 +835,7 @@ void Control::Impl::SetProperty( BaseObject* object, Property::Index index, cons { bool withTransitions=true; const Property::Value* valuePtr=&value; - Property::Map* map = value.GetMap(); + const Property::Map* map = value.GetMap(); if(map) { Property::Value* value2 = map->Find("withTransitions"); diff --git a/dali-toolkit/internal/controls/image-view/image-view-impl.cpp b/dali-toolkit/internal/controls/image-view/image-view-impl.cpp index 7f92138..36702a8 100755 --- a/dali-toolkit/internal/controls/image-view/image-view-impl.cpp +++ b/dali-toolkit/internal/controls/image-view/image-view-impl.cpp @@ -432,7 +432,7 @@ void ImageView::SetProperty( BaseObject* object, Property::Index index, const Pr case Toolkit::ImageView::Property::IMAGE: { std::string imageUrl; - Property::Map* map; + const Property::Map* map; if( value.Get( imageUrl ) ) { impl.SetImage( imageUrl, ImageDimensions() ); diff --git a/dali-toolkit/internal/controls/progress-bar/progress-bar-impl.cpp b/dali-toolkit/internal/controls/progress-bar/progress-bar-impl.cpp index 3d18ddb..0a4a7e5 100755 --- a/dali-toolkit/internal/controls/progress-bar/progress-bar-impl.cpp +++ b/dali-toolkit/internal/controls/progress-bar/progress-bar-impl.cpp @@ -404,7 +404,7 @@ void ProgressBar::CreateVisualsForComponent( Property::Index index, const Proper else // Does this code make text-visual can be accepted as visual? { // if its not a string then get a Property::Map from the property if possible. - Property::Map *map = value.GetMap(); + const Property::Map *map = value.GetMap(); if( map && !map->Empty() ) // Empty map results in current visual removal. { progressVisual = visualFactory.CreateVisual( *map ); diff --git a/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp b/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp index f002764..54dc431 100644 --- a/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp +++ b/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp @@ -689,7 +689,7 @@ void ScrollBar::SetProperty( BaseObject* object, Property::Index index, const Pr } case Toolkit::ScrollBar::Property::SCROLL_POSITION_INTERVALS: { - Property::Array* array = value.GetArray(); + const Property::Array* array = value.GetArray(); if( array ) { Dali::Vector positions; diff --git a/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp b/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp index c442fb8..12bd0c3 100644 --- a/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp +++ b/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp @@ -1819,7 +1819,7 @@ void ItemView::SetLayoutArray( const Property::Array& layouts ) { const Property::Value& element = layouts.GetElementAt( arrayIdx ); - Property::Map* layout = element.GetMap(); + const Property::Map* layout = element.GetMap(); if( layout != NULL ) { for( unsigned int mapIdx = 0, mapCount = (*layout).Count(); mapIdx < mapCount; ++mapIdx ) diff --git a/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp b/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp index 1273cd1..01c5731 100644 --- a/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp +++ b/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp @@ -2915,7 +2915,7 @@ void ScrollView::SetProperty( BaseObject* object, Property::Index index, const P } case Toolkit::ScrollView::Property::SCROLL_MODE: { - Property::Map* map = value.GetMap(); + const Property::Map* map = value.GetMap(); if( map ) { scrollViewImpl.SetScrollMode( *map ); diff --git a/dali-toolkit/internal/controls/table-view/table-view-impl.cpp b/dali-toolkit/internal/controls/table-view/table-view-impl.cpp index a0c1849..92cdd01 100755 --- a/dali-toolkit/internal/controls/table-view/table-view-impl.cpp +++ b/dali-toolkit/internal/controls/table-view/table-view-impl.cpp @@ -1212,7 +1212,7 @@ void TableView::SetHeightOrWidthProperty(TableView& tableViewImpl, void(TableView::*funcFit)(unsigned int), const Property::Value& value ) { - Property::Map* map = value.GetMap(); + const Property::Map* map = value.GetMap(); if( map ) { unsigned int index(0); diff --git a/dali-toolkit/internal/controls/tooltip/tooltip.cpp b/dali-toolkit/internal/controls/tooltip/tooltip.cpp index 80a558e..e7f8b9f 100644 --- a/dali-toolkit/internal/controls/tooltip/tooltip.cpp +++ b/dali-toolkit/internal/controls/tooltip/tooltip.cpp @@ -85,7 +85,7 @@ void Tooltip::SetProperties( const Property::Value& value ) Toolkit::Control control = mControl.GetHandle(); if( control ) { - Property::Map* properties = value.GetMap(); + const Property::Map* properties = value.GetMap(); if( properties ) { const Property::Map::SizeType count = properties->Count(); @@ -229,7 +229,7 @@ void Tooltip::SetContent( Toolkit::Control& control, const Property::Value& valu Property::Type type = value.GetType(); if( type == Property::MAP ) { - Property::Map* map = value.GetMap(); + const Property::Map* map = value.GetMap(); if( map ) { mContentTextVisual.Merge( *map ); @@ -302,7 +302,7 @@ void Tooltip::SetBackground( const Property::Value& value ) } else if( type == Property::MAP ) { - Property::Map* map = value.GetMap(); + const Property::Map* map = value.GetMap(); if( map ) { const Property::Map::SizeType count = map->Count(); diff --git a/dali-toolkit/internal/helpers/property-helper.cpp b/dali-toolkit/internal/helpers/property-helper.cpp index 94be023..db8597b 100644 --- a/dali-toolkit/internal/helpers/property-helper.cpp +++ b/dali-toolkit/internal/helpers/property-helper.cpp @@ -39,7 +39,7 @@ bool GetStringFromProperty( const Property::Value& value, std::string& output ) } else { - Property::Array* array = value.GetArray(); + const Property::Array* array = value.GetArray(); if( array ) { const unsigned int arraySize = array->Size(); diff --git a/dali-toolkit/internal/visuals/animated-vector-image/animated-vector-image-visual.cpp b/dali-toolkit/internal/visuals/animated-vector-image/animated-vector-image-visual.cpp index 453f14e..ea097e1 100644 --- a/dali-toolkit/internal/visuals/animated-vector-image/animated-vector-image-visual.cpp +++ b/dali-toolkit/internal/visuals/animated-vector-image/animated-vector-image-visual.cpp @@ -217,7 +217,7 @@ void AnimatedVectorImageVisual::DoSetProperty( Property::Index index, const Prop } case Toolkit::DevelImageVisual::Property::PLAY_RANGE: { - Property::Array* array = value.GetArray(); + const Property::Array* array = value.GetArray(); if( array ) { mAnimationData.playRange = *array; @@ -406,7 +406,7 @@ void AnimatedVectorImageVisual::OnDoAction( const Property::Index actionId, cons } case DevelAnimatedVectorImageVisual::Action::UPDATE_PROPERTY: { - Property::Map* map = attributes.GetMap(); + const Property::Map* map = attributes.GetMap(); if( map ) { DoSetProperties( *map ); diff --git a/dali-toolkit/internal/visuals/arc/arc-visual.cpp b/dali-toolkit/internal/visuals/arc/arc-visual.cpp index a16d72c..babfc94 100644 --- a/dali-toolkit/internal/visuals/arc/arc-visual.cpp +++ b/dali-toolkit/internal/visuals/arc/arc-visual.cpp @@ -276,7 +276,7 @@ void ArcVisual::OnDoAction( const Property::Index actionId, const Property::Valu { case DevelArcVisual::Action::UPDATE_PROPERTY: { - Property::Map* map = attributes.GetMap(); + const Property::Map* map = attributes.GetMap(); if( map ) { DoSetProperties( *map ); diff --git a/dali-toolkit/internal/visuals/color/color-visual.cpp b/dali-toolkit/internal/visuals/color/color-visual.cpp index 63d02ec..4fae268 100644 --- a/dali-toolkit/internal/visuals/color/color-visual.cpp +++ b/dali-toolkit/internal/visuals/color/color-visual.cpp @@ -289,7 +289,7 @@ void ColorVisual::OnDoAction( const Property::Index actionId, const Property::Va { case DevelColorVisual::Action::UPDATE_PROPERTY: { - Property::Map* map = attributes.GetMap(); + const Property::Map* map = attributes.GetMap(); if( map ) { DoSetProperties( *map ); diff --git a/dali-toolkit/internal/visuals/gradient/gradient-visual.cpp b/dali-toolkit/internal/visuals/gradient/gradient-visual.cpp index 7a3af39..462a6c0 100644 --- a/dali-toolkit/internal/visuals/gradient/gradient-visual.cpp +++ b/dali-toolkit/internal/visuals/gradient/gradient-visual.cpp @@ -589,7 +589,7 @@ void GradientVisual::GetStopOffsets(const Property::Value* value, Vector& } case Property::ARRAY: { - Property::Array* offsetArray = value->GetArray(); + const Property::Array* offsetArray = value->GetArray(); if( offsetArray ) { unsigned int numStop = offsetArray->Count(); diff --git a/dali-toolkit/internal/visuals/text/text-visual.cpp b/dali-toolkit/internal/visuals/text/text-visual.cpp index e9a32f6..f8d5f53 100755 --- a/dali-toolkit/internal/visuals/text/text-visual.cpp +++ b/dali-toolkit/internal/visuals/text/text-visual.cpp @@ -301,7 +301,7 @@ TextVisualPtr TextVisual::New( VisualFactoryCache& factoryCache, const Property: return TextVisualPtr; } -void TextVisual::ConvertStringKeysToIndexKeys( Property::Map& propertyMap ) +Property::Map TextVisual::ConvertStringKeysToIndexKeys( const Property::Map& propertyMap ) { Property::Map outMap; @@ -319,7 +319,7 @@ void TextVisual::ConvertStringKeysToIndexKeys( Property::Map& propertyMap ) outMap.Insert( indexKey, keyValue.second ); } - propertyMap = outMap; + return outMap; } float TextVisual::GetHeightForWidth( float width ) diff --git a/dali-toolkit/internal/visuals/text/text-visual.h b/dali-toolkit/internal/visuals/text/text-visual.h index e6c0ab8..136a23f 100755 --- a/dali-toolkit/internal/visuals/text/text-visual.h +++ b/dali-toolkit/internal/visuals/text/text-visual.h @@ -81,9 +81,10 @@ public: /** * @brief Converts all strings keys in property map to index keys. Property Map can then be merged correctly. - * @param[in,out] propertyMap containing string keys or a mix of strings and indexes. Will be changed to index keys. + * @param[in] propertyMap containing string keys or a mix of strings and indexes. + * @return Property::Map containing index keys. */ - static void ConvertStringKeysToIndexKeys( Property::Map& propertyMap ); + static Property::Map ConvertStringKeysToIndexKeys( const Property::Map& propertyMap ); /** * @brief Retrieve the text's controller. diff --git a/dali-toolkit/internal/visuals/transition-data-impl.cpp b/dali-toolkit/internal/visuals/transition-data-impl.cpp index a91b8ab..78dab18 100644 --- a/dali-toolkit/internal/visuals/transition-data-impl.cpp +++ b/dali-toolkit/internal/visuals/transition-data-impl.cpp @@ -101,7 +101,7 @@ void TransitionData::Initialize( const Property::Array& array ) const Property::Value& element = array.GetElementAt( arrayIdx ); // Expect each child to be an object representing an animator: - Property::Map* map = element.GetMap(); + const Property::Map* map = element.GetMap(); if( map != NULL ) { TransitionData::Animator* animator = ConvertMap( *map ); @@ -173,12 +173,12 @@ TransitionData::Animator* TransitionData::ConvertMap( const Property::Map& map) { bool valid = true; Vector4 controlPoints; - Property::Array *array = value.GetArray(); + const Property::Array* array = value.GetArray(); if( array && array->Count() >= 4 ) { for( size_t vecIdx = 0; vecIdx < 4; ++vecIdx ) { - Property::Value& v = array->GetElementAt(vecIdx); + const Property::Value& v = array->GetElementAt(vecIdx); if( v.GetType() == Property::FLOAT ) { controlPoints[vecIdx] = v.Get(); diff --git a/dali-toolkit/internal/visuals/visual-base-data-impl.cpp b/dali-toolkit/internal/visuals/visual-base-data-impl.cpp index ba9f925..631f61b 100644 --- a/dali-toolkit/internal/visuals/visual-base-data-impl.cpp +++ b/dali-toolkit/internal/visuals/visual-base-data-impl.cpp @@ -95,7 +95,7 @@ bool GetPolicyFromValue( const Property::Value& value, Vector2& policy ) } else { - Property::Array* array = value.GetArray(); + const Property::Array* array = value.GetArray(); if( array && array->Size() == 2 ) { Toolkit::Visual::Transform::Policy::Type xPolicy = static_cast< Toolkit::Visual::Transform::Policy::Type >( -1 ); // Assign an invalid value so definitely changes