Reduce compile time + __forced_unwind don't rethrow 94/267994/3
authorEunki, Hong <eunkiki.hong@samsung.com>
Tue, 14 Dec 2021 08:05:45 +0000 (17:05 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Wed, 15 Dec 2021 12:29:21 +0000 (21:29 +0900)
Change MACRO usage to function call.
It will make compile time as half
+
Let __forced_unwind don't rethrow.
.NET Core doesn't handle about this.
So we just let DALi catch it, and print log, and do nothing.
It will not make any problems for normal case.

Change-Id: Iaba8407abc0fbe425258451c9f033e715c350fff
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
12 files changed:
dali-csharp-binder/file.list
dali-csharp-binder/src/atspi-wrap.cpp
dali-csharp-binder/src/canvas-view-wrap.cpp
dali-csharp-binder/src/common.cpp [new file with mode: 0644]
dali-csharp-binder/src/common.h
dali-csharp-binder/src/dali-wrap.cpp
dali-csharp-binder/src/devel-property-wrap.cpp
dali-csharp-binder/src/keyboard-focus-manager-wrap.cpp
dali-csharp-binder/src/processor-controller.cpp
dali-csharp-binder/src/view-wrapper-impl-wrap.cpp
dali-csharp-binder/src/view-wrapper-impl-wrap.h
dali-csharp-binder/src/web-view-wrap.cpp

index ff958b5..65d6c14 100755 (executable)
@@ -6,6 +6,7 @@
 
 # module: csharp-binder, backend: common
 dali_csharp_binder_common_src_files = \
+  ${dali_csharp_binder_dir}/src/common.cpp \
   ${dali_csharp_binder_dir}/src/dali-wrap.cpp \
   ${dali_csharp_binder_dir}/src/callbackbase-wrap.cpp \
   ${dali_csharp_binder_dir}/src/canvas-view-wrap.cpp \
index 386ce1a..55de08b 100755 (executable)
@@ -16,6 +16,7 @@
 
 #include "common.h"
 #include <dali/devel-api/adaptor-framework/atspi-accessibility.h>
+#include <dali-toolkit/devel-api/controls/control-devel.h>
 #include <dali/integration-api/debug.h>
 
 #ifdef __cplusplus
index fbccdbf..61432ce 100644 (file)
@@ -2,6 +2,7 @@
 
 // INCLUDES
 #include "common.h"
+#include <dali-toolkit/dali-toolkit.h>
 #include <dali-toolkit/devel-api/controls/canvas-view/canvas-view.h>
 #include <dali/devel-api/adaptor-framework/canvas-renderer-drawable-group.h>
 #include <dali/devel-api/adaptor-framework/canvas-renderer-gradient.h>
diff --git a/dali-csharp-binder/src/common.cpp b/dali-csharp-binder/src/common.cpp
new file mode 100644 (file)
index 0000000..27f6276
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2020 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "common.h"
+
+void SWIG_ExceptionMessageWithFileAndLine(const int& code, const char* what, const char* filename, const int& linenumber, const char* funcname)
+{
+  std::string message(what);
+  std::stringstream fileAndLine;
+  fileAndLine << " file: " << (filename) << " line: " << (linenumber) << " func: " << (funcname);
+  message += fileAndLine.str();
+  SWIG_CSharpException((code), message.c_str());
+}
+
+void internal_try_catch(const std::function<void(void)>& func, const char* filename, const int& linenumber, const char* funcname) {
+    try {
+        func();
+    } CALL_CATCH_EXCEPTION_WITH_CUSTOM_FILE_AND_LINE(, filename, linenumber, funcname);
+}
\ No newline at end of file
index 938d55c..3901a0f 100755 (executable)
@@ -91,19 +91,19 @@ template <typename T> T SwigValueInit()
 #include <stdio.h>
 
 /*  Errors in SWIG */
-#define  SWIG_UnknownError         -1
-#define  SWIG_IOError            -2
-#define  SWIG_RuntimeError       -3
-#define  SWIG_IndexError         -4
-#define  SWIG_TypeError          -5
-#define  SWIG_DivisionByZero     -6
-#define  SWIG_OverflowError      -7
-#define  SWIG_SyntaxError        -8
-#define  SWIG_ValueError         -9
-#define  SWIG_SystemError        -10
-#define  SWIG_AttributeError     -11
-#define  SWIG_MemoryError        -12
-#define  SWIG_NullReferenceError   -13
+constexpr static int SWIG_UnknownError       = -1;
+constexpr static int SWIG_IOError            = -2;
+constexpr static int SWIG_RuntimeError       = -3;
+constexpr static int SWIG_IndexError         = -4;
+constexpr static int SWIG_TypeError          = -5;
+constexpr static int SWIG_DivisionByZero     = -6;
+constexpr static int SWIG_OverflowError      = -7;
+constexpr static int SWIG_SyntaxError        = -8;
+constexpr static int SWIG_ValueError         = -9;
+constexpr static int SWIG_SystemError        = -10;
+constexpr static int SWIG_AttributeError     = -11;
+constexpr static int SWIG_MemoryError        = -12;
+constexpr static int SWIG_NullReferenceError = -13;
 
 /* Support for throwing C# exceptions from C/C++. There are two types:
  * Exceptions that take a message and ArgumentExceptions that take a message and a parameter name. */
@@ -156,33 +156,18 @@ extern void SWIGUNUSED SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpExcepti
 extern void SWIG_CSharpException(int code, const char *msg);
 
 
-
-#include <stdexcept>
+#include <cxxabi.h>
 
 #define SWIGSTDCALL
 
 #include <dali/dali.h>
-#include <dali-toolkit/dali-toolkit.h>
-
-#include <dali-toolkit/devel-api/controls/control-wrapper.h>
-#include <dali-toolkit/devel-api/controls/control-wrapper-impl.h>
-#include <dali-toolkit/devel-api/controls/control-devel.h>
-
-// Macro to append SWIG_CSharpException message file/line/function.
-#define SWIG_EXCEPTION_MESSAGE(code, what, filename, linenumber, funcname)                          \
-do                                                                                                  \
-{                                                                                                   \
-  std::string message(what);                                                                        \
-  std::stringstream fileAndLine;                                                                    \
-  fileAndLine << " file: " << (filename) << " line: " << (linenumber) << " func: " << (funcname);   \
-  message += fileAndLine.str();                                                                     \
-  SWIG_CSharpException((code), message.c_str());                                                    \
-} while (0)
+#include <dali/integration-api/debug.h>
 
-#define SWIG_EXCEPTION_WITH_FILE_AND_LINE(code, what) \
-SWIG_EXCEPTION_MESSAGE(code, what, __FILE__, __LINE__, __FUNCTION__)
+// Function to append SWIG_CSharpException message file/line/function.
+extern void SWIG_ExceptionMessageWithFileAndLine(const int& code, const char* what, const char* filename, const int& linenumber, const char* funcname);
 
-#include <cxxabi.h>
+#define SWIG_EXCEPTION_WITH_FILE_AND_LINE(code, what) \
+SWIG_ExceptionMessageWithFileAndLine((code), (what), __FILE__, __LINE__, __FUNCTION__)
 
 // Define Catch exception
 #define CALL_CATCH_EXCEPTION(ret)                                                       \
@@ -201,32 +186,9 @@ SWIG_EXCEPTION_MESSAGE(code, what, __FILE__, __LINE__, __FUNCTION__)
     SWIG_EXCEPTION_WITH_FILE_AND_LINE(SWIG_SystemError, e.condition);                   \
     return ret;                                                                         \
   }                                                                                     \
