[Common] - Removing the macro assert()
authorAndrzej Popowski <a.popowski@samsung.com>
Mon, 6 Jul 2015 09:48:11 +0000 (11:48 +0200)
committerAndrzej Popowski <a.popowski@samsung.com>
Tue, 7 Jul 2015 07:00:14 +0000 (09:00 +0200)
Change-Id: Ia54a60da44b290ff186d293ccb8d467b53793ffc
Signed-off-by: Andrzej Popowski <a.popowski@samsung.com>
src/common/XW_Extension.cc
src/common/assert.h
src/common/extension.cc
src/common/optional.h
src/common/picojson.h

index f85beb7e5fbf19ef1df2104460aac51c3c0d4a48..b23e455c66572f66d8050f7cb00b67aca03e385b 100755 (executable)
@@ -6,6 +6,7 @@
 // This file is compiled into each plugin, hence its size should be minimized.
 
 #include "common/extension.h"
+#include "common/assert.h"
 #include "common/logger.h"
 
 namespace {
@@ -17,7 +18,7 @@ common::Extension* g_extension = nullptr;
 namespace common {
 
 Extension* GetCurrentExtension() {
-  assert(g_extension);
+  Assert(g_extension);
   return g_extension;
 }
 
index fb07d4fcfc8688f345d7d0d14e67a6ba027711dd..1e0fd39d75336de63bcbecf7c7f005b47ded4b64 100755 (executable)
@@ -32,4 +32,4 @@
 
 #define Assert(condition) AssertMsg(condition, "")
 
-#endif  // COMMON_ASSERT_H_
\ No newline at end of file
+#endif  // COMMON_ASSERT_H_
index c47986dbc5910732a25c9348e91b5412554efcda..b033931257a03cefcb6acb6c819d86bd16c9c26b 100755 (executable)
@@ -5,13 +5,13 @@
 
 #include "common/extension.h"
 
-#include <assert.h>
 #include <iostream>
 #include <vector>
 #include <string>
 #include <map>
 
 #include "common/logger.h"
+#include "common/assert.h"
 
 // This function is hidden, because each plugin needs to have own implementation.
 __attribute__ ((visibility ("hidden"))) common::Extension* CreateExtension() {
@@ -150,7 +150,7 @@ std::string Extension::GetRuntimeVariable(const char* var_name, unsigned len) {
 // static
 void Extension::OnInstanceCreated(XW_Instance xw_instance, Instance* instance) {
   LoggerD("Enter");
-  assert(!g_core->GetInstanceData(xw_instance));
+  Assert(!g_core->GetInstanceData(xw_instance));
   if (!instance)
     return;
   instance->xw_instance_ = xw_instance;
@@ -196,7 +196,7 @@ int32_t Extension::XW_Initialize(XW_Extension extension,
                                  XW_CreatedInstanceCallback created_instance,
                                  XW_ShutdownCallback shutdown) {
   LoggerD("Enter");
-  assert(extension);
+  Assert(extension);
 
   if (!InitializeInterfaces(get_interface)) {
     return XW_ERROR;
@@ -228,7 +228,7 @@ Instance::Instance() :
 
 Instance::~Instance() {
   LoggerD("Enter");
-  assert(xw_instance_ == 0);
+  Assert(xw_instance_ == 0);
 }
 
 void Instance::PostMessage(const char* msg) {
index ba467c30dcfaab41c124c165c065f91670f998e3..232a7456cf297ed6ccff5477928323092cdee1fb 100755 (executable)
 #endif
 
 
-#include <cassert>
 #include <new>
 #include <utility>
 #include <type_traits>
+#include "common/assert.h"
 
 namespace common {
 
@@ -75,12 +75,12 @@ class optional {
     get()->~T();
   }
   const T* get() const {
-    assert(exist_);
+    Assert(exist_);
     return reinterpret_cast<const T*>(value_);
   }
 
   T* get() {
-    assert(exist_);
+    Assert(exist_);
     return reinterpret_cast<T*>(value_);
   }
 
index 9f983197a8618ac6e3d85de0a1c7fd843923c60b..6921b1f12fc08f207afed7124f61cfbe41b810dd 100644 (file)
@@ -31,7 +31,6 @@
 #define picojson_h
 
 #include <algorithm>
-#include <cassert>
 #include <cmath>
 #include <cstdio>
 #include <cstdlib>
@@ -41,6 +40,7 @@
 #include <map>
 #include <string>
 #include <vector>
+#include "common/assert.h"
 
 #ifdef _MSC_VER
     #define SNPRINTF _snprintf_s
@@ -204,12 +204,12 @@ namespace picojson {
   
 #define GET(ctype, var)                                                \
   template <> inline const ctype& value::get<ctype>() const {  \
-    assert("type mismatch! call vis<type>() before get<type>()" \
+    Assert("type mismatch! call vis<type>() before get<type>()" \
           && is<ctype>());                                     \
     return var;                                                        \
   }                                                            \
   template <> inline ctype& value::get<ctype>() {              \
-    assert("type mismatch! call is<type>() before get<type>()" \
+    Assert("type mismatch! call is<type>() before get<type>()" \
           && is<ctype>());                                     \
     return var;                                                        \
   }
@@ -237,24 +237,24 @@ namespace picojson {
   
   inline const value& value::get(size_t idx) const {
     static value s_null;
-    assert(is<array>());
+    Assert(is<array>());
     return idx < u_.array_->size() ? (*u_.array_)[idx] : s_null;
   }
 
   inline const value& value::get(const std::string& key) const {
     static value s_null;
-    assert(is<object>());
+    Assert(is<object>());
     object::const_iterator i = u_.object_->find(key);
     return i != u_.object_->end() ? i->second : s_null;
   }
 
   inline bool value::contains(size_t idx) const {
-    assert(is<array>());
+    Assert(is<array>());
     return idx < u_.array_->size();
   }
 
   inline bool value::contains(const std::string& key) const {
-    assert(is<object>());
+    Assert(is<object>());
     object::const_iterator i = u_.object_->find(key);
     return i != u_.object_->end();
   }
@@ -272,7 +272,7 @@ namespace picojson {
     case string_type:    return *u_.string_;
     case array_type:     return "array";
     case object_type:    return "object";
-    default:             assert(0);
+    default:             Assert(0);
 #ifdef _MSC_VER
       __assume(0);
 #endif
@@ -382,7 +382,7 @@ namespace picojson {
     }
     void ungetc() {
       if (last_ch_ != -1) {
-       assert(! ungot_);
+       Assert(! ungot_);
        ungot_ = true;
       }
     }
@@ -760,7 +760,7 @@ namespace picojson {
     PICOJSON_CMP(array);
     PICOJSON_CMP(object);
 #undef PICOJSON_CMP
-    assert(0);
+    Assert(0);
 #ifdef _MSC_VER
     __assume(0);
 #endif