[Bf-blender-cvs] [4b62970dd37] blender-v3.3-release: Cleanup: replace CHECK_TYPE macro with static_assert
Brecht Van Lommel
noreply at git.blender.org
Fri Aug 19 21:01:54 CEST 2022
Commit: 4b62970dd378164a9f5d4592f923ae92a894da87
Author: Brecht Van Lommel
Date: Fri Aug 19 20:32:42 2022 +0200
Branches: blender-v3.3-release
https://developer.blender.org/rB4b62970dd378164a9f5d4592f923ae92a894da87
Cleanup: replace CHECK_TYPE macro with static_assert
To avoid conflicts with BLI headers and simplify code.
===================================================================
M intern/cycles/graph/node_type.h
M intern/cycles/util/defines.h
===================================================================
diff --git a/intern/cycles/graph/node_type.h b/intern/cycles/graph/node_type.h
index 65b16c9bf75..9101b51bb9f 100644
--- a/intern/cycles/graph/node_type.h
+++ b/intern/cycles/graph/node_type.h
@@ -171,7 +171,7 @@ struct NodeType {
#define SOCKET_DEFINE(name, ui_name, default_value, datatype, TYPE, flags, ...) \
{ \
static datatype defval = default_value; \
- CHECK_TYPE(T::name, datatype); \
+ static_assert(std::is_same_v<decltype(T::name), datatype>); \
type->register_input(ustring(#name), \
ustring(ui_name), \
TYPE, \
diff --git a/intern/cycles/util/defines.h b/intern/cycles/util/defines.h
index d0df1a221fc..56a41a1dc45 100644
--- a/intern/cycles/util/defines.h
+++ b/intern/cycles/util/defines.h
@@ -89,46 +89,6 @@
# define UNLIKELY(x) (x)
#endif
-#if defined(__GNUC__) || defined(__clang__)
-# if defined(__cplusplus)
-/* Some magic to be sure we don't have reference in the type. */
-template<typename T> static inline T decltype_helper(T x)
-{
- return x;
-}
-# define TYPEOF(x) decltype(decltype_helper(x))
-# else
-# define TYPEOF(x) typeof(x)
-# endif
-#endif
-
-/* Causes warning:
- * incompatible types when assigning to type 'Foo' from type 'Bar'
- * ... the compiler optimizes away the temp var */
-#ifdef __GNUC__
-# define CHECK_TYPE(var, type) \
- { \
- TYPEOF(var) * __tmp; \
- __tmp = (type *)NULL; \
- (void)__tmp; \
- } \
- (void)0
-
-# define CHECK_TYPE_PAIR(var_a, var_b) \
- { \
- TYPEOF(var_a) * __tmp; \
- __tmp = (typeof(var_b) *)NULL; \
- (void)__tmp; \
- } \
- (void)0
-#else
-# define CHECK_TYPE(var, type)
-# define CHECK_TYPE_PAIR(var_a, var_b)
-#endif
-
-/* can be used in simple macros */
-#define CHECK_TYPE_INLINE(val, type) ((void)(((type)0) != (val)))
-
#ifndef __KERNEL_GPU__
# include <cassert>
# define util_assert(statement) assert(statement)
More information about the Bf-blender-cvs
mailing list