Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions core/error/error_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ void _physics_interpolation_warning(const char *p_function, const char *p_file,
#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)); \
GODOT_DEPRECATED_BEGIN \
return m_retval; \
GODOT_DEPRECATED_END \
} else \
((void)0)

Expand All @@ -186,7 +188,9 @@ void _physics_interpolation_warning(const char *p_function, const char *p_file,
#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); \
GODOT_DEPRECATED_BEGIN \
return m_retval; \
GODOT_DEPRECATED_END \
} else \
((void)0)

Expand All @@ -196,7 +200,9 @@ void _physics_interpolation_warning(const char *p_function, const char *p_file,
#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); \
GODOT_DEPRECATED_BEGIN \
return m_retval; \
GODOT_DEPRECATED_END \
} else \
((void)0)

Expand Down Expand Up @@ -278,7 +284,9 @@ void _physics_interpolation_warning(const char *p_function, const char *p_file,
#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)); \
GODOT_DEPRECATED_BEGIN \
return m_retval; \
GODOT_DEPRECATED_END \
} else \
((void)0)

Expand All @@ -289,7 +297,9 @@ void _physics_interpolation_warning(const char *p_function, const char *p_file,
#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); \
GODOT_DEPRECATED_BEGIN \
return m_retval; \
GODOT_DEPRECATED_END \
} else \
((void)0)

Expand All @@ -299,7 +309,9 @@ void _physics_interpolation_warning(const char *p_function, const char *p_file,
#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); \
GODOT_DEPRECATED_BEGIN \
return m_retval; \
GODOT_DEPRECATED_END \
} else \
((void)0)

Expand Down Expand Up @@ -381,7 +393,9 @@ void _physics_interpolation_warning(const char *p_function, const char *p_file,
#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."); \
GODOT_DEPRECATED_BEGIN \
return m_retval; \
GODOT_DEPRECATED_END \
} else \
((void)0)

Expand All @@ -392,7 +406,9 @@ void _physics_interpolation_warning(const char *p_function, const char *p_file,
#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); \
GODOT_DEPRECATED_BEGIN \
return m_retval; \
GODOT_DEPRECATED_END \
} else \
((void)0)

Expand All @@ -402,7 +418,9 @@ void _physics_interpolation_warning(const char *p_function, const char *p_file,
#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); \
GODOT_DEPRECATED_BEGIN \
return m_retval; \
GODOT_DEPRECATED_END \
} else \
((void)0)

Expand Down Expand Up @@ -458,7 +476,9 @@ void _physics_interpolation_warning(const char *p_function, const char *p_file,
#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)); \
GODOT_DEPRECATED_BEGIN \
return m_retval; \
GODOT_DEPRECATED_END \
} else \
((void)0)

Expand All @@ -472,7 +492,9 @@ void _physics_interpolation_warning(const char *p_function, const char *p_file,
#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); \
GODOT_DEPRECATED_BEGIN \
return m_retval; \
GODOT_DEPRECATED_END \
} else \
((void)0)

Expand All @@ -482,7 +504,9 @@ void _physics_interpolation_warning(const char *p_function, const char *p_file,
#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); \
GODOT_DEPRECATED_BEGIN \
return m_retval; \
GODOT_DEPRECATED_END \
} else \
((void)0)

