summaryrefslogtreecommitdiffstats
path: root/modules/mono/utils/macros.h
diff options
context:
space:
mode:
authorIgnacio Etcheverry <ignalfonsore@gmail.com>2020-03-14 19:20:17 +0100
committerIgnacio Etcheverry <ignalfonsore@gmail.com>2020-03-17 16:30:04 +0100
commit6a85cdf640d735b1ca8216b4c6e16fb949f4d183 (patch)
treeafc06540f53d6d2f7ede36fc8383330dee149262 /modules/mono/utils/macros.h
parent0159787864e7ecce60a4d3142f5c82e024710f89 (diff)
downloadredot-engine-6a85cdf640d735b1ca8216b4c6e16fb949f4d183.tar.gz
Fix C# bindings after recent breaking changes
Implementation for new Variant types Callable, Signal, StringName. Added support for PackedInt64Array and PackedFloat64Array. Add generation of signal members as events, as well as support for user created signals as events. NOTE: As of now, raising such events will not emit the signal. As such, one must use `EmitSignal` instead of raising the event directly. Removed old ThreadLocal fallback class. It's safe to use thread_local now since it's supported on all minimum versions of compilers we support.
Diffstat (limited to 'modules/mono/utils/macros.h')
-rw-r--r--modules/mono/utils/macros.h53
1 files changed, 21 insertions, 32 deletions
diff --git a/modules/mono/utils/macros.h b/modules/mono/utils/macros.h
index 754000dc14..8650d6cc09 100644
--- a/modules/mono/utils/macros.h
+++ b/modules/mono/utils/macros.h
@@ -36,38 +36,6 @@
#define _GD_VARNAME_CONCAT_(m_a, m_b, m_c) _GD_VARNAME_CONCAT_A_(m_a, m_b, m_c)
#define GD_UNIQUE_NAME(m_name) _GD_VARNAME_CONCAT_(m_name, _, __COUNTER__)
-// static assert
-// TODO: Get rid of this macro once we upgrade to C++11
-
-#ifdef __cpp_static_assert
-#define GD_STATIC_ASSERT(m_cond) static_assert((m_cond), "Condition '" #m_cond "' failed")
-#else
-#define GD_STATIC_ASSERT(m_cond) typedef int GD_UNIQUE_NAME(godot_static_assert)[((m_cond) ? 1 : -1)]
-#endif
-
-// final
-// TODO: Get rid of this macro once we upgrade to C++11
-
-#if (__cplusplus >= 201103L)
-#define GD_FINAL final
-#else
-#define GD_FINAL
-#endif
-
-// noreturn
-// TODO: Get rid of this macro once we upgrade to C++11
-
-#if (__cplusplus >= 201103L)
-#define GD_NORETURN [[noreturn]]
-#elif defined(__GNUC__)
-#define GD_NORETURN __attribute__((noreturn))
-#elif defined(_MSC_VER)
-#define GD_NORETURN __declspec(noreturn)
-#else
-#define GD_NORETURN
-#pragma message "Macro GD_NORETURN will have no effect"
-#endif
-
// unreachable
#if defined(_MSC_VER)
@@ -81,4 +49,25 @@
} while (true);
#endif
+namespace gdmono {
+
+template <typename F>
+struct ScopeExit {
+ ScopeExit(F p_exit_func) :
+ exit_func(p_exit_func) {}
+ ~ScopeExit() { exit_func(); }
+ F exit_func;
+};
+
+class ScopeExitAux {
+public:
+ template <typename F>
+ ScopeExit<F> operator+(F p_exit_func) { return ScopeExit<F>(p_exit_func); }
+};
+
+} // namespace gdmono
+
+#define SCOPE_EXIT \
+ auto GD_UNIQUE_NAME(gd_scope_exit) = gdmono::ScopeExitAux() + [=]()
+
#endif // UTIL_MACROS_H