Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify debug/non-debug behavior of ClassDB::get_method_info() #78537

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
22 changes: 2 additions & 20 deletions core/object/class_db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,12 +462,12 @@ void ClassDB::get_method_list(const StringName &p_class, List<MethodInfo> *p_met
continue;
}

#ifdef DEBUG_METHODS_ENABLED

for (const MethodInfo &E : type->virtual_methods) {
p_methods->push_back(E);
}

#ifdef DEBUG_METHODS_ENABLED

for (const StringName &E : type->method_order) {
if (p_exclude_from_properties && type->methods_in_properties.has(E)) {
continue;
Expand Down Expand Up @@ -512,7 +512,6 @@ bool ClassDB::get_method_info(const StringName &p_class, const StringName &p_met
continue;
}

#ifdef DEBUG_METHODS_ENABLED
MethodBind **method = type->method_map.getptr(p_method);
if (method && *method) {
if (r_info != nullptr) {
Expand All @@ -526,16 +525,6 @@ bool ClassDB::get_method_info(const StringName &p_class, const StringName &p_met
}
return true;
}
#else
if (type->method_map.has(p_method)) {
if (r_info) {
MethodBind *m = type->method_map[p_method];
MethodInfo minfo = info_from_bind(m);
*r_info = minfo;
}
return true;
}
#endif

if (p_no_inheritance) {
break;
Expand Down Expand Up @@ -1465,7 +1454,6 @@ void ClassDB::add_virtual_method(const StringName &p_class, const MethodInfo &p_

OBJTYPE_WLOCK;

#ifdef DEBUG_METHODS_ENABLED
MethodInfo mi = p_method;
if (p_virtual) {
mi.flags |= METHOD_FLAG_VIRTUAL;
Expand All @@ -1490,15 +1478,11 @@ 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
}

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), "Request for nonexistent class '" + p_class + "'.");

#ifdef DEBUG_METHODS_ENABLED

ClassInfo *type = classes.getptr(p_class);
ClassInfo *check = type;
while (check) {
Expand All @@ -1511,8 +1495,6 @@ void ClassDB::get_virtual_methods(const StringName &p_class, List<MethodInfo> *p
}
check = check->inherits_ptr;
}

#endif
}

void ClassDB::set_class_enabled(const StringName &p_class, bool p_enable) {
Expand Down
4 changes: 2 additions & 2 deletions core/object/class_db.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@ class ClassDB {
HashMap<StringName, MethodInfo> signal_map;
List<PropertyInfo> property_list;
HashMap<StringName, PropertyInfo> property_map;
List<MethodInfo> virtual_methods;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% certain that moving virtual_methods out of DEBUG_METHODS_ENABLED is absolutely needed to fix the linked issue, but this makes the handling of virtual methods consistent, e.g. you can find the same things through get_method_info(), and get_method_list().

HashMap<StringName, MethodInfo> virtual_methods_map;
#ifdef DEBUG_METHODS_ENABLED
List<StringName> constant_order;
List<StringName> method_order;
HashSet<StringName> methods_in_properties;
List<MethodInfo> virtual_methods;
HashMap<StringName, MethodInfo> virtual_methods_map;
HashMap<StringName, Vector<Error>> method_error_values;
HashMap<StringName, List<StringName>> linked_properties;
#endif
Expand Down