From: Adeel Kazmi Date: Thu, 29 Jun 2017 17:43:49 +0000 (+0100) Subject: Replace DALI_COMPILE_TIME_ASSERT with C++11 static_assert X-Git-Tag: dali_1.2.47~1^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-core.git;a=commitdiff_plain;h=1eef2dbdff0344396b63ccf13e796cf11c33258d Replace DALI_COMPILE_TIME_ASSERT with C++11 static_assert Change-Id: Ieaf5b9b3f75d7d7a2fc5d29edda5e5c62ed672f6 --- diff --git a/automated-tests/src/dali/utc-Dali-ConditionalWait.cpp b/automated-tests/src/dali/utc-Dali-ConditionalWait.cpp index 88a3902..3ab2f36 100644 --- a/automated-tests/src/dali/utc-Dali-ConditionalWait.cpp +++ b/automated-tests/src/dali/utc-Dali-ConditionalWait.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 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. @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -250,7 +251,7 @@ int UtcConditionalWaitNonCopyable(void) { // we want to make sure that ConditionalWait is not copyable (its copy constructor is not defined) // this test will stop compiling if ConditionalWait has compiler generated copy constructor - DALI_COMPILE_TIME_ASSERT( !__has_trivial_copy( ConditionalWait ) ); + static_assert( !__has_trivial_copy( ConditionalWait ), "ConditionalWait should NOT be copyable" ); DALI_TEST_CHECK( true ); END_TEST; diff --git a/automated-tests/src/dali/utc-Dali-Mutex.cpp b/automated-tests/src/dali/utc-Dali-Mutex.cpp index 8a1a5b0..44ca204 100644 --- a/automated-tests/src/dali/utc-Dali-Mutex.cpp +++ b/automated-tests/src/dali/utc-Dali-Mutex.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 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. @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -133,7 +134,7 @@ int UtcDaliMutexNonCopyable(void) { // we want to make sure that mutex is not copyable (its copy constructor is not defined) // this test will stop compiling if Mutex has compiler generated copy constructor - DALI_COMPILE_TIME_ASSERT( !__has_trivial_copy( Mutex ) ); + static_assert( !__has_trivial_copy( Mutex ), "Mutex should NOT be copyable" ); DALI_TEST_CHECK( true ); END_TEST; diff --git a/automated-tests/src/dali/utc-Dali-Thread.cpp b/automated-tests/src/dali/utc-Dali-Thread.cpp index a62fde7..fafc10b 100644 --- a/automated-tests/src/dali/utc-Dali-Thread.cpp +++ b/automated-tests/src/dali/utc-Dali-Thread.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 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. @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -72,7 +73,7 @@ int UtcDaliThreadNonCopyable(void) { // we want to make sure that mutex is not copyable (its copy constructor is not defined) // this test will stop compiling if Mutex has compiler generated copy constructor - DALI_COMPILE_TIME_ASSERT( !__has_trivial_copy( Thread ) ); + static_assert( !__has_trivial_copy( Thread ), "Thread should NOT be copyable" ); DALI_TEST_CHECK( true ); END_TEST; diff --git a/dali/internal/render/gl-resources/context.cpp b/dali/internal/render/gl-resources/context.cpp index 041565e..2d883bc 100644 --- a/dali/internal/render/gl-resources/context.cpp +++ b/dali/internal/render/gl-resources/context.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 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. @@ -21,9 +21,9 @@ // EXTERNAL INCLUDES #include #include +#include // INTERNAL INCLUDES -#include #include #include #include @@ -39,7 +39,7 @@ namespace Internal namespace // unnamed namespace { -DALI_COMPILE_TIME_ASSERT( TEXTURE_UNIT_LAST <= Context::MAX_TEXTURE_UNITS ); +static_assert( TEXTURE_UNIT_LAST <= Context::MAX_TEXTURE_UNITS, "TEXTURE_UNIT_LAST is greater than Context::MAX_TEXTURE_UNITS" ); /** * GL error strings diff --git a/dali/internal/update/manager/transform-manager.cpp b/dali/internal/update/manager/transform-manager.cpp index 0d55efe..e72ea69 100644 --- a/dali/internal/update/manager/transform-manager.cpp +++ b/dali/internal/update/manager/transform-manager.cpp @@ -21,10 +21,10 @@ //EXTERNAL INCLUDES #include #include +#include //INTERNAL INCLUDES #include -#include #include namespace Dali @@ -44,8 +44,8 @@ static const float gDefaultTransformComponentAnimatableData[] = { 1.0f, 1.0f, 1. //Default values for anchor point (CENTER) and parent origin (TOP_LEFT) static const float gDefaultTransformComponentStaticData[] = { 0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 0.5f, true }; -DALI_COMPILE_TIME_ASSERT( sizeof(gDefaultTransformComponentAnimatableData) == sizeof(TransformComponentAnimatable) ); -DALI_COMPILE_TIME_ASSERT( sizeof(gDefaultTransformComponentStaticData) == sizeof(TransformComponentStatic) ); +static_assert( sizeof(gDefaultTransformComponentAnimatableData) == sizeof(TransformComponentAnimatable), "gDefaultTransformComponentAnimatableData should have the same number of floats as specified in TransformComponentAnimatable" ); +static_assert( sizeof(gDefaultTransformComponentStaticData) == sizeof(TransformComponentStatic), "gDefaultTransformComponentStaticData should have the same number of floats as specified in TransformComponentStatic" ); /** * @brief Calculates the center position for the transform component diff --git a/dali/public-api/math/compile-time-math.cpp b/dali/public-api/math/compile-time-math.cpp index 5199323..5948d78 100644 --- a/dali/public-api/math/compile-time-math.cpp +++ b/dali/public-api/math/compile-time-math.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 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. @@ -18,55 +18,34 @@ // CLASS HEADER #include -// INTERNAL INCLUDES -#include +// EXTERNAL INCLUDES +#include namespace Dali { -namespace -{ - // verification for static asserts, these get removed from final binary by the linker - const unsigned int value0 = Power<10,0>::value; - DALI_COMPILE_TIME_ASSERT( value0 == 1 ); // cannot have template with , inside macro... macros suck - const unsigned int value1 = Power<10,1>::value; - DALI_COMPILE_TIME_ASSERT( value1 == 10 ); - const unsigned int value2 = Power<10,2>::value; - DALI_COMPILE_TIME_ASSERT( value2 == 100 ); - const unsigned int value3 = Power<10,3>::value; - DALI_COMPILE_TIME_ASSERT( value3 == 1000 ); - const unsigned int value4 = Power<4,4>::value; - DALI_COMPILE_TIME_ASSERT( value4 == 256 ); - - const unsigned int log0 = Log<0, 10>::value; - DALI_COMPILE_TIME_ASSERT( log0 == 0 ); - const unsigned int log1 = Log<1, 10>::value; - DALI_COMPILE_TIME_ASSERT( log1 == 0 ); - const unsigned int log2 = Log<2, 10>::value; - DALI_COMPILE_TIME_ASSERT( log2 == 1 ); - const unsigned int log3 = Log<10, 10>::value; - DALI_COMPILE_TIME_ASSERT( log3 == 1 ); - const unsigned int log4 = Log<100, 10>::value; - DALI_COMPILE_TIME_ASSERT( log4 == 2 ); - const unsigned int log5 = Log<1000, 10>::value; - DALI_COMPILE_TIME_ASSERT( log5 == 3 ); - - const unsigned int logpow0 = Log::value, 10 >::value; - DALI_COMPILE_TIME_ASSERT( logpow0 == 0 ); - const unsigned int logpow1 = Log::value, 2 >::value; - DALI_COMPILE_TIME_ASSERT( logpow1 == 0 ); - const unsigned int logpow2 = Log::value, 10 >::value; - DALI_COMPILE_TIME_ASSERT( logpow2 == 2 ); - const unsigned int logpow3 = Log::value, 2 >::value; - DALI_COMPILE_TIME_ASSERT( logpow3 == 2 ); - - const unsigned int powlog0 = Power<10, Log<10,10>::value >::value; - DALI_COMPILE_TIME_ASSERT( powlog0 == 10 ); - const unsigned int powlog1 = Power<10, Log<100,10>::value >::value; - DALI_COMPILE_TIME_ASSERT( powlog1 == 100 ); - - // TODO unfortunately cannot static assert floats so cannot test EPSILON here... - -} // namespace +// verification for static asserts, these get removed from final binary by the linker +static_assert( Power<10,0>::value == 1, "" ); +static_assert( Power<10,1>::value == 10, "" ); +static_assert( Power<10,2>::value == 100, "" ); +static_assert( Power<10,3>::value == 1000, "" ); +static_assert( Power<4,4>::value == 256, "" ); + +static_assert( Log<0, 10>::value == 0, "" ); +static_assert( Log<1, 10>::value == 0, "" ); +static_assert( Log<2, 10>::value == 1, "" ); +static_assert( Log<10, 10>::value == 1, "" ); +static_assert( Log<100, 10>::value == 2, "" ); +static_assert( Log<1000, 10>::value == 3, "" ); + +static_assert( Log::value, 10 >::value == 0, "" ); +static_assert( Log::value, 2 >::value == 0, "" ); +static_assert( Log::value, 10 >::value == 2, "" ); +static_assert( Log::value, 2 >::value == 2, "" ); + +static_assert( Power<10, Log<10,10>::value >::value == 10, "" ); +static_assert( Power<10, Log<100,10>::value >::value == 100, "" ); + +// TODO unfortunately cannot static assert floats so cannot test EPSILON here... } // namespace Dali diff --git a/dali/public-api/signals/functor-delegate.cpp b/dali/public-api/signals/functor-delegate.cpp index 7f43284..8fafecd 100644 --- a/dali/public-api/signals/functor-delegate.cpp +++ b/dali/public-api/signals/functor-delegate.cpp @@ -18,8 +18,8 @@ // CLASS HEADER #include -// INTERNAL INCLUDES -#include +// EXTERNAL INCLUDES +#include namespace Dali { @@ -31,7 +31,7 @@ namespace * functions and regular functions. * If this assert fails, please implement the template specialisation for C functions. */ -DALI_COMPILE_TIME_ASSERT( sizeof(void*) == sizeof( &FunctorDispatcher::Dispatch ) ); +static_assert( sizeof(void*) == sizeof( &FunctorDispatcher::Dispatch ), "Need to implement template specialisation for C functions" ); } FunctorDelegate::~FunctorDelegate()