X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Fpublic-api%2Fcommon%2Fdali-common.h;h=4b7c4aaf877d5b32753257a2e5066966d862cfd9;hb=0643c768fd100bd7ffb522e3358b88d075bc1d2e;hp=5e756a4f9eff5ce6276a3756a7b5e4502193ae2d;hpb=7f018a22b7063e1fc4cab37bc24aa1c11c718a21;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/public-api/common/dali-common.h b/dali/public-api/common/dali-common.h old mode 100644 new mode 100755 index 5e756a4..4b7c4aa --- a/dali/public-api/common/dali-common.h +++ b/dali/public-api/common/dali-common.h @@ -2,7 +2,7 @@ #define __DALI_COMMON_H__ /* - * 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. @@ -19,30 +19,27 @@ */ // EXTERNAL INCLUDES -#include -#include -#ifdef EMSCRIPTEN -#include -#endif /* - * Definitions for shared library support + * Definitions for shared library support. * * If a library is configured with --enable-exportall or --enable-debug * then HIDE_DALI_INTERNALS is not defined, and nothing is hidden. * If it is configured without these options (the default), then HIDE_INTERNALS * is defined when building the library, visibility is automatically hidden, and the explicit * defines below come into use. - * When building a library that uses DALI, HIDE_DALI_INTERNALS + * When building a library that uses DALI, HIDE_DALI_INTERNALS. */ #if __GNUC__ >= 4 # ifndef HIDE_DALI_INTERNALS # define DALI_EXPORT_API # define DALI_IMPORT_API +# define DALI_CORE_API # define DALI_INTERNAL # else # define DALI_EXPORT_API __attribute__ ((visibility ("default"))) # define DALI_IMPORT_API __attribute__ ((visibility ("default"))) +# define DALI_CORE_API __attribute__ ((visibility ("default"))) # define DALI_INTERNAL __attribute__ ((visibility ("hidden"))) # endif #else @@ -50,10 +47,18 @@ # define DALI_EXPORT_API /** Visibility attribute to show declarations */ # define DALI_IMPORT_API +/** Visibility attribute to show declarations */ +# define DALI_CORE_API /** Visibility attribute to hide declarations */ # define DALI_INTERNAL #endif +#ifdef DEPRECATION_WARNING +#define DALI_DEPRECATED_API __attribute__((__visibility__("default"), deprecated)) +#else +#define DALI_DEPRECATED_API +#endif + #if defined (__GXX_EXPERIMENTAL_CXX0X__) || (__cplusplus >= 201103L) // C++0x support #define _CPP11 @@ -61,40 +66,41 @@ // C++0x not supported #endif -#ifdef EMSCRIPTEN - -#ifndef __clang__ -# error not clang? -#endif - -// clang cpp11 check is per feature -#if !__has_feature(cxx_constexpr) -# error constexpr needed for compile-time-math. Use -std=c+11 -#endif - -#define _CPP11 - -#endif +/** + * @brief Two macros to provide branch predictor information. + * DALI_LIKELY should be used when a branch is taken in almost all cases so the + * branch predictor can avoid pre-fetching. The code for else branch + * DALI_UNLIKELY should be used when a branch is almost never taken. + * @SINCE_1_0.0 + */ +#define DALI_LIKELY(expression) __builtin_expect( !!(expression), 1 ) +#define DALI_UNLIKELY(expression) __builtin_expect( !!(expression), 0 ) /** - * @brief The DALi namespace + * @brief The DALi namespace. + * @SINCE_1_0.0 */ namespace Dali { +/** + * @addtogroup dali_core_common + * @{ + */ /** * @brief Method to log assertion message in DALI_ASSERT_ALWAYS macro below. * + * @SINCE_1_0.0 + * @param[in] location Where the assertion occurred * @param[in] condition The assertion condition - * @param[in] file The file in which the assertion occurred - * @param[in] line The line number at which the assertion occured */ -DALI_IMPORT_API void DaliAssertMessage(const char* condition, const char* file, int line); +DALI_CORE_API void DaliAssertMessage( const char* location, const char* condition ); /** * @brief Exception class for Dali Core library - Raised by assertions in codebase. + * @SINCE_1_0.0 */ -class DALI_IMPORT_API DaliException +class DALI_CORE_API DaliException { public: /** @@ -102,15 +108,19 @@ public: * * Will always display a backtrace when raised in a debug build. * - * @param[in] location - the location of the assertion - * @param[in] condition - The assertion condition + * @SINCE_1_0.0 + * @param[in] location The location of the assertion + * @param[in] condition The assertion condition */ - DALI_IMPORT_API DaliException(const char *location, const char* condition); + DaliException( const char* location, const char* condition ); - std::string mLocation; ///< Location in code of the assertion - std::string mCondition; ///< The assertion string + const char* location; + const char* condition; }; +/** + * @} + */ }// Dali /** @@ -133,31 +143,36 @@ public: * (which it is often equivalent to in effect). * It should not be used for simple parameter validation for instance. */ -#ifdef EMSCRIPTEN - -#define DALI_ASSERT_ALWAYS(cond) \ - if(!(cond)) \ - { \ - Dali::DaliAssertMessage(#cond, __FILE__, __LINE__); \ - throw Dali::DaliException(__PRETTY_FUNCTION__, #cond); \ - EM_ASM(print(new Error().stack)); \ - }\ +/** + * @brief Strip assert location for release builds, assert text is descriptive enough. + * This is to save space for low spec devices. + * @SINCE_1_0.0 + */ +#if defined(DEBUG_ENABLED) +#define ASSERT_LOCATION __PRETTY_FUNCTION__ #else +#define ASSERT_LOCATION NULL +#endif #define DALI_ASSERT_ALWAYS(cond) \ - if(!(cond)) \ + if(DALI_UNLIKELY(!(cond))) \ { \ - Dali::DaliAssertMessage(#cond, __FILE__, __LINE__); \ - throw Dali::DaliException(__PRETTY_FUNCTION__, #cond); \ - }\ + Dali::DaliAssertMessage( ASSERT_LOCATION, #cond ); \ + throw Dali::DaliException( ASSERT_LOCATION, #cond ); \ + } -#endif +#define DALI_ABORT(message) \ + { \ + Dali::DaliAssertMessage( ASSERT_LOCATION, message ); \ + throw Dali::DaliException( ASSERT_LOCATION, message ); \ + } /** * @brief An invariant concurrent assertion to ensure its argument evaluates TRUE in debug builds. * - * Use this to sanity check algorithms and prevent internal programming errors + * Use this to sanity check algorithms and prevent internal programming errors. + * @SINCE_1_0.0 */ #if defined(DEBUG_ENABLED) #define DALI_ASSERT_DEBUG(cond) DALI_ASSERT_ALWAYS(cond)