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

Fix 3to4 conversions (thread arguments, OS.window_fullscreen and await) #63299

Closed
wants to merge 2 commits into from

Conversation

and3rson
Copy link
Contributor

@and3rson and3rson commented Jul 21, 2022

@and3rson
Copy link
Contributor Author

and3rson commented Jul 21, 2022

Tagging @qarmin as per Calinou's comments

@kleonc
Copy link
Member

kleonc commented Jul 21, 2022

Fixes #63291, #63292, #63293

Note you'd need to write "Fixes #issue_number" separately for each issue to make all of them be auto-linked to be closed by this PR. As above, only the first one was auto-linked (I've linked the other two manually).

@and3rson
Copy link
Contributor Author

FYI: I've also added converters for intersect_ray and intersect_shape since my project uses them extensively :)

@and3rson
Copy link
Contributor Author

Fixes #63291, #63292, #63293

Note you'd need to write "Fixes #issue_number" separately for each issue to make all of them be auto-linked to be closed by this PR. As above, only the first one was auto-linked (I've linked the other two manually).

Gotcha. Done!

@kleonc
Copy link
Member

kleonc commented Jul 21, 2022

Gotcha. Done!

I was referring to the PR description, not the commit message (which I see you've changed). I didn't notice you had the same "Fixes ..." text as the commit message, now I see why you could have interpreted it like this.
These keywords in the commit message will result in closing the linked issues when the commit is merged but the issues won't be linked to this PR (PR containing the merged commit). Hence you rather want to link the issues in the PR description. Here you can read more details on how this linking works.
Also you didn't need to change anything, as I've mentioned previously I've already linked the other two issues manually. It was just a note for the future. I guess I could have been a little more precise. 🙂

@@ -2803,6 +2807,98 @@ void ProjectConverter3To4::rename_gdscript_functions(String &file_content) {
}
}

// -- r.intersect_ray( a, b, c, d, e ) -> var ray_query = ... ray_query.from = from ... r.intersect_ray(ray_query) PhysicsDirectSpaceState2D & PhysicsDirectSpaceState3D
Copy link
Member

Choose a reason for hiding this comment

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

This will change after #61918 is merged.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great, didn't know there's a WIP for this. It surely will be much more convenient to have it as a one-liner rather than the current method of creating a separate object. Should we disregard this conversion and wait for #61918?

@@ -1968,11 +1968,14 @@ bool ProjectConverter3To4::test_conversion() {
valid = valid & test_conversion_single_additional("(Disconnect(A,B,C) != OK):", "(Disconnect(A,new Callable(B,C)) != OK):", &ProjectConverter3To4::rename_csharp_functions, "custom rename csharp");
valid = valid & test_conversion_single_additional("(IsConnected(A,B,C) != OK):", "(IsConnected(A,new Callable(B,C)) != OK):", &ProjectConverter3To4::rename_csharp_functions, "custom rename");

valid = valid & test_conversion_single_additional("OS.window_fullscreen = Settings.fullscreen", "ProjectSettings.set(\"display/window/size/fullscreen\", Settings.fullscreen)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename");
valid = valid & test_conversion_single_additional("OS.window_fullscreen = Settings.fullscreen", "ProjectSettings.set(\\\"display/window/size/fullscreen\\\", Settings.fullscreen)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename");
Copy link
Contributor

Choose a reason for hiding this comment

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

The problem happens probably only in builtin scripts, so should be fixed only there - otherwise it will broke normal .gd files(not tested yet)

Copy link
Member

Choose a reason for hiding this comment

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

Built-in scripts should be unescaped before conversion, if they aren't already.

Copy link
Contributor Author

@and3rson and3rson Jul 22, 2022

Choose a reason for hiding this comment

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

My bad, I've totally forgotten that scripts should not be unescaped since they're plaintext. Still, I cannot confirm that built-in scripts are unescaped, i. e. @KoBeWi I can still observe #63291 in the latest master. But I agree that the best solution would be to unescape all built-in scripts before conversion.

Copy link
Contributor Author

@and3rson and3rson Jul 23, 2022

Choose a reason for hiding this comment

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

What's the difference between rename_gdscript_functions and check_for_rename_gdscript_functions btw? Their code seems almost identical (except for the return value).

EDIT: I can see there's a check in project_converter_3_to_4.cpp:1665 which differentiates .gd and .tscn files. Should we probably introduce an extra argument to rename_gdscript_functions such as is_builtin? This way we could control the behavior of quote escaping inside rename_gdscript_functions. It would also make sense to call rename_gdscript_functions inside the .tres branch several lines below (since resources may also contain built-in scripts).

Copy link
Contributor

Choose a reason for hiding this comment

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

check_for_rename_gdscript_functions additionally prints exactly in which line change will happen.
At beginning it was very different than rename_gdscript_functions, but I unified this one day, so there is a lot of duplicated code, which could be extracted to another function, but when I tried to do it I failed due some strange Regex memory leaks(this shouldn't be too hard to fix)

I think that adding is_builtin is good solution, but this probably will be only needed by custom renames that use " inside regex e.g.

OS.window_fullscreen = true -> ProjectSettings.set("display/window/size/fullscreen",true)

but not with

sort_custom( a , b ) -> sort_custom(Callable( a , b ))

@and3rson
Copy link
Contributor Author

Gotcha. Done!

I was referring to the PR description, not the commit message (which I see you've changed). I didn't notice you had the same "Fixes ..." text as the commit message, now I see why you could have interpreted it like this. These keywords in the commit message will result in closing the linked issues when the commit is merged but the issues won't be linked to this PR (PR containing the merged commit). Hence you rather want to link the issues in the PR description. Here you can read more details on how this linking works. Also you didn't need to change anything, as I've mentioned previously I've already linked the other two issues manually. It was just a note for the future. I guess I could have been a little more precise. slightly_smiling_face

Oh, I see now. Thank you for taking time to explain!

@@ -2941,14 +2942,17 @@ void ProjectConverter3To4::rename_gdscript_functions(String &file_content) {
}
}
}
// -- start(a,b,c) -> start(a,Callable(b,c)) Thread
// -- start(a,b) -> start(Callable(a,b)) Thread
// -- start(a,b,c,d) -> start(Callable(a,b).bind(c,d)) Thread
Copy link
Contributor

Choose a reason for hiding this comment

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

Threads in 3.x can take only one userdata argument. start(a, b, c, d) should become start(Callable(a, b).bind(c), d), with d being the Thread priority.

@akien-mga
Copy link
Member

Superseded by #63887.

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