-  catch (abi::__forced_unwind & e)                                                      \
-  {                                                                                     \
-    /* Throwed by pthread API. just igore and rethrow */                                \
-    throw;                                                                              \
-  }                                                                                     \
-  catch (...)                                                                           \
-  {                                                                                     \
-    SWIG_EXCEPTION_WITH_FILE_AND_LINE(SWIG_UnknownError, "unknown error");              \
-    return ret;                                                                         \
-  }
-
-// Define Catch exception without rethrow
-#define CALL_CATCH_EXCEPTION_ALWAYS(ret)                                                \
-  catch (std::out_of_range & e)                                                         \
-  {                                                                                     \
-    SWIG_EXCEPTION_WITH_FILE_AND_LINE(SWIG_IndexError, const_cast<char *>(e.what()));   \
-    return ret;                                                                         \
-  }                                                                                     \
-  catch (std::exception & e)                                                            \
-  {                                                                                     \
-    SWIG_EXCEPTION_WITH_FILE_AND_LINE(SWIG_RuntimeError, const_cast<char *>(e.what())); \
-    return ret;                                                                         \
-  }                                                                                     \
-  catch (Dali::DaliException e)                                                         \
+  catch (abi::__forced_unwind &)                                                        \
   {                                                                                     \
-    SWIG_EXCEPTION_WITH_FILE_AND_LINE(SWIG_SystemError, e.condition);                   \
+    DALI_LOG_ERROR("abi::__forced_unwind occured\n");                                   \
     return ret;                                                                         \
   }                                                                                     \
   catch (...)                                                                           \