Expand Down Expand Up @@ -636,7 +660,9 @@ void _physics_interpolation_warning(const char *p_function, const char *p_file,
#define ERR_FAIL_V(m_retval) \
if (true) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Method/function failed. Returning: " _STR(m_retval)); \
GODOT_DEPRECATED_BEGIN \
return m_retval; \
GODOT_DEPRECATED_END \
} else \
((void)0)

Expand All @@ -649,7 +675,9 @@ void _physics_interpolation_warning(const char *p_function, const char *p_file,
#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); \
GODOT_DEPRECATED_BEGIN \
return m_retval; \
GODOT_DEPRECATED_END \
} else \
((void)0)

Expand All @@ -659,7 +687,9 @@ void _physics_interpolation_warning(const char *p_function, const char *p_file,
#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); \
GODOT_DEPRECATED_BEGIN \
return m_retval; \
GODOT_DEPRECATED_END \
} else \
((void)0)

Expand Down
2 changes: 1 addition & 1 deletion core/extension/extension_api_dump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ static String get_property_info_type_name(const PropertyInfo &p_info) {
}

static String get_type_meta_name(const GodotTypeInfo::Metadata metadata) {
static const char *argmeta[13] = { "none", "int8", "int16", "int32", "int64", "uint8", "uint16", "uint32", "uint64", "float", "double", "char16", "char32" };
static const char *argmeta[14] = { "none", "int8", "int16", "int32", "int64", "uint8", "uint16", "uint32", "uint64", "float", "double", "char16", "char32", "required" };
return argmeta[metadata];
}

Expand Down
1 change: 1 addition & 0 deletions core/extension/gdextension_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ typedef enum {
GDEXTENSION_METHOD_ARGUMENT_METADATA_REAL_IS_DOUBLE,
GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_CHAR16,
GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_CHAR32,
GDEXTENSION_METHOD_ARGUMENT_METADATA_OBJECT_IS_REQUIRED,
} GDExtensionClassMethodArgumentMetadata;

typedef void (*GDExtensionClassMethodCall)(void *method_userdata, GDExtensionClassInstancePtr p_instance, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionVariantPtr r_return, GDExtensionCallError *r_error);
Expand Down
4 changes: 2 additions & 2 deletions core/io/resource_saver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ void ResourceFormatSaver::_bind_methods() {
GDVIRTUAL_BIND(_recognize_path, "resource", "path");
}

Error ResourceSaver::save(const Ref<Resource> &p_resource, const String &p_path, uint32_t p_flags) {
ERR_FAIL_COND_V_MSG(p_resource.is_null(), ERR_INVALID_PARAMETER, vformat("Can't save empty resource to path '%s'.", p_path));
Error ResourceSaver::save(const RequiredParam<Resource> &rp_resource, const String &p_path, uint32_t p_flags) {
EXTRACT_REQUIRED_PARAM_OR_FAIL_V_MSG(p_resource, rp_resource, ERR_INVALID_PARAMETER, vformat("Can't save empty resource to path '%s'.", p_path));
String path = p_path;
if (path.is_empty()) {
path = p_resource->get_path();
Expand Down
2 changes: 1 addition & 1 deletion core/io/resource_saver.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class ResourceSaver {
FLAG_REPLACE_SUBRESOURCE_PATHS = 64,
};

static Error save(const Ref<Resource> &p_resource, const String &p_path = "", uint32_t p_flags = (uint32_t)FLAG_NONE);
static Error save(const RequiredParam<Resource> &p_resource, const String &p_path = "", uint32_t p_flags = (uint32_t)FLAG_NONE);
static void get_recognized_extensions(const Ref<Resource> &p_resource, List<String> *p_extensions);
static void add_resource_format_saver(Ref<ResourceFormatSaver> p_format_saver, bool p_at_front = false);
static void remove_resource_format_saver(Ref<ResourceFormatSaver> p_format_saver);
Expand Down
1 change: 1 addition & 0 deletions core/object/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "core/templates/hash_set.h"
#include "core/templates/list.h"
#include "core/templates/safe_refcount.h"
#include "core/variant/required_ptr.h"
#include "core/variant/variant.h"

template <typename T>
Expand Down
9 changes: 9 additions & 0 deletions core/typedefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,15 @@ inline constexpr bool is_zero_constructible_v = is_zero_constructible<T>::value;
#define GODOT_MSVC_WARNING_PUSH_AND_IGNORE(m_warning)
#endif

#define GODOT_DEPRECATED_BEGIN \
GODOT_CLANG_WARNING_PUSH_AND_IGNORE("-Wdeprecated-declarations") \
GODOT_GCC_WARNING_PUSH_AND_IGNORE("-Wdeprecated-declarations") \
GODOT_MSVC_WARNING_PUSH_AND_IGNORE(4996)
#define GODOT_DEPRECATED_END \
GODOT_CLANG_WARNING_POP \
GODOT_GCC_WARNING_POP \
GODOT_MSVC_WARNING_POP

template <typename T, typename = void>
struct is_fully_defined : std::false_type {};

Expand Down
1 change: 1 addition & 0 deletions core/variant/binder_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "core/templates/simple_type.h"
#include "core/typedefs.h"
#include "core/variant/method_ptrcall.h"
#include "core/variant/required_ptr.h"
#include "core/variant/type_info.h"
#include "core/variant/variant.h"
#include "core/variant/variant_internal.h"
Expand Down
45 changes: 45 additions & 0 deletions core/variant/method_ptrcall.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,51 @@ struct PtrToArg<const T *> {
}
};

// This is for RequiredParam.

template <class T>
struct PtrToArg<RequiredParam<T>> {
typedef typename RequiredParam<T>::value_type EncodeT;

_FORCE_INLINE_ static RequiredParam<T> convert(const void *p_ptr) {
if (p_ptr == nullptr) {
// Should we show an error?
GODOT_DEPRECATED_BEGIN
return RequiredParam<T>::err_return();
GODOT_DEPRECATED_END
}
return RequiredParam<T>(*reinterpret_cast<T *const *>(p_ptr));
}

_FORCE_INLINE_ static void encode(const RequiredParam<T> &p_var, void *p_ptr) {
GODOT_DEPRECATED_BEGIN
*((typename RequiredParam<T>::value_type *)p_ptr) = p_var._internal_ptr();
GODOT_DEPRECATED_END
}
};

// This is for RequiredResult.

template <class T>
struct PtrToArg<RequiredResult<T>> {
typedef typename RequiredResult<T>::value_type EncodeT;

_FORCE_INLINE_ static RequiredResult<T> convert(const void *p_ptr) {
if (p_ptr == nullptr) {
GODOT_DEPRECATED_BEGIN
return RequiredResult<T>::err_return();
GODOT_DEPRECATED_END
}
return RequiredResult<T>(*reinterpret_cast<T *const *>(p_ptr));
}

_FORCE_INLINE_ static void encode(const RequiredResult<T> &p_var, void *p_ptr) {
GODOT_DEPRECATED_BEGIN
*((typename RequiredResult<T>::value_type *)p_ptr) = p_var._internal_ptr();
GODOT_DEPRECATED_END
}
};

// This is for ObjectID.

template <>
Expand Down
Loading