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

Include name field in MethodInfo operator == #86259

Merged
merged 1 commit into from
Jan 2, 2024

Conversation

TitanNano
Copy link
Contributor

@TitanNano TitanNano commented Dec 17, 2023

The GDScript analyzer currently does not recognize Methods from other scripting languages as callable. This is caused by this section of the analyzer:

MethodInfo info = base_script->get_method_info(function_name);
if (!(info == MethodInfo())) {

Which uses either ScriptExtension::get_method_info which calls MethodInfo::from_dict that never sets a MethodInfo.id,

virtual MethodInfo get_method_info(const StringName &p_method) const override {
Dictionary mi;
GDVIRTUAL_REQUIRED_CALL(_get_method_info, p_method, mi);
return MethodInfo::from_dict(mi);
}

or CSharpScript::get_method_info which doesn't set an ID either.

for (int i = 0; i < methods_array.size(); i++) {
Dictionary method_info_dict = methods_array[i];
StringName name = method_info_dict["name"];
MethodInfo mi;
mi.name = name;
Array params = method_info_dict["params"];
for (int j = 0; j < params.size(); j++) {
Dictionary param = params[j];
Variant::Type param_type = (Variant::Type)(int)param["type"];
PropertyInfo arg_info = PropertyInfo(param_type, (String)param["name"]);
arg_info.usage = (uint32_t)param["usage"];
if (param.has("class_name")) {
arg_info.class_name = (StringName)param["class_name"];
}
mi.arguments.push_back(arg_info);
}
mi.flags = (uint32_t)method_info_dict["flags"];
p_script->methods.set(push_index++, CSharpMethodInfo{ name, mi });
}

Following the implementation of operator< I have therefore extended the equality operator to compare the name field as well.

(this fix is also compatible with at least 4.2 and 4.1)

@zaevi
Copy link
Contributor

zaevi commented Dec 19, 2023

Related to #86256

@akien-mga akien-mga added the cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release label Jan 2, 2024
@akien-mga akien-mga merged commit 35d1ffb into godotengine:master Jan 2, 2024
15 checks passed
@akien-mga
Copy link
Member

Thanks!

@TitanNano TitanNano deleted the jovan/fix_MethodInfo_eq branch January 2, 2024 15:10
@akien-mga
Copy link
Member

Cherry-picked for 4.2.2.

@akien-mga akien-mga removed the cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release label Mar 11, 2024
@raulsntos
Copy link
Member

@akien-mga Should likely cherry-pick #86972 as well, since it's a follow-up. For context, it fixes #86256 (comment).

@paulloz
Copy link
Member

paulloz commented Apr 20, 2024

This change is breaking interop for overloaded methods. I'm opening a dedicated issue.

Edit: See the issue linked below.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants