1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

Style: Remove redundant DEBUG_METHODS_ENABLED

• Replaced with functionally identical and far more ubiquitous `DEBUG_ENABLED`
This commit is contained in:
Thaddeus Crews
2025-05-15 13:09:41 -05:00
parent 5e27318b6c
commit d237e31a89
25 changed files with 328 additions and 337 deletions

View File

@@ -40,9 +40,9 @@ class CallableCustomMethodPointerBase : public CallableCustom {
uint32_t *comp_ptr = nullptr;
uint32_t comp_size;
uint32_t h;
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
const char *text = "";
#endif
#endif // DEBUG_ENABLED
static bool compare_equal(const CallableCustom *p_a, const CallableCustom *p_b);
static bool compare_less(const CallableCustom *p_a, const CallableCustom *p_b);
@@ -51,14 +51,14 @@ protected:
public:
virtual StringName get_method() const {
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
return StringName(text);
#else
return StringName();
#endif
#endif // DEBUG_ENABLED
}
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
void set_text(const char *p_text) {
text = p_text;
}
@@ -69,7 +69,7 @@ public:
virtual String get_as_text() const {
return String();
}
#endif
#endif // DEBUG_ENABLED
virtual CompareEqualFunc get_compare_equal_func() const;
virtual CompareLessFunc get_compare_less_func() const;
@@ -117,29 +117,29 @@ public:
template <typename T, typename... P>
Callable create_custom_callable_function_pointer(T *p_instance,
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
const char *p_func_text,
#endif
#endif // DEBUG_ENABLED
void (T::*p_method)(P...)) {
typedef CallableCustomMethodPointer<T, void, P...> CCMP; // Messes with memnew otherwise.
CCMP *ccmp = memnew(CCMP(p_instance, p_method));
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
ccmp->set_text(p_func_text + 1); // Try to get rid of the ampersand.
#endif
#endif // DEBUG_ENABLED
return Callable(ccmp);
}
template <typename T, typename R, typename... P>
Callable create_custom_callable_function_pointer(T *p_instance,
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
const char *p_func_text,
#endif
#endif // DEBUG_ENABLED
R (T::*p_method)(P...)) {
typedef CallableCustomMethodPointer<T, R, P...> CCMP; // Messes with memnew otherwise.
CCMP *ccmp = memnew(CCMP(p_instance, p_method));
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
ccmp->set_text(p_func_text + 1); // Try to get rid of the ampersand.
#endif
#endif // DEBUG_ENABLED
return Callable(ccmp);
}
@@ -186,37 +186,37 @@ public:
template <typename T, typename... P>
Callable create_custom_callable_function_pointer(T *p_instance,
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
const char *p_func_text,
#endif
#endif // DEBUG_ENABLED
void (T::*p_method)(P...) const) {
typedef CallableCustomMethodPointerC<T, void, P...> CCMP; // Messes with memnew otherwise.
CCMP *ccmp = memnew(CCMP(p_instance, p_method));
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
ccmp->set_text(p_func_text + 1); // Try to get rid of the ampersand.
#endif
#endif // DEBUG_ENABLED
return Callable(ccmp);
}
template <typename T, typename R, typename... P>
Callable create_custom_callable_function_pointer(T *p_instance,
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
const char *p_func_text,
#endif
R (T::*p_method)(P...) const) {
typedef CallableCustomMethodPointerC<T, R, P...> CCMP; // Messes with memnew otherwise.
CCMP *ccmp = memnew(CCMP(p_instance, p_method));
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
ccmp->set_text(p_func_text + 1); // Try to get rid of the ampersand.
#endif
#endif // DEBUG_ENABLED
return Callable(ccmp);
}
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
#define callable_mp(I, M) create_custom_callable_function_pointer(I, #M, M)
#else
#define callable_mp(I, M) create_custom_callable_function_pointer(I, M)
#endif
#endif // DEBUG_ENABLED
// STATIC VERSIONS
@@ -257,33 +257,33 @@ public:
template <typename... P>
Callable create_custom_callable_static_function_pointer(
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
const char *p_func_text,
#endif
#endif // DEBUG_ENABLED
void (*p_method)(P...)) {
typedef CallableCustomStaticMethodPointer<void, P...> CCMP; // Messes with memnew otherwise.
CCMP *ccmp = memnew(CCMP(p_method));
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
ccmp->set_text(p_func_text + 1); // Try to get rid of the ampersand.
#endif
#endif // DEBUG_ENABLED
return Callable(ccmp);
}
template <typename R, typename... P>
Callable create_custom_callable_static_function_pointer(
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
const char *p_func_text,
#endif
#endif // DEBUG_ENABLED
R (*p_method)(P...)) {
typedef CallableCustomStaticMethodPointer<R, P...> CCMP; // Messes with memnew otherwise.
CCMP *ccmp = memnew(CCMP(p_method));
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
ccmp->set_text(p_func_text + 1); // Try to get rid of the ampersand.
#endif
#endif // DEBUG_ENABLED
return Callable(ccmp);
}
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
#define callable_mp_static(M) create_custom_callable_static_function_pointer(#M, M)
#else
#define callable_mp_static(M) create_custom_callable_static_function_pointer(M)

View File

@@ -35,7 +35,7 @@
#include "core/object/script_language.h"
#include "core/version.h"
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
MethodDefinition D_METHODP(const char *p_name, const char *const **p_args, uint32_t p_argcount) {
MethodDefinition md;
@@ -47,7 +47,7 @@ MethodDefinition D_METHODP(const char *p_name, const char *const **p_args, uint3
return md;
}
#endif
#endif // DEBUG_ENABLED
ClassDB::APIType ClassDB::current_api = API_CORE;
HashMap<ClassDB::APIType, uint32_t> ClassDB::api_hashes_cache;
@@ -368,7 +368,7 @@ ClassDB::APIType ClassDB::get_api_type(const StringName &p_class) {
}
uint32_t ClassDB::get_api_hash(APIType p_api) {
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
Locker::Lock lock(Locker::STATE_WRITE);
if (api_hashes_cache.has(p_api)) {
@@ -513,7 +513,7 @@ uint32_t ClassDB::get_api_hash(APIType p_api) {
return hash;
#else
return 0;
#endif
#endif // DEBUG_ENABLED
}
bool ClassDB::class_exists(const StringName &p_class) {
@@ -898,7 +898,7 @@ void ClassDB::get_method_list(const StringName &p_class, List<MethodInfo> *p_met
continue;
}
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
for (const MethodInfo &E : type->virtual_methods) {
p_methods->push_back(E);
}
@@ -919,7 +919,7 @@ void ClassDB::get_method_list(const StringName &p_class, List<MethodInfo> *p_met
MethodInfo minfo = info_from_bind(m);
p_methods->push_back(minfo);
}
#endif
#endif // DEBUG_ENABLED
if (p_no_inheritance) {
break;
@@ -944,7 +944,7 @@ void ClassDB::get_method_list_with_compatibility(const StringName &p_class, List
continue;
}
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
for (const MethodInfo &E : type->virtual_methods) {
Pair<MethodInfo, uint32_t> pair(E, E.get_compatibility_hash());
p_methods->push_back(pair);
@@ -969,7 +969,7 @@ void ClassDB::get_method_list_with_compatibility(const StringName &p_class, List
Pair<MethodInfo, uint32_t> pair(minfo, method->get_hash());
p_methods->push_back(pair);
}
#endif
#endif // DEBUG_ENABLED
for (const KeyValue<StringName, LocalVector<MethodBind *, unsigned int, false, false>> &E : type->method_map_compatibility) {
LocalVector<MethodBind *> compat = E.value;
@@ -1004,7 +1004,7 @@ bool ClassDB::get_method_info(const StringName &p_class, const StringName &p_met
continue;
}
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
MethodBind **method = type->method_map.getptr(p_method);
if (method && *method) {
if (r_info != nullptr) {
@@ -1027,7 +1027,7 @@ bool ClassDB::get_method_info(const StringName &p_class, const StringName &p_met
}
return true;
}
#endif
#endif // DEBUG_ENABLED
if (p_no_inheritance) {
break;
@@ -1140,9 +1140,9 @@ void ClassDB::bind_integer_constant(const StringName &p_class, const StringName
}
}
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
type->constant_order.push_back(p_name);
#endif
#endif // DEBUG_ENABLED
}
void ClassDB::get_integer_constant_list(const StringName &p_class, List<String> *p_constants, bool p_no_inheritance) {
@@ -1151,7 +1151,7 @@ void ClassDB::get_integer_constant_list(const StringName &p_class, List<String>
ClassInfo *type = classes.getptr(p_class);
while (type) {
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
for (const StringName &E : type->constant_order) {
p_constants->push_back(E);
}
@@ -1161,7 +1161,7 @@ void ClassDB::get_integer_constant_list(const StringName &p_class, List<String>
p_constants->push_back(E.key);
}
#endif
#endif // DEBUG_ENABLED
if (p_no_inheritance) {
break;
}
@@ -1278,18 +1278,18 @@ void ClassDB::get_enum_constants(const StringName &p_class, const StringName &p_
}
void ClassDB::set_method_error_return_values(const StringName &p_class, const StringName &p_method, const Vector<Error> &p_values) {
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
Locker::Lock lock(Locker::STATE_WRITE);
ClassInfo *type = classes.getptr(p_class);
ERR_FAIL_NULL(type);
type->method_error_values[p_method] = p_values;
#endif
#endif // DEBUG_ENABLED
}
Vector<Error> ClassDB::get_method_error_return_values(const StringName &p_class, const StringName &p_method) {
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
Locker::Lock lock(Locker::STATE_READ);
ClassInfo *type = classes.getptr(p_class);
@@ -1301,7 +1301,7 @@ Vector<Error> ClassDB::get_method_error_return_values(const StringName &p_class,
return type->method_error_values[p_method];
#else
return Vector<Error>();
#endif
#endif // DEBUG_ENABLED
}
bool ClassDB::has_enum(const StringName &p_class, const StringName &p_name, bool p_no_inheritance) {
@@ -1350,13 +1350,13 @@ void ClassDB::add_signal(const StringName &p_class, const MethodInfo &p_signal)
StringName sname = p_signal.name;
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
ClassInfo *check = type;
while (check) {
ERR_FAIL_COND_MSG(check->signal_map.has(sname), vformat("Class '%s' already has signal '%s'.", String(p_class), String(sname)));
check = check->inherits_ptr;
}
#endif
#endif // DEBUG_ENABLED
type->signal_map[sname] = p_signal;
}
@@ -1465,41 +1465,41 @@ void ClassDB::add_property(const StringName &p_class, const PropertyInfo &p_pinf
MethodBind *mb_set = nullptr;
if (p_setter) {
mb_set = get_method(p_class, p_setter);
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
ERR_FAIL_NULL_MSG(mb_set, vformat("Invalid setter '%s::%s' for property '%s'.", p_class, p_setter, p_pinfo.name));
int exp_args = 1 + (p_index >= 0 ? 1 : 0);
ERR_FAIL_COND_MSG(mb_set->get_argument_count() != exp_args, vformat("Invalid function for setter '%s::%s' for property '%s'.", p_class, p_setter, p_pinfo.name));
#endif
#endif // DEBUG_ENABLED
}
MethodBind *mb_get = nullptr;
if (p_getter) {
mb_get = get_method(p_class, p_getter);
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
ERR_FAIL_NULL_MSG(mb_get, vformat("Invalid getter '%s::%s' for property '%s'.", p_class, p_getter, p_pinfo.name));
int exp_args = 0 + (p_index >= 0 ? 1 : 0);
ERR_FAIL_COND_MSG(mb_get->get_argument_count() != exp_args, vformat("Invalid function for getter '%s::%s' for property '%s'.", p_class, p_getter, p_pinfo.name));
#endif
#endif // DEBUG_ENABLED
}
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
ERR_FAIL_COND_MSG(type->property_setget.has(p_pinfo.name), vformat("Object '%s' already has property '%s'.", p_class, p_pinfo.name));
#endif
#endif // DEBUG_ENABLED
type->property_list.push_back(p_pinfo);
type->property_map[p_pinfo.name] = p_pinfo;
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
if (mb_get) {
type->methods_in_properties.insert(p_getter);
}
if (mb_set) {
type->methods_in_properties.insert(p_setter);
}
#endif
#endif // DEBUG_ENABLED
PropertySetGet psg;
psg.setter = p_setter;
psg.getter = p_getter;
@@ -1887,9 +1887,9 @@ void ClassDB::_bind_method_custom(const StringName &p_class, MethodBind *p_metho
ERR_FAIL_MSG(vformat("Method already bound '%s::%s'.", p_class, method_name));
}
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
type->method_order.push_back(method_name);
#endif
#endif // DEBUG_ENABLED
type->method_map[method_name] = p_method;
}
@@ -1918,22 +1918,22 @@ MethodBind *ClassDB::_bind_vararg_method(MethodBind *p_bind, const StringName &p
ERR_FAIL_V_MSG(nullptr, vformat("Method already bound: '%s::%s'.", instance_type, p_name));
}
type->method_map[p_name] = bind;
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
// FIXME: <reduz> set_return_type is no longer in MethodBind, so I guess it should be moved to vararg method bind
//bind->set_return_type("Variant");
type->method_order.push_back(p_name);
#endif
#endif // DEBUG_ENABLED
return bind;
}
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
MethodBind *ClassDB::bind_methodfi(uint32_t p_flags, MethodBind *p_bind, bool p_compatibility, const MethodDefinition &method_name, const Variant **p_defs, int p_defcount) {
StringName mdname = method_name.name;
#else
MethodBind *ClassDB::bind_methodfi(uint32_t p_flags, MethodBind *p_bind, bool p_compatibility, const char *method_name, const Variant **p_defs, int p_defcount) {
StringName mdname = StringName(method_name);
#endif
#endif // DEBUG_ENABLED
Locker::Lock lock(Locker::STATE_WRITE);
ERR_FAIL_NULL_V(p_bind, nullptr);
@@ -1944,7 +1944,7 @@ MethodBind *ClassDB::bind_methodfi(uint32_t p_flags, MethodBind *p_bind, bool p_
#ifdef DEBUG_ENABLED
ERR_FAIL_COND_V_MSG(!p_compatibility && has_method(instance_type, mdname), nullptr, vformat("Class '%s' already has a method '%s'.", String(instance_type), String(mdname)));
#endif
#endif // DEBUG_ENABLED
ClassInfo *type = classes.getptr(instance_type);
if (!type) {
@@ -1958,7 +1958,7 @@ MethodBind *ClassDB::bind_methodfi(uint32_t p_flags, MethodBind *p_bind, bool p_
ERR_FAIL_V_MSG(nullptr, vformat("Method already bound '%s::%s'.", instance_type, mdname));
}
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
if (method_name.args.size() > p_bind->get_argument_count()) {
memdelete(p_bind);
@@ -1975,7 +1975,7 @@ MethodBind *ClassDB::bind_methodfi(uint32_t p_flags, MethodBind *p_bind, bool p_
if (!p_compatibility) {
type->method_order.push_back(mdname);
}
#endif
#endif // DEBUG_ENABLED
if (p_compatibility) {
_bind_compatibility(type, p_bind);
@@ -2000,7 +2000,7 @@ void ClassDB::add_virtual_method(const StringName &p_class, const MethodInfo &p_
Locker::Lock lock(Locker::STATE_WRITE);
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
MethodInfo mi = p_method;
if (p_virtual) {
mi.flags |= METHOD_FLAG_VIRTUAL;
@@ -2026,7 +2026,7 @@ void ClassDB::add_virtual_method(const StringName &p_class, const MethodInfo &p_
classes[p_class].virtual_methods.push_back(mi);
classes[p_class].virtual_methods_map[p_method.name] = mi;
#endif
#endif // DEBUG_ENABLED
}
void ClassDB::add_virtual_compatibility_method(const StringName &p_class, const MethodInfo &p_method, bool p_virtual, const Vector<String> &p_arg_names, bool p_object_core) {
@@ -2048,7 +2048,7 @@ void ClassDB::add_virtual_compatibility_method(const StringName &p_class, const
void ClassDB::get_virtual_methods(const StringName &p_class, List<MethodInfo> *p_methods, bool p_no_inheritance) {
ERR_FAIL_COND_MSG(!classes.has(p_class), vformat("Request for nonexistent class '%s'.", p_class));
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
ClassInfo *type = classes.getptr(p_class);
ClassInfo *check = type;
@@ -2063,7 +2063,7 @@ void ClassDB::get_virtual_methods(const StringName &p_class, List<MethodInfo> *p
check = check->inherits_ptr;
}
#endif
#endif // DEBUG_ENABLED
}
Vector<uint32_t> ClassDB::get_virtual_method_compatibility_hashes(const StringName &p_class, const StringName &p_name) {
@@ -2088,7 +2088,7 @@ Vector<uint32_t> ClassDB::get_virtual_method_compatibility_hashes(const StringNa
void ClassDB::add_extension_class_virtual_method(const StringName &p_class, const GDExtensionClassVirtualMethodInfo *p_method_info) {
ERR_FAIL_COND_MSG(!classes.has(p_class), vformat("Request for nonexistent class '%s'.", p_class));
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
PackedStringArray arg_names;
MethodInfo mi;
@@ -2104,7 +2104,7 @@ void ClassDB::add_extension_class_virtual_method(const StringName &p_class, cons
}
add_virtual_method(p_class, mi, true, arg_names);
#endif
#endif // DEBUG_ENABLED
}
void ClassDB::set_class_enabled(const StringName &p_class, bool p_enable) {
@@ -2250,7 +2250,7 @@ Variant ClassDB::class_get_default_property_value(const StringName &p_class, con
WARN_PRINT(vformat("Instantiated %s used as default value for %s's \"%s\" property.", obj->get_class(), p_class, p_property));
}
}
#endif
#endif // DEBUG_ENABLED
return var;
}

View File

@@ -44,7 +44,7 @@
#define DEFVAL(m_defval) (m_defval)
#define DEFVAL_ARRAY DEFVAL(ClassDB::default_array_arg)
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
struct MethodDefinition {
StringName name;
@@ -71,11 +71,11 @@ MethodDefinition D_METHOD(const char *p_name, const VarArgs... p_args) {
#else
// When DEBUG_METHODS_ENABLED is set this will let the engine know
// When DEBUG_ENABLED is set this will let the engine know
// the argument names for easier debugging.
#define D_METHOD(m_c, ...) m_c
#endif
#endif // DEBUG_ENABLED
class ClassDB {
friend class Object;
@@ -118,7 +118,7 @@ public:
HashMap<StringName, MethodInfo> signal_map;
List<PropertyInfo> property_list;
HashMap<StringName, PropertyInfo> property_map;
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
List<StringName> constant_order;
List<StringName> method_order;
HashSet<StringName> methods_in_properties;
@@ -126,7 +126,7 @@ public:
HashMap<StringName, MethodInfo> virtual_methods_map;
HashMap<StringName, Vector<Error>> method_error_values;
HashMap<StringName, List<StringName>> linked_properties;
#endif
#endif // DEBUG_ENABLED
HashMap<StringName, PropertySetGet> property_setget;
HashMap<StringName, Vector<uint32_t>> virtual_methods_compat;
@@ -186,11 +186,11 @@ public:
static HashMap<StringName, ObjectGDExtension> placeholder_extensions;
#endif
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
static MethodBind *bind_methodfi(uint32_t p_flags, MethodBind *p_bind, bool p_compatibility, const MethodDefinition &method_name, const Variant **p_defs, int p_defcount);
#else
static MethodBind *bind_methodfi(uint32_t p_flags, MethodBind *p_bind, bool p_compatibility, const char *method_name, const Variant **p_defs, int p_defcount);
#endif
#endif // DEBUG_ENABLED
static APIType current_api;
static HashMap<APIType, uint32_t> api_hashes_cache;
@@ -529,7 +529,7 @@ public:
#define BIND_CONSTANT(m_constant) \
::ClassDB::bind_integer_constant(get_class_static(), StringName(), #m_constant, m_constant);
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
_FORCE_INLINE_ void errarray_add_str(Vector<Error> &arr) {
}
@@ -558,7 +558,7 @@ _FORCE_INLINE_ Vector<Error> errarray(P... p_args) {
#define BIND_METHOD_ERR_RETURN_DOC(m_method, ...)
#endif
#endif // DEBUG_ENABLED
#define GDREGISTER_CLASS(m_class) \
if (m_class::_class_is_enabled) { \

View File

@@ -50,11 +50,11 @@ PropertyInfo MethodBind::get_argument_info(int p_argument) const {
ERR_FAIL_INDEX_V(p_argument, get_argument_count(), PropertyInfo());
PropertyInfo info = _gen_argument_type_info(p_argument);
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
if (info.name.is_empty()) {
info.name = p_argument < arg_names.size() ? String(arg_names[p_argument]) : String("_unnamed_arg" + itos(p_argument));
}
#endif
#endif // DEBUG_ENABLED
return info;
}
@@ -82,7 +82,7 @@ void MethodBind::set_name(const StringName &p_name) {
name = p_name;
}
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
void MethodBind::set_argument_names(const Vector<StringName> &p_names) {
arg_names = p_names;
}
@@ -91,7 +91,7 @@ Vector<StringName> MethodBind::get_argument_names() const {
return arg_names;
}
#endif
#endif // DEBUG_ENABLED
void MethodBind::set_default_arguments(const Vector<Variant> &p_defargs) {
default_arguments = p_defargs;

View File

@@ -52,9 +52,9 @@ class MethodBind {
protected:
Variant::Type *argument_types = nullptr;
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
Vector<StringName> arg_names;
#endif
#endif // DEBUG_ENABLED
void _set_const(bool p_const);
void _set_static(bool p_static);
void _set_returns(bool p_returns);
@@ -96,12 +96,12 @@ public:
PropertyInfo get_argument_info(int p_argument) const;
PropertyInfo get_return_info() const;
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
void set_argument_names(const Vector<StringName> &p_names); // Set by ClassDB, can't be inferred otherwise.
Vector<StringName> get_argument_names() const;
virtual GodotTypeInfo::Metadata get_argument_meta(int p_arg) const = 0;
#endif
#endif // DEBUG_ENABLED
void set_hint_flags(uint32_t p_hint) { hint_flags = p_hint; }
uint32_t get_hint_flags() const { return hint_flags | (is_const() ? METHOD_FLAG_CONST : 0) | (is_vararg() ? METHOD_FLAG_VARARG : 0) | (is_static() ? METHOD_FLAG_STATIC : 0); }
@@ -160,11 +160,11 @@ public:
return _gen_argument_type_info(p_arg).type;
}
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
virtual GodotTypeInfo::Metadata get_argument_meta(int) const override {
return GodotTypeInfo::METADATA_NONE;
}
#endif
#endif // DEBUG_ENABLED
virtual void validated_call(Object *p_object, const Variant **p_args, Variant *r_ret) const override {
ERR_FAIL_MSG("Validated call can't be used with vararg methods. This is a bug.");
@@ -187,20 +187,20 @@ public:
Variant::Type *at = memnew_arr(Variant::Type, method_info.arguments.size() + 1);
at[0] = _gen_return_type_info().type;
if (method_info.arguments.size()) {
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
Vector<StringName> names;
names.resize(method_info.arguments.size());
#endif
#endif // DEBUG_ENABLED
for (int64_t i = 0; i < method_info.arguments.size(); ++i) {
at[i + 1] = method_info.arguments[i].type;
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
names.write[i] = method_info.arguments[i].name;
#endif
#endif // DEBUG_ENABLED
}
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
set_argument_names(names);
#endif
#endif // DEBUG_ENABLED
}
argument_types = at;
if (p_return_nil_is_variant) {
@@ -321,12 +321,12 @@ protected:
}
public:
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
virtual GodotTypeInfo::Metadata get_argument_meta(int p_arg) const override {
return call_get_argument_metadata<P...>(p_arg);
}
#endif
#endif // DEBUG_ENABLED
virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) const override {
#ifdef TOOLS_ENABLED
ERR_FAIL_COND_V_MSG(p_object && p_object->is_extension_placeholder() && p_object->get_class_name() == get_instance_class(), Variant(), vformat("Cannot call method bind '%s' on placeholder instance.", MethodBind::get_name()));
@@ -405,12 +405,12 @@ protected:
}
public:
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
virtual GodotTypeInfo::Metadata get_argument_meta(int p_arg) const override {
return call_get_argument_metadata<P...>(p_arg);
}
#endif
#endif // DEBUG_ENABLED
virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) const override {
#ifdef TOOLS_ENABLED
ERR_FAIL_COND_V_MSG(p_object && p_object->is_extension_placeholder() && p_object->get_class_name() == get_instance_class(), Variant(), vformat("Cannot call method bind '%s' on placeholder instance.", MethodBind::get_name()));
@@ -494,7 +494,7 @@ protected:
}
public:
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
virtual GodotTypeInfo::Metadata get_argument_meta(int p_arg) const override {
if (p_arg >= 0) {
return call_get_argument_metadata<P...>(p_arg);
@@ -502,7 +502,7 @@ public:
return GetTypeInfo<R>::METADATA;
}
}
#endif
#endif // DEBUG_ENABLED
virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) const override {
Variant ret;
@@ -589,7 +589,7 @@ protected:
}
public:
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
virtual GodotTypeInfo::Metadata get_argument_meta(int p_arg) const override {
if (p_arg >= 0) {
return call_get_argument_metadata<P...>(p_arg);
@@ -597,7 +597,7 @@ public:
return GetTypeInfo<R>::METADATA;
}
}
#endif
#endif // DEBUG_ENABLED
virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) const override {
Variant ret;
@@ -678,12 +678,12 @@ protected:
}
public:
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
virtual GodotTypeInfo::Metadata get_argument_meta(int p_arg) const override {
return call_get_argument_metadata<P...>(p_arg);
}
#endif
#endif // DEBUG_ENABLED
virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) const override {
(void)p_object; // unused
call_with_variant_args_static_dv(function, p_args, p_arg_count, r_error, get_default_arguments());
@@ -740,7 +740,7 @@ protected:
}
public:
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
virtual GodotTypeInfo::Metadata get_argument_meta(int p_arg) const override {
if (p_arg >= 0) {
return call_get_argument_metadata<P...>(p_arg);
@@ -749,7 +749,7 @@ public:
}
}
#endif
#endif // DEBUG_ENABLED
virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) const override {
Variant ret;
call_with_variant_args_static_ret_dv(function, p_args, p_arg_count, ret, r_error, get_default_arguments());

View File

@@ -380,11 +380,11 @@ struct ObjectGDExtension {
#define GDVIRTUAL_CALL(m_name, ...) _gdvirtual_##m_name##_call(__VA_ARGS__)
#define GDVIRTUAL_CALL_PTR(m_obj, m_name, ...) m_obj->_gdvirtual_##m_name##_call(__VA_ARGS__)
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
#define GDVIRTUAL_BIND(m_name, ...) ::ClassDB::add_virtual_method(get_class_static(), _gdvirtual_##m_name##_get_method_info(), true, sarray(__VA_ARGS__));
#else
#define GDVIRTUAL_BIND(m_name, ...)
#endif
#endif // DEBUG_ENABLED
#define GDVIRTUAL_BIND_COMPAT(m_alias, ...) ::ClassDB::add_virtual_compatibility_method(get_class_static(), _gdvirtual_##m_alias##_get_method_info(), true, sarray(__VA_ARGS__));
#define GDVIRTUAL_IS_OVERRIDDEN(m_name) _gdvirtual_##m_name##_overridden()
#define GDVIRTUAL_IS_OVERRIDDEN_PTR(m_obj, m_name) m_obj->_gdvirtual_##m_name##_overridden()
@@ -592,7 +592,7 @@ public:
private:
#ifdef DEBUG_ENABLED
friend struct _ObjectDebugLock;
#endif
#endif // DEBUG_ENABLED
friend bool predelete_handler(Object *);
friend void postinitialize_handler(Object *);
@@ -616,7 +616,7 @@ private:
List<Connection> connections;
#ifdef DEBUG_ENABLED
SafeRefCount _lock_index;
#endif
#endif // DEBUG_ENABLED
bool _block_signals = false;
int _predelete_ok = 0;
ObjectID _instance_id;
@@ -893,7 +893,7 @@ public:
#define MTVIRTUAL virtual
#else
#define MTVIRTUAL
#endif
#endif // DEBUG_ENABLED
MTVIRTUAL void set_script(const Variant &p_script);
MTVIRTUAL Variant get_script() const;