@@ -236,31 +198,31 @@ SWIG_EXCEPTION_MESSAGE(code, what, __FILE__, __LINE__, __FUNCTION__)
   }
 
 // Define Catch exception with inputed file and line infomations
-#define CALL_CATCH_EXCEPTION_WITH_CUSTOM_FILE_AND_LINE(ret, filename, linenumber, funcname)                        \
-  catch (std::out_of_range & e)                                                                                    \
-  {                                                                                                                \
-    SWIG_EXCEPTION_MESSAGE(SWIG_IndexError, const_cast<char *>(e.what()), (filename), (linenumber), (funcname));   \
-    return ret;                                                                                                    \
-  }                                                                                                                \
-  catch (std::exception & e)                                                                                       \
-  {                                                                                                                \
-    SWIG_EXCEPTION_MESSAGE(SWIG_RuntimeError, const_cast<char *>(e.what()), (filename), (linenumber), (funcname)); \
-    return ret;                                                                                                    \
-  }                                                                                                                \
-  catch (Dali::DaliException e)                                                                                    \
-  {                                                                                                                \
-    SWIG_EXCEPTION_MESSAGE(SWIG_SystemError, e.condition, (filename), (linenumber), (funcname));                   \
-    return ret;                                                                                                    \
-  }                                                                                                                \
-  catch (abi::__forced_unwind & e)                                                                                 \
-  {                                                                                                                \
-    /* Throwed by pthread API. just igore and rethrow */                                                           \
-    throw;                                                                                                         \
-  }                                                                                                                \
-  catch (...)                                                                                                      \
-  {                                                                                                                \
-    SWIG_EXCEPTION_MESSAGE(SWIG_UnknownError, "unknown error", (filename), (linenumber), (funcname));              \
-    return ret;                                                                                                    \
+#define CALL_CATCH_EXCEPTION_WITH_CUSTOM_FILE_AND_LINE(ret, filename, linenumber, funcname)                                      \
+  catch (std::out_of_range & e)                                                                                                  \
+  {                                                                                                                              \
+    SWIG_ExceptionMessageWithFileAndLine(SWIG_IndexError, const_cast<char *>(e.what()), (filename), (linenumber), (funcname));   \
+    return ret;                                                                                                                  \
+  }                                                                                                                              \
+  catch (std::exception & e)                                                                                                     \
+  {                                                                                                                              \
+    SWIG_ExceptionMessageWithFileAndLine(SWIG_RuntimeError, const_cast<char *>(e.what()), (filename), (linenumber), (funcname)); \
+    return ret;                                                                                                                  \
+  }                                                                                                                              \
+  catch (Dali::DaliException e)                                                                                                  \
+  {                                                                                                                              \
+    SWIG_ExceptionMessageWithFileAndLine(SWIG_SystemError, e.condition, (filename), (linenumber), (funcname));                   \
+    return ret;                                                                                                                  \
+  }                                                                                                                              \
+  catch (abi::__forced_unwind &)                                                                                                 \
+  {                                                                                                                              \
+    DALI_LOG_ERROR("abi::__forced_unwind occured\n");                                                                            \
+    return ret;                                                                                                                  \
+  }                                                                                                                              \
+  catch (...)                                                                                                                    \
+  {                                                                                                                              \
+    SWIG_ExceptionMessageWithFileAndLine(SWIG_UnknownError, "unknown error", (filename), (linenumber), (funcname));              \
+    return ret;                                                                                                                  \
   }
 
 // Define Catch exception if we need extra job before return
@@ -283,10 +245,11 @@ SWIG_EXCEPTION_MESSAGE(code, what, __FILE__, __LINE__, __FUNCTION__)
     (*(func))(__VA_ARGS__);                                                             \
     return ret;                                                                         \
   }                                                                                     \
