Making DALi public API typesafe using guaranteed types; uint8_t, uint32_t
[platform/core/uifw/dali-core.git] / dali / public-api / common / dali-common.cpp
index ab03ff1..42d1331 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 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.
 #include <string>
 #include <cstdio>
 
-#ifndef EMSCRIPTEN // cxxabi not supported
-# include <execinfo.h>
-# include <cxxabi.h>
-#endif
+#include <execinfo.h>
+#include <cxxabi.h>
 
 #include <cstring>
 
 // INTERNAL INCLUDES
 #include <dali/integration-api/debug.h>
 
-namespace
-{
-const int MAX_NUM_STACK_FRAMES = 25;
-}
-
 namespace Dali
 {
 
 #if defined(BACKTRACE_ENABLED)
 
+namespace
+{
+const int32_t MAX_NUM_STACK_FRAMES = 25;
+}
+
 std::string Demangle(const char* symbol)
 {
   std::string result;
@@ -69,14 +67,14 @@ std::string Demangle(const char* symbol)
       size_t tokenLength = endOfToken - startOfToken;
 
       // Allocate space for symbol
-      char *mangledSymbol = (char*)malloc(tokenLength+1u);
+      char *mangledSymbol = reinterpret_cast< char* >( malloc( tokenLength + 1u ) );
       if(mangledSymbol != NULL)
       {
         strncpy(mangledSymbol, startOfToken, tokenLength);
         mangledSymbol[tokenLength] = '\0';
 
         size_t size;
-        int    status;
+        int32_t    status;
         char*  demangled=NULL;
         demangled = abi::__cxa_demangle( mangledSymbol, NULL, &size, &status );
         if( demangled != NULL )
@@ -96,7 +94,7 @@ std::string Demangle(const char* symbol)
   return result;
 }
 
-DALI_EXPORT_API DaliException::DaliException( const char* location, const char* condition )
+DALI_CORE_API DaliException::DaliException( const char* location, const char* condition )
 : location( location ), condition( condition )
 {
   // Note, if a memory error has occured, then the backtrace won't work - backtrace_symbols relies on
@@ -113,9 +111,9 @@ DALI_EXPORT_API DaliException::DaliException( const char* location, const char*
   DALI_LOG_ERROR_NOFN("Backtrace:\n");
 
   void* frameArray[MAX_NUM_STACK_FRAMES];
-  int nSize = backtrace(frameArray, MAX_NUM_STACK_FRAMES);
+  int32_t nSize = backtrace(frameArray, MAX_NUM_STACK_FRAMES);
   char** symbols = backtrace_symbols(frameArray, nSize);
-  for(int i=1; i< nSize; i++)
+  for(int32_t i=1; i< nSize; i++)
   {
     std::string demangled_symbol = Demangle(symbols[i]);
     DALI_LOG_ERROR_NOFN("[%02d]   %s\n", i, demangled_symbol.c_str() );
@@ -126,7 +124,7 @@ DALI_EXPORT_API DaliException::DaliException( const char* location, const char*
 
 #else // BACKTRACE_ENABLED
 
-DALI_EXPORT_API DaliException::DaliException( const char* location, const char* condition )
+DALI_CORE_API DaliException::DaliException( const char* location, const char* condition )
 : location( location ), condition( condition )
 {
 #if defined(DEBUG_ENABLED)
@@ -139,7 +137,7 @@ DALI_EXPORT_API DaliException::DaliException( const char* location, const char*
 
 #endif // BACKTRACE_ENABLED
 
-DALI_EXPORT_API void DaliAssertMessage( const char* location, const char* condition )
+DALI_CORE_API void DaliAssertMessage( const char* location, const char* condition )
 {
 #if defined(DEBUG_ENABLED)
   DALI_LOG_ERROR_NOFN( "Assert (%s) failed in: %s\n", condition, location );