/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
namespace
{
-const int ARGINDEX_STEP_INDEX = 0;
-const int ARGINDEX_LIST_SIZE = 1;
-const int ARGINDEX_LIST_START = 2;
+const int32_t ARGINDEX_STEP_INDEX = 0;
+const int32_t ARGINDEX_LIST_SIZE = 1;
+const int32_t ARGINDEX_LIST_START = 2;
}
ConditionFunction VariableStep::GetFunction( Property::Type valueType )
{
- ConditionFunction function = NULL;
+ ConditionFunction function = nullptr;
switch( valueType )
{
- case Property::FLOAT:
+ case Property::INTEGER:
{
- function = EvalFloat;
+ function = EvalInteger;
break;
}
- case Property::INTEGER:
+ case Property::FLOAT:
{
- function = EvalInteger;
+ function = EvalFloat;
break;
}
case Property::VECTOR2:
bool VariableStep::Evaluate( const float propertyValue, PropertyNotification::RawArgumentContainer& arg )
{
- const int currentIndex = arg[ARGINDEX_STEP_INDEX];
- const int numSteps = arg[ARGINDEX_LIST_SIZE];
+ const int32_t currentIndex = static_cast<int32_t>( arg[ARGINDEX_STEP_INDEX] ); // truncated
+ const int32_t numSteps = static_cast<int32_t>( arg[ARGINDEX_LIST_SIZE] ); // truncated
const float first = arg[ARGINDEX_LIST_START];
const float last = arg[ARGINDEX_LIST_START + (numSteps - 1)];
const bool ascending = (last > first) ? true : false;
- int newIndex = currentIndex;
+ int32_t newIndex = currentIndex;
// avoid loop if property currently not within any of the range values
if( ascending )
newIndex = numSteps - 1;
}
}
- int i = 0;
+ int32_t i = 0;
for( i = 0 ; i < numSteps - 1 ; ++i )
{
const float arg1 = arg[ARGINDEX_LIST_START + i];
return false;
}
-bool VariableStep::EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+bool VariableStep::EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
{
- const float propertyValue = value.GetFloat();
+ const float propertyValue = static_cast<float>( value.GetInteger() );
return Evaluate( propertyValue, arg );
}
-bool VariableStep::EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+bool VariableStep::EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
{
- const float propertyValue = static_cast<float>( value.GetInteger() );
+ const float propertyValue = value.GetFloat();
return Evaluate( propertyValue, arg );
}