-  catch (abi::__forced_unwind & e)                                                      \
+  catch (abi::__forced_unwind &)                                                        \
   {                                                                                     \
-    /* Throwed by pthread API. just igore and rethrow */                                \
-    throw;                                                                              \
+    DALI_LOG_ERROR("abi::__forced_unwind occured\n");                                   \
+    (*(func))(__VA_ARGS__);                                                             \
+    return ret;                                                                         \
   }                                                                                     \
   catch (...)                                                                           \
   {                                                                                     \
@@ -311,23 +274,12 @@ SWIG_EXCEPTION_MESSAGE(code, what, __FILE__, __LINE__, __FUNCTION__)
         return 0;                                                                                                  \
     }
 
-namespace {
-
 // Define useful utils with lambda function
-inline void internal_try_catch(const std::function<void(void)>& func, const char* filename, const int& linenumber, const char* funcname) {
-    try {
-        func();
-    } CALL_CATCH_EXCEPTION_WITH_CUSTOM_FILE_AND_LINE(, filename, linenumber, funcname);
-}
+extern void internal_try_catch(const std::function<void(void)>& func, const char* filename, const int& linenumber, const char* funcname);
 
-#ifdef try_catch
-#undef try_catch
-#endif
 // Define try_catch macro to get correct line and function_name
 // NOTE: when lamda function use comma(,) at template, compiler think this is kind of argment divisor.
 // This is compiler bug. So we need to cover the function by additional parentheses.
 #define try_catch(func) internal_try_catch((func), __FILE__, __LINE__, __FUNCTION__)
 
-} // anonymous namespace
-
 #endif // CSHARP_COMMON_H
index 6c5cf84..800007b 100755 (executable)
 
 #include "common.h"
 
+#include <dali-toolkit/dali-toolkit.h>
+
 SWIG_CSharpException_t SWIG_csharp_exceptions[] = {
   { SWIG_CSharpApplicationException, NULL },
   { SWIG_CSharpArithmeticException, NULL },
index e11f5c7..773228c 100755 (executable)
@@ -17,6 +17,7 @@
 
 #include "common.h"
 
+#include <dali-toolkit/dali-toolkit.h>
 #include <dali-toolkit/devel-api/controls/buttons/button-devel.h>
 #include <dali-toolkit/devel-api/controls/control-devel.h>
 #include <dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h>
index 6eead57..3a26be9 100755 (executable)
@@ -16,6 +16,7 @@
  */
 
 #include "common.h"
+#include <dali-toolkit/dali-toolkit.h>
 
 SWIGINTERN bool Dali_Signal_Sl_Dali_Actor_Sp_Dali_Actor_Sc_Dali_Actor_Sc_Dali_Toolkit_Control_KeyboardFocus_Direction_SP__Sg__Empty(Dali::Signal< Dali::Actor (Dali::Actor,Dali::Actor,Dali::Toolkit::Control::KeyboardFocus::Direction) > const *self){
          return self->Empty();
index 586c7df..9fb5eb6 100644 (file)
@@ -41,7 +41,7 @@ ProcessorController::~ProcessorController()
     {
       Dali::Adaptor::Get().UnregisterProcessor(*this);
     }
-    CALL_CATCH_EXCEPTION_ALWAYS(); ///< We should not throw anything in deconstructor
+    CALL_CATCH_EXCEPTION();
   }
 }
 
index 86c39c8..a845948 100755 (executable)
 // CLASS HEADER
 #include "view-wrapper-impl-wrap.h"
 
-// INTERNAL INCLUDES
+// EXTERNAL INCLUDES
+#include <dali-toolkit/dali-toolkit.h>
 #include <dali-toolkit/devel-api/visual-factory/visual-base.h>
 
-
 #ifdef __cplusplus
 extern "C" {
 #endif
index 2538e76..e75cb9a 100644 (file)
@@ -20,6 +20,9 @@
 
 #include "common.h"
 
+#include <dali-toolkit/devel-api/controls/control-wrapper.h>
+#include <dali-toolkit/devel-api/controls/control-wrapper-impl.h>
+
 class SwigDirector_ViewWrapperImpl : public Dali::Toolkit::Internal::ControlWrapper
 {
 public:
index add4b11..909bbca 100755 (executable)
  *
  */
 
-// EXTERNAL INCLUDES
 #include "common.h"
 
+// EXTERNAL INCLUDES
+#include <dali-toolkit/dali-toolkit.h>
 #include <dali-toolkit/devel-api/controls/web-view/web-back-forward-list.h>
 #include <dali-toolkit/devel-api/controls/web-view/web-context.h>
 #include <dali-toolkit/devel-api/controls/web-view/web-cookie-manager.h>