diff --git a/.clang-format b/.clang-format index 22966e2db93..52d8f713959 100644 --- a/.clang-format +++ b/.clang-format @@ -38,7 +38,7 @@ AlignAfterOpenBracket: DontAlign # AcrossEmptyLines: false # AcrossComments: false # AlignCaseColons: false -# AlignEscapedNewlines: Right +AlignEscapedNewlines: DontAlign # Aligning leads to long diffs AlignOperands: DontAlign AlignTrailingComments: Kind: Never diff --git a/core/core_constants.cpp b/core/core_constants.cpp index b3251295389..f9b32da79e9 100644 --- a/core/core_constants.cpp +++ b/core/core_constants.cpp @@ -69,183 +69,183 @@ static HashMap> _global_enums; #ifdef DEBUG_ENABLED -#define BIND_CORE_CONSTANT(m_constant) \ +#define BIND_CORE_CONSTANT(m_constant) \ _global_constants.push_back(_CoreConstant(StringName(), #m_constant, m_constant)); \ _global_constants_map[#m_constant] = _global_constants.size() - 1; -#define BIND_CORE_ENUM_CONSTANT(m_constant) \ - { \ - StringName enum_name = __constant_get_enum_name(m_constant); \ - _global_constants.push_back(_CoreConstant(enum_name, #m_constant, m_constant)); \ - _global_constants_map[#m_constant] = _global_constants.size() - 1; \ +#define BIND_CORE_ENUM_CONSTANT(m_constant) \ + { \ + StringName enum_name = __constant_get_enum_name(m_constant); \ + _global_constants.push_back(_CoreConstant(enum_name, #m_constant, m_constant)); \ + _global_constants_map[#m_constant] = _global_constants.size() - 1; \ _global_enums[enum_name].push_back((_global_constants.ptr())[_global_constants.size() - 1]); \ } -#define BIND_CORE_BITFIELD_FLAG(m_constant) \ - { \ - StringName enum_name = __constant_get_bitfield_name(m_constant); \ +#define BIND_CORE_BITFIELD_FLAG(m_constant) \ + { \ + StringName enum_name = __constant_get_bitfield_name(m_constant); \ _global_constants.push_back(_CoreConstant(enum_name, #m_constant, m_constant, false, true)); \ - _global_constants_map[#m_constant] = _global_constants.size() - 1; \ + _global_constants_map[#m_constant] = _global_constants.size() - 1; \ _global_enums[enum_name].push_back((_global_constants.ptr())[_global_constants.size() - 1]); \ } // This just binds enum classes as if they were regular enum constants. -#define BIND_CORE_ENUM_CLASS_CONSTANT(m_enum, m_prefix, m_member) \ - { \ - StringName enum_name = __constant_get_enum_name(m_enum::m_member); \ +#define BIND_CORE_ENUM_CLASS_CONSTANT(m_enum, m_prefix, m_member) \ + { \ + StringName enum_name = __constant_get_enum_name(m_enum::m_member); \ _global_constants.push_back(_CoreConstant(enum_name, #m_prefix "_" #m_member, (int64_t)m_enum::m_member)); \ - _global_constants_map[#m_prefix "_" #m_member] = _global_constants.size() - 1; \ - _global_enums[enum_name].push_back((_global_constants.ptr())[_global_constants.size() - 1]); \ + _global_constants_map[#m_prefix "_" #m_member] = _global_constants.size() - 1; \ + _global_enums[enum_name].push_back((_global_constants.ptr())[_global_constants.size() - 1]); \ } -#define BIND_CORE_BITFIELD_CLASS_FLAG(m_enum, m_prefix, m_member) \ - { \ - StringName enum_name = __constant_get_bitfield_name(m_enum::m_member); \ +#define BIND_CORE_BITFIELD_CLASS_FLAG(m_enum, m_prefix, m_member) \ + { \ + StringName enum_name = __constant_get_bitfield_name(m_enum::m_member); \ _global_constants.push_back(_CoreConstant(enum_name, #m_prefix "_" #m_member, (int64_t)m_enum::m_member, false, true)); \ - _global_constants_map[#m_prefix "_" #m_member] = _global_constants.size() - 1; \ - _global_enums[enum_name].push_back((_global_constants.ptr())[_global_constants.size() - 1]); \ - } - -#define BIND_CORE_ENUM_CLASS_CONSTANT_CUSTOM(m_enum, m_name, m_member) \ - { \ - StringName enum_name = __constant_get_enum_name(m_enum::m_member); \ - _global_constants.push_back(_CoreConstant(enum_name, #m_name, (int64_t)m_enum::m_member)); \ - _global_constants_map[#m_name] = _global_constants.size() - 1; \ + _global_constants_map[#m_prefix "_" #m_member] = _global_constants.size() - 1; \ _global_enums[enum_name].push_back((_global_constants.ptr())[_global_constants.size() - 1]); \ } -#define BIND_CORE_BITFIELD_CLASS_FLAG_CUSTOM(m_enum, m_name, m_member) \ - { \ - StringName enum_name = __constant_get_bitfield_name(m_enum::m_member); \ +#define BIND_CORE_ENUM_CLASS_CONSTANT_CUSTOM(m_enum, m_name, m_member) \ + { \ + StringName enum_name = __constant_get_enum_name(m_enum::m_member); \ + _global_constants.push_back(_CoreConstant(enum_name, #m_name, (int64_t)m_enum::m_member)); \ + _global_constants_map[#m_name] = _global_constants.size() - 1; \ + _global_enums[enum_name].push_back((_global_constants.ptr())[_global_constants.size() - 1]); \ + } + +#define BIND_CORE_BITFIELD_CLASS_FLAG_CUSTOM(m_enum, m_name, m_member) \ + { \ + StringName enum_name = __constant_get_bitfield_name(m_enum::m_member); \ _global_constants.push_back(_CoreConstant(enum_name, #m_name, (int64_t)m_enum::m_member, false, true)); \ - _global_constants_map[#m_name] = _global_constants.size() - 1; \ - _global_enums[enum_name].push_back((_global_constants.ptr())[_global_constants.size() - 1]); \ - } - -#define BIND_CORE_ENUM_CLASS_CONSTANT_NO_VAL(m_enum, m_prefix, m_member) \ - { \ - StringName enum_name = __constant_get_enum_name(m_enum::m_member); \ - _global_constants.push_back(_CoreConstant(enum_name, #m_prefix "_" #m_member, (int64_t)m_enum::m_member, true)); \ - _global_constants_map[#m_prefix "_" #m_member] = _global_constants.size() - 1; \ - _global_enums[enum_name].push_back((_global_constants.ptr())[_global_constants.size() - 1]); \ - } - -#define BIND_CORE_ENUM_CONSTANT_CUSTOM(m_custom_name, m_constant) \ - { \ - StringName enum_name = __constant_get_enum_name(m_constant); \ - _global_constants.push_back(_CoreConstant(enum_name, m_custom_name, m_constant)); \ - _global_constants_map[m_custom_name] = _global_constants.size() - 1; \ + _global_constants_map[#m_name] = _global_constants.size() - 1; \ _global_enums[enum_name].push_back((_global_constants.ptr())[_global_constants.size() - 1]); \ } -#define BIND_CORE_CONSTANT_NO_VAL(m_constant) \ +#define BIND_CORE_ENUM_CLASS_CONSTANT_NO_VAL(m_enum, m_prefix, m_member) \ + { \ + StringName enum_name = __constant_get_enum_name(m_enum::m_member); \ + _global_constants.push_back(_CoreConstant(enum_name, #m_prefix "_" #m_member, (int64_t)m_enum::m_member, true)); \ + _global_constants_map[#m_prefix "_" #m_member] = _global_constants.size() - 1; \ + _global_enums[enum_name].push_back((_global_constants.ptr())[_global_constants.size() - 1]); \ + } + +#define BIND_CORE_ENUM_CONSTANT_CUSTOM(m_custom_name, m_constant) \ + { \ + StringName enum_name = __constant_get_enum_name(m_constant); \ + _global_constants.push_back(_CoreConstant(enum_name, m_custom_name, m_constant)); \ + _global_constants_map[m_custom_name] = _global_constants.size() - 1; \ + _global_enums[enum_name].push_back((_global_constants.ptr())[_global_constants.size() - 1]); \ + } + +#define BIND_CORE_CONSTANT_NO_VAL(m_constant) \ _global_constants.push_back(_CoreConstant(StringName(), #m_constant, m_constant, true)); \ _global_constants_map[#m_constant] = _global_constants.size() - 1; -#define BIND_CORE_ENUM_CONSTANT_NO_VAL(m_constant) \ - { \ - StringName enum_name = __constant_get_enum_name(m_constant); \ - _global_constants.push_back(_CoreConstant(enum_name, #m_constant, m_constant, true)); \ - _global_constants_map[#m_constant] = _global_constants.size() - 1; \ +#define BIND_CORE_ENUM_CONSTANT_NO_VAL(m_constant) \ + { \ + StringName enum_name = __constant_get_enum_name(m_constant); \ + _global_constants.push_back(_CoreConstant(enum_name, #m_constant, m_constant, true)); \ + _global_constants_map[#m_constant] = _global_constants.size() - 1; \ _global_enums[enum_name].push_back((_global_constants.ptr())[_global_constants.size() - 1]); \ } -#define BIND_CORE_ENUM_CONSTANT_CUSTOM_NO_VAL(m_custom_name, m_constant) \ - { \ - StringName enum_name = __constant_get_enum_name(m_constant); \ - _global_constants.push_back(_CoreConstant(enum_name, m_custom_name, m_constant, true)); \ - _global_constants_map[m_custom_name] = _global_constants.size() - 1; \ +#define BIND_CORE_ENUM_CONSTANT_CUSTOM_NO_VAL(m_custom_name, m_constant) \ + { \ + StringName enum_name = __constant_get_enum_name(m_constant); \ + _global_constants.push_back(_CoreConstant(enum_name, m_custom_name, m_constant, true)); \ + _global_constants_map[m_custom_name] = _global_constants.size() - 1; \ _global_enums[enum_name].push_back((_global_constants.ptr())[_global_constants.size() - 1]); \ } #else -#define BIND_CORE_CONSTANT(m_constant) \ +#define BIND_CORE_CONSTANT(m_constant) \ _global_constants.push_back(_CoreConstant(StringName(), #m_constant, m_constant)); \ _global_constants_map[#m_constant] = _global_constants.size() - 1; -#define BIND_CORE_ENUM_CONSTANT(m_constant) \ - { \ - StringName enum_name = __constant_get_enum_name(m_constant); \ - _global_constants.push_back(_CoreConstant(enum_name, #m_constant, m_constant)); \ - _global_constants_map[#m_constant] = _global_constants.size() - 1; \ +#define BIND_CORE_ENUM_CONSTANT(m_constant) \ + { \ + StringName enum_name = __constant_get_enum_name(m_constant); \ + _global_constants.push_back(_CoreConstant(enum_name, #m_constant, m_constant)); \ + _global_constants_map[#m_constant] = _global_constants.size() - 1; \ _global_enums[enum_name].push_back((_global_constants.ptr())[_global_constants.size() - 1]); \ } -#define BIND_CORE_BITFIELD_FLAG(m_constant) \ - { \ - StringName enum_name = __constant_get_bitfield_name(m_constant); \ - _global_constants.push_back(_CoreConstant(enum_name, #m_constant, m_constant)); \ - _global_constants_map[#m_constant] = _global_constants.size() - 1; \ +#define BIND_CORE_BITFIELD_FLAG(m_constant) \ + { \ + StringName enum_name = __constant_get_bitfield_name(m_constant); \ + _global_constants.push_back(_CoreConstant(enum_name, #m_constant, m_constant)); \ + _global_constants_map[#m_constant] = _global_constants.size() - 1; \ _global_enums[enum_name].push_back((_global_constants.ptr())[_global_constants.size() - 1]); \ } // This just binds enum classes as if they were regular enum constants. -#define BIND_CORE_ENUM_CLASS_CONSTANT(m_enum, m_prefix, m_member) \ - { \ - StringName enum_name = __constant_get_enum_name(m_enum::m_member); \ +#define BIND_CORE_ENUM_CLASS_CONSTANT(m_enum, m_prefix, m_member) \ + { \ + StringName enum_name = __constant_get_enum_name(m_enum::m_member); \ _global_constants.push_back(_CoreConstant(enum_name, #m_prefix "_" #m_member, (int64_t)m_enum::m_member)); \ - _global_constants_map[#m_prefix "_" #m_member] = _global_constants.size() - 1; \ - _global_enums[enum_name].push_back((_global_constants.ptr())[_global_constants.size() - 1]); \ - } - -#define BIND_CORE_BITFIELD_CLASS_FLAG(m_enum, m_prefix, m_member) \ - { \ - StringName enum_name = __constant_get_bitfield_name(m_enum::m_member); \ - _global_constants.push_back(_CoreConstant(enum_name, #m_prefix "_" #m_member, (int64_t)m_enum::m_member)); \ - _global_constants_map[#m_prefix "_" #m_member] = _global_constants.size() - 1; \ - _global_enums[enum_name].push_back((_global_constants.ptr())[_global_constants.size() - 1]); \ - } - -#define BIND_CORE_ENUM_CLASS_CONSTANT_CUSTOM(m_enum, m_name, m_member) \ - { \ - StringName enum_name = __constant_get_enum_name(m_enum::m_member); \ - _global_constants.push_back(_CoreConstant(enum_name, #m_name, (int64_t)m_enum::m_member)); \ - _global_constants_map[#m_name] = _global_constants.size() - 1; \ + _global_constants_map[#m_prefix "_" #m_member] = _global_constants.size() - 1; \ _global_enums[enum_name].push_back((_global_constants.ptr())[_global_constants.size() - 1]); \ } -#define BIND_CORE_BITFIELD_CLASS_FLAG_CUSTOM(m_enum, m_name, m_member) \ - { \ - StringName enum_name = __constant_get_bitfield_name(m_enum::m_member); \ - _global_constants.push_back(_CoreConstant(enum_name, #m_name, (int64_t)m_enum::m_member)); \ - _global_constants_map[#m_name] = _global_constants.size() - 1; \ - _global_enums[enum_name].push_back((_global_constants.ptr())[_global_constants.size() - 1]); \ - } - -#define BIND_CORE_ENUM_CLASS_CONSTANT_NO_VAL(m_enum, m_prefix, m_member) \ - { \ - StringName enum_name = __constant_get_enum_name(m_enum::m_member); \ +#define BIND_CORE_BITFIELD_CLASS_FLAG(m_enum, m_prefix, m_member) \ + { \ + StringName enum_name = __constant_get_bitfield_name(m_enum::m_member); \ _global_constants.push_back(_CoreConstant(enum_name, #m_prefix "_" #m_member, (int64_t)m_enum::m_member)); \ - _global_constants_map[#m_prefix "_" #m_member] = _global_constants.size() - 1; \ - _global_enums[enum_name].push_back((_global_constants.ptr())[_global_constants.size() - 1]); \ - } - -#define BIND_CORE_ENUM_CONSTANT_CUSTOM(m_custom_name, m_constant) \ - { \ - StringName enum_name = __constant_get_enum_name(m_constant); \ - _global_constants.push_back(_CoreConstant(enum_name, m_custom_name, m_constant)); \ - _global_constants_map[m_custom_name] = _global_constants.size() - 1; \ + _global_constants_map[#m_prefix "_" #m_member] = _global_constants.size() - 1; \ _global_enums[enum_name].push_back((_global_constants.ptr())[_global_constants.size() - 1]); \ } -#define BIND_CORE_CONSTANT_NO_VAL(m_constant) \ +#define BIND_CORE_ENUM_CLASS_CONSTANT_CUSTOM(m_enum, m_name, m_member) \ + { \ + StringName enum_name = __constant_get_enum_name(m_enum::m_member); \ + _global_constants.push_back(_CoreConstant(enum_name, #m_name, (int64_t)m_enum::m_member)); \ + _global_constants_map[#m_name] = _global_constants.size() - 1; \ + _global_enums[enum_name].push_back((_global_constants.ptr())[_global_constants.size() - 1]); \ + } + +#define BIND_CORE_BITFIELD_CLASS_FLAG_CUSTOM(m_enum, m_name, m_member) \ + { \ + StringName enum_name = __constant_get_bitfield_name(m_enum::m_member); \ + _global_constants.push_back(_CoreConstant(enum_name, #m_name, (int64_t)m_enum::m_member)); \ + _global_constants_map[#m_name] = _global_constants.size() - 1; \ + _global_enums[enum_name].push_back((_global_constants.ptr())[_global_constants.size() - 1]); \ + } + +#define BIND_CORE_ENUM_CLASS_CONSTANT_NO_VAL(m_enum, m_prefix, m_member) \ + { \ + StringName enum_name = __constant_get_enum_name(m_enum::m_member); \ + _global_constants.push_back(_CoreConstant(enum_name, #m_prefix "_" #m_member, (int64_t)m_enum::m_member)); \ + _global_constants_map[#m_prefix "_" #m_member] = _global_constants.size() - 1; \ + _global_enums[enum_name].push_back((_global_constants.ptr())[_global_constants.size() - 1]); \ + } + +#define BIND_CORE_ENUM_CONSTANT_CUSTOM(m_custom_name, m_constant) \ + { \ + StringName enum_name = __constant_get_enum_name(m_constant); \ + _global_constants.push_back(_CoreConstant(enum_name, m_custom_name, m_constant)); \ + _global_constants_map[m_custom_name] = _global_constants.size() - 1; \ + _global_enums[enum_name].push_back((_global_constants.ptr())[_global_constants.size() - 1]); \ + } + +#define BIND_CORE_CONSTANT_NO_VAL(m_constant) \ _global_constants.push_back(_CoreConstant(StringName(), #m_constant, m_constant)); \ _global_constants_map[#m_constant] = _global_constants.size() - 1; -#define BIND_CORE_ENUM_CONSTANT_NO_VAL(m_constant) \ - { \ - StringName enum_name = __constant_get_enum_name(m_constant); \ - _global_constants.push_back(_CoreConstant(enum_name, #m_constant, m_constant)); \ - _global_constants_map[#m_constant] = _global_constants.size() - 1; \ +#define BIND_CORE_ENUM_CONSTANT_NO_VAL(m_constant) \ + { \ + StringName enum_name = __constant_get_enum_name(m_constant); \ + _global_constants.push_back(_CoreConstant(enum_name, #m_constant, m_constant)); \ + _global_constants_map[#m_constant] = _global_constants.size() - 1; \ _global_enums[enum_name].push_back((_global_constants.ptr())[_global_constants.size() - 1]); \ } -#define BIND_CORE_ENUM_CONSTANT_CUSTOM_NO_VAL(m_custom_name, m_constant) \ - { \ - StringName enum_name = __constant_get_enum_name(m_constant); \ - _global_constants.push_back(_CoreConstant(enum_name, m_custom_name, m_constant)); \ - _global_constants_map[m_custom_name] = _global_constants.size() - 1; \ +#define BIND_CORE_ENUM_CONSTANT_CUSTOM_NO_VAL(m_custom_name, m_constant) \ + { \ + StringName enum_name = __constant_get_enum_name(m_constant); \ + _global_constants.push_back(_CoreConstant(enum_name, m_custom_name, m_constant)); \ + _global_constants_map[m_custom_name] = _global_constants.size() - 1; \ _global_enums[enum_name].push_back((_global_constants.ptr())[_global_constants.size() - 1]); \ } diff --git a/core/error/error_macros.h b/core/error/error_macros.h index 034f16f2cba..94d90ff7e6d 100644 --- a/core/error/error_macros.h +++ b/core/error/error_macros.h @@ -135,32 +135,32 @@ void _physics_interpolation_warning(const char *p_function, const char *p_file, * Ensures an integer index `m_index` is less than `m_size` and greater than or equal to 0. * If not, the current function returns. */ -#define ERR_FAIL_INDEX(m_index, m_size) \ - if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \ +#define ERR_FAIL_INDEX(m_index, m_size) \ + if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \ _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size)); \ - return; \ - } else \ + return; \ + } else \ ((void)0) /** * Ensures an integer index `m_index` is less than `m_size` and greater than or equal to 0. * If not, prints `m_msg` and the current function returns. */ -#define ERR_FAIL_INDEX_MSG(m_index, m_size, m_msg) \ - if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \ +#define ERR_FAIL_INDEX_MSG(m_index, m_size, m_msg) \ + if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \ _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), m_msg); \ - return; \ - } else \ + return; \ + } else \ ((void)0) /** * Same as `ERR_FAIL_INDEX_MSG` but also notifies the editor. */ -#define ERR_FAIL_INDEX_EDMSG(m_index, m_size, m_msg) \ - if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \ +#define ERR_FAIL_INDEX_EDMSG(m_index, m_size, m_msg) \ + if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \ _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), m_msg, true); \ - return; \ - } else \ + return; \ + } else \ ((void)0) /** @@ -170,32 +170,32 @@ void _physics_interpolation_warning(const char *p_function, const char *p_file, * Ensures an integer index `m_index` is less than `m_size` and greater than or equal to 0. * If not, the current function returns `m_retval`. */ -#define ERR_FAIL_INDEX_V(m_index, m_size, m_retval) \ - if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \ +#define ERR_FAIL_INDEX_V(m_index, m_size, m_retval) \ + if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \ _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size)); \ - return m_retval; \ - } else \ + return m_retval; \ + } else \ ((void)0) /** * Ensures an integer index `m_index` is less than `m_size` and greater than or equal to 0. * If not, prints `m_msg` and the current function returns `m_retval`. */ -#define ERR_FAIL_INDEX_V_MSG(m_index, m_size, m_retval, m_msg) \ - if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \ +#define ERR_FAIL_INDEX_V_MSG(m_index, m_size, m_retval, m_msg) \ + if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \ _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), m_msg); \ - return m_retval; \ - } else \ + return m_retval; \ + } else \ ((void)0) /** * Same as `ERR_FAIL_INDEX_V_MSG` but also notifies the editor. */ -#define ERR_FAIL_INDEX_V_EDMSG(m_index, m_size, m_retval, m_msg) \ - if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \ +#define ERR_FAIL_INDEX_V_EDMSG(m_index, m_size, m_retval, m_msg) \ + if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \ _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), m_msg, true); \ - return m_retval; \ - } else \ + return m_retval; \ + } else \ ((void)0) /** @@ -206,12 +206,12 @@ void _physics_interpolation_warning(const char *p_function, const char *p_file, * Ensures an integer index `m_index` is less than `m_size` and greater than or equal to 0. * If not, the application crashes. */ -#define CRASH_BAD_INDEX(m_index, m_size) \ - if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \ +#define CRASH_BAD_INDEX(m_index, m_size) \ + if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \ _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), "", false, true); \ - _err_flush_stdout(); \ - GENERATE_TRAP(); \ - } else \ + _err_flush_stdout(); \ + GENERATE_TRAP(); \ + } else \ ((void)0) /** @@ -221,12 +221,12 @@ void _physics_interpolation_warning(const char *p_function, const char *p_file, * Ensures an integer index `m_index` is less than `m_size` and greater than or equal to 0. * If not, prints `m_msg` and the application crashes. */ -#define CRASH_BAD_INDEX_MSG(m_index, m_size, m_msg) \ - if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \ +#define CRASH_BAD_INDEX_MSG(m_index, m_size, m_msg) \ + if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \ _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), m_msg, false, true); \ - _err_flush_stdout(); \ - GENERATE_TRAP(); \ - } else \ + _err_flush_stdout(); \ + GENERATE_TRAP(); \ + } else \ ((void)0) // Unsigned integer index out of bounds error macros. @@ -238,32 +238,32 @@ void _physics_interpolation_warning(const char *p_function, const char *p_file, * Ensures an unsigned integer index `m_index` is less than `m_size`. * If not, the current function returns. */ -#define ERR_FAIL_UNSIGNED_INDEX(m_index, m_size) \ - if (unlikely((m_index) >= (m_size))) { \ +#define ERR_FAIL_UNSIGNED_INDEX(m_index, m_size) \ + if (unlikely((m_index) >= (m_size))) { \ _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size)); \ - return; \ - } else \ + return; \ + } else \ ((void)0) /** * Ensures an unsigned integer index `m_index` is less than `m_size`. * If not, prints `m_msg` and the current function returns. */ -#define ERR_FAIL_UNSIGNED_INDEX_MSG(m_index, m_size, m_msg) \ - if (unlikely((m_index) >= (m_size))) { \ +#define ERR_FAIL_UNSIGNED_INDEX_MSG(m_index, m_size, m_msg) \ + if (unlikely((m_index) >= (m_size))) { \ _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), m_msg); \ - return; \ - } else \ + return; \ + } else \ ((void)0) /** * Same as `ERR_FAIL_UNSIGNED_INDEX_MSG` but also notifies the editor. */ -#define ERR_FAIL_UNSIGNED_INDEX_EDMSG(m_index, m_size, m_msg) \ - if (unlikely((m_index) >= (m_size))) { \ +#define ERR_FAIL_UNSIGNED_INDEX_EDMSG(m_index, m_size, m_msg) \ + if (unlikely((m_index) >= (m_size))) { \ _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), m_msg, true); \ - return; \ - } else \ + return; \ + } else \ ((void)0) /** @@ -273,32 +273,32 @@ void _physics_interpolation_warning(const char *p_function, const char *p_file, * Ensures an unsigned integer index `m_index` is less than `m_size`. * If not, the current function returns `m_retval`. */ -#define ERR_FAIL_UNSIGNED_INDEX_V(m_index, m_size, m_retval) \ - if (unlikely((m_index) >= (m_size))) { \ +#define ERR_FAIL_UNSIGNED_INDEX_V(m_index, m_size, m_retval) \ + if (unlikely((m_index) >= (m_size))) { \ _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size)); \ - return m_retval; \ - } else \ + return m_retval; \ + } else \ ((void)0) /** * Ensures an unsigned integer index `m_index` is less than `m_size`. * If not, prints `m_msg` and the current function returns `m_retval`. */ -#define ERR_FAIL_UNSIGNED_INDEX_V_MSG(m_index, m_size, m_retval, m_msg) \ - if (unlikely((m_index) >= (m_size))) { \ +#define ERR_FAIL_UNSIGNED_INDEX_V_MSG(m_index, m_size, m_retval, m_msg) \ + if (unlikely((m_index) >= (m_size))) { \ _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), m_msg); \ - return m_retval; \ - } else \ + return m_retval; \ + } else \ ((void)0) /** * Same as `ERR_FAIL_UNSIGNED_INDEX_V_MSG` but also notifies the editor. */ -#define ERR_FAIL_UNSIGNED_INDEX_V_EDMSG(m_index, m_size, m_retval, m_msg) \ - if (unlikely((m_index) >= (m_size))) { \ +#define ERR_FAIL_UNSIGNED_INDEX_V_EDMSG(m_index, m_size, m_retval, m_msg) \ + if (unlikely((m_index) >= (m_size))) { \ _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), m_msg, true); \ - return m_retval; \ - } else \ + return m_retval; \ + } else \ ((void)0) /** @@ -309,12 +309,12 @@ void _physics_interpolation_warning(const char *p_function, const char *p_file, * Ensures an unsigned integer index `m_index` is less than `m_size`. * If not, the application crashes. */ -#define CRASH_BAD_UNSIGNED_INDEX(m_index, m_size) \ - if (unlikely((m_index) >= (m_size))) { \ +#define CRASH_BAD_UNSIGNED_INDEX(m_index, m_size) \ + if (unlikely((m_index) >= (m_size))) { \ _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), "", false, true); \ - _err_flush_stdout(); \ - GENERATE_TRAP(); \ - } else \ + _err_flush_stdout(); \ + GENERATE_TRAP(); \ + } else \ ((void)0) /** @@ -324,12 +324,12 @@ void _physics_interpolation_warning(const char *p_function, const char *p_file, * Ensures an unsigned integer index `m_index` is less than `m_size`. * If not, prints `m_msg` and the application crashes. */ -#define CRASH_BAD_UNSIGNED_INDEX_MSG(m_index, m_size, m_msg) \ - if (unlikely((m_index) >= (m_size))) { \ +#define CRASH_BAD_UNSIGNED_INDEX_MSG(m_index, m_size, m_msg) \ + if (unlikely((m_index) >= (m_size))) { \ _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), m_msg, false, true); \ - _err_flush_stdout(); \ - GENERATE_TRAP(); \ - } else \ + _err_flush_stdout(); \ + GENERATE_TRAP(); \ + } else \ ((void)0) // Null reference error macros. @@ -341,32 +341,32 @@ void _physics_interpolation_warning(const char *p_function, const char *p_file, * Ensures a pointer `m_param` is not null. * If it is null, the current function returns. */ -#define ERR_FAIL_NULL(m_param) \ - if (unlikely(m_param == nullptr)) { \ +#define ERR_FAIL_NULL(m_param) \ + if (unlikely(m_param == nullptr)) { \ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Parameter \"" _STR(m_param) "\" is null."); \ - return; \ - } else \ + return; \ + } else \ ((void)0) /** * Ensures a pointer `m_param` is not null. * If it is null, prints `m_msg` and the current function returns. */ -#define ERR_FAIL_NULL_MSG(m_param, m_msg) \ - if (unlikely(m_param == nullptr)) { \ +#define ERR_FAIL_NULL_MSG(m_param, m_msg) \ + if (unlikely(m_param == nullptr)) { \ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Parameter \"" _STR(m_param) "\" is null.", m_msg); \ - return; \ - } else \ + return; \ + } else \ ((void)0) /** * Same as `ERR_FAIL_NULL_MSG` but also notifies the editor. */ -#define ERR_FAIL_NULL_EDMSG(m_param, m_msg) \ - if (unlikely(m_param == nullptr)) { \ +#define ERR_FAIL_NULL_EDMSG(m_param, m_msg) \ + if (unlikely(m_param == nullptr)) { \ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Parameter \"" _STR(m_param) "\" is null.", m_msg, true); \ - return; \ - } else \ + return; \ + } else \ ((void)0) /** @@ -376,32 +376,32 @@ void _physics_interpolation_warning(const char *p_function, const char *p_file, * Ensures a pointer `m_param` is not null. * If it is null, the current function returns `m_retval`. */ -#define ERR_FAIL_NULL_V(m_param, m_retval) \ - if (unlikely(m_param == nullptr)) { \ +#define ERR_FAIL_NULL_V(m_param, m_retval) \ + if (unlikely(m_param == nullptr)) { \ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Parameter \"" _STR(m_param) "\" is null."); \ - return m_retval; \ - } else \ + return m_retval; \ + } else \ ((void)0) /** * Ensures a pointer `m_param` is not null. * If it is null, prints `m_msg` and the current function returns `m_retval`. */ -#define ERR_FAIL_NULL_V_MSG(m_param, m_retval, m_msg) \ - if (unlikely(m_param == nullptr)) { \ +#define ERR_FAIL_NULL_V_MSG(m_param, m_retval, m_msg) \ + if (unlikely(m_param == nullptr)) { \ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Parameter \"" _STR(m_param) "\" is null.", m_msg); \ - return m_retval; \ - } else \ + return m_retval; \ + } else \ ((void)0) /** * Same as `ERR_FAIL_NULL_V_MSG` but also notifies the editor. */ -#define ERR_FAIL_NULL_V_EDMSG(m_param, m_retval, m_msg) \ - if (unlikely(m_param == nullptr)) { \ +#define ERR_FAIL_NULL_V_EDMSG(m_param, m_retval, m_msg) \ + if (unlikely(m_param == nullptr)) { \ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Parameter \"" _STR(m_param) "\" is null.", m_msg, true); \ - return m_retval; \ - } else \ + return m_retval; \ + } else \ ((void)0) /** @@ -413,11 +413,11 @@ void _physics_interpolation_warning(const char *p_function, const char *p_file, * Ensures `m_cond` is false. * If `m_cond` is true, the current function returns. */ -#define ERR_FAIL_COND(m_cond) \ - if (unlikely(m_cond)) { \ +#define ERR_FAIL_COND(m_cond) \ + if (unlikely(m_cond)) { \ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true."); \ - return; \ - } else \ + return; \ + } else \ ((void)0) /** @@ -427,21 +427,21 @@ void _physics_interpolation_warning(const char *p_function, const char *p_file, * If checking for null use ERR_FAIL_NULL_MSG instead. * If checking index bounds use ERR_FAIL_INDEX_MSG instead. */ -#define ERR_FAIL_COND_MSG(m_cond, m_msg) \ - if (unlikely(m_cond)) { \ +#define ERR_FAIL_COND_MSG(m_cond, m_msg) \ + if (unlikely(m_cond)) { \ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true.", m_msg); \ - return; \ - } else \ + return; \ + } else \ ((void)0) /** * Same as `ERR_FAIL_COND_MSG` but also notifies the editor. */ -#define ERR_FAIL_COND_EDMSG(m_cond, m_msg) \ - if (unlikely(m_cond)) { \ +#define ERR_FAIL_COND_EDMSG(m_cond, m_msg) \ + if (unlikely(m_cond)) { \ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true.", m_msg, true); \ - return; \ - } else \ + return; \ + } else \ ((void)0) /** @@ -453,11 +453,11 @@ void _physics_interpolation_warning(const char *p_function, const char *p_file, * Ensures `m_cond` is false. * If `m_cond` is true, the current function returns `m_retval`. */ -#define ERR_FAIL_COND_V(m_cond, m_retval) \ - if (unlikely(m_cond)) { \ +#define ERR_FAIL_COND_V(m_cond, m_retval) \ + if (unlikely(m_cond)) { \ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true. Returning: " _STR(m_retval)); \ - return m_retval; \ - } else \ + return m_retval; \ + } else \ ((void)0) /** @@ -467,21 +467,21 @@ void _physics_interpolation_warning(const char *p_function, const char *p_file, * If checking for null use ERR_FAIL_NULL_V_MSG instead. * If checking index bounds use ERR_FAIL_INDEX_V_MSG instead. */ -#define ERR_FAIL_COND_V_MSG(m_cond, m_retval, m_msg) \ - if (unlikely(m_cond)) { \ +#define ERR_FAIL_COND_V_MSG(m_cond, m_retval, m_msg) \ + if (unlikely(m_cond)) { \ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true. Returning: " _STR(m_retval), m_msg); \ - return m_retval; \ - } else \ + return m_retval; \ + } else \ ((void)0) /** * Same as `ERR_FAIL_COND_V_MSG` but also notifies the editor. */ -#define ERR_FAIL_COND_V_EDMSG(m_cond, m_retval, m_msg) \ - if (unlikely(m_cond)) { \ +#define ERR_FAIL_COND_V_EDMSG(m_cond, m_retval, m_msg) \ + if (unlikely(m_cond)) { \ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true. Returning: " _STR(m_retval), m_msg, true); \ - return m_retval; \ - } else \ + return m_retval; \ + } else \ ((void)0) /** @@ -491,32 +491,32 @@ void _physics_interpolation_warning(const char *p_function, const char *p_file, * Ensures `m_cond` is false. * If `m_cond` is true, the current loop continues. */ -#define ERR_CONTINUE(m_cond) \ - if (unlikely(m_cond)) { \ +#define ERR_CONTINUE(m_cond) \ + if (unlikely(m_cond)) { \ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true. Continuing."); \ - continue; \ - } else \ + continue; \ + } else \ ((void)0) /** * Ensures `m_cond` is false. * If `m_cond` is true, prints `m_msg` and the current loop continues. */ -#define ERR_CONTINUE_MSG(m_cond, m_msg) \ - if (unlikely(m_cond)) { \ +#define ERR_CONTINUE_MSG(m_cond, m_msg) \ + if (unlikely(m_cond)) { \ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true. Continuing.", m_msg); \ - continue; \ - } else \ + continue; \ + } else \ ((void)0) /** * Same as `ERR_CONTINUE_MSG` but also notifies the editor. */ -#define ERR_CONTINUE_EDMSG(m_cond, m_msg) \ - if (unlikely(m_cond)) { \ +#define ERR_CONTINUE_EDMSG(m_cond, m_msg) \ + if (unlikely(m_cond)) { \ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true. Continuing.", m_msg, true); \ - continue; \ - } else \ + continue; \ + } else \ ((void)0) /** @@ -526,32 +526,32 @@ void _physics_interpolation_warning(const char *p_function, const char *p_file, * Ensures `m_cond` is false. * If `m_cond` is true, the current loop breaks. */ -#define ERR_BREAK(m_cond) \ - if (unlikely(m_cond)) { \ +#define ERR_BREAK(m_cond) \ + if (unlikely(m_cond)) { \ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true. Breaking."); \ - break; \ - } else \ + break; \ + } else \ ((void)0) /** * Ensures `m_cond` is false. * If `m_cond` is true, prints `m_msg` and the current loop breaks. */ -#define ERR_BREAK_MSG(m_cond, m_msg) \ - if (unlikely(m_cond)) { \ +#define ERR_BREAK_MSG(m_cond, m_msg) \ + if (unlikely(m_cond)) { \ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true. Breaking.", m_msg); \ - break; \ - } else \ + break; \ + } else \ ((void)0) /** * Same as `ERR_BREAK_MSG` but also notifies the editor. */ -#define ERR_BREAK_EDMSG(m_cond, m_msg) \ - if (unlikely(m_cond)) { \ +#define ERR_BREAK_EDMSG(m_cond, m_msg) \ + if (unlikely(m_cond)) { \ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true. Breaking.", m_msg, true); \ - break; \ - } else \ + break; \ + } else \ ((void)0) /** @@ -562,12 +562,12 @@ void _physics_interpolation_warning(const char *p_function, const char *p_file, * Ensures `m_cond` is false. * If `m_cond` is true, the application crashes. */ -#define CRASH_COND(m_cond) \ - if (unlikely(m_cond)) { \ +#define CRASH_COND(m_cond) \ + if (unlikely(m_cond)) { \ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "FATAL: Condition \"" _STR(m_cond) "\" is true."); \ - _err_flush_stdout(); \ - GENERATE_TRAP(); \ - } else \ + _err_flush_stdout(); \ + GENERATE_TRAP(); \ + } else \ ((void)0) /** @@ -577,12 +577,12 @@ void _physics_interpolation_warning(const char *p_function, const char *p_file, * Ensures `m_cond` is false. * If `m_cond` is true, prints `m_msg` and the application crashes. */ -#define CRASH_COND_MSG(m_cond, m_msg) \ - if (unlikely(m_cond)) { \ +#define CRASH_COND_MSG(m_cond, m_msg) \ + if (unlikely(m_cond)) { \ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "FATAL: Condition \"" _STR(m_cond) "\" is true.", m_msg); \ - _err_flush_stdout(); \ - GENERATE_TRAP(); \ - } else \ + _err_flush_stdout(); \ + GENERATE_TRAP(); \ + } else \ ((void)0) // Generic error macros. @@ -594,11 +594,11 @@ void _physics_interpolation_warning(const char *p_function, const char *p_file, * * The current function returns. */ -#define ERR_FAIL() \ - if (true) { \ +#define ERR_FAIL() \ + if (true) { \ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Method/function failed."); \ - return; \ - } else \ + return; \ + } else \ ((void)0) /** @@ -607,21 +607,21 @@ void _physics_interpolation_warning(const char *p_function, const char *p_file, * * Prints `m_msg`, and the current function returns. */ -#define ERR_FAIL_MSG(m_msg) \ - if (true) { \ +#define ERR_FAIL_MSG(m_msg) \ + if (true) { \ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Method/function failed.", m_msg); \ - return; \ - } else \ + return; \ + } else \ ((void)0) /** * Same as `ERR_FAIL_MSG` but also notifies the editor. */ -#define ERR_FAIL_EDMSG(m_msg) \ - if (true) { \ +#define ERR_FAIL_EDMSG(m_msg) \ + if (true) { \ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Method/function failed.", m_msg, true); \ - return; \ - } else \ + return; \ + } else \ ((void)0) /** @@ -631,11 +631,11 @@ void _physics_interpolation_warning(const char *p_function, const char *p_file, * * The current function returns `m_retval`. */ -#define ERR_FAIL_V(m_retval) \ - if (true) { \ +#define ERR_FAIL_V(m_retval) \ + if (true) { \ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Method/function failed. Returning: " _STR(m_retval)); \ - return m_retval; \ - } else \ + return m_retval; \ + } else \ ((void)0) /** @@ -644,21 +644,21 @@ void _physics_interpolation_warning(const char *p_function, const char *p_file, * * Prints `m_msg`, and the current function returns `m_retval`. */ -#define ERR_FAIL_V_MSG(m_retval, m_msg) \ - if (true) { \ +#define ERR_FAIL_V_MSG(m_retval, m_msg) \ + if (true) { \ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Method/function failed. Returning: " _STR(m_retval), m_msg); \ - return m_retval; \ - } else \ + return m_retval; \ + } else \ ((void)0) /** * Same as `ERR_FAIL_V_MSG` but also notifies the editor. */ -#define ERR_FAIL_V_EDMSG(m_retval, m_msg) \ - if (true) { \ +#define ERR_FAIL_V_EDMSG(m_retval, m_msg) \ + if (true) { \ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Method/function failed. Returning: " _STR(m_retval), m_msg, true); \ - return m_retval; \ - } else \ + return m_retval; \ + } else \ ((void)0) /** @@ -680,27 +680,27 @@ void _physics_interpolation_warning(const char *p_function, const char *p_file, /** * Prints `m_msg` once during the application lifetime. */ -#define ERR_PRINT_ONCE(m_msg) \ - if (true) { \ - static bool warning_shown = false; \ - if (unlikely(!warning_shown)) { \ - warning_shown = true; \ +#define ERR_PRINT_ONCE(m_msg) \ + if (true) { \ + static bool warning_shown = false; \ + if (unlikely(!warning_shown)) { \ + warning_shown = true; \ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, m_msg); \ - } \ - } else \ + } \ + } else \ ((void)0) /** * Same as `ERR_PRINT_ONCE` but also notifies the editor. */ -#define ERR_PRINT_ONCE_ED(m_msg) \ - if (true) { \ - static bool warning_shown = false; \ - if (unlikely(!warning_shown)) { \ - warning_shown = true; \ +#define ERR_PRINT_ONCE_ED(m_msg) \ + if (true) { \ + static bool warning_shown = false; \ + if (unlikely(!warning_shown)) { \ + warning_shown = true; \ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, m_msg, true); \ - } \ - } else \ + } \ + } else \ ((void)0) // Print warning message macros. @@ -724,37 +724,37 @@ void _physics_interpolation_warning(const char *p_function, const char *p_file, * * If warning about deprecated usage, use `WARN_DEPRECATED` or `WARN_DEPRECATED_MSG` instead. */ -#define WARN_PRINT_ONCE(m_msg) \ - if (true) { \ - static bool warning_shown = false; \ - if (unlikely(!warning_shown)) { \ - warning_shown = true; \ +#define WARN_PRINT_ONCE(m_msg) \ + if (true) { \ + static bool warning_shown = false; \ + if (unlikely(!warning_shown)) { \ + warning_shown = true; \ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, m_msg, false, ERR_HANDLER_WARNING); \ - } \ - } else \ + } \ + } else \ ((void)0) /** * Same as `WARN_PRINT_ONCE` but also notifies the editor. */ -#define WARN_PRINT_ONCE_ED(m_msg) \ - if (true) { \ - static bool warning_shown = false; \ - if (unlikely(!warning_shown)) { \ - warning_shown = true; \ +#define WARN_PRINT_ONCE_ED(m_msg) \ + if (true) { \ + static bool warning_shown = false; \ + if (unlikely(!warning_shown)) { \ + warning_shown = true; \ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, m_msg, true, ERR_HANDLER_WARNING); \ - } \ - } else \ + } \ + } else \ ((void)0) /** * Warns about `m_msg` only when verbose mode is enabled. */ -#define WARN_VERBOSE(m_msg) \ - { \ +#define WARN_VERBOSE(m_msg) \ + { \ if (is_print_verbose_enabled()) { \ - WARN_PRINT(m_msg); \ - } \ + WARN_PRINT(m_msg); \ + } \ } // Print deprecated warning message macros. @@ -762,27 +762,27 @@ void _physics_interpolation_warning(const char *p_function, const char *p_file, /** * Warns that the current function is deprecated. */ -#define WARN_DEPRECATED \ - if (true) { \ - static bool warning_shown = false; \ - if (unlikely(!warning_shown)) { \ - warning_shown = true; \ +#define WARN_DEPRECATED \ + if (true) { \ + static bool warning_shown = false; \ + if (unlikely(!warning_shown)) { \ + warning_shown = true; \ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "This method has been deprecated and will be removed in the future.", false, ERR_HANDLER_WARNING); \ - } \ - } else \ + } \ + } else \ ((void)0) /** * Warns that the current function is deprecated and prints `m_msg`. */ -#define WARN_DEPRECATED_MSG(m_msg) \ - if (true) { \ - static bool warning_shown = false; \ - if (unlikely(!warning_shown)) { \ - warning_shown = true; \ +#define WARN_DEPRECATED_MSG(m_msg) \ + if (true) { \ + static bool warning_shown = false; \ + if (unlikely(!warning_shown)) { \ + warning_shown = true; \ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "This method has been deprecated and will be removed in the future.", m_msg, false, ERR_HANDLER_WARNING); \ - } \ - } else \ + } \ + } else \ ((void)0) /** @@ -791,12 +791,12 @@ void _physics_interpolation_warning(const char *p_function, const char *p_file, * * The application crashes. */ -#define CRASH_NOW() \ - if (true) { \ +#define CRASH_NOW() \ + if (true) { \ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "FATAL: Method/function failed."); \ - _err_flush_stdout(); \ - GENERATE_TRAP(); \ - } else \ + _err_flush_stdout(); \ + GENERATE_TRAP(); \ + } else \ ((void)0) /** @@ -804,12 +804,12 @@ void _physics_interpolation_warning(const char *p_function, const char *p_file, * * Prints `m_msg`, and then the application crashes. */ -#define CRASH_NOW_MSG(m_msg) \ - if (true) { \ +#define CRASH_NOW_MSG(m_msg) \ + if (true) { \ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "FATAL: Method/function failed.", m_msg); \ - _err_flush_stdout(); \ - GENERATE_TRAP(); \ - } else \ + _err_flush_stdout(); \ + GENERATE_TRAP(); \ + } else \ ((void)0) /** @@ -828,26 +828,26 @@ void _physics_interpolation_warning(const char *p_function, const char *p_file, * and that can't fail for other contributors once the code is finished and merged. */ #ifdef DEV_ENABLED -#define DEV_ASSERT(m_cond) \ - if (unlikely(!(m_cond))) { \ +#define DEV_ASSERT(m_cond) \ + if (unlikely(!(m_cond))) { \ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "FATAL: DEV_ASSERT failed \"" _STR(m_cond) "\" is false."); \ - _err_flush_stdout(); \ - GENERATE_TRAP(); \ - } else \ + _err_flush_stdout(); \ + GENERATE_TRAP(); \ + } else \ ((void)0) #else #define DEV_ASSERT(m_cond) #endif #ifdef DEV_ENABLED -#define DEV_CHECK_ONCE(m_cond) \ - if (true) { \ - static bool first_print = true; \ - if (first_print && unlikely(!(m_cond))) { \ +#define DEV_CHECK_ONCE(m_cond) \ + if (true) { \ + static bool first_print = true; \ + if (first_print && unlikely(!(m_cond))) { \ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "DEV_CHECK_ONCE failed \"" _STR(m_cond) "\" is false."); \ - first_print = false; \ - } \ - } else \ + first_print = false; \ + } \ + } else \ ((void)0) #else #define DEV_CHECK_ONCE(m_cond) diff --git a/core/extension/extension_api_dump.cpp b/core/extension/extension_api_dump.cpp index 06e7a990d24..21884bf9694 100644 --- a/core/extension/extension_api_dump.cpp +++ b/core/extension/extension_api_dump.cpp @@ -281,59 +281,59 @@ Dictionary GDExtensionAPIDump::generate_extension_api(bool p_include_docs) { // Member offsets, meta types and sizes. #define REAL_MEMBER_OFFSET(type, member) \ - { \ - type, \ - member, \ - "float", \ - sizeof(float), \ - "float", \ - sizeof(float), \ - "double", \ - sizeof(double), \ - "double", \ - sizeof(double), \ + { \ + type, \ + member, \ + "float", \ + sizeof(float), \ + "float", \ + sizeof(float), \ + "double", \ + sizeof(double), \ + "double", \ + sizeof(double), \ } #define INT32_MEMBER_OFFSET(type, member) \ - { \ - type, \ - member, \ - "int32", \ - sizeof(int32_t), \ - "int32", \ - sizeof(int32_t), \ - "int32", \ - sizeof(int32_t), \ - "int32", \ - sizeof(int32_t), \ + { \ + type, \ + member, \ + "int32", \ + sizeof(int32_t), \ + "int32", \ + sizeof(int32_t), \ + "int32", \ + sizeof(int32_t), \ + "int32", \ + sizeof(int32_t), \ } #define INT32_BASED_BUILTIN_MEMBER_OFFSET(type, member, member_type, member_elems) \ - { \ - type, \ - member, \ - member_type, \ - sizeof(int32_t) * member_elems, \ - member_type, \ - sizeof(int32_t) * member_elems, \ - member_type, \ - sizeof(int32_t) * member_elems, \ - member_type, \ - sizeof(int32_t) * member_elems, \ + { \ + type, \ + member, \ + member_type, \ + sizeof(int32_t) * member_elems, \ + member_type, \ + sizeof(int32_t) * member_elems, \ + member_type, \ + sizeof(int32_t) * member_elems, \ + member_type, \ + sizeof(int32_t) * member_elems, \ } #define REAL_BASED_BUILTIN_MEMBER_OFFSET(type, member, member_type, member_elems) \ - { \ - type, \ - member, \ - member_type, \ - sizeof(float) * member_elems, \ - member_type, \ - sizeof(float) * member_elems, \ - member_type, \ - sizeof(double) * member_elems, \ - member_type, \ - sizeof(double) * member_elems, \ + { \ + type, \ + member, \ + member_type, \ + sizeof(float) * member_elems, \ + member_type, \ + sizeof(float) * member_elems, \ + member_type, \ + sizeof(double) * member_elems, \ + member_type, \ + sizeof(double) * member_elems, \ } struct { diff --git a/core/io/image.cpp b/core/io/image.cpp index 47e7342e48a..bee62b15389 100644 --- a/core/io/image.cpp +++ b/core/io/image.cpp @@ -2600,24 +2600,24 @@ void Image::initialize_data(const char **p_xpm) { #define DETECT_ALPHA_MAX_THRESHOLD 254 #define DETECT_ALPHA_MIN_THRESHOLD 2 -#define DETECT_ALPHA(m_value) \ - { \ - uint8_t value = m_value; \ - if (value < DETECT_ALPHA_MIN_THRESHOLD) \ - bit = true; \ +#define DETECT_ALPHA(m_value) \ + { \ + uint8_t value = m_value; \ + if (value < DETECT_ALPHA_MIN_THRESHOLD) \ + bit = true; \ else if (value < DETECT_ALPHA_MAX_THRESHOLD) { \ - detected = true; \ - break; \ - } \ + detected = true; \ + break; \ + } \ } #define DETECT_NON_ALPHA(m_value) \ - { \ - uint8_t value = m_value; \ - if (value > 0) { \ - detected = true; \ - break; \ - } \ + { \ + uint8_t value = m_value; \ + if (value > 0) { \ + detected = true; \ + break; \ + } \ } bool Image::is_invisible() const { diff --git a/core/io/json.cpp b/core/io/json.cpp index 857695e2b95..6ecc05338e1 100644 --- a/core/io/json.cpp +++ b/core/io/json.cpp @@ -668,10 +668,10 @@ static bool _encode_container_type(Dictionary &r_dict, const String &p_key, cons } Variant JSON::_from_native(const Variant &p_variant, bool p_full_objects, int p_depth) { -#define RETURN_ARGS \ - Dictionary ret; \ +#define RETURN_ARGS \ + Dictionary ret; \ ret[TYPE] = Variant::get_type_name(p_variant.get_type()); \ - ret[ARGS] = args; \ + ret[ARGS] = args; \ return ret switch (p_variant.get_type()) { @@ -1093,18 +1093,18 @@ Variant JSON::_to_native(const Variant &p_json, bool p_allow_objects, int p_dept ERR_FAIL_COND_V(!dict.has(TYPE), Variant()); -#define LOAD_ARGS() \ +#define LOAD_ARGS() \ ERR_FAIL_COND_V(!dict.has(ARGS), Variant()); \ const Array args = dict[ARGS] -#define LOAD_ARGS_CHECK_SIZE(m_size) \ +#define LOAD_ARGS_CHECK_SIZE(m_size) \ ERR_FAIL_COND_V(!dict.has(ARGS), Variant()); \ - const Array args = dict[ARGS]; \ + const Array args = dict[ARGS]; \ ERR_FAIL_COND_V(args.size() != (m_size), Variant()) -#define LOAD_ARGS_CHECK_FACTOR(m_factor) \ +#define LOAD_ARGS_CHECK_FACTOR(m_factor) \ ERR_FAIL_COND_V(!dict.has(ARGS), Variant()); \ - const Array args = dict[ARGS]; \ + const Array args = dict[ARGS]; \ ERR_FAIL_COND_V(args.size() % (m_factor) != 0, Variant()) switch (Variant::get_type_by_name(dict[TYPE])) { diff --git a/core/io/resource.cpp b/core/io/resource.cpp index 50d399db717..2d3ab2ae374 100644 --- a/core/io/resource.cpp +++ b/core/io/resource.cpp @@ -373,7 +373,7 @@ Ref Resource::_duplicate(const DuplicateParams &p_params) const { // These are for avoiding potential duplicates that can happen in custom code // from participating in the same duplication session (remap cache). #define BEFORE_USER_CODE thread_duplicate_remap_cache = nullptr; -#define AFTER_USER_CODE \ +#define AFTER_USER_CODE \ thread_duplicate_remap_cache = remap_cache_backup; \ thread_duplicate_remap_cache_needs_deallocation = remap_cache_needs_deallocation_backup; diff --git a/core/io/resource.h b/core/io/resource.h index 7feffb7458f..38e615ac467 100644 --- a/core/io/resource.h +++ b/core/io/resource.h @@ -39,15 +39,15 @@ class Node; -#define RES_BASE_EXTENSION(m_ext) \ -public: \ - static void register_custom_data_to_otdb() { \ +#define RES_BASE_EXTENSION(m_ext) \ +public: \ + static void register_custom_data_to_otdb() { \ ClassDB::add_resource_base_extension(m_ext, get_class_static()); \ - } \ - virtual String get_base_extension() const override { \ - return m_ext; \ - } \ - \ + } \ + virtual String get_base_extension() const override { \ + return m_ext; \ + } \ +\ private: class Resource : public RefCounted { diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index 952a7e93cc5..57f072e6d53 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -225,16 +225,16 @@ void ResourceFormatLoader::_bind_methods() { // something we must treat as a different stack for the purposes // of tracking nesting. -#define PREPARE_FOR_WTP_WAIT \ - int load_nesting_backup = ResourceLoader::load_nesting; \ +#define PREPARE_FOR_WTP_WAIT \ + int load_nesting_backup = ResourceLoader::load_nesting; \ Vector load_paths_stack_backup = ResourceLoader::load_paths_stack; \ - ResourceLoader::load_nesting = 0; \ + ResourceLoader::load_nesting = 0; \ ResourceLoader::load_paths_stack.clear(); -#define RESTORE_AFTER_WTP_WAIT \ - DEV_ASSERT(ResourceLoader::load_nesting == 0); \ - DEV_ASSERT(ResourceLoader::load_paths_stack.is_empty()); \ - ResourceLoader::load_nesting = load_nesting_backup; \ +#define RESTORE_AFTER_WTP_WAIT \ + DEV_ASSERT(ResourceLoader::load_nesting == 0); \ + DEV_ASSERT(ResourceLoader::load_paths_stack.is_empty()); \ + ResourceLoader::load_nesting = load_nesting_backup; \ ResourceLoader::load_paths_stack = load_paths_stack_backup; \ load_paths_stack_backup.clear(); diff --git a/core/math/convex_hull.cpp b/core/math/convex_hull.cpp index 87f0652cc18..926fb0d28ab 100644 --- a/core/math/convex_hull.cpp +++ b/core/math/convex_hull.cpp @@ -73,17 +73,17 @@ subject to the following restrictions: // -- GODOT end -- #ifdef DEBUG_ENABLED -#define CHULL_ASSERT(m_cond) \ - if constexpr (true) { \ - if (unlikely(!(m_cond))) { \ +#define CHULL_ASSERT(m_cond) \ + if constexpr (true) { \ + if (unlikely(!(m_cond))) { \ ERR_PRINT("Assertion \"" _STR(m_cond) "\" failed."); \ - } \ - } else \ + } \ + } else \ ((void)0) #else #define CHULL_ASSERT(m_cond) \ - if constexpr (true) { \ - } else \ + if constexpr (true) { \ + } else \ ((void)0) #endif diff --git a/core/math/face3.cpp b/core/math/face3.cpp index 5972f429c79..6a21056093a 100644 --- a/core/math/face3.cpp +++ b/core/math/face3.cpp @@ -144,22 +144,22 @@ bool Face3::intersects_aabb(const AABB &p_aabb) const { return false; } -#define TEST_AXIS(m_ax) \ - /** TEST FACE AXIS */ \ - { \ - real_t aabb_min = p_aabb.position.m_ax; \ +#define TEST_AXIS(m_ax) \ + /** TEST FACE AXIS */ \ + { \ + real_t aabb_min = p_aabb.position.m_ax; \ real_t aabb_max = p_aabb.position.m_ax + p_aabb.size.m_ax; \ - real_t tri_min = vertex[0].m_ax; \ - real_t tri_max = vertex[0].m_ax; \ - for (int i = 1; i < 3; i++) { \ - if (vertex[i].m_ax > tri_max) \ - tri_max = vertex[i].m_ax; \ - if (vertex[i].m_ax < tri_min) \ - tri_min = vertex[i].m_ax; \ - } \ - \ - if (tri_max < aabb_min || aabb_max < tri_min) \ - return false; \ + real_t tri_min = vertex[0].m_ax; \ + real_t tri_max = vertex[0].m_ax; \ + for (int i = 1; i < 3; i++) { \ + if (vertex[i].m_ax > tri_max) \ + tri_max = vertex[i].m_ax; \ + if (vertex[i].m_ax < tri_min) \ + tri_min = vertex[i].m_ax; \ + } \ +\ + if (tri_max < aabb_min || aabb_max < tri_min) \ + return false; \ } TEST_AXIS(x); diff --git a/core/math/face3.h b/core/math/face3.h index 96e4584c22a..0ae5efc4a06 100644 --- a/core/math/face3.h +++ b/core/math/face3.h @@ -102,20 +102,20 @@ bool Face3::intersects_aabb2(const AABB &p_aabb) const { return false; //does not intersect the plane } -#define TEST_AXIS(m_ax) \ - { \ - real_t aabb_min = p_aabb.position.m_ax; \ +#define TEST_AXIS(m_ax) \ + { \ + real_t aabb_min = p_aabb.position.m_ax; \ real_t aabb_max = p_aabb.position.m_ax + p_aabb.size.m_ax; \ - real_t tri_min, tri_max; \ - for (int i = 0; i < 3; i++) { \ - if (i == 0 || vertex[i].m_ax > tri_max) \ - tri_max = vertex[i].m_ax; \ - if (i == 0 || vertex[i].m_ax < tri_min) \ - tri_min = vertex[i].m_ax; \ - } \ - \ - if (tri_max < aabb_min || aabb_max < tri_min) \ - return false; \ + real_t tri_min, tri_max; \ + for (int i = 0; i < 3; i++) { \ + if (i == 0 || vertex[i].m_ax > tri_max) \ + tri_max = vertex[i].m_ax; \ + if (i == 0 || vertex[i].m_ax < tri_min) \ + tri_min = vertex[i].m_ax; \ + } \ +\ + if (tri_max < aabb_min || aabb_max < tri_min) \ + return false; \ } TEST_AXIS(x); diff --git a/core/math/geometry_3d.cpp b/core/math/geometry_3d.cpp index 15799cdb456..987e0c2399b 100644 --- a/core/math/geometry_3d.cpp +++ b/core/math/geometry_3d.cpp @@ -237,15 +237,15 @@ static inline void _plot_face(uint8_t ***p_cell_status, int x, int y, int z, int int div_z = len_z > 1 ? 2 : 1; #define SPLIT_DIV(m_i, m_div, m_v, m_len_v, m_new_v, m_new_len_v) \ - if (m_div == 1) { \ - m_new_v = m_v; \ - m_new_len_v = 1; \ - } else if (m_i == 0) { \ - m_new_v = m_v; \ - m_new_len_v = m_len_v / 2; \ - } else { \ - m_new_v = m_v + m_len_v / 2; \ - m_new_len_v = m_len_v - m_len_v / 2; \ + if (m_div == 1) { \ + m_new_v = m_v; \ + m_new_len_v = 1; \ + } else if (m_i == 0) { \ + m_new_v = m_v; \ + m_new_len_v = m_len_v / 2; \ + } else { \ + m_new_v = m_v + m_len_v / 2; \ + m_new_len_v = m_len_v - m_len_v / 2; \ } int new_x; diff --git a/core/math/geometry_3d.h b/core/math/geometry_3d.h index af2f22ac7e2..ec98bd9f246 100644 --- a/core/math/geometry_3d.h +++ b/core/math/geometry_3d.h @@ -601,18 +601,18 @@ Vector build_capsule_planes(real_t p_radius, real_t p_height, int p_sides Vector compute_convex_mesh_points(const Plane *p_planes, int p_plane_count); #define FINDMINMAX(x0, x1, x2, min, max) \ - min = max = x0; \ - if (x1 < min) { \ - min = x1; \ - } \ - if (x1 > max) { \ - max = x1; \ - } \ - if (x2 < min) { \ - min = x2; \ - } \ - if (x2 > max) { \ - max = x2; \ + min = max = x0; \ + if (x1 < min) { \ + min = x1; \ + } \ + if (x1 > max) { \ + max = x1; \ + } \ + if (x2 < min) { \ + min = x2; \ + } \ + if (x2 > max) { \ + max = x2; \ } _FORCE_INLINE_ bool planeBoxOverlap(Vector3 normal, real_t d, Vector3 maxbox) { @@ -638,96 +638,96 @@ _FORCE_INLINE_ bool planeBoxOverlap(Vector3 normal, real_t d, Vector3 maxbox) { } /*======================== X-tests ========================*/ -#define AXISTEST_X01(a, b, fa, fb) \ - p0 = a * v0.y - b * v0.z; \ - p2 = a * v2.y - b * v2.z; \ - if (p0 < p2) { \ - min = p0; \ - max = p2; \ - } else { \ - min = p2; \ - max = p0; \ - } \ +#define AXISTEST_X01(a, b, fa, fb) \ + p0 = a * v0.y - b * v0.z; \ + p2 = a * v2.y - b * v2.z; \ + if (p0 < p2) { \ + min = p0; \ + max = p2; \ + } else { \ + min = p2; \ + max = p0; \ + } \ rad = fa * boxhalfsize.y + fb * boxhalfsize.z; \ - if (min > rad || max < -rad) { \ - return false; \ + if (min > rad || max < -rad) { \ + return false; \ } -#define AXISTEST_X2(a, b, fa, fb) \ - p0 = a * v0.y - b * v0.z; \ - p1 = a * v1.y - b * v1.z; \ - if (p0 < p1) { \ - min = p0; \ - max = p1; \ - } else { \ - min = p1; \ - max = p0; \ - } \ +#define AXISTEST_X2(a, b, fa, fb) \ + p0 = a * v0.y - b * v0.z; \ + p1 = a * v1.y - b * v1.z; \ + if (p0 < p1) { \ + min = p0; \ + max = p1; \ + } else { \ + min = p1; \ + max = p0; \ + } \ rad = fa * boxhalfsize.y + fb * boxhalfsize.z; \ - if (min > rad || max < -rad) { \ - return false; \ + if (min > rad || max < -rad) { \ + return false; \ } /*======================== Y-tests ========================*/ -#define AXISTEST_Y02(a, b, fa, fb) \ - p0 = -a * v0.x + b * v0.z; \ - p2 = -a * v2.x + b * v2.z; \ - if (p0 < p2) { \ - min = p0; \ - max = p2; \ - } else { \ - min = p2; \ - max = p0; \ - } \ +#define AXISTEST_Y02(a, b, fa, fb) \ + p0 = -a * v0.x + b * v0.z; \ + p2 = -a * v2.x + b * v2.z; \ + if (p0 < p2) { \ + min = p0; \ + max = p2; \ + } else { \ + min = p2; \ + max = p0; \ + } \ rad = fa * boxhalfsize.x + fb * boxhalfsize.z; \ - if (min > rad || max < -rad) { \ - return false; \ + if (min > rad || max < -rad) { \ + return false; \ } -#define AXISTEST_Y1(a, b, fa, fb) \ - p0 = -a * v0.x + b * v0.z; \ - p1 = -a * v1.x + b * v1.z; \ - if (p0 < p1) { \ - min = p0; \ - max = p1; \ - } else { \ - min = p1; \ - max = p0; \ - } \ +#define AXISTEST_Y1(a, b, fa, fb) \ + p0 = -a * v0.x + b * v0.z; \ + p1 = -a * v1.x + b * v1.z; \ + if (p0 < p1) { \ + min = p0; \ + max = p1; \ + } else { \ + min = p1; \ + max = p0; \ + } \ rad = fa * boxhalfsize.x + fb * boxhalfsize.z; \ - if (min > rad || max < -rad) { \ - return false; \ + if (min > rad || max < -rad) { \ + return false; \ } /*======================== Z-tests ========================*/ -#define AXISTEST_Z12(a, b, fa, fb) \ - p1 = a * v1.x - b * v1.y; \ - p2 = a * v2.x - b * v2.y; \ - if (p2 < p1) { \ - min = p2; \ - max = p1; \ - } else { \ - min = p1; \ - max = p2; \ - } \ +#define AXISTEST_Z12(a, b, fa, fb) \ + p1 = a * v1.x - b * v1.y; \ + p2 = a * v2.x - b * v2.y; \ + if (p2 < p1) { \ + min = p2; \ + max = p1; \ + } else { \ + min = p1; \ + max = p2; \ + } \ rad = fa * boxhalfsize.x + fb * boxhalfsize.y; \ - if (min > rad || max < -rad) { \ - return false; \ + if (min > rad || max < -rad) { \ + return false; \ } -#define AXISTEST_Z0(a, b, fa, fb) \ - p0 = a * v0.x - b * v0.y; \ - p1 = a * v1.x - b * v1.y; \ - if (p0 < p1) { \ - min = p0; \ - max = p1; \ - } else { \ - min = p1; \ - max = p0; \ - } \ +#define AXISTEST_Z0(a, b, fa, fb) \ + p0 = a * v0.x - b * v0.y; \ + p1 = a * v1.x - b * v1.y; \ + if (p0 < p1) { \ + min = p0; \ + max = p1; \ + } else { \ + min = p1; \ + max = p0; \ + } \ rad = fa * boxhalfsize.x + fb * boxhalfsize.y; \ - if (min > rad || max < -rad) { \ - return false; \ + if (min > rad || max < -rad) { \ + return false; \ } _FORCE_INLINE_ bool triangle_box_overlap(const Vector3 &boxcenter, const Vector3 boxhalfsize, const Vector3 *triverts) { diff --git a/core/math/math_fieldwise.cpp b/core/math/math_fieldwise.cpp index 8e81e4cc346..36cccfc651e 100644 --- a/core/math/math_fieldwise.cpp +++ b/core/math/math_fieldwise.cpp @@ -32,12 +32,12 @@ #include "math_fieldwise.h" -#define SETUP_TYPE(m_type) \ +#define SETUP_TYPE(m_type) \ m_type source = p_source; \ m_type target = p_target; #define TRY_TRANSFER_FIELD(m_name, m_member) \ - if (p_field == m_name) { \ - target.m_member = source.m_member; \ + if (p_field == m_name) { \ + target.m_member = source.m_member; \ } Variant fieldwise_assign(const Variant &p_target, const Variant &p_source, const String &p_field) { diff --git a/core/object/class_db.h b/core/object/class_db.h index 9516f655df5..6fe14ba64ef 100644 --- a/core/object/class_db.h +++ b/core/object/class_db.h @@ -574,24 +574,24 @@ public: #endif // DEBUG_ENABLED -#define GDREGISTER_CLASS(m_class) \ +#define GDREGISTER_CLASS(m_class) \ if constexpr (GD_IS_CLASS_ENABLED(m_class)) { \ - ::ClassDB::register_class(); \ + ::ClassDB::register_class(); \ } -#define GDREGISTER_VIRTUAL_CLASS(m_class) \ +#define GDREGISTER_VIRTUAL_CLASS(m_class) \ if constexpr (GD_IS_CLASS_ENABLED(m_class)) { \ ::ClassDB::register_class(true); \ } -#define GDREGISTER_ABSTRACT_CLASS(m_class) \ - if constexpr (GD_IS_CLASS_ENABLED(m_class)) { \ +#define GDREGISTER_ABSTRACT_CLASS(m_class) \ + if constexpr (GD_IS_CLASS_ENABLED(m_class)) { \ ::ClassDB::register_abstract_class(); \ } -#define GDREGISTER_INTERNAL_CLASS(m_class) \ - if constexpr (GD_IS_CLASS_ENABLED(m_class)) { \ +#define GDREGISTER_INTERNAL_CLASS(m_class) \ + if constexpr (GD_IS_CLASS_ENABLED(m_class)) { \ ::ClassDB::register_internal_class(); \ } -#define GDREGISTER_RUNTIME_CLASS(m_class) \ - if constexpr (GD_IS_CLASS_ENABLED(m_class)) { \ +#define GDREGISTER_RUNTIME_CLASS(m_class) \ + if constexpr (GD_IS_CLASS_ENABLED(m_class)) { \ ::ClassDB::register_runtime_class(); \ } diff --git a/core/object/message_queue.cpp b/core/object/message_queue.cpp index eb2066ecf58..f5afc6f17ea 100644 --- a/core/object/message_queue.cpp +++ b/core/object/message_queue.cpp @@ -39,23 +39,23 @@ #ifdef DEV_ENABLED // Includes safety checks to ensure that a queue set as a thread singleton override // is only ever called from the thread it was set for. -#define LOCK_MUTEX \ +#define LOCK_MUTEX \ if (this != MessageQueue::thread_singleton) { \ - DEV_ASSERT(!is_current_thread_override); \ - mutex.lock(); \ - } else { \ - DEV_ASSERT(is_current_thread_override); \ + DEV_ASSERT(!is_current_thread_override); \ + mutex.lock(); \ + } else { \ + DEV_ASSERT(is_current_thread_override); \ } #else -#define LOCK_MUTEX \ +#define LOCK_MUTEX \ if (this != MessageQueue::thread_singleton) { \ - mutex.lock(); \ + mutex.lock(); \ } #endif -#define UNLOCK_MUTEX \ +#define UNLOCK_MUTEX \ if (this != MessageQueue::thread_singleton) { \ - mutex.unlock(); \ + mutex.unlock(); \ } void CallQueue::_add_page() { diff --git a/core/object/object.h b/core/object/object.h index 0d270759728..a4f6bdf16e9 100644 --- a/core/object/object.h +++ b/core/object/object.h @@ -399,168 +399,168 @@ struct ObjectGDExtension { /// `GDSOFTCLASS` provides `Object` functionality, such as being able to use `Object::cast_to()`. /// Use this for `Object` subclasses that are not registered in `ClassDB` (use `GDCLASS` otherwise). -#define GDSOFTCLASS(m_class, m_inherits) \ -public: \ - using self_type = m_class; \ - using super_type = m_inherits; \ - static _FORCE_INLINE_ void *get_class_ptr_static() { \ - static int ptr; \ - return &ptr; \ - } \ - virtual bool is_class_ptr(void *p_ptr) const override { \ - return (p_ptr == get_class_ptr_static()) || m_inherits::is_class_ptr(p_ptr); \ - } \ - \ -protected: \ - _FORCE_INLINE_ bool (Object::*_get_get() const)(const StringName &p_name, Variant &) const { \ - return (bool (Object::*)(const StringName &, Variant &) const) & m_class::_get; \ - } \ - virtual bool _getv(const StringName &p_name, Variant &r_ret) const override { \ - if (m_class::_get_get() != m_inherits::_get_get()) { \ - if (_get(p_name, r_ret)) { \ - return true; \ - } \ - } \ - return m_inherits::_getv(p_name, r_ret); \ - } \ - _FORCE_INLINE_ bool (Object::*_get_set() const)(const StringName &p_name, const Variant &p_property) { \ - return (bool (Object::*)(const StringName &, const Variant &)) & m_class::_set; \ - } \ - virtual bool _setv(const StringName &p_name, const Variant &p_property) override { \ - if (m_inherits::_setv(p_name, p_property)) { \ - return true; \ - } \ - if (m_class::_get_set() != m_inherits::_get_set()) { \ - return _set(p_name, p_property); \ - } \ - return false; \ - } \ - _FORCE_INLINE_ void (Object::*_get_validate_property() const)(PropertyInfo & p_property) const { \ - return (void (Object::*)(PropertyInfo &) const) & m_class::_validate_property; \ - } \ - virtual void _validate_propertyv(PropertyInfo &p_property) const override { \ - m_inherits::_validate_propertyv(p_property); \ - if (m_class::_get_validate_property() != m_inherits::_get_validate_property()) { \ - _validate_property(p_property); \ - } \ - } \ - _FORCE_INLINE_ bool (Object::*_get_property_can_revert() const)(const StringName &p_name) const { \ - return (bool (Object::*)(const StringName &) const) & m_class::_property_can_revert; \ - } \ - virtual bool _property_can_revertv(const StringName &p_name) const override { \ - if (m_class::_get_property_can_revert() != m_inherits::_get_property_can_revert()) { \ - if (_property_can_revert(p_name)) { \ - return true; \ - } \ - } \ - return m_inherits::_property_can_revertv(p_name); \ - } \ +#define GDSOFTCLASS(m_class, m_inherits) \ +public: \ + using self_type = m_class; \ + using super_type = m_inherits; \ + static _FORCE_INLINE_ void *get_class_ptr_static() { \ + static int ptr; \ + return &ptr; \ + } \ + virtual bool is_class_ptr(void *p_ptr) const override { \ + return (p_ptr == get_class_ptr_static()) || m_inherits::is_class_ptr(p_ptr); \ + } \ +\ +protected: \ + _FORCE_INLINE_ bool (Object::*_get_get() const)(const StringName &p_name, Variant &) const { \ + return (bool (Object::*)(const StringName &, Variant &) const) & m_class::_get; \ + } \ + virtual bool _getv(const StringName &p_name, Variant &r_ret) const override { \ + if (m_class::_get_get() != m_inherits::_get_get()) { \ + if (_get(p_name, r_ret)) { \ + return true; \ + } \ + } \ + return m_inherits::_getv(p_name, r_ret); \ + } \ + _FORCE_INLINE_ bool (Object::*_get_set() const)(const StringName &p_name, const Variant &p_property) { \ + return (bool (Object::*)(const StringName &, const Variant &)) & m_class::_set; \ + } \ + virtual bool _setv(const StringName &p_name, const Variant &p_property) override { \ + if (m_inherits::_setv(p_name, p_property)) { \ + return true; \ + } \ + if (m_class::_get_set() != m_inherits::_get_set()) { \ + return _set(p_name, p_property); \ + } \ + return false; \ + } \ + _FORCE_INLINE_ void (Object::*_get_validate_property() const)(PropertyInfo & p_property) const { \ + return (void (Object::*)(PropertyInfo &) const) & m_class::_validate_property; \ + } \ + virtual void _validate_propertyv(PropertyInfo &p_property) const override { \ + m_inherits::_validate_propertyv(p_property); \ + if (m_class::_get_validate_property() != m_inherits::_get_validate_property()) { \ + _validate_property(p_property); \ + } \ + } \ + _FORCE_INLINE_ bool (Object::*_get_property_can_revert() const)(const StringName &p_name) const { \ + return (bool (Object::*)(const StringName &) const) & m_class::_property_can_revert; \ + } \ + virtual bool _property_can_revertv(const StringName &p_name) const override { \ + if (m_class::_get_property_can_revert() != m_inherits::_get_property_can_revert()) { \ + if (_property_can_revert(p_name)) { \ + return true; \ + } \ + } \ + return m_inherits::_property_can_revertv(p_name); \ + } \ _FORCE_INLINE_ bool (Object::*_get_property_get_revert() const)(const StringName &p_name, Variant &) const { \ - return (bool (Object::*)(const StringName &, Variant &) const) & m_class::_property_get_revert; \ - } \ - virtual bool _property_get_revertv(const StringName &p_name, Variant &r_ret) const override { \ - if (m_class::_get_property_get_revert() != m_inherits::_get_property_get_revert()) { \ - if (_property_get_revert(p_name, r_ret)) { \ - return true; \ - } \ - } \ - return m_inherits::_property_get_revertv(p_name, r_ret); \ - } \ - _FORCE_INLINE_ void (Object::*_get_notification() const)(int) { \ - return (void (Object::*)(int)) & m_class::_notification; \ - } \ - virtual void _notification_forwardv(int p_notification) override { \ - m_inherits::_notification_forwardv(p_notification); \ - if (m_class::_get_notification() != m_inherits::_get_notification()) { \ - _notification(p_notification); \ - } \ - } \ - virtual void _notification_backwardv(int p_notification) override { \ - if (m_class::_get_notification() != m_inherits::_get_notification()) { \ - _notification(p_notification); \ - } \ - m_inherits::_notification_backwardv(p_notification); \ - } \ - \ + return (bool (Object::*)(const StringName &, Variant &) const) & m_class::_property_get_revert; \ + } \ + virtual bool _property_get_revertv(const StringName &p_name, Variant &r_ret) const override { \ + if (m_class::_get_property_get_revert() != m_inherits::_get_property_get_revert()) { \ + if (_property_get_revert(p_name, r_ret)) { \ + return true; \ + } \ + } \ + return m_inherits::_property_get_revertv(p_name, r_ret); \ + } \ + _FORCE_INLINE_ void (Object::*_get_notification() const)(int) { \ + return (void (Object::*)(int)) & m_class::_notification; \ + } \ + virtual void _notification_forwardv(int p_notification) override { \ + m_inherits::_notification_forwardv(p_notification); \ + if (m_class::_get_notification() != m_inherits::_get_notification()) { \ + _notification(p_notification); \ + } \ + } \ + virtual void _notification_backwardv(int p_notification) override { \ + if (m_class::_get_notification() != m_inherits::_get_notification()) { \ + _notification(p_notification); \ + } \ + m_inherits::_notification_backwardv(p_notification); \ + } \ +\ private: /// `GDSOFTCLASS` provides `Object` functionality, such as being able to use `Object::cast_to()`. /// Use this for `Object` subclasses that are registered in `ObjectDB` (use `GDSOFTCLASS` otherwise). -#define GDCLASS(m_class, m_inherits) \ - GDSOFTCLASS(m_class, m_inherits) \ -private: \ - void operator=(const m_class &p_rval) {} \ - friend class ::ClassDB; \ - \ -public: \ - virtual const GDType &_get_typev() const override { \ - return get_gdtype_static(); \ - } \ - static const GDType &get_gdtype_static() { \ - static GDType *_class_static; \ - if (unlikely(!_class_static)) { \ - assign_type_static(&_class_static, #m_class, &super_type::get_gdtype_static()); \ - } \ - return *_class_static; \ - } \ - static const StringName &get_class_static() { \ - return get_gdtype_static().get_name(); \ - } \ - \ -protected: \ - _FORCE_INLINE_ static void (*_get_bind_methods())() { \ - return &m_class::_bind_methods; \ - } \ - _FORCE_INLINE_ static void (*_get_bind_compatibility_methods())() { \ - return &m_class::_bind_compatibility_methods; \ - } \ - \ -public: \ - static void initialize_class() { \ - static bool initialized = false; \ - if (initialized) { \ - return; \ - } \ - m_inherits::initialize_class(); \ - _add_class_to_classdb(get_gdtype_static(), &super_type::get_gdtype_static()); \ - if (m_class::_get_bind_methods() != m_inherits::_get_bind_methods()) { \ - _bind_methods(); \ - } \ - if (m_class::_get_bind_compatibility_methods() != m_inherits::_get_bind_compatibility_methods()) { \ - _bind_compatibility_methods(); \ - } \ - initialized = true; \ - } \ - \ -protected: \ - virtual void _initialize_classv() override { \ - initialize_class(); \ - } \ - _FORCE_INLINE_ void (Object::*_get_get_property_list() const)(List * p_list) const { \ - return (void (Object::*)(List *) const) & m_class::_get_property_list; \ - } \ - virtual void _get_property_listv(List *p_list, bool p_reversed) const override { \ - if (!p_reversed) { \ - m_inherits::_get_property_listv(p_list, p_reversed); \ - } \ +#define GDCLASS(m_class, m_inherits) \ + GDSOFTCLASS(m_class, m_inherits) \ +private: \ + void operator=(const m_class &p_rval) {} \ + friend class ::ClassDB; \ +\ +public: \ + virtual const GDType &_get_typev() const override { \ + return get_gdtype_static(); \ + } \ + static const GDType &get_gdtype_static() { \ + static GDType *_class_static; \ + if (unlikely(!_class_static)) { \ + assign_type_static(&_class_static, #m_class, &super_type::get_gdtype_static()); \ + } \ + return *_class_static; \ + } \ + static const StringName &get_class_static() { \ + return get_gdtype_static().get_name(); \ + } \ +\ +protected: \ + _FORCE_INLINE_ static void (*_get_bind_methods())() { \ + return &m_class::_bind_methods; \ + } \ + _FORCE_INLINE_ static void (*_get_bind_compatibility_methods())() { \ + return &m_class::_bind_compatibility_methods; \ + } \ +\ +public: \ + static void initialize_class() { \ + static bool initialized = false; \ + if (initialized) { \ + return; \ + } \ + m_inherits::initialize_class(); \ + _add_class_to_classdb(get_gdtype_static(), &super_type::get_gdtype_static()); \ + if (m_class::_get_bind_methods() != m_inherits::_get_bind_methods()) { \ + _bind_methods(); \ + } \ + if (m_class::_get_bind_compatibility_methods() != m_inherits::_get_bind_compatibility_methods()) { \ + _bind_compatibility_methods(); \ + } \ + initialized = true; \ + } \ +\ +protected: \ + virtual void _initialize_classv() override { \ + initialize_class(); \ + } \ + _FORCE_INLINE_ void (Object::*_get_get_property_list() const)(List * p_list) const { \ + return (void (Object::*)(List *) const) & m_class::_get_property_list; \ + } \ + virtual void _get_property_listv(List *p_list, bool p_reversed) const override { \ + if (!p_reversed) { \ + m_inherits::_get_property_listv(p_list, p_reversed); \ + } \ p_list->push_back(PropertyInfo(Variant::NIL, get_class_static(), PROPERTY_HINT_NONE, get_class_static(), PROPERTY_USAGE_CATEGORY)); \ - _get_property_list_from_classdb(#m_class, p_list, true, this); \ - if (m_class::_get_get_property_list() != m_inherits::_get_get_property_list()) { \ - _get_property_list(p_list); \ - } \ - if (p_reversed) { \ - m_inherits::_get_property_listv(p_list, p_reversed); \ - } \ - } \ - \ + _get_property_list_from_classdb(#m_class, p_list, true, this); \ + if (m_class::_get_get_property_list() != m_inherits::_get_get_property_list()) { \ + _get_property_list(p_list); \ + } \ + if (p_reversed) { \ + m_inherits::_get_property_listv(p_list, p_reversed); \ + } \ + } \ +\ private: -#define OBJ_SAVE_TYPE(m_class) \ -public: \ +#define OBJ_SAVE_TYPE(m_class) \ +public: \ virtual String get_save_class() const override { \ - return #m_class; \ - } \ - \ + return #m_class; \ + } \ +\ private: class ClassDB; @@ -1340,12 +1340,12 @@ public: } }; -#define TMPL_EXTRACT_PARAM_OR_FAIL(m_name, m_param, m_retval, m_msg, m_editor) \ - if (unlikely(m_param._is_null_dont_use())) { \ +#define TMPL_EXTRACT_PARAM_OR_FAIL(m_name, m_param, m_retval, m_msg, m_editor) \ + if (unlikely(m_param._is_null_dont_use())) { \ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Required object \"" _STR(m_param) "\" is null.", m_msg, m_editor); \ - return m_retval; \ - } \ - typename std::decay_t::extracted_type m_name = m_param._internal_ptr_dont_use(); \ + return m_retval; \ + } \ + typename std::decay_t::extracted_type m_name = m_param._internal_ptr_dont_use(); \ static_assert(true) // These macros are equivalent to the ERR_FAIL_NULL*() family of macros, only for RequiredParam instead of raw pointers. diff --git a/core/os/memory.h b/core/os/memory.h index f7d9d5c1687..329c9003412 100644 --- a/core/os/memory.h +++ b/core/os/memory.h @@ -168,10 +168,10 @@ void memdelete_allocator(T *p_class) { } #define memdelete_notnull(m_v) \ - { \ - if (m_v) { \ - memdelete(m_v); \ - } \ + { \ + if (m_v) { \ + memdelete(m_v); \ + } \ } #define memnew_arr(m_class, m_count) memnew_arr_template(m_count) diff --git a/core/os/time.cpp b/core/os/time.cpp index e930d9aef07..7a71e8d9610 100644 --- a/core/os/time.cpp +++ b/core/os/time.cpp @@ -79,125 +79,125 @@ static const uint8_t MONTH_DAYS_TABLE[2][12] = { { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } }; -#define UNIX_TIME_TO_HMS \ - uint8_t hour, minute, second; \ - { \ - /* The time of the day (in seconds since start of day). */ \ +#define UNIX_TIME_TO_HMS \ + uint8_t hour, minute, second; \ + { \ + /* The time of the day (in seconds since start of day). */ \ uint32_t day_clock = Math::posmod(p_unix_time_val, SECONDS_PER_DAY); \ - /* On x86 these 4 lines can be optimized to only 2 divisions. */ \ - second = day_clock % 60; \ - day_clock /= 60; \ - minute = day_clock % 60; \ - hour = day_clock / 60; \ + /* On x86 these 4 lines can be optimized to only 2 divisions. */ \ + second = day_clock % 60; \ + day_clock /= 60; \ + minute = day_clock % 60; \ + hour = day_clock / 60; \ } -#define UNIX_TIME_TO_YMD \ - int64_t year; \ - Month month; \ - uint8_t day; \ - /* The day number since Unix epoch (0-index). Days before 1970 are negative. */ \ - int64_t day_number = Math::floor(p_unix_time_val / (double)SECONDS_PER_DAY); \ - { \ - int64_t day_number_copy = day_number; \ - day_number_copy += year_to_days(UNIX_EPOCH_YEAR_AD); \ - year = days_to_year(day_number_copy); \ - day_number_copy -= year_to_days(year); \ - uint8_t month_zero_index = 0; \ - /* After the above, day_number now represents the day of the year (0-index). */ \ +#define UNIX_TIME_TO_YMD \ + int64_t year; \ + Month month; \ + uint8_t day; \ + /* The day number since Unix epoch (0-index). Days before 1970 are negative. */ \ + int64_t day_number = Math::floor(p_unix_time_val / (double)SECONDS_PER_DAY); \ + { \ + int64_t day_number_copy = day_number; \ + day_number_copy += year_to_days(UNIX_EPOCH_YEAR_AD); \ + year = days_to_year(day_number_copy); \ + day_number_copy -= year_to_days(year); \ + uint8_t month_zero_index = 0; \ + /* After the above, day_number now represents the day of the year (0-index). */ \ while (day_number_copy >= MONTH_DAYS_TABLE[IS_LEAP_YEAR(year)][month_zero_index]) { \ - day_number_copy -= MONTH_DAYS_TABLE[IS_LEAP_YEAR(year)][month_zero_index]; \ - month_zero_index++; \ - } \ - /* After the above, day_number now represents the day of the month (0-index). */ \ - month = (Month)(month_zero_index + 1); \ - day = day_number_copy + 1; \ + day_number_copy -= MONTH_DAYS_TABLE[IS_LEAP_YEAR(year)][month_zero_index]; \ + month_zero_index++; \ + } \ + /* After the above, day_number now represents the day of the month (0-index). */ \ + month = (Month)(month_zero_index + 1); \ + day = day_number_copy + 1; \ } -#define VALIDATE_YMDHMS(ret) \ +#define VALIDATE_YMDHMS(ret) \ ERR_FAIL_COND_V_MSG(month == 0, ret, "Invalid month value of: " + itos(month) + ", months are 1-indexed and cannot be 0. See the Time.Month enum for valid values."); \ - ERR_FAIL_COND_V_MSG(month < 0, ret, "Invalid month value of: " + itos(month) + "."); \ - ERR_FAIL_COND_V_MSG(month > 12, ret, "Invalid month value of: " + itos(month) + ". See the Time.Month enum for valid values."); \ - ERR_FAIL_COND_V_MSG(hour > 23, ret, "Invalid hour value of: " + itos(hour) + "."); \ - ERR_FAIL_COND_V_MSG(hour < 0, ret, "Invalid hour value of: " + itos(hour) + "."); \ - ERR_FAIL_COND_V_MSG(minute > 59, ret, "Invalid minute value of: " + itos(minute) + "."); \ - ERR_FAIL_COND_V_MSG(minute < 0, ret, "Invalid minute value of: " + itos(minute) + "."); \ - ERR_FAIL_COND_V_MSG(second > 59, ret, "Invalid second value of: " + itos(second) + " (leap seconds are not supported)."); \ - ERR_FAIL_COND_V_MSG(second < 0, ret, "Invalid second value of: " + itos(second) + "."); \ - ERR_FAIL_COND_V_MSG(day == 0, ret, "Invalid day value of: " + itos(day) + ", days are 1-indexed and cannot be 0."); \ - ERR_FAIL_COND_V_MSG(day < 0, ret, "Invalid day value of: " + itos(day) + "."); \ - /* Do this check after month is tested as valid. */ \ - uint8_t days_in_this_month = MONTH_DAYS_TABLE[IS_LEAP_YEAR(year)][month - 1]; \ + ERR_FAIL_COND_V_MSG(month < 0, ret, "Invalid month value of: " + itos(month) + "."); \ + ERR_FAIL_COND_V_MSG(month > 12, ret, "Invalid month value of: " + itos(month) + ". See the Time.Month enum for valid values."); \ + ERR_FAIL_COND_V_MSG(hour > 23, ret, "Invalid hour value of: " + itos(hour) + "."); \ + ERR_FAIL_COND_V_MSG(hour < 0, ret, "Invalid hour value of: " + itos(hour) + "."); \ + ERR_FAIL_COND_V_MSG(minute > 59, ret, "Invalid minute value of: " + itos(minute) + "."); \ + ERR_FAIL_COND_V_MSG(minute < 0, ret, "Invalid minute value of: " + itos(minute) + "."); \ + ERR_FAIL_COND_V_MSG(second > 59, ret, "Invalid second value of: " + itos(second) + " (leap seconds are not supported)."); \ + ERR_FAIL_COND_V_MSG(second < 0, ret, "Invalid second value of: " + itos(second) + "."); \ + ERR_FAIL_COND_V_MSG(day == 0, ret, "Invalid day value of: " + itos(day) + ", days are 1-indexed and cannot be 0."); \ + ERR_FAIL_COND_V_MSG(day < 0, ret, "Invalid day value of: " + itos(day) + "."); \ + /* Do this check after month is tested as valid. */ \ + uint8_t days_in_this_month = MONTH_DAYS_TABLE[IS_LEAP_YEAR(year)][month - 1]; \ ERR_FAIL_COND_V_MSG(day > days_in_this_month, ret, "Invalid day value of: " + itos(day) + " which is larger than the maximum for this month, " + itos(days_in_this_month) + "."); -#define YMD_TO_DAY_NUMBER \ +#define YMD_TO_DAY_NUMBER \ /* The day number since Unix epoch (0-index). Days before 1970 are negative. */ \ - int64_t day_number = day - 1; \ - /* Add the days in the months to day_number. */ \ - for (int i = 0; i < month - 1; i++) { \ - day_number += MONTH_DAYS_TABLE[IS_LEAP_YEAR(year)][i]; \ - } \ - /* Add the days in the years to day_number. */ \ - day_number += year_to_days(year); \ + int64_t day_number = day - 1; \ + /* Add the days in the months to day_number. */ \ + for (int i = 0; i < month - 1; i++) { \ + day_number += MONTH_DAYS_TABLE[IS_LEAP_YEAR(year)][i]; \ + } \ + /* Add the days in the years to day_number. */ \ + day_number += year_to_days(year); \ day_number -= year_to_days(UNIX_EPOCH_YEAR_AD); -#define PARSE_ISO8601_STRING(ret) \ - int64_t year = UNIX_EPOCH_YEAR_AD; \ - Month month = MONTH_JANUARY; \ - int day = 1; \ - int hour = 0; \ - int minute = 0; \ - int second = 0; \ - { \ - bool has_date = false, has_time = false; \ - String date, time; \ - if (p_datetime.find_char('T') > 0) { \ - has_date = has_time = true; \ - PackedStringArray array = p_datetime.split("T"); \ +#define PARSE_ISO8601_STRING(ret) \ + int64_t year = UNIX_EPOCH_YEAR_AD; \ + Month month = MONTH_JANUARY; \ + int day = 1; \ + int hour = 0; \ + int minute = 0; \ + int second = 0; \ + { \ + bool has_date = false, has_time = false; \ + String date, time; \ + if (p_datetime.find_char('T') > 0) { \ + has_date = has_time = true; \ + PackedStringArray array = p_datetime.split("T"); \ ERR_FAIL_COND_V_MSG(array.size() < 2, ret, "Invalid ISO 8601 date/time string."); \ - date = array[0]; \ - time = array[1]; \ - } else if (p_datetime.find_char(' ') > 0) { \ - has_date = has_time = true; \ - PackedStringArray array = p_datetime.split(" "); \ + date = array[0]; \ + time = array[1]; \ + } else if (p_datetime.find_char(' ') > 0) { \ + has_date = has_time = true; \ + PackedStringArray array = p_datetime.split(" "); \ ERR_FAIL_COND_V_MSG(array.size() < 2, ret, "Invalid ISO 8601 date/time string."); \ - date = array[0]; \ - time = array[1]; \ - } else if (p_datetime.find_char('-', 1) > 0) { \ - has_date = true; \ - date = p_datetime; \ - } else if (p_datetime.find_char(':') > 0) { \ - has_time = true; \ - time = p_datetime; \ - } \ - /* Set the variables from the contents of the string. */ \ - if (has_date) { \ - PackedInt32Array array = date.split_ints("-", false); \ - ERR_FAIL_COND_V_MSG(array.size() < 3, ret, "Invalid ISO 8601 date string."); \ - year = array[0]; \ - month = (Month)array[1]; \ - day = array[2]; \ - /* Handle negative years. */ \ - if (p_datetime.find_char('-') == 0) { \ - year *= -1; \ - } \ - } \ - if (has_time) { \ - PackedInt32Array array = time.split_ints(":", false); \ - ERR_FAIL_COND_V_MSG(array.size() < 3, ret, "Invalid ISO 8601 time string."); \ - hour = array[0]; \ - minute = array[1]; \ - second = array[2]; \ - } \ + date = array[0]; \ + time = array[1]; \ + } else if (p_datetime.find_char('-', 1) > 0) { \ + has_date = true; \ + date = p_datetime; \ + } else if (p_datetime.find_char(':') > 0) { \ + has_time = true; \ + time = p_datetime; \ + } \ + /* Set the variables from the contents of the string. */ \ + if (has_date) { \ + PackedInt32Array array = date.split_ints("-", false); \ + ERR_FAIL_COND_V_MSG(array.size() < 3, ret, "Invalid ISO 8601 date string."); \ + year = array[0]; \ + month = (Month)array[1]; \ + day = array[2]; \ + /* Handle negative years. */ \ + if (p_datetime.find_char('-') == 0) { \ + year *= -1; \ + } \ + } \ + if (has_time) { \ + PackedInt32Array array = time.split_ints(":", false); \ + ERR_FAIL_COND_V_MSG(array.size() < 3, ret, "Invalid ISO 8601 time string."); \ + hour = array[0]; \ + minute = array[1]; \ + second = array[2]; \ + } \ } -#define EXTRACT_FROM_DICTIONARY \ - /* Get all time values from the dictionary. If it doesn't exist, set the */ \ - /* values to the default values for Unix epoch (1970-01-01 00:00:00). */ \ +#define EXTRACT_FROM_DICTIONARY \ + /* Get all time values from the dictionary. If it doesn't exist, set the */ \ + /* values to the default values for Unix epoch (1970-01-01 00:00:00). */ \ int64_t year = p_datetime.has(YEAR_KEY) ? int64_t(p_datetime[YEAR_KEY]) : UNIX_EPOCH_YEAR_AD; \ - Month month = Month((p_datetime.has(MONTH_KEY)) ? int(p_datetime[MONTH_KEY]) : 1); \ - int day = p_datetime.has(DAY_KEY) ? int(p_datetime[DAY_KEY]) : 1; \ - int hour = p_datetime.has(HOUR_KEY) ? int(p_datetime[HOUR_KEY]) : 0; \ - int minute = p_datetime.has(MINUTE_KEY) ? int(p_datetime[MINUTE_KEY]) : 0; \ + Month month = Month((p_datetime.has(MONTH_KEY)) ? int(p_datetime[MONTH_KEY]) : 1); \ + int day = p_datetime.has(DAY_KEY) ? int(p_datetime[DAY_KEY]) : 1; \ + int hour = p_datetime.has(HOUR_KEY) ? int(p_datetime[HOUR_KEY]) : 0; \ + int minute = p_datetime.has(MINUTE_KEY) ? int(p_datetime[MINUTE_KEY]) : 0; \ int second = p_datetime.has(SECOND_KEY) ? int(p_datetime[SECOND_KEY]) : 0; Time *Time::singleton = nullptr; diff --git a/core/profiling/profiling.h b/core/profiling/profiling.h index a18d0c28afd..4928fb8a8d6 100644 --- a/core/profiling/profiling.h +++ b/core/profiling/profiling.h @@ -62,13 +62,13 @@ const SourceLocationData *intern_source_location(const void *p_function_ptr, con #define GodotProfileZoneGroupedFirst(m_group_name, m_zone_name) ZoneNamedN(__godot_tracy_zone_##m_group_name, m_zone_name, true) #define GodotProfileZoneGroupedEndEarly(m_group_name, m_zone_name) __godot_tracy_zone_##m_group_name.~ScopedZone(); #ifndef TRACY_CALLSTACK -#define GodotProfileZoneGrouped(m_group_name, m_zone_name) \ - GodotProfileZoneGroupedEndEarly(m_group_name, m_zone_name); \ +#define GodotProfileZoneGrouped(m_group_name, m_zone_name) \ + GodotProfileZoneGroupedEndEarly(m_group_name, m_zone_name); \ static constexpr tracy::SourceLocationData TracyConcat(__tracy_source_location, TracyLine){ m_zone_name, TracyFunction, TracyFile, (uint32_t)TracyLine, 0 }; \ new (&__godot_tracy_zone_##m_group_name) tracy::ScopedZone(&TracyConcat(__tracy_source_location, TracyLine), true) #else -#define GodotProfileZoneGrouped(m_group_name, m_zone_name) \ - GodotProfileZoneGroupedEndEarly(m_group_name, m_zone_name); \ +#define GodotProfileZoneGrouped(m_group_name, m_zone_name) \ + GodotProfileZoneGroupedEndEarly(m_group_name, m_zone_name); \ static constexpr tracy::SourceLocationData TracyConcat(__tracy_source_location, TracyLine){ m_zone_name, TracyFunction, TracyFile, (uint32_t)TracyLine, 0 }; \ new (&__godot_tracy_zone_##m_group_name) tracy::ScopedZone(&TracyConcat(__tracy_source_location, TracyLine), TRACY_CALLSTACK, true) #endif @@ -80,9 +80,9 @@ const SourceLocationData *intern_source_location(const void *p_function_ptr, con // Memory allocation #ifdef GODOT_PROFILER_TRACK_MEMORY -#define GodotProfileAlloc(m_ptr, m_size) \ +#define GodotProfileAlloc(m_ptr, m_size) \ GODOT_GCC_WARNING_PUSH_AND_IGNORE("-Wmaybe-uninitialized") \ - TracyAlloc(m_ptr, m_size); \ + TracyAlloc(m_ptr, m_size); \ GODOT_GCC_WARNING_POP #define GodotProfileFree(m_ptr) TracyFree(m_ptr) #else @@ -118,11 +118,11 @@ struct PerfettoGroupedEventEnder { #define GodotProfileFrameMark // TODO #define GodotProfileZone(m_zone_name) TRACE_EVENT("godot", m_zone_name); #define GodotProfileZoneGroupedFirst(m_group_name, m_zone_name) \ - TRACE_EVENT_BEGIN("godot", m_zone_name); \ + TRACE_EVENT_BEGIN("godot", m_zone_name); \ PerfettoGroupedEventEnder __godot_perfetto_zone_##m_group_name #define GodotProfileZoneGroupedEndEarly(m_group_name, m_zone_name) __godot_perfetto_zone_##m_group_name.~PerfettoGroupedEventEnder() #define GodotProfileZoneGrouped(m_group_name, m_zone_name) \ - __godot_perfetto_zone_##m_group_name._end_now(); \ + __godot_perfetto_zone_##m_group_name._end_now(); \ TRACE_EVENT_BEGIN("godot", m_zone_name); #define GodotProfileZoneScript(m_ptr, m_file, m_function, m_name, m_line) @@ -163,22 +163,22 @@ private: #define GodotProfileFrameMark \ os_signpost_event_emit(apple::instruments::LOG, OS_SIGNPOST_ID_EXCLUSIVE, "Frame"); -#define GodotProfileZoneGroupedFirst(m_group_name, m_zone_name) \ - os_signpost_interval_begin(apple::instruments::LOG_TRACING, OS_SIGNPOST_ID_EXCLUSIVE, m_zone_name); \ - apple::instruments::DeferFunc _GD_VARNAME_CONCAT_(defer__fn, _, m_group_name) = []() { \ +#define GodotProfileZoneGroupedFirst(m_group_name, m_zone_name) \ + os_signpost_interval_begin(apple::instruments::LOG_TRACING, OS_SIGNPOST_ID_EXCLUSIVE, m_zone_name); \ + apple::instruments::DeferFunc _GD_VARNAME_CONCAT_(defer__fn, _, m_group_name) = []() { \ os_signpost_interval_end(apple::instruments::LOG_TRACING, OS_SIGNPOST_ID_EXCLUSIVE, m_zone_name); \ - }; \ + }; \ apple::instruments::Defer _GD_VARNAME_CONCAT_(__instruments_defer_zone_end__, _, m_group_name)(_GD_VARNAME_CONCAT_(defer__fn, _, m_group_name)); #define GodotProfileZoneGroupedEndEarly(m_group_name, m_zone_name) \ _GD_VARNAME_CONCAT_(__instruments_defer_zone_end__, _, m_group_name).~Defer(); -#define GodotProfileZoneGrouped(m_group_name, m_zone_name) \ - GodotProfileZoneGroupedEndEarly(m_group_name, m_zone_name); \ - os_signpost_interval_begin(apple::instruments::LOG_TRACING, OS_SIGNPOST_ID_EXCLUSIVE, m_zone_name); \ - _GD_VARNAME_CONCAT_(defer__fn, _, m_group_name) = []() { \ +#define GodotProfileZoneGrouped(m_group_name, m_zone_name) \ + GodotProfileZoneGroupedEndEarly(m_group_name, m_zone_name); \ + os_signpost_interval_begin(apple::instruments::LOG_TRACING, OS_SIGNPOST_ID_EXCLUSIVE, m_zone_name); \ + _GD_VARNAME_CONCAT_(defer__fn, _, m_group_name) = []() { \ os_signpost_interval_end(apple::instruments::LOG_TRACING, OS_SIGNPOST_ID_EXCLUSIVE, m_zone_name); \ - }; \ + }; \ new (&_GD_VARNAME_CONCAT_(__instruments_defer_zone_end__, _, m_group_name)) apple::instruments::Defer(_GD_VARNAME_CONCAT_(defer__fn, _, m_group_name)); #define GodotProfileZone(m_zone_name) \ diff --git a/core/string/char_utils.h b/core/string/char_utils.h index db5f7a9ebfd..df52ac1f757 100644 --- a/core/string/char_utils.h +++ b/core/string/char_utils.h @@ -37,23 +37,23 @@ static constexpr char hex_char_table_upper[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; static constexpr char hex_char_table_lower[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; -#define BSEARCH_CHAR_RANGE(m_array) \ - int low = 0; \ - int high = std_size(m_array) - 1; \ - int middle = (low + high) / 2; \ - \ - while (low <= high) { \ - if (p_char < m_array[middle].start) { \ - high = middle - 1; \ +#define BSEARCH_CHAR_RANGE(m_array) \ + int low = 0; \ + int high = std_size(m_array) - 1; \ + int middle = (low + high) / 2; \ +\ + while (low <= high) { \ + if (p_char < m_array[middle].start) { \ + high = middle - 1; \ } else if (p_char > m_array[middle].end) { \ - low = middle + 1; \ - } else { \ - return true; \ - } \ - \ - middle = (low + high) / 2; \ - } \ - \ + low = middle + 1; \ + } else { \ + return true; \ + } \ +\ + middle = (low + high) / 2; \ + } \ +\ return false constexpr bool is_unicode_identifier_start(char32_t p_char) { diff --git a/core/string/print_string.h b/core/string/print_string.h index 43b358a06b4..673e2d70e75 100644 --- a/core/string/print_string.h +++ b/core/string/print_string.h @@ -58,11 +58,11 @@ extern void print_error(const String &p_string); extern bool is_print_verbose_enabled(); // This version avoids processing the text to be printed until it actually has to be printed, saving some CPU usage. -#define print_verbose(m_text) \ - { \ +#define print_verbose(m_text) \ + { \ if (is_print_verbose_enabled()) { \ - print_line(m_text); \ - } \ + print_line(m_text); \ + } \ } template diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp index cf614b09143..2772ddf055c 100644 --- a/core/string/ustring.cpp +++ b/core/string/ustring.cpp @@ -1645,16 +1645,16 @@ String String::hex_encode_buffer(const uint8_t *p_buffer, int p_len) { Vector String::hex_decode() const { ERR_FAIL_COND_V_MSG(length() % 2 != 0, Vector(), "Hexadecimal string of uneven length."); -#define HEX_TO_BYTE(m_output, m_index) \ - uint8_t m_output; \ - c = operator[](m_index); \ - if (is_digit(c)) { \ - m_output = c - '0'; \ - } else if (c >= 'a' && c <= 'f') { \ - m_output = c - 'a' + 10; \ - } else if (c >= 'A' && c <= 'F') { \ - m_output = c - 'A' + 10; \ - } else { \ +#define HEX_TO_BYTE(m_output, m_index) \ + uint8_t m_output; \ + c = operator[](m_index); \ + if (is_digit(c)) { \ + m_output = c - '0'; \ + } else if (c >= 'a' && c <= 'f') { \ + m_output = c - 'a' + 10; \ + } else if (c >= 'A' && c <= 'F') { \ + m_output = c - 'A' + 10; \ + } else { \ ERR_FAIL_V_MSG(Vector(), "Invalid hexadecimal character \"" + chr(c) + "\" at index " + m_index + "."); \ } diff --git a/core/templates/pass_func.h b/core/templates/pass_func.h index 118011d5119..091cb186642 100644 --- a/core/templates/pass_func.h +++ b/core/templates/pass_func.h @@ -30,132 +30,132 @@ #pragma once -#define PASS0R(m_r, m_name) \ - m_r m_name() { \ +#define PASS0R(m_r, m_name) \ + m_r m_name() { \ return PASSBASE->m_name(); \ } -#define PASS0RC(m_r, m_name) \ - m_r m_name() const { \ +#define PASS0RC(m_r, m_name) \ + m_r m_name() const { \ return PASSBASE->m_name(); \ } -#define PASS1R(m_r, m_name, m_type1) \ - m_r m_name(m_type1 arg1) { \ +#define PASS1R(m_r, m_name, m_type1) \ + m_r m_name(m_type1 arg1) { \ return PASSBASE->m_name(arg1); \ } -#define PASS1RC(m_r, m_name, m_type1) \ - m_r m_name(m_type1 arg1) const { \ +#define PASS1RC(m_r, m_name, m_type1) \ + m_r m_name(m_type1 arg1) const { \ return PASSBASE->m_name(arg1); \ } #define PASS2R(m_r, m_name, m_type1, m_type2) \ - m_r m_name(m_type1 arg1, m_type2 arg2) { \ - return PASSBASE->m_name(arg1, arg2); \ + m_r m_name(m_type1 arg1, m_type2 arg2) { \ + return PASSBASE->m_name(arg1, arg2); \ } -#define PASS2RC(m_r, m_name, m_type1, m_type2) \ +#define PASS2RC(m_r, m_name, m_type1, m_type2) \ m_r m_name(m_type1 arg1, m_type2 arg2) const { \ - return PASSBASE->m_name(arg1, arg2); \ + return PASSBASE->m_name(arg1, arg2); \ } -#define PASS3R(m_r, m_name, m_type1, m_type2, m_type3) \ +#define PASS3R(m_r, m_name, m_type1, m_type2, m_type3) \ m_r m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3) { \ - return PASSBASE->m_name(arg1, arg2, arg3); \ + return PASSBASE->m_name(arg1, arg2, arg3); \ } -#define PASS3RC(m_r, m_name, m_type1, m_type2, m_type3) \ +#define PASS3RC(m_r, m_name, m_type1, m_type2, m_type3) \ m_r m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3) const { \ - return PASSBASE->m_name(arg1, arg2, arg3); \ + return PASSBASE->m_name(arg1, arg2, arg3); \ } -#define PASS4R(m_r, m_name, m_type1, m_type2, m_type3, m_type4) \ +#define PASS4R(m_r, m_name, m_type1, m_type2, m_type3, m_type4) \ m_r m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4) { \ - return PASSBASE->m_name(arg1, arg2, arg3, arg4); \ + return PASSBASE->m_name(arg1, arg2, arg3, arg4); \ } -#define PASS4RC(m_r, m_name, m_type1, m_type2, m_type3, m_type4) \ +#define PASS4RC(m_r, m_name, m_type1, m_type2, m_type3, m_type4) \ m_r m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4) const { \ - return PASSBASE->m_name(arg1, arg2, arg3, arg4); \ + return PASSBASE->m_name(arg1, arg2, arg3, arg4); \ } -#define PASS5R(m_r, m_name, m_type1, m_type2, m_type3, m_type4, m_type5) \ +#define PASS5R(m_r, m_name, m_type1, m_type2, m_type3, m_type4, m_type5) \ m_r m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5) { \ - return PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5); \ + return PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5); \ } -#define PASS5RC(m_r, m_name, m_type1, m_type2, m_type3, m_type4, m_type5) \ +#define PASS5RC(m_r, m_name, m_type1, m_type2, m_type3, m_type4, m_type5) \ m_r m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5) const { \ - return PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5); \ + return PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5); \ } -#define PASS6R(m_r, m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6) \ +#define PASS6R(m_r, m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6) \ m_r m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6) { \ - return PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6); \ + return PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6); \ } -#define PASS6RC(m_r, m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6) \ +#define PASS6RC(m_r, m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6) \ m_r m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6) const { \ - return PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6); \ + return PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6); \ } -#define PASS0(m_name) \ - void m_name() { \ +#define PASS0(m_name) \ + void m_name() { \ PASSBASE->m_name(); \ } -#define PASS1(m_name, m_type1) \ +#define PASS1(m_name, m_type1) \ void m_name(m_type1 arg1) { \ PASSBASE->m_name(arg1); \ } -#define PASS1C(m_name, m_type1) \ +#define PASS1C(m_name, m_type1) \ void m_name(m_type1 arg1) const { \ - PASSBASE->m_name(arg1); \ + PASSBASE->m_name(arg1); \ } -#define PASS2(m_name, m_type1, m_type2) \ +#define PASS2(m_name, m_type1, m_type2) \ void m_name(m_type1 arg1, m_type2 arg2) { \ - PASSBASE->m_name(arg1, arg2); \ + PASSBASE->m_name(arg1, arg2); \ } -#define PASS2C(m_name, m_type1, m_type2) \ +#define PASS2C(m_name, m_type1, m_type2) \ void m_name(m_type1 arg1, m_type2 arg2) const { \ - PASSBASE->m_name(arg1, arg2); \ + PASSBASE->m_name(arg1, arg2); \ } -#define PASS3(m_name, m_type1, m_type2, m_type3) \ +#define PASS3(m_name, m_type1, m_type2, m_type3) \ void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3) { \ - PASSBASE->m_name(arg1, arg2, arg3); \ + PASSBASE->m_name(arg1, arg2, arg3); \ } -#define PASS4(m_name, m_type1, m_type2, m_type3, m_type4) \ +#define PASS4(m_name, m_type1, m_type2, m_type3, m_type4) \ void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4) { \ - PASSBASE->m_name(arg1, arg2, arg3, arg4); \ + PASSBASE->m_name(arg1, arg2, arg3, arg4); \ } -#define PASS5(m_name, m_type1, m_type2, m_type3, m_type4, m_type5) \ +#define PASS5(m_name, m_type1, m_type2, m_type3, m_type4, m_type5) \ void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5) { \ - PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5); \ + PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5); \ } -#define PASS6(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6) \ +#define PASS6(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6) \ void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6) { \ - PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6); \ + PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6); \ } -#define PASS7(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7) \ +#define PASS7(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7) \ void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7) { \ - PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7); \ + PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7); \ } -#define PASS8(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7, m_type8) \ +#define PASS8(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7, m_type8) \ void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7, m_type8 arg8) { \ - PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); \ + PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); \ } -#define PASS9(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7, m_type8, m_type9) \ +#define PASS9(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7, m_type8, m_type9) \ void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7, m_type8 arg8, m_type9 arg9) { \ - PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); \ + PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); \ } -#define PASS10(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7, m_type8, m_type9, m_type10) \ +#define PASS10(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7, m_type8, m_type9, m_type10) \ void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7, m_type8 arg8, m_type9 arg9, m_type10 arg10) { \ - PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); \ + PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); \ } -#define PASS11(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7, m_type8, m_type9, m_type10, m_type11) \ +#define PASS11(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7, m_type8, m_type9, m_type10, m_type11) \ void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7, m_type8 arg8, m_type9 arg9, m_type10 arg10, m_type11 arg11) { \ - PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11); \ + PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11); \ } -#define PASS12(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7, m_type8, m_type9, m_type10, m_type11, m_type12) \ +#define PASS12(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7, m_type8, m_type9, m_type10, m_type11, m_type12) \ void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7, m_type8 arg8, m_type9 arg9, m_type10 arg10, m_type11 arg11, m_type12 arg12) { \ - PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12); \ + PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12); \ } -#define PASS13(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7, m_type8, m_type9, m_type10, m_type11, m_type12, m_type13) \ +#define PASS13(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7, m_type8, m_type9, m_type10, m_type11, m_type12, m_type13) \ void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7, m_type8 arg8, m_type9 arg9, m_type10 arg10, m_type11 arg11, m_type12 arg12, m_type13 arg13) { \ - PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13); \ + PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13); \ } -#define PASS14(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7, m_type8, m_type9, m_type10, m_type11, m_type12, m_type13, m_type14) \ +#define PASS14(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7, m_type8, m_type9, m_type10, m_type11, m_type12, m_type13, m_type14) \ void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7, m_type8 arg8, m_type9 arg9, m_type10 arg10, m_type11 arg11, m_type12 arg12, m_type13 arg13, m_type14 arg14) { \ - PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14); \ + PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14); \ } -#define PASS15(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7, m_type8, m_type9, m_type10, m_type11, m_type12, m_type13, m_type14, m_type15) \ +#define PASS15(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7, m_type8, m_type9, m_type10, m_type11, m_type12, m_type13, m_type14, m_type15) \ void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7, m_type8 arg8, m_type9 arg9, m_type10 arg10, m_type11 arg11, m_type12 arg12, m_type13 arg13, m_type14 arg14, m_type15 arg15) { \ - PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15); \ + PASSBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15); \ } diff --git a/core/templates/safe_refcount.h b/core/templates/safe_refcount.h index 4173f756b46..df243409003 100644 --- a/core/templates/safe_refcount.h +++ b/core/templates/safe_refcount.h @@ -50,11 +50,11 @@ // even with threads that are already running. // These are used in very specific areas of the engine where it's critical that these guarantees are held -#define SAFE_NUMERIC_TYPE_PUN_GUARANTEES(m_type) \ - static_assert(sizeof(SafeNumeric) == sizeof(m_type)); \ +#define SAFE_NUMERIC_TYPE_PUN_GUARANTEES(m_type) \ + static_assert(sizeof(SafeNumeric) == sizeof(m_type)); \ static_assert(alignof(SafeNumeric) == alignof(m_type)); \ static_assert(std::is_trivially_destructible_v>); -#define SAFE_FLAG_TYPE_PUN_GUARANTEES \ +#define SAFE_FLAG_TYPE_PUN_GUARANTEES \ static_assert(sizeof(SafeFlag) == sizeof(bool)); \ static_assert(alignof(SafeFlag) == alignof(bool)); diff --git a/core/templates/sort_array.h b/core/templates/sort_array.h index 9bfee2991cc..8ccc96c1cb1 100644 --- a/core/templates/sort_array.h +++ b/core/templates/sort_array.h @@ -33,10 +33,10 @@ #include "core/error/error_macros.h" #include "core/typedefs.h" -#define ERR_BAD_COMPARE(cond) \ - if (unlikely(cond)) { \ +#define ERR_BAD_COMPARE(cond) \ + if (unlikely(cond)) { \ ERR_PRINT("bad comparison function; sorting will be broken"); \ - break; \ + break; \ } #ifdef DEBUG_ENABLED diff --git a/core/typedefs.h b/core/typedefs.h index 0928f8aaff0..c3264861e88 100644 --- a/core/typedefs.h +++ b/core/typedefs.h @@ -461,7 +461,7 @@ constexpr bool is_fully_defined_v = is_fully_defined::value; /// This can be used to reduce include coupling and keep compile times low. /// The check must be made at the top of the corresponding .cpp file of a header. #define STATIC_ASSERT_INCOMPLETE_TYPE(m_keyword, m_type) \ - m_keyword m_type; \ + m_keyword m_type; \ static_assert(!is_fully_defined_v, #m_type " was unexpectedly fully defined. Please check the include hierarchy of '" __FILE__ "' and remove includes that resolve the " #m_keyword "."); #else #define STATIC_ASSERT_INCOMPLETE_TYPE(m_keyword, m_type) diff --git a/core/variant/native_ptr.h b/core/variant/native_ptr.h index a0715e28cd9..70f92e78e7d 100644 --- a/core/variant/native_ptr.h +++ b/core/variant/native_ptr.h @@ -53,70 +53,70 @@ struct GDExtensionPtr { operator Variant() const { return uint64_t(data); } }; -#define GDVIRTUAL_NATIVE_PTR(m_type) \ - template <> \ - struct GDExtensionConstPtr { \ - const m_type *data = nullptr; \ - GDExtensionConstPtr() {} \ - GDExtensionConstPtr(const m_type *p_assign) { \ - data = p_assign; \ - } \ - static const char *get_name() { \ - return "const " #m_type; \ - } \ - operator const m_type *() const { \ - return data; \ - } \ - operator Variant() const { \ - return uint64_t(data); \ - } \ - }; \ - template <> \ - struct VariantCaster> { \ - static _FORCE_INLINE_ GDExtensionConstPtr cast(const Variant &p_variant) { \ - return GDExtensionConstPtr((const m_type *)p_variant.operator uint64_t()); \ - } \ - }; \ - template <> \ - struct VariantInternalAccessor> { \ - static _FORCE_INLINE_ const GDExtensionConstPtr &get(const Variant *v) { \ +#define GDVIRTUAL_NATIVE_PTR(m_type) \ + template <> \ + struct GDExtensionConstPtr { \ + const m_type *data = nullptr; \ + GDExtensionConstPtr() {} \ + GDExtensionConstPtr(const m_type *p_assign) { \ + data = p_assign; \ + } \ + static const char *get_name() { \ + return "const " #m_type; \ + } \ + operator const m_type *() const { \ + return data; \ + } \ + operator Variant() const { \ + return uint64_t(data); \ + } \ + }; \ + template <> \ + struct VariantCaster> { \ + static _FORCE_INLINE_ GDExtensionConstPtr cast(const Variant &p_variant) { \ + return GDExtensionConstPtr((const m_type *)p_variant.operator uint64_t()); \ + } \ + }; \ + template <> \ + struct VariantInternalAccessor> { \ + static _FORCE_INLINE_ const GDExtensionConstPtr &get(const Variant *v) { \ return *reinterpret_cast *>(VariantInternal::get_int(v)); \ - } \ - static _FORCE_INLINE_ void set(Variant *v, const GDExtensionConstPtr &p_value) { \ - *VariantInternal::get_int(v) = uint64_t(p_value.data); \ - } \ - }; \ - template <> \ - struct GDExtensionPtr { \ - m_type *data = nullptr; \ - GDExtensionPtr() {} \ - GDExtensionPtr(m_type *p_assign) { \ - data = p_assign; \ - } \ - static const char *get_name() { \ - return #m_type; \ - } \ - operator m_type *() const { \ - return data; \ - } \ - operator Variant() const { \ - return uint64_t(data); \ - } \ - }; \ - template <> \ - struct VariantCaster> { \ - static _FORCE_INLINE_ GDExtensionPtr cast(const Variant &p_variant) { \ - return GDExtensionPtr((m_type *)p_variant.operator uint64_t()); \ - } \ - }; \ - template <> \ - struct VariantInternalAccessor> { \ - static _FORCE_INLINE_ const GDExtensionPtr &get(const Variant *v) { \ - return *reinterpret_cast *>(VariantInternal::get_int(v)); \ - } \ - static _FORCE_INLINE_ void set(Variant *v, const GDExtensionPtr &p_value) { \ - *VariantInternal::get_int(v) = uint64_t(p_value.data); \ - } \ + } \ + static _FORCE_INLINE_ void set(Variant *v, const GDExtensionConstPtr &p_value) { \ + *VariantInternal::get_int(v) = uint64_t(p_value.data); \ + } \ + }; \ + template <> \ + struct GDExtensionPtr { \ + m_type *data = nullptr; \ + GDExtensionPtr() {} \ + GDExtensionPtr(m_type *p_assign) { \ + data = p_assign; \ + } \ + static const char *get_name() { \ + return #m_type; \ + } \ + operator m_type *() const { \ + return data; \ + } \ + operator Variant() const { \ + return uint64_t(data); \ + } \ + }; \ + template <> \ + struct VariantCaster> { \ + static _FORCE_INLINE_ GDExtensionPtr cast(const Variant &p_variant) { \ + return GDExtensionPtr((m_type *)p_variant.operator uint64_t()); \ + } \ + }; \ + template <> \ + struct VariantInternalAccessor> { \ + static _FORCE_INLINE_ const GDExtensionPtr &get(const Variant *v) { \ + return *reinterpret_cast *>(VariantInternal::get_int(v)); \ + } \ + static _FORCE_INLINE_ void set(Variant *v, const GDExtensionPtr &p_value) { \ + *VariantInternal::get_int(v) = uint64_t(p_value.data); \ + } \ }; template diff --git a/core/variant/type_info.h b/core/variant/type_info.h index f137ee23ce5..08ba739acb2 100644 --- a/core/variant/type_info.h +++ b/core/variant/type_info.h @@ -67,24 +67,24 @@ struct GetTypeInfo; template struct GetTypeInfo>>> : GetTypeInfo> {}; -#define MAKE_TYPE_INFO(m_type, m_var_type) \ - template <> \ - struct GetTypeInfo { \ - static const Variant::Type VARIANT_TYPE = m_var_type; \ +#define MAKE_TYPE_INFO(m_type, m_var_type) \ + template <> \ + struct GetTypeInfo { \ + static const Variant::Type VARIANT_TYPE = m_var_type; \ static const GodotTypeInfo::Metadata METADATA = GodotTypeInfo::METADATA_NONE; \ - static inline PropertyInfo get_class_info() { \ - return PropertyInfo(VARIANT_TYPE, String()); \ - } \ + static inline PropertyInfo get_class_info() { \ + return PropertyInfo(VARIANT_TYPE, String()); \ + } \ }; -#define MAKE_TYPE_INFO_WITH_META(m_type, m_var_type, m_metadata) \ - template <> \ - struct GetTypeInfo { \ - static const Variant::Type VARIANT_TYPE = m_var_type; \ +#define MAKE_TYPE_INFO_WITH_META(m_type, m_var_type, m_metadata) \ + template <> \ + struct GetTypeInfo { \ + static const Variant::Type VARIANT_TYPE = m_var_type; \ static const GodotTypeInfo::Metadata METADATA = m_metadata; \ - static inline PropertyInfo get_class_info() { \ - return PropertyInfo(VARIANT_TYPE, String()); \ - } \ + static inline PropertyInfo get_class_info() { \ + return PropertyInfo(VARIANT_TYPE, String()); \ + } \ }; MAKE_TYPE_INFO(bool, Variant::BOOL) @@ -158,14 +158,14 @@ struct GetTypeInfo { } }; -#define MAKE_TEMPLATE_TYPE_INFO(m_template, m_type, m_var_type) \ - template <> \ - struct GetTypeInfo> { \ - static const Variant::Type VARIANT_TYPE = m_var_type; \ +#define MAKE_TEMPLATE_TYPE_INFO(m_template, m_type, m_var_type) \ + template <> \ + struct GetTypeInfo> { \ + static const Variant::Type VARIANT_TYPE = m_var_type; \ static const GodotTypeInfo::Metadata METADATA = GodotTypeInfo::METADATA_NONE; \ - static inline PropertyInfo get_class_info() { \ - return PropertyInfo(VARIANT_TYPE, String()); \ - } \ + static inline PropertyInfo get_class_info() { \ + return PropertyInfo(VARIANT_TYPE, String()); \ + } \ }; MAKE_TEMPLATE_TYPE_INFO(Vector, Variant, Variant::ARRAY) @@ -234,15 +234,15 @@ inline String enum_qualified_name_to_class_info_name(const String &p_qualified_n } // namespace Internal } // namespace GodotTypeInfo -#define MAKE_ENUM_TYPE_INFO(m_enum) \ - template <> \ - struct GetTypeInfo { \ - static const Variant::Type VARIANT_TYPE = Variant::INT; \ - static const GodotTypeInfo::Metadata METADATA = GodotTypeInfo::METADATA_NONE; \ - static inline PropertyInfo get_class_info() { \ +#define MAKE_ENUM_TYPE_INFO(m_enum) \ + template <> \ + struct GetTypeInfo { \ + static const Variant::Type VARIANT_TYPE = Variant::INT; \ + static const GodotTypeInfo::Metadata METADATA = GodotTypeInfo::METADATA_NONE; \ + static inline PropertyInfo get_class_info() { \ return PropertyInfo(Variant::INT, String(), PROPERTY_HINT_NONE, String(), PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_CLASS_IS_ENUM, \ - GodotTypeInfo::Internal::enum_qualified_name_to_class_info_name(String(#m_enum))); \ - } \ + GodotTypeInfo::Internal::enum_qualified_name_to_class_info_name(String(#m_enum))); \ + } \ }; template @@ -250,24 +250,24 @@ inline StringName __constant_get_enum_name(T param) { return GetTypeInfo::get_class_info().class_name; } -#define MAKE_BITFIELD_TYPE_INFO(m_enum) \ - template <> \ - struct GetTypeInfo { \ - static const Variant::Type VARIANT_TYPE = Variant::INT; \ - static const GodotTypeInfo::Metadata METADATA = GodotTypeInfo::METADATA_NONE; \ - static inline PropertyInfo get_class_info() { \ +#define MAKE_BITFIELD_TYPE_INFO(m_enum) \ + template <> \ + struct GetTypeInfo { \ + static const Variant::Type VARIANT_TYPE = Variant::INT; \ + static const GodotTypeInfo::Metadata METADATA = GodotTypeInfo::METADATA_NONE; \ + static inline PropertyInfo get_class_info() { \ return PropertyInfo(Variant::INT, String(), PROPERTY_HINT_NONE, String(), PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_CLASS_IS_BITFIELD, \ - GodotTypeInfo::Internal::enum_qualified_name_to_class_info_name(String(#m_enum))); \ - } \ - }; \ - template <> \ - struct GetTypeInfo> { \ - static const Variant::Type VARIANT_TYPE = Variant::INT; \ - static const GodotTypeInfo::Metadata METADATA = GodotTypeInfo::METADATA_NONE; \ - static inline PropertyInfo get_class_info() { \ + GodotTypeInfo::Internal::enum_qualified_name_to_class_info_name(String(#m_enum))); \ + } \ + }; \ + template <> \ + struct GetTypeInfo> { \ + static const Variant::Type VARIANT_TYPE = Variant::INT; \ + static const GodotTypeInfo::Metadata METADATA = GodotTypeInfo::METADATA_NONE; \ + static inline PropertyInfo get_class_info() { \ return PropertyInfo(Variant::INT, String(), PROPERTY_HINT_NONE, String(), PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_CLASS_IS_BITFIELD, \ - GodotTypeInfo::Internal::enum_qualified_name_to_class_info_name(String(#m_enum))); \ - } \ + GodotTypeInfo::Internal::enum_qualified_name_to_class_info_name(String(#m_enum))); \ + } \ }; template diff --git a/core/variant/variant.cpp b/core/variant/variant.cpp index a42666150a6..524dbf47087 100644 --- a/core/variant/variant.cpp +++ b/core/variant/variant.cpp @@ -3155,18 +3155,18 @@ uint32_t Variant::recursive_hash(int recursion_count) const { #define hash_compare_packed_array(p_lhs, p_rhs, p_type, p_compare_func) \ const Vector &l = PackedArrayRef::get_array(p_lhs); \ const Vector &r = PackedArrayRef::get_array(p_rhs); \ - \ - if (l.size() != r.size()) \ - return false; \ - \ - const p_type *lr = l.ptr(); \ - const p_type *rr = r.ptr(); \ - \ - for (int i = 0; i < l.size(); ++i) { \ - if (!p_compare_func((lr[i]), (rr[i]))) \ - return false; \ - } \ - \ +\ + if (l.size() != r.size()) \ + return false; \ +\ + const p_type *lr = l.ptr(); \ + const p_type *rr = r.ptr(); \ +\ + for (int i = 0; i < l.size(); ++i) { \ + if (!p_compare_func((lr[i]), (rr[i]))) \ + return false; \ + } \ +\ return true bool Variant::hash_compare(const Variant &p_variant, int recursion_count, bool semantic_comparison) const { diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp index b4d9e8c36f3..e46d14558fa 100644 --- a/core/variant/variant_call.cpp +++ b/core/variant/variant_call.cpp @@ -369,84 +369,84 @@ static _FORCE_INLINE_ Variant::Type vc_get_base_type(void (T::*method)(P...) con return GetTypeInfo::VARIANT_TYPE; } -#define METHOD_CLASS(m_class, m_exposed_name, m_method_name, m_method_ptr) \ - struct Method_##m_class##_##m_method_name { \ +#define METHOD_CLASS(m_class, m_exposed_name, m_method_name, m_method_ptr) \ + struct Method_##m_class##_##m_method_name { \ static void call(Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector &p_defvals, Callable::CallError &r_error) { \ - vc_method_call(m_method_ptr, base, p_args, p_argcount, r_ret, p_defvals, r_error); \ - } \ - static void validated_call(Variant *base, const Variant **p_args, int p_argcount, Variant *r_ret) { \ - vc_validated_call(m_method_ptr, base, p_args, r_ret); \ - } \ - static void ptrcall(void *p_base, const void **p_args, void *r_ret, int p_argcount) { \ - vc_ptrcall(m_method_ptr, p_base, p_args, r_ret); \ - } \ - static int get_argument_count() { \ - return vc_get_argument_count(m_method_ptr); \ - } \ - static Variant::Type get_argument_type(int p_arg) { \ - return vc_get_argument_type(m_method_ptr, p_arg); \ - } \ - static Variant::Type get_return_type() { \ - return vc_get_return_type(m_method_ptr); \ - } \ - static bool has_return_type() { \ - return vc_has_return_type(m_method_ptr); \ - } \ - static bool is_const() { \ - return vc_is_const(m_method_ptr); \ - } \ - static bool is_static() { \ - return false; \ - } \ - static bool is_vararg() { \ - return false; \ - } \ - static Variant::Type get_base_type() { \ - return vc_get_base_type(m_method_ptr); \ - } \ - static StringName get_name() { \ - return #m_exposed_name; \ - } \ + vc_method_call(m_method_ptr, base, p_args, p_argcount, r_ret, p_defvals, r_error); \ + } \ + static void validated_call(Variant *base, const Variant **p_args, int p_argcount, Variant *r_ret) { \ + vc_validated_call(m_method_ptr, base, p_args, r_ret); \ + } \ + static void ptrcall(void *p_base, const void **p_args, void *r_ret, int p_argcount) { \ + vc_ptrcall(m_method_ptr, p_base, p_args, r_ret); \ + } \ + static int get_argument_count() { \ + return vc_get_argument_count(m_method_ptr); \ + } \ + static Variant::Type get_argument_type(int p_arg) { \ + return vc_get_argument_type(m_method_ptr, p_arg); \ + } \ + static Variant::Type get_return_type() { \ + return vc_get_return_type(m_method_ptr); \ + } \ + static bool has_return_type() { \ + return vc_has_return_type(m_method_ptr); \ + } \ + static bool is_const() { \ + return vc_is_const(m_method_ptr); \ + } \ + static bool is_static() { \ + return false; \ + } \ + static bool is_vararg() { \ + return false; \ + } \ + static Variant::Type get_base_type() { \ + return vc_get_base_type(m_method_ptr); \ + } \ + static StringName get_name() { \ + return #m_exposed_name; \ + } \ }; -#define CONVERT_METHOD_CLASS(m_class, m_exposed_name, m_method_name, m_method_ptr) \ - struct Method_##m_class##_##m_method_name { \ +#define CONVERT_METHOD_CLASS(m_class, m_exposed_name, m_method_name, m_method_ptr) \ + struct Method_##m_class##_##m_method_name { \ static void call(Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector &p_defvals, Callable::CallError &r_error) { \ - vc_convert_method_call(m_method_ptr, base, p_args, p_argcount, r_ret, p_defvals, r_error); \ - } \ - static void validated_call(Variant *base, const Variant **p_args, int p_argcount, Variant *r_ret) { \ - vc_convert_validated_call(m_method_ptr, base, p_args, r_ret); \ - } \ - static void ptrcall(void *p_base, const void **p_args, void *r_ret, int p_argcount) { \ - vc_convert_ptrcall(m_method_ptr, p_base, p_args, r_ret); \ - } \ - static int get_argument_count() { \ - return vc_get_argument_count(m_method_ptr); \ - } \ - static Variant::Type get_argument_type(int p_arg) { \ - return vc_get_argument_type(m_method_ptr, p_arg); \ - } \ - static Variant::Type get_return_type() { \ - return vc_get_return_type(m_method_ptr); \ - } \ - static bool has_return_type() { \ - return vc_has_return_type(m_method_ptr); \ - } \ - static bool is_const() { \ - return vc_is_const(m_method_ptr); \ - } \ - static bool is_static() { \ - return false; \ - } \ - static bool is_vararg() { \ - return false; \ - } \ - static Variant::Type get_base_type() { \ - return GetTypeInfo::VARIANT_TYPE; \ - } \ - static StringName get_name() { \ - return #m_exposed_name; \ - } \ + vc_convert_method_call(m_method_ptr, base, p_args, p_argcount, r_ret, p_defvals, r_error); \ + } \ + static void validated_call(Variant *base, const Variant **p_args, int p_argcount, Variant *r_ret) { \ + vc_convert_validated_call(m_method_ptr, base, p_args, r_ret); \ + } \ + static void ptrcall(void *p_base, const void **p_args, void *r_ret, int p_argcount) { \ + vc_convert_ptrcall(m_method_ptr, p_base, p_args, r_ret); \ + } \ + static int get_argument_count() { \ + return vc_get_argument_count(m_method_ptr); \ + } \ + static Variant::Type get_argument_type(int p_arg) { \ + return vc_get_argument_type(m_method_ptr, p_arg); \ + } \ + static Variant::Type get_return_type() { \ + return vc_get_return_type(m_method_ptr); \ + } \ + static bool has_return_type() { \ + return vc_has_return_type(m_method_ptr); \ + } \ + static bool is_const() { \ + return vc_is_const(m_method_ptr); \ + } \ + static bool is_static() { \ + return false; \ + } \ + static bool is_vararg() { \ + return false; \ + } \ + static Variant::Type get_base_type() { \ + return GetTypeInfo::VARIANT_TYPE; \ + } \ + static StringName get_name() { \ + return #m_exposed_name; \ + } \ }; template @@ -459,44 +459,44 @@ static _FORCE_INLINE_ void vc_static_ptrcall(void (*method)(P...), const void ** call_with_ptr_args_static_method(method, p_args); } -#define STATIC_METHOD_CLASS(m_class, m_exposed_name, m_method_name, m_method_ptr) \ - struct Method_##m_class##_##m_method_name { \ +#define STATIC_METHOD_CLASS(m_class, m_exposed_name, m_method_name, m_method_ptr) \ + struct Method_##m_class##_##m_method_name { \ static void call(Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector &p_defvals, Callable::CallError &r_error) { \ - vc_static_method_call(m_method_ptr, p_args, p_argcount, r_ret, p_defvals, r_error); \ - } \ - static void validated_call(Variant *base, const Variant **p_args, int p_argcount, Variant *r_ret) { \ - vc_validated_static_call(m_method_ptr, p_args, r_ret); \ - } \ - static void ptrcall(void *p_base, const void **p_args, void *r_ret, int p_argcount) { \ - vc_static_ptrcall(m_method_ptr, p_args, r_ret); \ - } \ - static int get_argument_count() { \ - return vc_get_argument_count_static(m_method_ptr); \ - } \ - static Variant::Type get_argument_type(int p_arg) { \ - return vc_get_argument_type_static(m_method_ptr, p_arg); \ - } \ - static Variant::Type get_return_type() { \ - return vc_get_return_type(m_method_ptr); \ - } \ - static bool has_return_type() { \ - return vc_has_return_type_static(m_method_ptr); \ - } \ - static bool is_const() { \ - return false; \ - } \ - static bool is_static() { \ - return true; \ - } \ - static bool is_vararg() { \ - return false; \ - } \ - static Variant::Type get_base_type() { \ - return GetTypeInfo::VARIANT_TYPE; \ - } \ - static StringName get_name() { \ - return #m_exposed_name; \ - } \ + vc_static_method_call(m_method_ptr, p_args, p_argcount, r_ret, p_defvals, r_error); \ + } \ + static void validated_call(Variant *base, const Variant **p_args, int p_argcount, Variant *r_ret) { \ + vc_validated_static_call(m_method_ptr, p_args, r_ret); \ + } \ + static void ptrcall(void *p_base, const void **p_args, void *r_ret, int p_argcount) { \ + vc_static_ptrcall(m_method_ptr, p_args, r_ret); \ + } \ + static int get_argument_count() { \ + return vc_get_argument_count_static(m_method_ptr); \ + } \ + static Variant::Type get_argument_type(int p_arg) { \ + return vc_get_argument_type_static(m_method_ptr, p_arg); \ + } \ + static Variant::Type get_return_type() { \ + return vc_get_return_type(m_method_ptr); \ + } \ + static bool has_return_type() { \ + return vc_has_return_type_static(m_method_ptr); \ + } \ + static bool is_const() { \ + return false; \ + } \ + static bool is_static() { \ + return true; \ + } \ + static bool is_vararg() { \ + return false; \ + } \ + static Variant::Type get_base_type() { \ + return GetTypeInfo::VARIANT_TYPE; \ + } \ + static StringName get_name() { \ + return #m_exposed_name; \ + } \ }; template @@ -509,162 +509,162 @@ static _FORCE_INLINE_ void vc_ptrcall(void (*method)(T *, P...), void *p_base, c call_with_ptr_args_static(reinterpret_cast(p_base), method, p_args); } -#define FUNCTION_CLASS(m_class, m_exposed_name, m_method_name, m_method_ptr, m_const) \ - struct Method_##m_class##_##m_method_name { \ +#define FUNCTION_CLASS(m_class, m_exposed_name, m_method_name, m_method_ptr, m_const) \ + struct Method_##m_class##_##m_method_name { \ static void call(Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector &p_defvals, Callable::CallError &r_error) { \ - vc_method_call_static(m_method_ptr, base, p_args, p_argcount, r_ret, p_defvals, r_error); \ - } \ - static void validated_call(Variant *base, const Variant **p_args, int p_argcount, Variant *r_ret) { \ - vc_validated_call_static(m_method_ptr, base, p_args, r_ret); \ - } \ - static void ptrcall(void *p_base, const void **p_args, void *r_ret, int p_argcount) { \ - vc_ptrcall(m_method_ptr, p_base, p_args, r_ret); \ - } \ - static int get_argument_count() { \ - return vc_get_argument_count(m_method_ptr); \ - } \ - static Variant::Type get_argument_type(int p_arg) { \ - return vc_get_argument_type(m_method_ptr, p_arg); \ - } \ - static Variant::Type get_return_type() { \ - return vc_get_return_type(m_method_ptr); \ - } \ - static bool has_return_type() { \ - return vc_has_return_type_static(m_method_ptr); \ - } \ - static bool is_const() { \ - return m_const; \ - } \ - static bool is_static() { \ - return false; \ - } \ - static bool is_vararg() { \ - return false; \ - } \ - static Variant::Type get_base_type() { \ - return GetTypeInfo::VARIANT_TYPE; \ - } \ - static StringName get_name() { \ - return #m_exposed_name; \ - } \ + vc_method_call_static(m_method_ptr, base, p_args, p_argcount, r_ret, p_defvals, r_error); \ + } \ + static void validated_call(Variant *base, const Variant **p_args, int p_argcount, Variant *r_ret) { \ + vc_validated_call_static(m_method_ptr, base, p_args, r_ret); \ + } \ + static void ptrcall(void *p_base, const void **p_args, void *r_ret, int p_argcount) { \ + vc_ptrcall(m_method_ptr, p_base, p_args, r_ret); \ + } \ + static int get_argument_count() { \ + return vc_get_argument_count(m_method_ptr); \ + } \ + static Variant::Type get_argument_type(int p_arg) { \ + return vc_get_argument_type(m_method_ptr, p_arg); \ + } \ + static Variant::Type get_return_type() { \ + return vc_get_return_type(m_method_ptr); \ + } \ + static bool has_return_type() { \ + return vc_has_return_type_static(m_method_ptr); \ + } \ + static bool is_const() { \ + return m_const; \ + } \ + static bool is_static() { \ + return false; \ + } \ + static bool is_vararg() { \ + return false; \ + } \ + static Variant::Type get_base_type() { \ + return GetTypeInfo::VARIANT_TYPE; \ + } \ + static StringName get_name() { \ + return #m_exposed_name; \ + } \ }; -#define VARARG_CLASS(m_class, m_exposed_name, m_method_name, m_method_ptr, m_has_return, m_return_type) \ - struct Method_##m_class##_##m_method_name { \ +#define VARARG_CLASS(m_class, m_exposed_name, m_method_name, m_method_ptr, m_has_return, m_return_type) \ + struct Method_##m_class##_##m_method_name { \ static void call(Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector &p_defvals, Callable::CallError &r_error) { \ - m_method_ptr(base, p_args, p_argcount, r_ret, r_error); \ - } \ - static void validated_call(Variant *base, const Variant **p_args, int p_argcount, Variant *r_ret) { \ - Callable::CallError ce; \ - m_method_ptr(base, p_args, p_argcount, *r_ret, ce); \ - } \ - static void ptrcall(void *p_base, const void **p_args, void *r_ret, int p_argcount) { \ - LocalVector vars; \ - LocalVector vars_ptrs; \ - vars.resize(p_argcount); \ - vars_ptrs.resize(p_argcount); \ - for (int i = 0; i < p_argcount; i++) { \ - vars[i] = PtrToArg::convert(p_args[i]); \ - vars_ptrs[i] = &vars[i]; \ - } \ - Variant base = PtrToArg::convert(p_base); \ - Variant ret; \ - Callable::CallError ce; \ - m_method_ptr(&base, vars_ptrs.ptr(), p_argcount, ret, ce); \ - if (m_has_return) { \ - m_return_type r = ret; \ - PtrToArg::encode(ret, r_ret); \ - } \ - } \ - static int get_argument_count() { \ - return 0; \ - } \ - static Variant::Type get_argument_type(int p_arg) { \ - return Variant::NIL; \ - } \ - static Variant::Type get_return_type() { \ - return GetTypeInfo::VARIANT_TYPE; \ - } \ - static bool has_return_type() { \ - return m_has_return; \ - } \ - static bool is_const() { \ - return true; \ - } \ - static bool is_static() { \ - return false; \ - } \ - static bool is_vararg() { \ - return true; \ - } \ - static Variant::Type get_base_type() { \ - return GetTypeInfo::VARIANT_TYPE; \ - } \ - static StringName get_name() { \ - return #m_exposed_name; \ - } \ + m_method_ptr(base, p_args, p_argcount, r_ret, r_error); \ + } \ + static void validated_call(Variant *base, const Variant **p_args, int p_argcount, Variant *r_ret) { \ + Callable::CallError ce; \ + m_method_ptr(base, p_args, p_argcount, *r_ret, ce); \ + } \ + static void ptrcall(void *p_base, const void **p_args, void *r_ret, int p_argcount) { \ + LocalVector vars; \ + LocalVector vars_ptrs; \ + vars.resize(p_argcount); \ + vars_ptrs.resize(p_argcount); \ + for (int i = 0; i < p_argcount; i++) { \ + vars[i] = PtrToArg::convert(p_args[i]); \ + vars_ptrs[i] = &vars[i]; \ + } \ + Variant base = PtrToArg::convert(p_base); \ + Variant ret; \ + Callable::CallError ce; \ + m_method_ptr(&base, vars_ptrs.ptr(), p_argcount, ret, ce); \ + if (m_has_return) { \ + m_return_type r = ret; \ + PtrToArg::encode(ret, r_ret); \ + } \ + } \ + static int get_argument_count() { \ + return 0; \ + } \ + static Variant::Type get_argument_type(int p_arg) { \ + return Variant::NIL; \ + } \ + static Variant::Type get_return_type() { \ + return GetTypeInfo::VARIANT_TYPE; \ + } \ + static bool has_return_type() { \ + return m_has_return; \ + } \ + static bool is_const() { \ + return true; \ + } \ + static bool is_static() { \ + return false; \ + } \ + static bool is_vararg() { \ + return true; \ + } \ + static Variant::Type get_base_type() { \ + return GetTypeInfo::VARIANT_TYPE; \ + } \ + static StringName get_name() { \ + return #m_exposed_name; \ + } \ }; -#define VARARG_CLASS1(m_class, m_exposed_name, m_method_name, m_method_ptr, m_arg_type) \ - struct Method_##m_class##_##m_method_name { \ +#define VARARG_CLASS1(m_class, m_exposed_name, m_method_name, m_method_ptr, m_arg_type) \ + struct Method_##m_class##_##m_method_name { \ static void call(Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector &p_defvals, Callable::CallError &r_error) { \ - m_method_ptr(base, p_args, p_argcount, r_ret, r_error); \ - } \ - static void validated_call(Variant *base, const Variant **p_args, int p_argcount, Variant *r_ret) { \ - Callable::CallError ce; \ - m_method_ptr(base, p_args, p_argcount, *r_ret, ce); \ - } \ - static void ptrcall(void *p_base, const void **p_args, void *r_ret, int p_argcount) { \ - LocalVector vars; \ - LocalVector vars_ptrs; \ - vars.resize(p_argcount); \ - vars_ptrs.resize(p_argcount); \ - for (int i = 0; i < p_argcount; i++) { \ - vars[i] = PtrToArg::convert(p_args[i]); \ - vars_ptrs[i] = &vars[i]; \ - } \ - Variant base = PtrToArg::convert(p_base); \ - Variant ret; \ - Callable::CallError ce; \ - m_method_ptr(&base, vars_ptrs.ptr(), p_argcount, ret, ce); \ - } \ - static int get_argument_count() { \ - return 1; \ - } \ - static Variant::Type get_argument_type(int p_arg) { \ - return m_arg_type; \ - } \ - static Variant::Type get_return_type() { \ - return Variant::NIL; \ - } \ - static bool has_return_type() { \ - return false; \ - } \ - static bool is_const() { \ - return true; \ - } \ - static bool is_static() { \ - return false; \ - } \ - static bool is_vararg() { \ - return true; \ - } \ - static Variant::Type get_base_type() { \ - return GetTypeInfo::VARIANT_TYPE; \ - } \ - static StringName get_name() { \ - return #m_exposed_name; \ - } \ + m_method_ptr(base, p_args, p_argcount, r_ret, r_error); \ + } \ + static void validated_call(Variant *base, const Variant **p_args, int p_argcount, Variant *r_ret) { \ + Callable::CallError ce; \ + m_method_ptr(base, p_args, p_argcount, *r_ret, ce); \ + } \ + static void ptrcall(void *p_base, const void **p_args, void *r_ret, int p_argcount) { \ + LocalVector vars; \ + LocalVector vars_ptrs; \ + vars.resize(p_argcount); \ + vars_ptrs.resize(p_argcount); \ + for (int i = 0; i < p_argcount; i++) { \ + vars[i] = PtrToArg::convert(p_args[i]); \ + vars_ptrs[i] = &vars[i]; \ + } \ + Variant base = PtrToArg::convert(p_base); \ + Variant ret; \ + Callable::CallError ce; \ + m_method_ptr(&base, vars_ptrs.ptr(), p_argcount, ret, ce); \ + } \ + static int get_argument_count() { \ + return 1; \ + } \ + static Variant::Type get_argument_type(int p_arg) { \ + return m_arg_type; \ + } \ + static Variant::Type get_return_type() { \ + return Variant::NIL; \ + } \ + static bool has_return_type() { \ + return false; \ + } \ + static bool is_const() { \ + return true; \ + } \ + static bool is_static() { \ + return false; \ + } \ + static bool is_vararg() { \ + return true; \ + } \ + static Variant::Type get_base_type() { \ + return GetTypeInfo::VARIANT_TYPE; \ + } \ + static StringName get_name() { \ + return #m_exposed_name; \ + } \ }; -#define VARCALL_ARRAY_GETTER_SETTER(m_packed_type, m_type) \ - static m_type func_##m_packed_type##_get(m_packed_type *p_instance, int64_t p_index) { \ - ERR_FAIL_INDEX_V(p_index, p_instance->size(), m_type()); \ - return p_instance->get(p_index); \ - } \ +#define VARCALL_ARRAY_GETTER_SETTER(m_packed_type, m_type) \ + static m_type func_##m_packed_type##_get(m_packed_type *p_instance, int64_t p_index) { \ + ERR_FAIL_INDEX_V(p_index, p_instance->size(), m_type()); \ + return p_instance->get(p_index); \ + } \ static void func_##m_packed_type##_set(m_packed_type *p_instance, int64_t p_index, const m_type &p_value) { \ - ERR_FAIL_INDEX(p_index, p_instance->size()); \ - p_instance->set(p_index, p_value); \ + ERR_FAIL_INDEX(p_index, p_instance->size()); \ + p_instance->set(p_index, p_value); \ } struct _VariantCall { @@ -1808,194 +1808,194 @@ StringName Variant::get_enum_for_enumeration(Variant::Type p_type, const StringN #ifdef DEBUG_ENABLED #define bind_method(m_type, m_method, m_arg_names, m_default_args) \ - METHOD_CLASS(m_type, m_method, m_method, &m_type::m_method); \ + METHOD_CLASS(m_type, m_method, m_method, &m_type::m_method); \ register_builtin_method(m_arg_names, m_default_args); #else #define bind_method(m_type, m_method, m_arg_names, m_default_args) \ - METHOD_CLASS(m_type, m_method, m_method, &m_type ::m_method); \ + METHOD_CLASS(m_type, m_method, m_method, &m_type ::m_method); \ register_builtin_method(sarray(), m_default_args); #endif // DEBUG_ENABLED #ifdef DEBUG_ENABLED #define bind_compat_method(m_type, m_exposed_method, m_method, m_arg_names, m_default_args) \ - METHOD_CLASS(m_type, m_exposed_method, m_method, &m_type::m_method); \ + METHOD_CLASS(m_type, m_exposed_method, m_method, &m_type::m_method); \ register_builtin_compat_method(m_arg_names, m_default_args); #else #define bind_compat_method(m_type, m_exposed_method, m_method, m_arg_names, m_default_args) \ - METHOD_CLASS(m_type, m_exposed_method, m_method, &m_type ::m_method); \ + METHOD_CLASS(m_type, m_exposed_method, m_method, &m_type ::m_method); \ register_builtin_compat_method(sarray(), m_default_args); #endif // DEBUG_ENABLED #ifdef DEBUG_ENABLED #define bind_convert_method(m_type_from, m_type_to, m_method, m_arg_names, m_default_args) \ - CONVERT_METHOD_CLASS(m_type_from, m_method, m_method, &m_type_to::m_method); \ + CONVERT_METHOD_CLASS(m_type_from, m_method, m_method, &m_type_to::m_method); \ register_builtin_method(m_arg_names, m_default_args); #else #define bind_convert_method(m_type_from, m_type_to, m_method, m_arg_names, m_default_args) \ - CONVERT_METHOD_CLASS(m_type_from, m_method, m_method, &m_type_to ::m_method); \ + CONVERT_METHOD_CLASS(m_type_from, m_method, m_method, &m_type_to ::m_method); \ register_builtin_method(sarray(), m_default_args); #endif // DEBUG_ENABLED #ifdef DEBUG_ENABLED #define bind_convert_compat_method(m_type_from, m_type_to, m_exposed_method, m_method, m_arg_names, m_default_args) \ - CONVERT_METHOD_CLASS(m_type_from, m_exposed_method, m_method, &m_type_to::m_method); \ + CONVERT_METHOD_CLASS(m_type_from, m_exposed_method, m_method, &m_type_to::m_method); \ register_builtin_compat_method(m_arg_names, m_default_args); #else #define bind_convert_compat_method(m_type_from, m_type_to, m_exposed_method, m_method, m_arg_names, m_default_args) \ - CONVERT_METHOD_CLASS(m_type_from, m_exposed_method, m_method, &m_type_to ::m_method); \ + CONVERT_METHOD_CLASS(m_type_from, m_exposed_method, m_method, &m_type_to ::m_method); \ register_builtin_compat_method(sarray(), m_default_args); #endif // DEBUG_ENABLED #ifdef DEBUG_ENABLED #define bind_static_method(m_type, m_method, m_arg_names, m_default_args) \ - STATIC_METHOD_CLASS(m_type, m_method, m_method, m_type::m_method); \ + STATIC_METHOD_CLASS(m_type, m_method, m_method, m_type::m_method); \ register_builtin_method(m_arg_names, m_default_args); #else #define bind_static_method(m_type, m_method, m_arg_names, m_default_args) \ - STATIC_METHOD_CLASS(m_type, m_method, m_method, m_type ::m_method); \ + STATIC_METHOD_CLASS(m_type, m_method, m_method, m_type ::m_method); \ register_builtin_method(sarray(), m_default_args); #endif // DEBUG_ENABLED #ifdef DEBUG_ENABLED #define bind_static_compat_method(m_type, m_exposed_method, m_method, m_arg_names, m_default_args) \ - STATIC_METHOD_CLASS(m_type, m_exposed_method, m_method, m_type::m_method); \ + STATIC_METHOD_CLASS(m_type, m_exposed_method, m_method, m_type::m_method); \ register_builtin_compat_method(m_arg_names, m_default_args); #else #define bind_static_compat_method(m_type, m_exposed_method, m_method, m_arg_names, m_default_args) \ - STATIC_METHOD_CLASS(m_type, m_exposed_method, m_method, m_type ::m_method); \ + STATIC_METHOD_CLASS(m_type, m_exposed_method, m_method, m_type ::m_method); \ register_builtin_compat_method(sarray(), m_default_args); #endif // DEBUG_ENABLED #ifdef DEBUG_ENABLED #define bind_static_methodv(m_type, m_name, m_method, m_arg_names, m_default_args) \ - STATIC_METHOD_CLASS(m_type, m_name, m_name, m_method); \ + STATIC_METHOD_CLASS(m_type, m_name, m_name, m_method); \ register_builtin_method(m_arg_names, m_default_args); #else #define bind_static_methodv(m_type, m_name, m_method, m_arg_names, m_default_args) \ - STATIC_METHOD_CLASS(m_type, m_name, m_name, m_method); \ + STATIC_METHOD_CLASS(m_type, m_name, m_name, m_method); \ register_builtin_method(sarray(), m_default_args); #endif #ifdef DEBUG_ENABLED #define bind_static_compat_methodv(m_type, m_exposed_name, m_name, m_method, m_arg_names, m_default_args) \ - STATIC_METHOD_CLASS(m_type, m_exposed_name, m_name, m_method); \ + STATIC_METHOD_CLASS(m_type, m_exposed_name, m_name, m_method); \ register_builtin_compat_method(m_arg_names, m_default_args); #else #define bind_static_compat_methodv(m_type, m_exposed_name, m_name, m_method, m_arg_names, m_default_args) \ - STATIC_METHOD_CLASS(m_type, m_exposed_name, m_name, m_method); \ + STATIC_METHOD_CLASS(m_type, m_exposed_name, m_name, m_method); \ register_builtin_compat_method(sarray(), m_default_args); #endif #ifdef DEBUG_ENABLED #define bind_methodv(m_type, m_name, m_method, m_arg_names, m_default_args) \ - METHOD_CLASS(m_type, m_name, m_name, m_method); \ + METHOD_CLASS(m_type, m_name, m_name, m_method); \ register_builtin_method(m_arg_names, m_default_args); #else #define bind_methodv(m_type, m_name, m_method, m_arg_names, m_default_args) \ - METHOD_CLASS(m_type, m_name, m_name, m_method); \ + METHOD_CLASS(m_type, m_name, m_name, m_method); \ register_builtin_method(sarray(), m_default_args); #endif // DEBUG_ENABLED #ifdef DEBUG_ENABLED #define bind_compat_methodv(m_type, m_exposed_name, m_name, m_method, m_arg_names, m_default_args) \ - METHOD_CLASS(m_type, m_exposed_name, m_name, m_method); \ + METHOD_CLASS(m_type, m_exposed_name, m_name, m_method); \ register_builtin_compat_method(m_arg_names, m_default_args); #else #define bind_compat_methodv(m_type, m_exposed_name, m_name, m_method, m_arg_names, m_default_args) \ - METHOD_CLASS(m_type, m_exposed_name, m_name, m_method); \ + METHOD_CLASS(m_type, m_exposed_name, m_name, m_method); \ register_builtin_compat_method(sarray(), m_default_args); #endif // DEBUG_ENABLED #ifdef DEBUG_ENABLED #define bind_convert_methodv(m_type_from, m_type_to, m_name, m_method, m_arg_names, m_default_args) \ - CONVERT_METHOD_CLASS(m_type_from, m_name, m_name, m_method); \ + CONVERT_METHOD_CLASS(m_type_from, m_name, m_name, m_method); \ register_builtin_method(m_arg_names, m_default_args); #else #define bind_convert_methodv(m_type_from, m_type_to, m_name, m_method, m_arg_names, m_default_args) \ - CONVERT_METHOD_CLASS(m_type_from, m_name, m_name, m_method); \ + CONVERT_METHOD_CLASS(m_type_from, m_name, m_name, m_method); \ register_builtin_method(sarray(), m_default_args); #endif // DEBUG_ENABLED #ifdef DEBUG_ENABLED #define bind_convert_compat_methodv(m_type_from, m_type_to, m_exposed_name, m_name, m_method, m_arg_names, m_default_args) \ - CONVERT_METHOD_CLASS(m_type_from, m_exposed_name, m_name, m_method); \ + CONVERT_METHOD_CLASS(m_type_from, m_exposed_name, m_name, m_method); \ register_builtin_compat_method(m_arg_names, m_default_args); #else #define bind_convert_compat_methodv(m_type_from, m_type_to, m_exposed_name, m_name, m_method, m_arg_names, m_default_args) \ - CONVERT_METHOD_CLASS(m_type_from, m_exposed_name, m_name, m_method); \ + CONVERT_METHOD_CLASS(m_type_from, m_exposed_name, m_name, m_method); \ register_builtin_compat_method(sarray(), m_default_args); #endif // DEBUG_ENABLED #ifdef DEBUG_ENABLED #define bind_function(m_type, m_name, m_method, m_arg_names, m_default_args) \ - FUNCTION_CLASS(m_type, m_name, m_name, m_method, true); \ + FUNCTION_CLASS(m_type, m_name, m_name, m_method, true); \ register_builtin_method(m_arg_names, m_default_args); #else #define bind_function(m_type, m_name, m_method, m_arg_names, m_default_args) \ - FUNCTION_CLASS(m_type, m_name, m_name, m_method, true); \ + FUNCTION_CLASS(m_type, m_name, m_name, m_method, true); \ register_builtin_method(sarray(), m_default_args); #endif // DEBUG_ENABLED #ifdef DEBUG_ENABLED #define bind_compat_function(m_type, m_exposed_name, m_name, m_method, m_arg_names, m_default_args) \ - FUNCTION_CLASS(m_type, m_exposed_name, m_name, m_method, true); \ + FUNCTION_CLASS(m_type, m_exposed_name, m_name, m_method, true); \ register_builtin_compat_method(m_arg_names, m_default_args); #else #define bind_compat_function(m_type, m_exposed_name, m_name, m_method, m_arg_names, m_default_args) \ - FUNCTION_CLASS(m_type, m_exposed_name, m_name, m_method, true); \ + FUNCTION_CLASS(m_type, m_exposed_name, m_name, m_method, true); \ register_builtin_compat_method(sarray(), m_default_args); #endif // DEBUG_ENABLED #ifdef DEBUG_ENABLED #define bind_functionnc(m_type, m_name, m_method, m_arg_names, m_default_args) \ - FUNCTION_CLASS(m_type, m_name, m_name, m_method, false); \ + FUNCTION_CLASS(m_type, m_name, m_name, m_method, false); \ register_builtin_method(m_arg_names, m_default_args); #else #define bind_functionnc(m_type, m_name, m_method, m_arg_names, m_default_args) \ - FUNCTION_CLASS(m_type, m_name, m_name, m_method, false); \ + FUNCTION_CLASS(m_type, m_name, m_name, m_method, false); \ register_builtin_method(sarray(), m_default_args); #endif // DEBUG_ENABLED #ifdef DEBUG_ENABLED #define bind_compat_functionnc(m_type, m_exposed_name, m_name, m_method, m_arg_names, m_default_args) \ - FUNCTION_CLASS(m_type, m_exposed_name, m_name, m_method, false); \ + FUNCTION_CLASS(m_type, m_exposed_name, m_name, m_method, false); \ register_builtin_compat_method(m_arg_names, m_default_args); #else #define bind_compat_functionnc(m_type, m_exposed_name, m_name, m_method, m_arg_names, m_default_args) \ - FUNCTION_CLASS(m_type, m_exposed_name, m_name, m_method, false); \ + FUNCTION_CLASS(m_type, m_exposed_name, m_name, m_method, false); \ register_builtin_compat_method(sarray(), m_default_args); #endif // DEBUG_ENABLED #define bind_string_method(m_method, m_arg_names, m_default_args) \ - bind_method(String, m_method, m_arg_names, m_default_args); \ + bind_method(String, m_method, m_arg_names, m_default_args); \ bind_convert_method(StringName, String, m_method, m_arg_names, m_default_args); #define bind_string_methodv(m_name, m_method, m_arg_names, m_default_args) \ - bind_methodv(String, m_name, m_method, m_arg_names, m_default_args); \ + bind_methodv(String, m_name, m_method, m_arg_names, m_default_args); \ bind_convert_methodv(StringName, String, m_name, m_method, m_arg_names, m_default_args); #define bind_string_compat_method(m_exposed_name, m_method, m_arg_names, m_default_args) \ - bind_compat_method(String, m_exposed_name, m_method, m_arg_names, m_default_args); \ + bind_compat_method(String, m_exposed_name, m_method, m_arg_names, m_default_args); \ bind_convert_compat_method(StringName, String, m_exposed_name, m_method, m_arg_names, m_default_args); #define bind_string_compat_methodv(m_exposed_name, m_name, m_method, m_arg_names, m_default_args) \ - bind_compat_methodv(String, m_exposed_name, m_name, m_method, m_arg_names, m_default_args); \ + bind_compat_methodv(String, m_exposed_name, m_name, m_method, m_arg_names, m_default_args); \ bind_convert_compat_methodv(StringName, String, m_exposed_name, m_name, m_method, m_arg_names, m_default_args); -#define bind_custom(m_type, m_name, m_method, m_has_return, m_ret_type) \ +#define bind_custom(m_type, m_name, m_method, m_has_return, m_ret_type) \ VARARG_CLASS(m_type, m_name, m_name, m_method, m_has_return, m_ret_type) \ register_builtin_method(sarray(), Vector()); #define bind_custom1(m_type, m_name, m_method, m_arg_type, m_arg_name) \ - VARARG_CLASS1(m_type, m_name, m_name, m_method, m_arg_type) \ + VARARG_CLASS1(m_type, m_name, m_name, m_method, m_arg_type) \ register_builtin_method(sarray(m_arg_name), Vector()); #define bind_compat_custom(m_type, m_exposed_name, m_name, m_method, m_has_return, m_ret_type) \ - VARARG_CLASS(m_type, m_exposed_name, m_name, m_method, m_has_return, m_ret_type) \ + VARARG_CLASS(m_type, m_exposed_name, m_name, m_method, m_has_return, m_ret_type) \ register_builtin_compat_method(sarray(), Vector()); #define bind_compat_custom1(m_type, m_exposed_name, m_name, m_method, m_arg_type, m_arg_name) \ - VARARG_CLASS1(m_type, m_exposed_name, m_name, m_method, m_arg_type) \ + VARARG_CLASS1(m_type, m_exposed_name, m_name, m_method, m_arg_type) \ register_builtin_compat_method(sarray(m_arg_name), Vector()); static void _register_variant_builtin_methods_string() { diff --git a/core/variant/variant_construct.h b/core/variant/variant_construct.h index bd2f48dafcd..60bfbf275cf 100644 --- a/core/variant/variant_construct.h +++ b/core/variant/variant_construct.h @@ -43,12 +43,12 @@ template struct PtrConstruct {}; -#define MAKE_PTRCONSTRUCT(m_type) \ - template <> \ - struct PtrConstruct { \ +#define MAKE_PTRCONSTRUCT(m_type) \ + template <> \ + struct PtrConstruct { \ _FORCE_INLINE_ static void construct(const m_type &p_value, void *p_ptr) { \ - memnew_placement(p_ptr, m_type(p_value)); \ - } \ + memnew_placement(p_ptr, m_type(p_value)); \ + } \ }; MAKE_PTRCONSTRUCT(bool); diff --git a/core/variant/variant_destruct.h b/core/variant/variant_destruct.h index 730bcc820c1..39fc20f5cea 100644 --- a/core/variant/variant_destruct.h +++ b/core/variant/variant_destruct.h @@ -37,15 +37,15 @@ template struct VariantDestruct {}; -#define MAKE_PTRDESTRUCT(m_type) \ - template <> \ - struct VariantDestruct { \ +#define MAKE_PTRDESTRUCT(m_type) \ + template <> \ + struct VariantDestruct { \ _FORCE_INLINE_ static void ptr_destruct(void *p_ptr) { \ - reinterpret_cast(p_ptr)->~m_type(); \ - } \ - _FORCE_INLINE_ static Variant::Type get_base_type() { \ - return GetTypeInfo::VARIANT_TYPE; \ - } \ + reinterpret_cast(p_ptr)->~m_type(); \ + } \ + _FORCE_INLINE_ static Variant::Type get_base_type() { \ + return GetTypeInfo::VARIANT_TYPE; \ + } \ } MAKE_PTRDESTRUCT(String); diff --git a/core/variant/variant_op.cpp b/core/variant/variant_op.cpp index b25556a903f..430eff74c8e 100644 --- a/core/variant/variant_op.cpp +++ b/core/variant/variant_op.cpp @@ -193,20 +193,20 @@ public: static Variant::Type get_return_type() { return GetTypeInfo::VARIANT_TYPE; } }; -#define register_string_op(m_op_type, m_op_code) \ - if constexpr (true) { \ - register_op>(m_op_code, Variant::STRING, Variant::STRING); \ - register_op>(m_op_code, Variant::STRING, Variant::STRING_NAME); \ - register_op>(m_op_code, Variant::STRING_NAME, Variant::STRING); \ +#define register_string_op(m_op_type, m_op_code) \ + if constexpr (true) { \ + register_op>(m_op_code, Variant::STRING, Variant::STRING); \ + register_op>(m_op_code, Variant::STRING, Variant::STRING_NAME); \ + register_op>(m_op_code, Variant::STRING_NAME, Variant::STRING); \ register_op>(m_op_code, Variant::STRING_NAME, Variant::STRING_NAME); \ - } else \ + } else \ ((void)0) -#define register_string_modulo_op(m_class, m_type) \ - if constexpr (true) { \ - register_op>(Variant::OP_MODULE, Variant::STRING, m_type); \ +#define register_string_modulo_op(m_class, m_type) \ + if constexpr (true) { \ + register_op>(Variant::OP_MODULE, Variant::STRING, m_type); \ register_op>(Variant::OP_MODULE, Variant::STRING_NAME, m_type); \ - } else \ + } else \ ((void)0) void Variant::_register_variant_operators() { diff --git a/core/variant/variant_op.h b/core/variant/variant_op.h index e9eb66f9c9a..c4f4642011a 100644 --- a/core/variant/variant_op.h +++ b/core/variant/variant_op.h @@ -912,18 +912,18 @@ _FORCE_INLINE_ static bool _operate_get_ptr_object(const void *p_ptr) { return PtrToArg::convert(p_ptr) != nullptr; } -#define OP_EVALUATOR(m_class_name, m_left, m_right, m_op) \ - class m_class_name : public CommonEvaluate { \ - public: \ - static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { \ +#define OP_EVALUATOR(m_class_name, m_left, m_right, m_op) \ + class m_class_name : public CommonEvaluate { \ + public: \ + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { \ VariantInternalAccessor::get(r_ret) = m_op(_operate_get_##m_left(left), _operate_get_##m_right(right)); \ - } \ - \ - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { \ - PtrToArg::encode(m_op(_operate_get_ptr_##m_left(left), _operate_get_ptr_##m_right(right)), r_ret); \ - } \ - \ - using ReturnType = bool; \ + } \ +\ + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { \ + PtrToArg::encode(m_op(_operate_get_ptr_##m_left(left), _operate_get_ptr_##m_right(right)), r_ret); \ + } \ +\ + using ReturnType = bool; \ }; // OR diff --git a/core/variant/variant_setget.cpp b/core/variant/variant_setget.cpp index 90c976d6e66..ec9a25cdaee 100644 --- a/core/variant/variant_setget.cpp +++ b/core/variant/variant_setget.cpp @@ -329,329 +329,329 @@ Variant Variant::get_named(const StringName &p_member, bool &r_valid) const { #endif -#define INDEXED_SETGET_STRUCT_TYPED(m_base_type, m_elem_type) \ - struct VariantIndexedSetGet_##m_base_type { \ - static void get(const Variant *base, int64_t index, Variant *value, bool *oob) { \ - int64_t size = VariantInternalAccessor::get(base).size(); \ - if (index < 0) { \ - index += size; \ - } \ - if (index < 0 || index >= size) { \ - *oob = true; \ - return; \ - } \ - VariantTypeAdjust::adjust(value); \ - VariantInternalAccessor::get(value) = (VariantInternalAccessor::get(base))[index]; \ - *oob = false; \ - } \ - static void ptr_get(const void *base, int64_t index, void *member) { \ - /* avoid ptrconvert for performance*/ \ - const m_base_type &v = *reinterpret_cast(base); \ - if (index < 0) \ - index += v.size(); \ - OOB_TEST(index, v.size()); \ - PtrToArg::encode(v[index], member); \ - } \ - static void set(Variant *base, int64_t index, const Variant *value, bool *valid, bool *oob) { \ - if (value->get_type() != GetTypeInfo::VARIANT_TYPE) { \ - *oob = false; \ - *valid = false; \ - return; \ - } \ - int64_t size = VariantInternalAccessor::get(base).size(); \ - if (index < 0) { \ - index += size; \ - } \ - if (index < 0 || index >= size) { \ - *oob = true; \ - *valid = false; \ - return; \ - } \ - (VariantInternalAccessor::get(base)).write[index] = VariantInternalAccessor::get(value); \ - *oob = false; \ - *valid = true; \ - } \ - static void validated_set(Variant *base, int64_t index, const Variant *value, bool *oob) { \ - int64_t size = VariantInternalAccessor::get(base).size(); \ - if (index < 0) { \ - index += size; \ - } \ - if (index < 0 || index >= size) { \ - *oob = true; \ - return; \ - } \ - (VariantInternalAccessor::get(base)).write[index] = VariantInternalAccessor::get(value); \ - *oob = false; \ - } \ - static void ptr_set(void *base, int64_t index, const void *member) { \ - /* avoid ptrconvert for performance*/ \ - m_base_type &v = *reinterpret_cast(base); \ - if (index < 0) \ - index += v.size(); \ - OOB_TEST(index, v.size()); \ - v.write[index] = PtrToArg::convert(member); \ - } \ - static Variant::Type get_index_type() { \ - return GetTypeInfo::VARIANT_TYPE; \ - } \ - static uint32_t get_index_usage() { \ - return GetTypeInfo::get_class_info().usage; \ - } \ - static uint64_t get_indexed_size(const Variant *base) { \ - return VariantInternalAccessor::get(base).size(); \ - } \ - }; - -#define INDEXED_SETGET_STRUCT_TYPED_NUMERIC(m_base_type, m_elem_type, m_assign_type) \ - struct VariantIndexedSetGet_##m_base_type { \ - static void get(const Variant *base, int64_t index, Variant *value, bool *oob) { \ - int64_t size = VariantInternalAccessor::get(base).size(); \ - if (index < 0) { \ - index += size; \ - } \ - if (index < 0 || index >= size) { \ - *oob = true; \ - return; \ - } \ - VariantTypeAdjust::adjust(value); \ - VariantInternalAccessor::get(value) = (VariantInternalAccessor::get(base))[index]; \ - *oob = false; \ - } \ - static void ptr_get(const void *base, int64_t index, void *member) { \ - /* avoid ptrconvert for performance*/ \ - const m_base_type &v = *reinterpret_cast(base); \ - if (index < 0) \ - index += v.size(); \ - OOB_TEST(index, v.size()); \ - PtrToArg::encode(v[index], member); \ - } \ - static void set(Variant *base, int64_t index, const Variant *value, bool *valid, bool *oob) { \ - int64_t size = VariantInternalAccessor::get(base).size(); \ - if (index < 0) { \ - index += size; \ - } \ - if (index < 0 || index >= size) { \ - *oob = true; \ - *valid = false; \ - return; \ - } \ - m_assign_type num; \ - if (value->get_type() == Variant::INT) { \ - num = (m_assign_type) * &VariantInternalAccessor::get(value); \ - } else if (value->get_type() == Variant::FLOAT) { \ - num = (m_assign_type) * &VariantInternalAccessor::get(value); \ - } else { \ - *oob = false; \ - *valid = false; \ - return; \ - } \ - (VariantInternalAccessor::get(base)).write[index] = num; \ - *oob = false; \ - *valid = true; \ - } \ - static void validated_set(Variant *base, int64_t index, const Variant *value, bool *oob) { \ - int64_t size = VariantInternalAccessor::get(base).size(); \ - if (index < 0) { \ - index += size; \ - } \ - if (index < 0 || index >= size) { \ - *oob = true; \ - return; \ - } \ - (VariantInternalAccessor::get(base)).write[index] = VariantInternalAccessor::get(value); \ - *oob = false; \ - } \ - static void ptr_set(void *base, int64_t index, const void *member) { \ - /* avoid ptrconvert for performance*/ \ - m_base_type &v = *reinterpret_cast(base); \ - if (index < 0) \ - index += v.size(); \ - OOB_TEST(index, v.size()); \ - v.write[index] = PtrToArg::convert(member); \ - } \ - static Variant::Type get_index_type() { \ - return GetTypeInfo::VARIANT_TYPE; \ - } \ - static uint32_t get_index_usage() { \ - return GetTypeInfo::get_class_info().usage; \ - } \ - static uint64_t get_indexed_size(const Variant *base) { \ - return VariantInternalAccessor::get(base).size(); \ - } \ - }; - -#define INDEXED_SETGET_STRUCT_BUILTIN_NUMERIC(m_base_type, m_elem_type, m_assign_type, m_max) \ - struct VariantIndexedSetGet_##m_base_type { \ - static void get(const Variant *base, int64_t index, Variant *value, bool *oob) { \ - if (index < 0 || index >= m_max) { \ - *oob = true; \ - return; \ - } \ - VariantTypeAdjust::adjust(value); \ +#define INDEXED_SETGET_STRUCT_TYPED(m_base_type, m_elem_type) \ + struct VariantIndexedSetGet_##m_base_type { \ + static void get(const Variant *base, int64_t index, Variant *value, bool *oob) { \ + int64_t size = VariantInternalAccessor::get(base).size(); \ + if (index < 0) { \ + index += size; \ + } \ + if (index < 0 || index >= size) { \ + *oob = true; \ + return; \ + } \ + VariantTypeAdjust::adjust(value); \ VariantInternalAccessor::get(value) = (VariantInternalAccessor::get(base))[index]; \ - *oob = false; \ - } \ - static void ptr_get(const void *base, int64_t index, void *member) { \ - /* avoid ptrconvert for performance*/ \ - const m_base_type &v = *reinterpret_cast(base); \ - OOB_TEST(index, m_max); \ - PtrToArg::encode(v[index], member); \ - } \ - static void set(Variant *base, int64_t index, const Variant *value, bool *valid, bool *oob) { \ - if (index < 0 || index >= m_max) { \ - *oob = true; \ - *valid = false; \ - return; \ - } \ - m_assign_type num; \ - if (value->get_type() == Variant::INT) { \ - num = (m_assign_type) * &VariantInternalAccessor::get(value); \ - } else if (value->get_type() == Variant::FLOAT) { \ - num = (m_assign_type) * &VariantInternalAccessor::get(value); \ - } else { \ - *oob = false; \ - *valid = false; \ - return; \ - } \ - (VariantInternalAccessor::get(base))[index] = num; \ - *oob = false; \ - *valid = true; \ - } \ - static void validated_set(Variant *base, int64_t index, const Variant *value, bool *oob) { \ - if (index < 0 || index >= m_max) { \ - *oob = true; \ - return; \ - } \ + *oob = false; \ + } \ + static void ptr_get(const void *base, int64_t index, void *member) { \ + /* avoid ptrconvert for performance*/ \ + const m_base_type &v = *reinterpret_cast(base); \ + if (index < 0) \ + index += v.size(); \ + OOB_TEST(index, v.size()); \ + PtrToArg::encode(v[index], member); \ + } \ + static void set(Variant *base, int64_t index, const Variant *value, bool *valid, bool *oob) { \ + if (value->get_type() != GetTypeInfo::VARIANT_TYPE) { \ + *oob = false; \ + *valid = false; \ + return; \ + } \ + int64_t size = VariantInternalAccessor::get(base).size(); \ + if (index < 0) { \ + index += size; \ + } \ + if (index < 0 || index >= size) { \ + *oob = true; \ + *valid = false; \ + return; \ + } \ + (VariantInternalAccessor::get(base)).write[index] = VariantInternalAccessor::get(value); \ + *oob = false; \ + *valid = true; \ + } \ + static void validated_set(Variant *base, int64_t index, const Variant *value, bool *oob) { \ + int64_t size = VariantInternalAccessor::get(base).size(); \ + if (index < 0) { \ + index += size; \ + } \ + if (index < 0 || index >= size) { \ + *oob = true; \ + return; \ + } \ + (VariantInternalAccessor::get(base)).write[index] = VariantInternalAccessor::get(value); \ + *oob = false; \ + } \ + static void ptr_set(void *base, int64_t index, const void *member) { \ + /* avoid ptrconvert for performance*/ \ + m_base_type &v = *reinterpret_cast(base); \ + if (index < 0) \ + index += v.size(); \ + OOB_TEST(index, v.size()); \ + v.write[index] = PtrToArg::convert(member); \ + } \ + static Variant::Type get_index_type() { \ + return GetTypeInfo::VARIANT_TYPE; \ + } \ + static uint32_t get_index_usage() { \ + return GetTypeInfo::get_class_info().usage; \ + } \ + static uint64_t get_indexed_size(const Variant *base) { \ + return VariantInternalAccessor::get(base).size(); \ + } \ + }; + +#define INDEXED_SETGET_STRUCT_TYPED_NUMERIC(m_base_type, m_elem_type, m_assign_type) \ + struct VariantIndexedSetGet_##m_base_type { \ + static void get(const Variant *base, int64_t index, Variant *value, bool *oob) { \ + int64_t size = VariantInternalAccessor::get(base).size(); \ + if (index < 0) { \ + index += size; \ + } \ + if (index < 0 || index >= size) { \ + *oob = true; \ + return; \ + } \ + VariantTypeAdjust::adjust(value); \ + VariantInternalAccessor::get(value) = (VariantInternalAccessor::get(base))[index]; \ + *oob = false; \ + } \ + static void ptr_get(const void *base, int64_t index, void *member) { \ + /* avoid ptrconvert for performance*/ \ + const m_base_type &v = *reinterpret_cast(base); \ + if (index < 0) \ + index += v.size(); \ + OOB_TEST(index, v.size()); \ + PtrToArg::encode(v[index], member); \ + } \ + static void set(Variant *base, int64_t index, const Variant *value, bool *valid, bool *oob) { \ + int64_t size = VariantInternalAccessor::get(base).size(); \ + if (index < 0) { \ + index += size; \ + } \ + if (index < 0 || index >= size) { \ + *oob = true; \ + *valid = false; \ + return; \ + } \ + m_assign_type num; \ + if (value->get_type() == Variant::INT) { \ + num = (m_assign_type) * &VariantInternalAccessor::get(value); \ + } else if (value->get_type() == Variant::FLOAT) { \ + num = (m_assign_type) * &VariantInternalAccessor::get(value); \ + } else { \ + *oob = false; \ + *valid = false; \ + return; \ + } \ + (VariantInternalAccessor::get(base)).write[index] = num; \ + *oob = false; \ + *valid = true; \ + } \ + static void validated_set(Variant *base, int64_t index, const Variant *value, bool *oob) { \ + int64_t size = VariantInternalAccessor::get(base).size(); \ + if (index < 0) { \ + index += size; \ + } \ + if (index < 0 || index >= size) { \ + *oob = true; \ + return; \ + } \ + (VariantInternalAccessor::get(base)).write[index] = VariantInternalAccessor::get(value); \ + *oob = false; \ + } \ + static void ptr_set(void *base, int64_t index, const void *member) { \ + /* avoid ptrconvert for performance*/ \ + m_base_type &v = *reinterpret_cast(base); \ + if (index < 0) \ + index += v.size(); \ + OOB_TEST(index, v.size()); \ + v.write[index] = PtrToArg::convert(member); \ + } \ + static Variant::Type get_index_type() { \ + return GetTypeInfo::VARIANT_TYPE; \ + } \ + static uint32_t get_index_usage() { \ + return GetTypeInfo::get_class_info().usage; \ + } \ + static uint64_t get_indexed_size(const Variant *base) { \ + return VariantInternalAccessor::get(base).size(); \ + } \ + }; + +#define INDEXED_SETGET_STRUCT_BUILTIN_NUMERIC(m_base_type, m_elem_type, m_assign_type, m_max) \ + struct VariantIndexedSetGet_##m_base_type { \ + static void get(const Variant *base, int64_t index, Variant *value, bool *oob) { \ + if (index < 0 || index >= m_max) { \ + *oob = true; \ + return; \ + } \ + VariantTypeAdjust::adjust(value); \ + VariantInternalAccessor::get(value) = (VariantInternalAccessor::get(base))[index]; \ + *oob = false; \ + } \ + static void ptr_get(const void *base, int64_t index, void *member) { \ + /* avoid ptrconvert for performance*/ \ + const m_base_type &v = *reinterpret_cast(base); \ + OOB_TEST(index, m_max); \ + PtrToArg::encode(v[index], member); \ + } \ + static void set(Variant *base, int64_t index, const Variant *value, bool *valid, bool *oob) { \ + if (index < 0 || index >= m_max) { \ + *oob = true; \ + *valid = false; \ + return; \ + } \ + m_assign_type num; \ + if (value->get_type() == Variant::INT) { \ + num = (m_assign_type) * &VariantInternalAccessor::get(value); \ + } else if (value->get_type() == Variant::FLOAT) { \ + num = (m_assign_type) * &VariantInternalAccessor::get(value); \ + } else { \ + *oob = false; \ + *valid = false; \ + return; \ + } \ + (VariantInternalAccessor::get(base))[index] = num; \ + *oob = false; \ + *valid = true; \ + } \ + static void validated_set(Variant *base, int64_t index, const Variant *value, bool *oob) { \ + if (index < 0 || index >= m_max) { \ + *oob = true; \ + return; \ + } \ (VariantInternalAccessor::get(base))[index] = VariantInternalAccessor::get(value); \ - *oob = false; \ - } \ - static void ptr_set(void *base, int64_t index, const void *member) { \ - /* avoid ptrconvert for performance*/ \ - m_base_type &v = *reinterpret_cast(base); \ - OOB_TEST(index, m_max); \ - v[index] = PtrToArg::convert(member); \ - } \ - static Variant::Type get_index_type() { \ - return GetTypeInfo::VARIANT_TYPE; \ - } \ - static uint32_t get_index_usage() { \ - return GetTypeInfo::get_class_info().usage; \ - } \ - static uint64_t get_indexed_size(const Variant *base) { \ - return m_max; \ - } \ + *oob = false; \ + } \ + static void ptr_set(void *base, int64_t index, const void *member) { \ + /* avoid ptrconvert for performance*/ \ + m_base_type &v = *reinterpret_cast(base); \ + OOB_TEST(index, m_max); \ + v[index] = PtrToArg::convert(member); \ + } \ + static Variant::Type get_index_type() { \ + return GetTypeInfo::VARIANT_TYPE; \ + } \ + static uint32_t get_index_usage() { \ + return GetTypeInfo::get_class_info().usage; \ + } \ + static uint64_t get_indexed_size(const Variant *base) { \ + return m_max; \ + } \ }; -#define INDEXED_SETGET_STRUCT_BUILTIN_ACCESSOR(m_base_type, m_elem_type, m_accessor, m_max) \ - struct VariantIndexedSetGet_##m_base_type { \ - static void get(const Variant *base, int64_t index, Variant *value, bool *oob) { \ - if (index < 0 || index >= m_max) { \ - *oob = true; \ - return; \ - } \ - VariantTypeAdjust::adjust(value); \ - VariantInternalAccessor::get(value) = (VariantInternalAccessor::get(base))m_accessor[index]; \ - *oob = false; \ - } \ - static void ptr_get(const void *base, int64_t index, void *member) { \ - /* avoid ptrconvert for performance*/ \ - const m_base_type &v = *reinterpret_cast(base); \ - OOB_TEST(index, m_max); \ - PtrToArg::encode(v m_accessor[index], member); \ - } \ - static void set(Variant *base, int64_t index, const Variant *value, bool *valid, bool *oob) { \ - if (value->get_type() != GetTypeInfo::VARIANT_TYPE) { \ - *oob = false; \ - *valid = false; \ - } \ - if (index < 0 || index >= m_max) { \ - *oob = true; \ - *valid = false; \ - return; \ - } \ +#define INDEXED_SETGET_STRUCT_BUILTIN_ACCESSOR(m_base_type, m_elem_type, m_accessor, m_max) \ + struct VariantIndexedSetGet_##m_base_type { \ + static void get(const Variant *base, int64_t index, Variant *value, bool *oob) { \ + if (index < 0 || index >= m_max) { \ + *oob = true; \ + return; \ + } \ + VariantTypeAdjust::adjust(value); \ + VariantInternalAccessor::get(value) = (VariantInternalAccessor::get(base))m_accessor[index]; \ + *oob = false; \ + } \ + static void ptr_get(const void *base, int64_t index, void *member) { \ + /* avoid ptrconvert for performance*/ \ + const m_base_type &v = *reinterpret_cast(base); \ + OOB_TEST(index, m_max); \ + PtrToArg::encode(v m_accessor[index], member); \ + } \ + static void set(Variant *base, int64_t index, const Variant *value, bool *valid, bool *oob) { \ + if (value->get_type() != GetTypeInfo::VARIANT_TYPE) { \ + *oob = false; \ + *valid = false; \ + } \ + if (index < 0 || index >= m_max) { \ + *oob = true; \ + *valid = false; \ + return; \ + } \ (VariantInternalAccessor::get(base)) m_accessor[index] = VariantInternalAccessor::get(value); \ - *oob = false; \ - *valid = true; \ - } \ - static void validated_set(Variant *base, int64_t index, const Variant *value, bool *oob) { \ - if (index < 0 || index >= m_max) { \ - *oob = true; \ - return; \ - } \ + *oob = false; \ + *valid = true; \ + } \ + static void validated_set(Variant *base, int64_t index, const Variant *value, bool *oob) { \ + if (index < 0 || index >= m_max) { \ + *oob = true; \ + return; \ + } \ (VariantInternalAccessor::get(base)) m_accessor[index] = VariantInternalAccessor::get(value); \ - *oob = false; \ - } \ - static void ptr_set(void *base, int64_t index, const void *member) { \ - /* avoid ptrconvert for performance*/ \ - m_base_type &v = *reinterpret_cast(base); \ - OOB_TEST(index, m_max); \ - v m_accessor[index] = PtrToArg::convert(member); \ - } \ - static Variant::Type get_index_type() { \ - return GetTypeInfo::VARIANT_TYPE; \ - } \ - static uint32_t get_index_usage() { \ - return GetTypeInfo::get_class_info().usage; \ - } \ - static uint64_t get_indexed_size(const Variant *base) { \ - return m_max; \ - } \ + *oob = false; \ + } \ + static void ptr_set(void *base, int64_t index, const void *member) { \ + /* avoid ptrconvert for performance*/ \ + m_base_type &v = *reinterpret_cast(base); \ + OOB_TEST(index, m_max); \ + v m_accessor[index] = PtrToArg::convert(member); \ + } \ + static Variant::Type get_index_type() { \ + return GetTypeInfo::VARIANT_TYPE; \ + } \ + static uint32_t get_index_usage() { \ + return GetTypeInfo::get_class_info().usage; \ + } \ + static uint64_t get_indexed_size(const Variant *base) { \ + return m_max; \ + } \ }; -#define INDEXED_SETGET_STRUCT_BUILTIN_FUNC(m_base_type, m_elem_type, m_set, m_get, m_max) \ - struct VariantIndexedSetGet_##m_base_type { \ - static void get(const Variant *base, int64_t index, Variant *value, bool *oob) { \ - if (index < 0 || index >= m_max) { \ - *oob = true; \ - return; \ - } \ - VariantTypeAdjust::adjust(value); \ +#define INDEXED_SETGET_STRUCT_BUILTIN_FUNC(m_base_type, m_elem_type, m_set, m_get, m_max) \ + struct VariantIndexedSetGet_##m_base_type { \ + static void get(const Variant *base, int64_t index, Variant *value, bool *oob) { \ + if (index < 0 || index >= m_max) { \ + *oob = true; \ + return; \ + } \ + VariantTypeAdjust::adjust(value); \ VariantInternalAccessor::get(value) = VariantInternalAccessor::get(base).m_get(index); \ - *oob = false; \ - } \ - static void ptr_get(const void *base, int64_t index, void *member) { \ - /* avoid ptrconvert for performance*/ \ - const m_base_type &v = *reinterpret_cast(base); \ - OOB_TEST(index, m_max); \ - PtrToArg::encode(v.m_get(index), member); \ - } \ - static void set(Variant *base, int64_t index, const Variant *value, bool *valid, bool *oob) { \ - if (value->get_type() != GetTypeInfo::VARIANT_TYPE) { \ - *oob = false; \ - *valid = false; \ - } \ - if (index < 0 || index >= m_max) { \ - *oob = true; \ - *valid = false; \ - return; \ - } \ - VariantInternalAccessor::get(base).m_set(index, VariantInternalAccessor::get(value)); \ - *oob = false; \ - *valid = true; \ - } \ - static void validated_set(Variant *base, int64_t index, const Variant *value, bool *oob) { \ - if (index < 0 || index >= m_max) { \ - *oob = true; \ - return; \ - } \ - VariantInternalAccessor::get(base).m_set(index, VariantInternalAccessor::get(value)); \ - *oob = false; \ - } \ - static void ptr_set(void *base, int64_t index, const void *member) { \ - /* avoid ptrconvert for performance*/ \ - m_base_type &v = *reinterpret_cast(base); \ - OOB_TEST(index, m_max); \ - v.m_set(index, PtrToArg::convert(member)); \ - } \ - static Variant::Type get_index_type() { \ - return GetTypeInfo::VARIANT_TYPE; \ - } \ - static uint32_t get_index_usage() { \ - return GetTypeInfo::get_class_info().usage; \ - } \ - static uint64_t get_indexed_size(const Variant *base) { \ - return m_max; \ - } \ + *oob = false; \ + } \ + static void ptr_get(const void *base, int64_t index, void *member) { \ + /* avoid ptrconvert for performance*/ \ + const m_base_type &v = *reinterpret_cast(base); \ + OOB_TEST(index, m_max); \ + PtrToArg::encode(v.m_get(index), member); \ + } \ + static void set(Variant *base, int64_t index, const Variant *value, bool *valid, bool *oob) { \ + if (value->get_type() != GetTypeInfo::VARIANT_TYPE) { \ + *oob = false; \ + *valid = false; \ + } \ + if (index < 0 || index >= m_max) { \ + *oob = true; \ + *valid = false; \ + return; \ + } \ + VariantInternalAccessor::get(base).m_set(index, VariantInternalAccessor::get(value)); \ + *oob = false; \ + *valid = true; \ + } \ + static void validated_set(Variant *base, int64_t index, const Variant *value, bool *oob) { \ + if (index < 0 || index >= m_max) { \ + *oob = true; \ + return; \ + } \ + VariantInternalAccessor::get(base).m_set(index, VariantInternalAccessor::get(value)); \ + *oob = false; \ + } \ + static void ptr_set(void *base, int64_t index, const void *member) { \ + /* avoid ptrconvert for performance*/ \ + m_base_type &v = *reinterpret_cast(base); \ + OOB_TEST(index, m_max); \ + v.m_set(index, PtrToArg::convert(member)); \ + } \ + static Variant::Type get_index_type() { \ + return GetTypeInfo::VARIANT_TYPE; \ + } \ + static uint32_t get_index_usage() { \ + return GetTypeInfo::get_class_info().usage; \ + } \ + static uint64_t get_indexed_size(const Variant *base) { \ + return m_max; \ + } \ }; struct VariantIndexedSetGet_Array { diff --git a/core/variant/variant_setget.h b/core/variant/variant_setget.h index 470184b8b6b..db3be67a795 100644 --- a/core/variant/variant_setget.h +++ b/core/variant/variant_setget.h @@ -38,244 +38,244 @@ /**** NAMED SETTERS AND GETTERS ****/ -#define SETGET_STRUCT(m_base_type, m_member_type, m_member) \ - struct VariantSetGet_##m_base_type##_##m_member { \ - static void get(const Variant *base, Variant *member) { \ - VariantTypeAdjust::adjust(member); \ - VariantInternalAccessor::get(member) = VariantInternalAccessor::get(base).m_member; \ - } \ - static inline void validated_get(const Variant *base, Variant *member) { \ - VariantInternalAccessor::get(member) = VariantInternalAccessor::get(base).m_member; \ - } \ - static void ptr_get(const void *base, void *member) { \ - PtrToArg::encode(PtrToArg::convert(base).m_member, member); \ - } \ - static void set(Variant *base, const Variant *value, bool &valid) { \ - if (value->get_type() == GetTypeInfo::VARIANT_TYPE) { \ +#define SETGET_STRUCT(m_base_type, m_member_type, m_member) \ + struct VariantSetGet_##m_base_type##_##m_member { \ + static void get(const Variant *base, Variant *member) { \ + VariantTypeAdjust::adjust(member); \ + VariantInternalAccessor::get(member) = VariantInternalAccessor::get(base).m_member; \ + } \ + static inline void validated_get(const Variant *base, Variant *member) { \ + VariantInternalAccessor::get(member) = VariantInternalAccessor::get(base).m_member; \ + } \ + static void ptr_get(const void *base, void *member) { \ + PtrToArg::encode(PtrToArg::convert(base).m_member, member); \ + } \ + static void set(Variant *base, const Variant *value, bool &valid) { \ + if (value->get_type() == GetTypeInfo::VARIANT_TYPE) { \ VariantInternalAccessor::get(base).m_member = VariantInternalAccessor::get(value); \ - valid = true; \ - } else { \ - valid = false; \ - } \ - } \ - static inline void validated_set(Variant *base, const Variant *value) { \ - VariantInternalAccessor::get(base).m_member = VariantInternalAccessor::get(value); \ - } \ - static void ptr_set(void *base, const void *member) { \ - m_base_type b = PtrToArg::convert(base); \ - b.m_member = PtrToArg::convert(member); \ - PtrToArg::encode(b, base); \ - } \ - static Variant::Type get_type() { \ - return GetTypeInfo::VARIANT_TYPE; \ - } \ + valid = true; \ + } else { \ + valid = false; \ + } \ + } \ + static inline void validated_set(Variant *base, const Variant *value) { \ + VariantInternalAccessor::get(base).m_member = VariantInternalAccessor::get(value); \ + } \ + static void ptr_set(void *base, const void *member) { \ + m_base_type b = PtrToArg::convert(base); \ + b.m_member = PtrToArg::convert(member); \ + PtrToArg::encode(b, base); \ + } \ + static Variant::Type get_type() { \ + return GetTypeInfo::VARIANT_TYPE; \ + } \ }; -#define SETGET_NUMBER_STRUCT(m_base_type, m_member_type, m_member) \ - struct VariantSetGet_##m_base_type##_##m_member { \ - static void get(const Variant *base, Variant *member) { \ - VariantTypeAdjust::adjust(member); \ +#define SETGET_NUMBER_STRUCT(m_base_type, m_member_type, m_member) \ + struct VariantSetGet_##m_base_type##_##m_member { \ + static void get(const Variant *base, Variant *member) { \ + VariantTypeAdjust::adjust(member); \ VariantInternalAccessor::get(member) = VariantInternalAccessor::get(base).m_member; \ - } \ - static inline void validated_get(const Variant *base, Variant *member) { \ + } \ + static inline void validated_get(const Variant *base, Variant *member) { \ VariantInternalAccessor::get(member) = VariantInternalAccessor::get(base).m_member; \ - } \ - static void ptr_get(const void *base, void *member) { \ - PtrToArg::encode(PtrToArg::convert(base).m_member, member); \ - } \ - static void set(Variant *base, const Variant *value, bool &valid) { \ - if (value->get_type() == Variant::FLOAT) { \ - VariantInternalAccessor::get(base).m_member = VariantInternalAccessor::get(value); \ - valid = true; \ - } else if (value->get_type() == Variant::INT) { \ - VariantInternalAccessor::get(base).m_member = VariantInternalAccessor::get(value); \ - valid = true; \ - } else { \ - valid = false; \ - } \ - } \ - static inline void validated_set(Variant *base, const Variant *value) { \ - VariantInternalAccessor::get(base).m_member = VariantInternalAccessor::get(value); \ - } \ - static void ptr_set(void *base, const void *member) { \ - m_base_type b = PtrToArg::convert(base); \ - b.m_member = PtrToArg::convert(member); \ - PtrToArg::encode(b, base); \ - } \ - static Variant::Type get_type() { \ - return GetTypeInfo::VARIANT_TYPE; \ - } \ + } \ + static void ptr_get(const void *base, void *member) { \ + PtrToArg::encode(PtrToArg::convert(base).m_member, member); \ + } \ + static void set(Variant *base, const Variant *value, bool &valid) { \ + if (value->get_type() == Variant::FLOAT) { \ + VariantInternalAccessor::get(base).m_member = VariantInternalAccessor::get(value); \ + valid = true; \ + } else if (value->get_type() == Variant::INT) { \ + VariantInternalAccessor::get(base).m_member = VariantInternalAccessor::get(value); \ + valid = true; \ + } else { \ + valid = false; \ + } \ + } \ + static inline void validated_set(Variant *base, const Variant *value) { \ + VariantInternalAccessor::get(base).m_member = VariantInternalAccessor::get(value); \ + } \ + static void ptr_set(void *base, const void *member) { \ + m_base_type b = PtrToArg::convert(base); \ + b.m_member = PtrToArg::convert(member); \ + PtrToArg::encode(b, base); \ + } \ + static Variant::Type get_type() { \ + return GetTypeInfo::VARIANT_TYPE; \ + } \ }; -#define SETGET_STRUCT_CUSTOM(m_base_type, m_member_type, m_member, m_custom) \ - struct VariantSetGet_##m_base_type##_##m_member { \ - static void get(const Variant *base, Variant *member) { \ - VariantTypeAdjust::adjust(member); \ - VariantInternalAccessor::get(member) = VariantInternalAccessor::get(base).m_custom; \ - } \ - static inline void validated_get(const Variant *base, Variant *member) { \ - VariantInternalAccessor::get(member) = VariantInternalAccessor::get(base).m_custom; \ - } \ - static void ptr_get(const void *base, void *member) { \ - PtrToArg::encode(PtrToArg::convert(base).m_custom, member); \ - } \ - static void set(Variant *base, const Variant *value, bool &valid) { \ - if (value->get_type() == GetTypeInfo::VARIANT_TYPE) { \ +#define SETGET_STRUCT_CUSTOM(m_base_type, m_member_type, m_member, m_custom) \ + struct VariantSetGet_##m_base_type##_##m_member { \ + static void get(const Variant *base, Variant *member) { \ + VariantTypeAdjust::adjust(member); \ + VariantInternalAccessor::get(member) = VariantInternalAccessor::get(base).m_custom; \ + } \ + static inline void validated_get(const Variant *base, Variant *member) { \ + VariantInternalAccessor::get(member) = VariantInternalAccessor::get(base).m_custom; \ + } \ + static void ptr_get(const void *base, void *member) { \ + PtrToArg::encode(PtrToArg::convert(base).m_custom, member); \ + } \ + static void set(Variant *base, const Variant *value, bool &valid) { \ + if (value->get_type() == GetTypeInfo::VARIANT_TYPE) { \ VariantInternalAccessor::get(base).m_custom = VariantInternalAccessor::get(value); \ - valid = true; \ - } else { \ - valid = false; \ - } \ - } \ - static inline void validated_set(Variant *base, const Variant *value) { \ - VariantInternalAccessor::get(base).m_custom = VariantInternalAccessor::get(value); \ - } \ - static void ptr_set(void *base, const void *member) { \ - m_base_type b = PtrToArg::convert(base); \ - b.m_custom = PtrToArg::convert(member); \ - PtrToArg::encode(b, base); \ - } \ - static Variant::Type get_type() { \ - return GetTypeInfo::VARIANT_TYPE; \ - } \ + valid = true; \ + } else { \ + valid = false; \ + } \ + } \ + static inline void validated_set(Variant *base, const Variant *value) { \ + VariantInternalAccessor::get(base).m_custom = VariantInternalAccessor::get(value); \ + } \ + static void ptr_set(void *base, const void *member) { \ + m_base_type b = PtrToArg::convert(base); \ + b.m_custom = PtrToArg::convert(member); \ + PtrToArg::encode(b, base); \ + } \ + static Variant::Type get_type() { \ + return GetTypeInfo::VARIANT_TYPE; \ + } \ }; -#define SETGET_NUMBER_STRUCT_CUSTOM(m_base_type, m_member_type, m_member, m_custom) \ - struct VariantSetGet_##m_base_type##_##m_member { \ - static void get(const Variant *base, Variant *member) { \ - VariantTypeAdjust::adjust(member); \ +#define SETGET_NUMBER_STRUCT_CUSTOM(m_base_type, m_member_type, m_member, m_custom) \ + struct VariantSetGet_##m_base_type##_##m_member { \ + static void get(const Variant *base, Variant *member) { \ + VariantTypeAdjust::adjust(member); \ VariantInternalAccessor::get(member) = VariantInternalAccessor::get(base).m_custom; \ - } \ - static inline void validated_get(const Variant *base, Variant *member) { \ + } \ + static inline void validated_get(const Variant *base, Variant *member) { \ VariantInternalAccessor::get(member) = VariantInternalAccessor::get(base).m_custom; \ - } \ - static void ptr_get(const void *base, void *member) { \ - PtrToArg::encode(PtrToArg::convert(base).m_custom, member); \ - } \ - static void set(Variant *base, const Variant *value, bool &valid) { \ - if (value->get_type() == Variant::FLOAT) { \ - VariantInternalAccessor::get(base).m_custom = VariantInternalAccessor::get(value); \ - valid = true; \ - } else if (value->get_type() == Variant::INT) { \ - VariantInternalAccessor::get(base).m_custom = VariantInternalAccessor::get(value); \ - valid = true; \ - } else { \ - valid = false; \ - } \ - } \ - static inline void validated_set(Variant *base, const Variant *value) { \ - VariantInternalAccessor::get(base).m_custom = VariantInternalAccessor::get(value); \ - } \ - static void ptr_set(void *base, const void *member) { \ - m_base_type b = PtrToArg::convert(base); \ - b.m_custom = PtrToArg::convert(member); \ - PtrToArg::encode(b, base); \ - } \ - static Variant::Type get_type() { \ - return GetTypeInfo::VARIANT_TYPE; \ - } \ + } \ + static void ptr_get(const void *base, void *member) { \ + PtrToArg::encode(PtrToArg::convert(base).m_custom, member); \ + } \ + static void set(Variant *base, const Variant *value, bool &valid) { \ + if (value->get_type() == Variant::FLOAT) { \ + VariantInternalAccessor::get(base).m_custom = VariantInternalAccessor::get(value); \ + valid = true; \ + } else if (value->get_type() == Variant::INT) { \ + VariantInternalAccessor::get(base).m_custom = VariantInternalAccessor::get(value); \ + valid = true; \ + } else { \ + valid = false; \ + } \ + } \ + static inline void validated_set(Variant *base, const Variant *value) { \ + VariantInternalAccessor::get(base).m_custom = VariantInternalAccessor::get(value); \ + } \ + static void ptr_set(void *base, const void *member) { \ + m_base_type b = PtrToArg::convert(base); \ + b.m_custom = PtrToArg::convert(member); \ + PtrToArg::encode(b, base); \ + } \ + static Variant::Type get_type() { \ + return GetTypeInfo::VARIANT_TYPE; \ + } \ }; -#define SETGET_STRUCT_FUNC(m_base_type, m_member_type, m_member, m_setter, m_getter) \ - struct VariantSetGet_##m_base_type##_##m_member { \ - static void get(const Variant *base, Variant *member) { \ - VariantTypeAdjust::adjust(member); \ +#define SETGET_STRUCT_FUNC(m_base_type, m_member_type, m_member, m_setter, m_getter) \ + struct VariantSetGet_##m_base_type##_##m_member { \ + static void get(const Variant *base, Variant *member) { \ + VariantTypeAdjust::adjust(member); \ VariantInternalAccessor::get(member) = VariantInternalAccessor::get(base).m_getter(); \ - } \ - static inline void validated_get(const Variant *base, Variant *member) { \ + } \ + static inline void validated_get(const Variant *base, Variant *member) { \ VariantInternalAccessor::get(member) = VariantInternalAccessor::get(base).m_getter(); \ - } \ - static void ptr_get(const void *base, void *member) { \ - PtrToArg::encode(PtrToArg::convert(base).m_getter(), member); \ - } \ - static void set(Variant *base, const Variant *value, bool &valid) { \ - if (value->get_type() == GetTypeInfo::VARIANT_TYPE) { \ + } \ + static void ptr_get(const void *base, void *member) { \ + PtrToArg::encode(PtrToArg::convert(base).m_getter(), member); \ + } \ + static void set(Variant *base, const Variant *value, bool &valid) { \ + if (value->get_type() == GetTypeInfo::VARIANT_TYPE) { \ VariantInternalAccessor::get(base).m_setter(VariantInternalAccessor::get(value)); \ - valid = true; \ - } else { \ - valid = false; \ - } \ - } \ - static inline void validated_set(Variant *base, const Variant *value) { \ - VariantInternalAccessor::get(base).m_setter(VariantInternalAccessor::get(value)); \ - } \ - static void ptr_set(void *base, const void *member) { \ - m_base_type b = PtrToArg::convert(base); \ - b.m_setter(PtrToArg::convert(member)); \ - PtrToArg::encode(b, base); \ - } \ - static Variant::Type get_type() { \ - return GetTypeInfo::VARIANT_TYPE; \ - } \ + valid = true; \ + } else { \ + valid = false; \ + } \ + } \ + static inline void validated_set(Variant *base, const Variant *value) { \ + VariantInternalAccessor::get(base).m_setter(VariantInternalAccessor::get(value)); \ + } \ + static void ptr_set(void *base, const void *member) { \ + m_base_type b = PtrToArg::convert(base); \ + b.m_setter(PtrToArg::convert(member)); \ + PtrToArg::encode(b, base); \ + } \ + static Variant::Type get_type() { \ + return GetTypeInfo::VARIANT_TYPE; \ + } \ }; -#define SETGET_NUMBER_STRUCT_FUNC(m_base_type, m_member_type, m_member, m_setter, m_getter) \ - struct VariantSetGet_##m_base_type##_##m_member { \ - static void get(const Variant *base, Variant *member) { \ - VariantTypeAdjust::adjust(member); \ +#define SETGET_NUMBER_STRUCT_FUNC(m_base_type, m_member_type, m_member, m_setter, m_getter) \ + struct VariantSetGet_##m_base_type##_##m_member { \ + static void get(const Variant *base, Variant *member) { \ + VariantTypeAdjust::adjust(member); \ VariantInternalAccessor::get(member) = VariantInternalAccessor::get(base).m_getter(); \ - } \ - static inline void validated_get(const Variant *base, Variant *member) { \ + } \ + static inline void validated_get(const Variant *base, Variant *member) { \ VariantInternalAccessor::get(member) = VariantInternalAccessor::get(base).m_getter(); \ - } \ - static void ptr_get(const void *base, void *member) { \ - PtrToArg::encode(PtrToArg::convert(base).m_getter(), member); \ - } \ - static void set(Variant *base, const Variant *value, bool &valid) { \ - if (value->get_type() == Variant::FLOAT) { \ - VariantInternalAccessor::get(base).m_setter(VariantInternalAccessor::get(value)); \ - valid = true; \ - } else if (value->get_type() == Variant::INT) { \ - VariantInternalAccessor::get(base).m_setter(VariantInternalAccessor::get(value)); \ - valid = true; \ - } else { \ - valid = false; \ - } \ - } \ - static inline void validated_set(Variant *base, const Variant *value) { \ - VariantInternalAccessor::get(base).m_setter(VariantInternalAccessor::get(value)); \ - } \ - static void ptr_set(void *base, const void *member) { \ - m_base_type b = PtrToArg::convert(base); \ - b.m_setter(PtrToArg::convert(member)); \ - PtrToArg::encode(b, base); \ - } \ - static Variant::Type get_type() { \ - return GetTypeInfo::VARIANT_TYPE; \ - } \ + } \ + static void ptr_get(const void *base, void *member) { \ + PtrToArg::encode(PtrToArg::convert(base).m_getter(), member); \ + } \ + static void set(Variant *base, const Variant *value, bool &valid) { \ + if (value->get_type() == Variant::FLOAT) { \ + VariantInternalAccessor::get(base).m_setter(VariantInternalAccessor::get(value)); \ + valid = true; \ + } else if (value->get_type() == Variant::INT) { \ + VariantInternalAccessor::get(base).m_setter(VariantInternalAccessor::get(value)); \ + valid = true; \ + } else { \ + valid = false; \ + } \ + } \ + static inline void validated_set(Variant *base, const Variant *value) { \ + VariantInternalAccessor::get(base).m_setter(VariantInternalAccessor::get(value)); \ + } \ + static void ptr_set(void *base, const void *member) { \ + m_base_type b = PtrToArg::convert(base); \ + b.m_setter(PtrToArg::convert(member)); \ + PtrToArg::encode(b, base); \ + } \ + static Variant::Type get_type() { \ + return GetTypeInfo::VARIANT_TYPE; \ + } \ }; -#define SETGET_STRUCT_FUNC_INDEX(m_base_type, m_member_type, m_member, m_setter, m_getter, m_index) \ - struct VariantSetGet_##m_base_type##_##m_member { \ - static void get(const Variant *base, Variant *member) { \ - VariantTypeAdjust::adjust(member); \ - VariantInternalAccessor::get(member) = VariantInternalAccessor::get(base).m_getter(m_index); \ - } \ - static inline void validated_get(const Variant *base, Variant *member) { \ - VariantInternalAccessor::get(member) = VariantInternalAccessor::get(base).m_getter(m_index); \ - } \ - static void ptr_get(const void *base, void *member) { \ - PtrToArg::encode(PtrToArg::convert(base).m_getter(m_index), member); \ - } \ - static void set(Variant *base, const Variant *value, bool &valid) { \ - if (value->get_type() == GetTypeInfo::VARIANT_TYPE) { \ +#define SETGET_STRUCT_FUNC_INDEX(m_base_type, m_member_type, m_member, m_setter, m_getter, m_index) \ + struct VariantSetGet_##m_base_type##_##m_member { \ + static void get(const Variant *base, Variant *member) { \ + VariantTypeAdjust::adjust(member); \ + VariantInternalAccessor::get(member) = VariantInternalAccessor::get(base).m_getter(m_index); \ + } \ + static inline void validated_get(const Variant *base, Variant *member) { \ + VariantInternalAccessor::get(member) = VariantInternalAccessor::get(base).m_getter(m_index); \ + } \ + static void ptr_get(const void *base, void *member) { \ + PtrToArg::encode(PtrToArg::convert(base).m_getter(m_index), member); \ + } \ + static void set(Variant *base, const Variant *value, bool &valid) { \ + if (value->get_type() == GetTypeInfo::VARIANT_TYPE) { \ VariantInternalAccessor::get(base).m_setter(m_index, VariantInternalAccessor::get(value)); \ - valid = true; \ - } else { \ - valid = false; \ - } \ - } \ - static inline void validated_set(Variant *base, const Variant *value) { \ - VariantInternalAccessor::get(base).m_setter(m_index, VariantInternalAccessor::get(value)); \ - } \ - static void ptr_set(void *base, const void *member) { \ - m_base_type b = PtrToArg::convert(base); \ - b.m_setter(m_index, PtrToArg::convert(member)); \ - PtrToArg::encode(b, base); \ - } \ - static Variant::Type get_type() { \ - return GetTypeInfo::VARIANT_TYPE; \ - } \ + valid = true; \ + } else { \ + valid = false; \ + } \ + } \ + static inline void validated_set(Variant *base, const Variant *value) { \ + VariantInternalAccessor::get(base).m_setter(m_index, VariantInternalAccessor::get(value)); \ + } \ + static void ptr_set(void *base, const void *member) { \ + m_base_type b = PtrToArg::convert(base); \ + b.m_setter(m_index, PtrToArg::convert(member)); \ + PtrToArg::encode(b, base); \ + } \ + static Variant::Type get_type() { \ + return GetTypeInfo::VARIANT_TYPE; \ + } \ }; SETGET_NUMBER_STRUCT(Vector2, double, x) diff --git a/core/variant/variant_utility.cpp b/core/variant/variant_utility.cpp index 6e95fe80957..694f292817a 100644 --- a/core/variant/variant_utility.cpp +++ b/core/variant/variant_utility.cpp @@ -1269,318 +1269,318 @@ static _FORCE_INLINE_ Variant::Type get_ret_type_helper(void (*p_func)(P...)) { return Variant::NIL; } -#define FUNCBINDR(m_func, m_args, m_category) \ - class Func_##m_func { \ - public: \ +#define FUNCBINDR(m_func, m_args, m_category) \ + class Func_##m_func { \ + public: \ static void call(Variant *r_ret, const Variant **p_args, int p_argcount, Callable::CallError &r_error) { \ - call_helperr(VariantUtilityFunctions::m_func, r_ret, p_args, r_error); \ - } \ - static void validated_call(Variant *r_ret, const Variant **p_args, int p_argcount) { \ - validated_call_helperr(VariantUtilityFunctions::m_func, r_ret, p_args); \ - } \ - static void ptrcall(void *ret, const void **p_args, int p_argcount) { \ - ptr_call_helperr(VariantUtilityFunctions::m_func, ret, p_args); \ - } \ - static int get_argument_count() { \ - return get_arg_count_helperr(VariantUtilityFunctions::m_func); \ - } \ - static Variant::Type get_argument_type(int p_arg) { \ - return get_arg_type_helperr(VariantUtilityFunctions::m_func, p_arg); \ - } \ - static Variant::Type get_return_type() { \ - return get_ret_type_helperr(VariantUtilityFunctions::m_func); \ - } \ - static bool has_return_type() { \ - return true; \ - } \ - static bool is_vararg() { \ - return false; \ - } \ - static Variant::UtilityFunctionType get_type() { \ - return m_category; \ - } \ - }; \ + call_helperr(VariantUtilityFunctions::m_func, r_ret, p_args, r_error); \ + } \ + static void validated_call(Variant *r_ret, const Variant **p_args, int p_argcount) { \ + validated_call_helperr(VariantUtilityFunctions::m_func, r_ret, p_args); \ + } \ + static void ptrcall(void *ret, const void **p_args, int p_argcount) { \ + ptr_call_helperr(VariantUtilityFunctions::m_func, ret, p_args); \ + } \ + static int get_argument_count() { \ + return get_arg_count_helperr(VariantUtilityFunctions::m_func); \ + } \ + static Variant::Type get_argument_type(int p_arg) { \ + return get_arg_type_helperr(VariantUtilityFunctions::m_func, p_arg); \ + } \ + static Variant::Type get_return_type() { \ + return get_ret_type_helperr(VariantUtilityFunctions::m_func); \ + } \ + static bool has_return_type() { \ + return true; \ + } \ + static bool is_vararg() { \ + return false; \ + } \ + static Variant::UtilityFunctionType get_type() { \ + return m_category; \ + } \ + }; \ register_utility_function(#m_func, m_args) -#define FUNCBINDVR(m_func, m_args, m_category) \ - class Func_##m_func { \ - public: \ - static void call(Variant *r_ret, const Variant **p_args, int p_argcount, Callable::CallError &r_error) { \ - r_error.error = Callable::CallError::CALL_OK; \ - *r_ret = VariantUtilityFunctions::m_func(*p_args[0], r_error); \ - } \ - static void validated_call(Variant *r_ret, const Variant **p_args, int p_argcount) { \ - Callable::CallError ce; \ - *r_ret = VariantUtilityFunctions::m_func(*p_args[0], ce); \ - } \ - static void ptrcall(void *ret, const void **p_args, int p_argcount) { \ - Callable::CallError ce; \ +#define FUNCBINDVR(m_func, m_args, m_category) \ + class Func_##m_func { \ + public: \ + static void call(Variant *r_ret, const Variant **p_args, int p_argcount, Callable::CallError &r_error) { \ + r_error.error = Callable::CallError::CALL_OK; \ + *r_ret = VariantUtilityFunctions::m_func(*p_args[0], r_error); \ + } \ + static void validated_call(Variant *r_ret, const Variant **p_args, int p_argcount) { \ + Callable::CallError ce; \ + *r_ret = VariantUtilityFunctions::m_func(*p_args[0], ce); \ + } \ + static void ptrcall(void *ret, const void **p_args, int p_argcount) { \ + Callable::CallError ce; \ PtrToArg::encode(VariantUtilityFunctions::m_func(PtrToArg::convert(p_args[0]), ce), ret); \ - } \ - static int get_argument_count() { \ - return 1; \ - } \ - static Variant::Type get_argument_type(int p_arg) { \ - return Variant::NIL; \ - } \ - static Variant::Type get_return_type() { \ - return Variant::NIL; \ - } \ - static bool has_return_type() { \ - return true; \ - } \ - static bool is_vararg() { \ - return false; \ - } \ - static Variant::UtilityFunctionType get_type() { \ - return m_category; \ - } \ - }; \ + } \ + static int get_argument_count() { \ + return 1; \ + } \ + static Variant::Type get_argument_type(int p_arg) { \ + return Variant::NIL; \ + } \ + static Variant::Type get_return_type() { \ + return Variant::NIL; \ + } \ + static bool has_return_type() { \ + return true; \ + } \ + static bool is_vararg() { \ + return false; \ + } \ + static Variant::UtilityFunctionType get_type() { \ + return m_category; \ + } \ + }; \ register_utility_function(#m_func, m_args) -#define FUNCBINDVR2(m_func, m_args, m_category) \ - class Func_##m_func { \ - public: \ - static void call(Variant *r_ret, const Variant **p_args, int p_argcount, Callable::CallError &r_error) { \ - r_error.error = Callable::CallError::CALL_OK; \ - *r_ret = VariantUtilityFunctions::m_func(*p_args[0], *p_args[1], r_error); \ - } \ - static void validated_call(Variant *r_ret, const Variant **p_args, int p_argcount) { \ - Callable::CallError ce; \ - *r_ret = VariantUtilityFunctions::m_func(*p_args[0], *p_args[1], ce); \ - } \ - static void ptrcall(void *ret, const void **p_args, int p_argcount) { \ - Callable::CallError ce; \ - Variant r; \ +#define FUNCBINDVR2(m_func, m_args, m_category) \ + class Func_##m_func { \ + public: \ + static void call(Variant *r_ret, const Variant **p_args, int p_argcount, Callable::CallError &r_error) { \ + r_error.error = Callable::CallError::CALL_OK; \ + *r_ret = VariantUtilityFunctions::m_func(*p_args[0], *p_args[1], r_error); \ + } \ + static void validated_call(Variant *r_ret, const Variant **p_args, int p_argcount) { \ + Callable::CallError ce; \ + *r_ret = VariantUtilityFunctions::m_func(*p_args[0], *p_args[1], ce); \ + } \ + static void ptrcall(void *ret, const void **p_args, int p_argcount) { \ + Callable::CallError ce; \ + Variant r; \ r = VariantUtilityFunctions::m_func(PtrToArg::convert(p_args[0]), PtrToArg::convert(p_args[1]), ce); \ - PtrToArg::encode(r, ret); \ - } \ - static int get_argument_count() { \ - return 2; \ - } \ - static Variant::Type get_argument_type(int p_arg) { \ - return Variant::NIL; \ - } \ - static Variant::Type get_return_type() { \ - return Variant::NIL; \ - } \ - static bool has_return_type() { \ - return true; \ - } \ - static bool is_vararg() { \ - return false; \ - } \ - static Variant::UtilityFunctionType get_type() { \ - return m_category; \ - } \ - }; \ + PtrToArg::encode(r, ret); \ + } \ + static int get_argument_count() { \ + return 2; \ + } \ + static Variant::Type get_argument_type(int p_arg) { \ + return Variant::NIL; \ + } \ + static Variant::Type get_return_type() { \ + return Variant::NIL; \ + } \ + static bool has_return_type() { \ + return true; \ + } \ + static bool is_vararg() { \ + return false; \ + } \ + static Variant::UtilityFunctionType get_type() { \ + return m_category; \ + } \ + }; \ register_utility_function(#m_func, m_args) -#define FUNCBINDVR3(m_func, m_args, m_category) \ - class Func_##m_func { \ - public: \ - static void call(Variant *r_ret, const Variant **p_args, int p_argcount, Callable::CallError &r_error) { \ - r_error.error = Callable::CallError::CALL_OK; \ - *r_ret = VariantUtilityFunctions::m_func(*p_args[0], *p_args[1], *p_args[2], r_error); \ - } \ - static void validated_call(Variant *r_ret, const Variant **p_args, int p_argcount) { \ - Callable::CallError ce; \ - *r_ret = VariantUtilityFunctions::m_func(*p_args[0], *p_args[1], *p_args[2], ce); \ - } \ - static void ptrcall(void *ret, const void **p_args, int p_argcount) { \ - Callable::CallError ce; \ - Variant r; \ +#define FUNCBINDVR3(m_func, m_args, m_category) \ + class Func_##m_func { \ + public: \ + static void call(Variant *r_ret, const Variant **p_args, int p_argcount, Callable::CallError &r_error) { \ + r_error.error = Callable::CallError::CALL_OK; \ + *r_ret = VariantUtilityFunctions::m_func(*p_args[0], *p_args[1], *p_args[2], r_error); \ + } \ + static void validated_call(Variant *r_ret, const Variant **p_args, int p_argcount) { \ + Callable::CallError ce; \ + *r_ret = VariantUtilityFunctions::m_func(*p_args[0], *p_args[1], *p_args[2], ce); \ + } \ + static void ptrcall(void *ret, const void **p_args, int p_argcount) { \ + Callable::CallError ce; \ + Variant r; \ r = VariantUtilityFunctions::m_func(PtrToArg::convert(p_args[0]), PtrToArg::convert(p_args[1]), PtrToArg::convert(p_args[2]), ce); \ - PtrToArg::encode(r, ret); \ - } \ - static int get_argument_count() { \ - return 3; \ - } \ - static Variant::Type get_argument_type(int p_arg) { \ - return Variant::NIL; \ - } \ - static Variant::Type get_return_type() { \ - return Variant::NIL; \ - } \ - static bool has_return_type() { \ - return true; \ - } \ - static bool is_vararg() { \ - return false; \ - } \ - static Variant::UtilityFunctionType get_type() { \ - return m_category; \ - } \ - }; \ + PtrToArg::encode(r, ret); \ + } \ + static int get_argument_count() { \ + return 3; \ + } \ + static Variant::Type get_argument_type(int p_arg) { \ + return Variant::NIL; \ + } \ + static Variant::Type get_return_type() { \ + return Variant::NIL; \ + } \ + static bool has_return_type() { \ + return true; \ + } \ + static bool is_vararg() { \ + return false; \ + } \ + static Variant::UtilityFunctionType get_type() { \ + return m_category; \ + } \ + }; \ register_utility_function(#m_func, m_args) -#define FUNCBINDVARARG(m_func, m_args, m_category) \ - class Func_##m_func { \ - public: \ +#define FUNCBINDVARARG(m_func, m_args, m_category) \ + class Func_##m_func { \ + public: \ static void call(Variant *r_ret, const Variant **p_args, int p_argcount, Callable::CallError &r_error) { \ - r_error.error = Callable::CallError::CALL_OK; \ - *r_ret = VariantUtilityFunctions::m_func(p_args, p_argcount, r_error); \ - } \ - static void validated_call(Variant *r_ret, const Variant **p_args, int p_argcount) { \ - Callable::CallError c; \ - *r_ret = VariantUtilityFunctions::m_func(p_args, p_argcount, c); \ - } \ - static void ptrcall(void *ret, const void **p_args, int p_argcount) { \ - Vector args; \ - for (int i = 0; i < p_argcount; i++) { \ - args.push_back(PtrToArg::convert(p_args[i])); \ - } \ - Vector argsp; \ - for (int i = 0; i < p_argcount; i++) { \ - argsp.push_back(&args[i]); \ - } \ - Variant r; \ - validated_call(&r, (const Variant **)argsp.ptr(), p_argcount); \ - PtrToArg::encode(r, ret); \ - } \ - static int get_argument_count() { \ - return 2; \ - } \ - static Variant::Type get_argument_type(int p_arg) { \ - return Variant::NIL; \ - } \ - static Variant::Type get_return_type() { \ - return Variant::NIL; \ - } \ - static bool has_return_type() { \ - return true; \ - } \ - static bool is_vararg() { \ - return true; \ - } \ - static Variant::UtilityFunctionType get_type() { \ - return m_category; \ - } \ - }; \ + r_error.error = Callable::CallError::CALL_OK; \ + *r_ret = VariantUtilityFunctions::m_func(p_args, p_argcount, r_error); \ + } \ + static void validated_call(Variant *r_ret, const Variant **p_args, int p_argcount) { \ + Callable::CallError c; \ + *r_ret = VariantUtilityFunctions::m_func(p_args, p_argcount, c); \ + } \ + static void ptrcall(void *ret, const void **p_args, int p_argcount) { \ + Vector args; \ + for (int i = 0; i < p_argcount; i++) { \ + args.push_back(PtrToArg::convert(p_args[i])); \ + } \ + Vector argsp; \ + for (int i = 0; i < p_argcount; i++) { \ + argsp.push_back(&args[i]); \ + } \ + Variant r; \ + validated_call(&r, (const Variant **)argsp.ptr(), p_argcount); \ + PtrToArg::encode(r, ret); \ + } \ + static int get_argument_count() { \ + return 2; \ + } \ + static Variant::Type get_argument_type(int p_arg) { \ + return Variant::NIL; \ + } \ + static Variant::Type get_return_type() { \ + return Variant::NIL; \ + } \ + static bool has_return_type() { \ + return true; \ + } \ + static bool is_vararg() { \ + return true; \ + } \ + static Variant::UtilityFunctionType get_type() { \ + return m_category; \ + } \ + }; \ register_utility_function(#m_func, m_args) -#define FUNCBINDVARARGS(m_func, m_args, m_category) \ - class Func_##m_func { \ - public: \ +#define FUNCBINDVARARGS(m_func, m_args, m_category) \ + class Func_##m_func { \ + public: \ static void call(Variant *r_ret, const Variant **p_args, int p_argcount, Callable::CallError &r_error) { \ - r_error.error = Callable::CallError::CALL_OK; \ - *r_ret = VariantUtilityFunctions::m_func(p_args, p_argcount, r_error); \ - } \ - static void validated_call(Variant *r_ret, const Variant **p_args, int p_argcount) { \ - Callable::CallError c; \ - *r_ret = VariantUtilityFunctions::m_func(p_args, p_argcount, c); \ - } \ - static void ptrcall(void *ret, const void **p_args, int p_argcount) { \ - Vector args; \ - for (int i = 0; i < p_argcount; i++) { \ - args.push_back(PtrToArg::convert(p_args[i])); \ - } \ - Vector argsp; \ - for (int i = 0; i < p_argcount; i++) { \ - argsp.push_back(&args[i]); \ - } \ - Variant r; \ - validated_call(&r, (const Variant **)argsp.ptr(), p_argcount); \ - PtrToArg::encode(r.operator String(), ret); \ - } \ - static int get_argument_count() { \ - return 1; \ - } \ - static Variant::Type get_argument_type(int p_arg) { \ - return Variant::NIL; \ - } \ - static Variant::Type get_return_type() { \ - return Variant::STRING; \ - } \ - static bool has_return_type() { \ - return true; \ - } \ - static bool is_vararg() { \ - return true; \ - } \ - static Variant::UtilityFunctionType get_type() { \ - return m_category; \ - } \ - }; \ + r_error.error = Callable::CallError::CALL_OK; \ + *r_ret = VariantUtilityFunctions::m_func(p_args, p_argcount, r_error); \ + } \ + static void validated_call(Variant *r_ret, const Variant **p_args, int p_argcount) { \ + Callable::CallError c; \ + *r_ret = VariantUtilityFunctions::m_func(p_args, p_argcount, c); \ + } \ + static void ptrcall(void *ret, const void **p_args, int p_argcount) { \ + Vector args; \ + for (int i = 0; i < p_argcount; i++) { \ + args.push_back(PtrToArg::convert(p_args[i])); \ + } \ + Vector argsp; \ + for (int i = 0; i < p_argcount; i++) { \ + argsp.push_back(&args[i]); \ + } \ + Variant r; \ + validated_call(&r, (const Variant **)argsp.ptr(), p_argcount); \ + PtrToArg::encode(r.operator String(), ret); \ + } \ + static int get_argument_count() { \ + return 1; \ + } \ + static Variant::Type get_argument_type(int p_arg) { \ + return Variant::NIL; \ + } \ + static Variant::Type get_return_type() { \ + return Variant::STRING; \ + } \ + static bool has_return_type() { \ + return true; \ + } \ + static bool is_vararg() { \ + return true; \ + } \ + static Variant::UtilityFunctionType get_type() { \ + return m_category; \ + } \ + }; \ register_utility_function(#m_func, m_args) -#define FUNCBINDVARARGV_CNAME(m_func, m_func_cname, m_args, m_category) \ - class Func_##m_func { \ - public: \ +#define FUNCBINDVARARGV_CNAME(m_func, m_func_cname, m_args, m_category) \ + class Func_##m_func { \ + public: \ static void call(Variant *r_ret, const Variant **p_args, int p_argcount, Callable::CallError &r_error) { \ - r_error.error = Callable::CallError::CALL_OK; \ - VariantUtilityFunctions::m_func_cname(p_args, p_argcount, r_error); \ - } \ - static void validated_call(Variant *r_ret, const Variant **p_args, int p_argcount) { \ - Callable::CallError c; \ - VariantUtilityFunctions::m_func_cname(p_args, p_argcount, c); \ - } \ - static void ptrcall(void *ret, const void **p_args, int p_argcount) { \ - Vector args; \ - for (int i = 0; i < p_argcount; i++) { \ - args.push_back(PtrToArg::convert(p_args[i])); \ - } \ - Vector argsp; \ - for (int i = 0; i < p_argcount; i++) { \ - argsp.push_back(&args[i]); \ - } \ - Variant r; \ - validated_call(&r, (const Variant **)argsp.ptr(), p_argcount); \ - } \ - static int get_argument_count() { \ - return 1; \ - } \ - static Variant::Type get_argument_type(int p_arg) { \ - return Variant::NIL; \ - } \ - static Variant::Type get_return_type() { \ - return Variant::NIL; \ - } \ - static bool has_return_type() { \ - return false; \ - } \ - static bool is_vararg() { \ - return true; \ - } \ - static Variant::UtilityFunctionType get_type() { \ - return m_category; \ - } \ - }; \ + r_error.error = Callable::CallError::CALL_OK; \ + VariantUtilityFunctions::m_func_cname(p_args, p_argcount, r_error); \ + } \ + static void validated_call(Variant *r_ret, const Variant **p_args, int p_argcount) { \ + Callable::CallError c; \ + VariantUtilityFunctions::m_func_cname(p_args, p_argcount, c); \ + } \ + static void ptrcall(void *ret, const void **p_args, int p_argcount) { \ + Vector args; \ + for (int i = 0; i < p_argcount; i++) { \ + args.push_back(PtrToArg::convert(p_args[i])); \ + } \ + Vector argsp; \ + for (int i = 0; i < p_argcount; i++) { \ + argsp.push_back(&args[i]); \ + } \ + Variant r; \ + validated_call(&r, (const Variant **)argsp.ptr(), p_argcount); \ + } \ + static int get_argument_count() { \ + return 1; \ + } \ + static Variant::Type get_argument_type(int p_arg) { \ + return Variant::NIL; \ + } \ + static Variant::Type get_return_type() { \ + return Variant::NIL; \ + } \ + static bool has_return_type() { \ + return false; \ + } \ + static bool is_vararg() { \ + return true; \ + } \ + static Variant::UtilityFunctionType get_type() { \ + return m_category; \ + } \ + }; \ register_utility_function(#m_func, m_args) #define FUNCBINDVARARGV(m_func, m_args, m_category) FUNCBINDVARARGV_CNAME(m_func, m_func, m_args, m_category) -#define FUNCBIND(m_func, m_args, m_category) \ - class Func_##m_func { \ - public: \ +#define FUNCBIND(m_func, m_args, m_category) \ + class Func_##m_func { \ + public: \ static void call(Variant *r_ret, const Variant **p_args, int p_argcount, Callable::CallError &r_error) { \ - call_helper(VariantUtilityFunctions::m_func, p_args, r_error); \ - } \ - static void validated_call(Variant *r_ret, const Variant **p_args, int p_argcount) { \ - validated_call_helper(VariantUtilityFunctions::m_func, p_args); \ - } \ - static void ptrcall(void *ret, const void **p_args, int p_argcount) { \ - ptr_call_helper(VariantUtilityFunctions::m_func, p_args); \ - } \ - static int get_argument_count() { \ - return get_arg_count_helper(VariantUtilityFunctions::m_func); \ - } \ - static Variant::Type get_argument_type(int p_arg) { \ - return get_arg_type_helper(VariantUtilityFunctions::m_func, p_arg); \ - } \ - static Variant::Type get_return_type() { \ - return get_ret_type_helper(VariantUtilityFunctions::m_func); \ - } \ - static bool has_return_type() { \ - return false; \ - } \ - static bool is_vararg() { \ - return false; \ - } \ - static Variant::UtilityFunctionType get_type() { \ - return m_category; \ - } \ - }; \ + call_helper(VariantUtilityFunctions::m_func, p_args, r_error); \ + } \ + static void validated_call(Variant *r_ret, const Variant **p_args, int p_argcount) { \ + validated_call_helper(VariantUtilityFunctions::m_func, p_args); \ + } \ + static void ptrcall(void *ret, const void **p_args, int p_argcount) { \ + ptr_call_helper(VariantUtilityFunctions::m_func, p_args); \ + } \ + static int get_argument_count() { \ + return get_arg_count_helper(VariantUtilityFunctions::m_func); \ + } \ + static Variant::Type get_argument_type(int p_arg) { \ + return get_arg_type_helper(VariantUtilityFunctions::m_func, p_arg); \ + } \ + static Variant::Type get_return_type() { \ + return get_ret_type_helper(VariantUtilityFunctions::m_func); \ + } \ + static bool has_return_type() { \ + return false; \ + } \ + static bool is_vararg() { \ + return false; \ + } \ + static Variant::UtilityFunctionType get_type() { \ + return m_category; \ + } \ + }; \ register_utility_function(#m_func, m_args) struct VariantUtilityFunctionInfo { diff --git a/drivers/alsa/audio_driver_alsa.cpp b/drivers/alsa/audio_driver_alsa.cpp index 960f0fb9ada..126d47f8ca8 100644 --- a/drivers/alsa/audio_driver_alsa.cpp +++ b/drivers/alsa/audio_driver_alsa.cpp @@ -62,14 +62,14 @@ Error AudioDriverALSA::init_output_device() { snd_pcm_hw_params_t *hwparams; snd_pcm_sw_params_t *swparams; -#define CHECK_FAIL(m_cond) \ - if (m_cond) { \ +#define CHECK_FAIL(m_cond) \ + if (m_cond) { \ fprintf(stderr, "ALSA ERR: %s\n", snd_strerror(status)); \ - if (pcm_handle) { \ - snd_pcm_close(pcm_handle); \ - pcm_handle = nullptr; \ - } \ - ERR_FAIL_COND_V(m_cond, ERR_CANT_OPEN); \ + if (pcm_handle) { \ + snd_pcm_close(pcm_handle); \ + pcm_handle = nullptr; \ + } \ + ERR_FAIL_COND_V(m_cond, ERR_CANT_OPEN); \ } //todo, add diff --git a/drivers/apple_embedded/platform_config.h b/drivers/apple_embedded/platform_config.h index bc8b45603ab..3e46717d282 100644 --- a/drivers/apple_embedded/platform_config.h +++ b/drivers/apple_embedded/platform_config.h @@ -37,8 +37,8 @@ #define PTHREAD_RENAME_SELF #define _weakify(var) __weak typeof(var) GDWeak_##var = var; -#define _strongify(var) \ - _Pragma("clang diagnostic push") \ +#define _strongify(var) \ + _Pragma("clang diagnostic push") \ _Pragma("clang diagnostic ignored \"-Wshadow\"") \ __strong typeof(var) var = GDWeak_##var; \ _Pragma("clang diagnostic pop") diff --git a/drivers/metal/metal_objects.h b/drivers/metal/metal_objects.h index 8f6e3222cd6..1d3d512f557 100644 --- a/drivers/metal/metal_objects.h +++ b/drivers/metal/metal_objects.h @@ -1075,9 +1075,9 @@ public: }; namespace rid { -#define MAKE_ID(FROM, TO) \ +#define MAKE_ID(FROM, TO) \ _FORCE_INLINE_ TO make(FROM p_obj) { \ - return TO(owned(p_obj)); \ + return TO(owned(p_obj)); \ } MAKE_ID(id, RDD::CommandPoolID) diff --git a/drivers/metal/metal_objects_shared.h b/drivers/metal/metal_objects_shared.h index d74072c95a0..ce7993a6b8d 100644 --- a/drivers/metal/metal_objects_shared.h +++ b/drivers/metal/metal_objects_shared.h @@ -38,14 +38,14 @@ using RDC = RenderingDeviceCommons; // These types can be used in Vector and other containers that use // pointer operations not supported by ARC. namespace MTL { -#define MTL_CLASS(name) \ - class name { \ - public: \ +#define MTL_CLASS(name) \ + class name { \ + public: \ name(id obj = nil) : m_obj(obj) {} \ - operator id() const { \ - return m_obj; \ - } \ - id m_obj; \ + operator id() const { \ + return m_obj; \ + } \ + id m_obj; \ }; MTL_CLASS(Texture) @@ -169,9 +169,9 @@ _FORCE_INLINE_ void *owned(id p_id) { return (__bridge_retained void *)p_id; } -#define MAKE_ID(FROM, TO) \ +#define MAKE_ID(FROM, TO) \ _FORCE_INLINE_ TO make(FROM p_obj) { \ - return TO(owned(p_obj)); \ + return TO(owned(p_obj)); \ } // These are shared for Metal and Metal 4 drivers diff --git a/drivers/metal/pixel_formats.mm b/drivers/metal/pixel_formats.mm index ba15ca026ea..386f1090408 100644 --- a/drivers/metal/pixel_formats.mm +++ b/drivers/metal/pixel_formats.mm @@ -279,10 +279,10 @@ PixelFormats::PixelFormats(id p_device, const MetalFeatures &p_feat) } #define addDataFormatDescFull(DATA_FMT, MTL_FMT, MTL_FMT_ALT, MTL_VTX_FMT, MTL_VTX_FMT_ALT, CSPC, CSCB, BLK_W, BLK_H, BLK_BYTE_CNT, MVK_FMT_TYPE, SWIZ_R, SWIZ_G, SWIZ_B, SWIZ_A) \ - dfFmt = RD::DATA_FORMAT_##DATA_FMT; \ - _data_format_descs[dfFmt] = { dfFmt, MTLPixelFormat##MTL_FMT, MTLPixelFormat##MTL_FMT_ALT, MTLVertexFormat##MTL_VTX_FMT, MTLVertexFormat##MTL_VTX_FMT_ALT, \ - CSPC, CSCB, { BLK_W, BLK_H }, BLK_BYTE_CNT, MTLFormatType::MVK_FMT_TYPE, \ - { RD::TEXTURE_SWIZZLE_##SWIZ_R, RD::TEXTURE_SWIZZLE_##SWIZ_G, RD::TEXTURE_SWIZZLE_##SWIZ_B, RD::TEXTURE_SWIZZLE_##SWIZ_A }, \ + dfFmt = RD::DATA_FORMAT_##DATA_FMT; \ + _data_format_descs[dfFmt] = { dfFmt, MTLPixelFormat##MTL_FMT, MTLPixelFormat##MTL_FMT_ALT, MTLVertexFormat##MTL_VTX_FMT, MTLVertexFormat##MTL_VTX_FMT_ALT, \ + CSPC, CSCB, { BLK_W, BLK_H }, BLK_BYTE_CNT, MTLFormatType::MVK_FMT_TYPE, \ + { RD::TEXTURE_SWIZZLE_##SWIZ_R, RD::TEXTURE_SWIZZLE_##SWIZ_G, RD::TEXTURE_SWIZZLE_##SWIZ_B, RD::TEXTURE_SWIZZLE_##SWIZ_A }, \ "DATA_FORMAT_" #DATA_FMT, false } #define addDataFormatDesc(VK_FMT, MTL_FMT, MTL_FMT_ALT, MTL_VTX_FMT, MTL_VTX_FMT_ALT, BLK_W, BLK_H, BLK_BYTE_CNT, MVK_FMT_TYPE) \ @@ -582,20 +582,20 @@ void PixelFormats::addMTLPixelFormatDescImpl(MTLPixelFormat p_pix_fmt, MTLPixelF _mtl_pixel_format_descs[p_pix_fmt] = { .mtlPixelFormat = p_pix_fmt, DataFormat::DATA_FORMAT_MAX, p_fmt_caps, p_view_class, p_pix_fmt_linear, p_name }; } -#define addMTLPixelFormatDescFull(mtlFmt, mtlFmtLinear, viewClass, appleGPUCaps) \ +#define addMTLPixelFormatDescFull(mtlFmt, mtlFmtLinear, viewClass, appleGPUCaps) \ addMTLPixelFormatDescImpl(MTLPixelFormat##mtlFmt, MTLPixelFormat##mtlFmtLinear, MTLViewClass::viewClass, \ appleGPUCaps, "MTLPixelFormat" #mtlFmt) #define addMTLPixelFormatDesc(mtlFmt, viewClass, appleGPUCaps) \ addMTLPixelFormatDescFull(mtlFmt, mtlFmt, viewClass, kMTLFmtCaps##appleGPUCaps) -#define addMTLPixelFormatDescSRGB(mtlFmt, viewClass, appleGPUCaps, mtlFmtLinear) \ - /* Cannot write to sRGB textures in the simulator */ \ - if (TARGET_OS_SIMULATOR) { \ - MTLFmtCaps appleFmtCaps = kMTLFmtCaps##appleGPUCaps; \ - flags::clear(appleFmtCaps, kMTLFmtCapsWrite); \ - addMTLPixelFormatDescFull(mtlFmt, mtlFmtLinear, viewClass, appleFmtCaps); \ - } else { \ +#define addMTLPixelFormatDescSRGB(mtlFmt, viewClass, appleGPUCaps, mtlFmtLinear) \ + /* Cannot write to sRGB textures in the simulator */ \ + if (TARGET_OS_SIMULATOR) { \ + MTLFmtCaps appleFmtCaps = kMTLFmtCaps##appleGPUCaps; \ + flags::clear(appleFmtCaps, kMTLFmtCapsWrite); \ + addMTLPixelFormatDescFull(mtlFmt, mtlFmtLinear, viewClass, appleFmtCaps); \ + } else { \ addMTLPixelFormatDescFull(mtlFmt, mtlFmtLinear, viewClass, kMTLFmtCaps##appleGPUCaps); \ } @@ -787,8 +787,8 @@ void PixelFormats::addMTLVertexFormatDescImpl(MTLVertexFormat mtlVtxFmt, MTLFmtC } // Check mtlVtx exists on platform, to avoid overwriting the MTLVertexFormatInvalid entry. -#define addMTLVertexFormatDesc(mtlVtx) \ - if (MTLVertexFormat##mtlVtx) { \ +#define addMTLVertexFormatDesc(mtlVtx) \ + if (MTLVertexFormat##mtlVtx) { \ addMTLVertexFormatDescImpl(MTLVertexFormat##mtlVtx, kMTLFmtCapsVertex, "MTLVertexFormat" #mtlVtx); \ } diff --git a/drivers/metal/rendering_device_driver_metal.mm b/drivers/metal/rendering_device_driver_metal.mm index 7840bad20a5..654196d943c 100644 --- a/drivers/metal/rendering_device_driver_metal.mm +++ b/drivers/metal/rendering_device_driver_metal.mm @@ -2485,13 +2485,13 @@ uint64_t RenderingDeviceDriverMetal::limit_get(Limit p_limit) { MetalLimits const &limits = props.limits; uint64_t safe_unbounded = ((uint64_t)1 << 30); #if defined(DEV_ENABLED) -#define UNKNOWN(NAME) \ - case NAME: \ +#define UNKNOWN(NAME) \ + case NAME: \ WARN_PRINT_ONCE("Returning maximum value for unknown limit " #NAME "."); \ return safe_unbounded; #else #define UNKNOWN(NAME) \ - case NAME: \ + case NAME: \ return safe_unbounded #endif diff --git a/drivers/sdl/joypad_sdl.cpp b/drivers/sdl/joypad_sdl.cpp index ee1ab101b12..4848dc87367 100644 --- a/drivers/sdl/joypad_sdl.cpp +++ b/drivers/sdl/joypad_sdl.cpp @@ -47,9 +47,9 @@ JoypadSDL *JoypadSDL::singleton = nullptr; // Macro to skip the SDL joystick event handling if the device is an SDL gamepad, because // there are separate events for SDL gamepads -#define SKIP_EVENT_FOR_GAMEPAD \ +#define SKIP_EVENT_FOR_GAMEPAD \ if (SDL_IsGamepad(sdl_event.jdevice.which)) { \ - continue; \ + continue; \ } JoypadSDL::JoypadSDL() { diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index 044e9a0cf6d..7e8292c6e96 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -711,23 +711,23 @@ PackedByteArray OS_Unix::string_to_multibyte(const String &p_encoding, const Str } Dictionary OS_Unix::execute_with_pipe(const String &p_path, const List &p_arguments, bool p_blocking) { -#define CLEAN_PIPES \ - if (pipe_in[0] >= 0) { \ - ::close(pipe_in[0]); \ - } \ - if (pipe_in[1] >= 0) { \ - ::close(pipe_in[1]); \ - } \ - if (pipe_out[0] >= 0) { \ +#define CLEAN_PIPES \ + if (pipe_in[0] >= 0) { \ + ::close(pipe_in[0]); \ + } \ + if (pipe_in[1] >= 0) { \ + ::close(pipe_in[1]); \ + } \ + if (pipe_out[0] >= 0) { \ ::close(pipe_out[0]); \ - } \ - if (pipe_out[1] >= 0) { \ + } \ + if (pipe_out[1] >= 0) { \ ::close(pipe_out[1]); \ - } \ - if (pipe_err[0] >= 0) { \ + } \ + if (pipe_err[0] >= 0) { \ ::close(pipe_err[0]); \ - } \ - if (pipe_err[1] >= 0) { \ + } \ + if (pipe_err[1] >= 0) { \ ::close(pipe_err[1]); \ } diff --git a/drivers/vulkan/rendering_device_driver_vulkan.cpp b/drivers/vulkan/rendering_device_driver_vulkan.cpp index b852f86df5e..742a10bd4f4 100644 --- a/drivers/vulkan/rendering_device_driver_vulkan.cpp +++ b/drivers/vulkan/rendering_device_driver_vulkan.cpp @@ -738,10 +738,10 @@ Error RenderingDeviceDriverVulkan::_check_device_features() { // - sparseResidencyAliased // - inheritedQueries -#define VK_DEVICEFEATURE_ENABLE_IF(x) \ - if (physical_device_features.x) { \ +#define VK_DEVICEFEATURE_ENABLE_IF(x) \ + if (physical_device_features.x) { \ requested_device_features.x = physical_device_features.x; \ - } else \ + } else \ ((void)0) requested_device_features = {}; diff --git a/drivers/wasapi/audio_driver_wasapi.cpp b/drivers/wasapi/audio_driver_wasapi.cpp index 3cdfd4ca545..2d9399fe6a8 100644 --- a/drivers/wasapi/audio_driver_wasapi.cpp +++ b/drivers/wasapi/audio_driver_wasapi.cpp @@ -110,10 +110,10 @@ const IID IID_IAudioClient3 = __uuidof(IAudioClient3); const IID IID_IAudioRenderClient = __uuidof(IAudioRenderClient); const IID IID_IAudioCaptureClient = __uuidof(IAudioCaptureClient); -#define SAFE_RELEASE(memory) \ +#define SAFE_RELEASE(memory) \ if ((memory) != nullptr) { \ - (memory)->Release(); \ - (memory) = nullptr; \ + (memory)->Release(); \ + (memory) = nullptr; \ } #define REFTIMES_PER_SEC 10000000 diff --git a/editor/doc/editor_help.cpp b/editor/doc/editor_help.cpp index b20e9ccee8a..6874360bbe2 100644 --- a/editor/doc/editor_help.cpp +++ b/editor/doc/editor_help.cpp @@ -488,56 +488,56 @@ void EditorHelp::_add_type_icon(const String &p_type, int p_size, const String & // Macros for assigning the deprecated/experimental marks to class members in overview. -#define DEPRECATED_DOC_TAG \ - class_desc->push_font(theme_cache.doc_bold_font); \ +#define DEPRECATED_DOC_TAG \ + class_desc->push_font(theme_cache.doc_bold_font); \ class_desc->push_color(get_theme_color(SNAME("error_color"), EditorStringName(Editor))); \ - Ref error_icon = get_editor_theme_icon(SNAME("StatusError")); \ - class_desc->add_image(error_icon, error_icon->get_width(), error_icon->get_height()); \ - class_desc->add_text(String::chr(160) + TTR("Deprecated")); \ - class_desc->pop(); \ + Ref error_icon = get_editor_theme_icon(SNAME("StatusError")); \ + class_desc->add_image(error_icon, error_icon->get_width(), error_icon->get_height()); \ + class_desc->add_text(String::chr(160) + TTR("Deprecated")); \ + class_desc->pop(); \ class_desc->pop(); -#define EXPERIMENTAL_DOC_TAG \ - class_desc->push_font(theme_cache.doc_bold_font); \ - class_desc->push_color(get_theme_color(SNAME("warning_color"), EditorStringName(Editor))); \ - Ref warning_icon = get_editor_theme_icon(SNAME("NodeWarning")); \ +#define EXPERIMENTAL_DOC_TAG \ + class_desc->push_font(theme_cache.doc_bold_font); \ + class_desc->push_color(get_theme_color(SNAME("warning_color"), EditorStringName(Editor))); \ + Ref warning_icon = get_editor_theme_icon(SNAME("NodeWarning")); \ class_desc->add_image(warning_icon, warning_icon->get_width(), warning_icon->get_height()); \ - class_desc->add_text(String::chr(160) + TTR("Experimental")); \ - class_desc->pop(); \ + class_desc->add_text(String::chr(160) + TTR("Experimental")); \ + class_desc->pop(); \ class_desc->pop(); // Macros for displaying the deprecated/experimental info in class member descriptions. -#define DEPRECATED_DOC_MSG(m_message, m_default_message) \ - Ref error_icon = get_editor_theme_icon(SNAME("StatusError")); \ - class_desc->add_image(error_icon, error_icon->get_width(), error_icon->get_height()); \ - class_desc->add_text(nbsp); \ +#define DEPRECATED_DOC_MSG(m_message, m_default_message) \ + Ref error_icon = get_editor_theme_icon(SNAME("StatusError")); \ + class_desc->add_image(error_icon, error_icon->get_width(), error_icon->get_height()); \ + class_desc->add_text(nbsp); \ class_desc->push_color(get_theme_color(SNAME("error_color"), EditorStringName(Editor))); \ - class_desc->push_font(theme_cache.doc_bold_font); \ - class_desc->add_text(TTR("Deprecated:")); \ - class_desc->pop(); \ - class_desc->pop(); \ - class_desc->add_text(" "); \ - if ((m_message).is_empty()) { \ - class_desc->add_text(m_default_message); \ - } else { \ - _add_text(m_message); \ + class_desc->push_font(theme_cache.doc_bold_font); \ + class_desc->add_text(TTR("Deprecated:")); \ + class_desc->pop(); \ + class_desc->pop(); \ + class_desc->add_text(" "); \ + if ((m_message).is_empty()) { \ + class_desc->add_text(m_default_message); \ + } else { \ + _add_text(m_message); \ } -#define EXPERIMENTAL_DOC_MSG(m_message, m_default_message) \ - Ref warning_icon = get_editor_theme_icon(SNAME("NodeWarning")); \ +#define EXPERIMENTAL_DOC_MSG(m_message, m_default_message) \ + Ref warning_icon = get_editor_theme_icon(SNAME("NodeWarning")); \ class_desc->add_image(warning_icon, warning_icon->get_width(), warning_icon->get_height()); \ - class_desc->add_text(nbsp); \ - class_desc->push_color(get_theme_color(SNAME("warning_color"), EditorStringName(Editor))); \ - class_desc->push_font(theme_cache.doc_bold_font); \ - class_desc->add_text(TTR("Experimental:")); \ - class_desc->pop(); \ - class_desc->pop(); \ - class_desc->add_text(" "); \ - if ((m_message).is_empty()) { \ - class_desc->add_text(m_default_message); \ - } else { \ - _add_text(m_message); \ + class_desc->add_text(nbsp); \ + class_desc->push_color(get_theme_color(SNAME("warning_color"), EditorStringName(Editor))); \ + class_desc->push_font(theme_cache.doc_bold_font); \ + class_desc->add_text(TTR("Experimental:")); \ + class_desc->pop(); \ + class_desc->pop(); \ + class_desc->add_text(" "); \ + if ((m_message).is_empty()) { \ + class_desc->add_text(m_default_message); \ + } else { \ + _add_text(m_message); \ } void EditorHelp::_add_method(const DocData::MethodDoc &p_method, bool p_overview, bool p_override) { diff --git a/editor/docks/scene_tree_dock.cpp b/editor/docks/scene_tree_dock.cpp index e43d979e6ff..615634d67b1 100644 --- a/editor/docks/scene_tree_dock.cpp +++ b/editor/docks/scene_tree_dock.cpp @@ -3845,21 +3845,21 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { bool section_ended = false; // Marks beginning of a new separated section. When used multiple times in a row, only first use has effect. -#define BEGIN_SECTION() \ - { \ - if (section_ended) { \ +#define BEGIN_SECTION() \ + { \ + if (section_ended) { \ section_ended = false; \ menu->add_separator(); \ - } \ - section_started = true; \ + } \ + section_started = true; \ } // Marks end of a section. -#define END_SECTION() \ - { \ - if (section_started) { \ - section_ended = true; \ +#define END_SECTION() \ + { \ + if (section_started) { \ + section_ended = true; \ section_started = false; \ - } \ + } \ } Ref