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

Cleanup 3-to-4 renames, prevent common words replacements, handle project.godot settings #74040

Merged
merged 2 commits into from
Feb 27, 2023

Conversation

akien-mga
Copy link
Member

@akien-mga akien-mga commented Feb 27, 2023

@@ -456,7 +466,6 @@ const char *RenamesMap3To4::gdscript_function_renames[][2] = {
{ "post_import", "_post_import" }, // EditorScenePostImport
{ "print_stray_nodes", "print_orphan_nodes" }, // Node
{ "property_list_changed_notify", "notify_property_list_changed" }, // Object
{ "raise", "move_to_front" }, // CanvasItem
Copy link
Member Author

Choose a reason for hiding this comment

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

Removed as possibly conflicting with comments / user-defined methods.

{ "clamped", "limit_length" }, // Vector2
{ "get_rotation_quat", "get_rotation_quaternion" }, // Basis
{ "grow_margin", "grow_side" }, // Rect2
{ "invert", "reverse" }, // Array -- Give it a check. Be careful, this will be used everywhere.
Copy link
Member Author

Choose a reason for hiding this comment

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

Too common.

{ "is_abs_path", "is_absolute_path" }, // String
{ "is_valid_integer", "is_valid_int" }, // String
{ "linear_interpolate", "lerp" }, // Color
{ "find_last", "rfind" }, // Array, String
{ "to_ascii", "to_ascii_buffer" }, // String
{ "to_utf8", "to_utf8_buffer" }, // String
{ "to_wchar", "to_utf32_buffer" }, // String -- utf32 or utf16?
Copy link
Member Author

Choose a reason for hiding this comment

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

Wrong (will be fixed by #73225).

Copy link
Contributor

Choose a reason for hiding this comment

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

So, shouldn't it be changed to convert to to_wchar_buffer then?

Copy link
Member Author

@akien-mga akien-mga Feb 27, 2023

Choose a reason for hiding this comment

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

It's not merged yet, because production folks are stingy on their merges :P

Copy link
Contributor

Choose a reason for hiding this comment

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

Ahh, right right, the vermin of this world get in our way again!

Comment on lines +157 to +161
// NOTE: Commented out renames are disabled because deemed not suitable for
// the current way the regex-based converter works.
// When uncommenting any of those as suitable for conversion, please move it
// to the block with other enabled conversions, ordered alphabetically, and
// make sure to add it to the C# rename map too.
Copy link
Member Author

Choose a reason for hiding this comment

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

Added this blurb so we don't have to keep commented out stuff in sync too.

@@ -617,52 +623,6 @@ const char *RenamesMap3To4::gdscript_function_renames[][2] = {

// gdscript_function_renames clone with CamelCase
const char *RenamesMap3To4::csharp_function_renames[][2] = {
Copy link
Member Author

Choose a reason for hiding this comment

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

For properties I did a full comparative review of GDScript vs C#, but not for this one.

@@ -1155,6 +1118,7 @@ const char *RenamesMap3To4::gdscript_properties_renames[][2] = {
{ "refuse_new_network_connections", "refuse_new_connections" }, // MultiplayerAPI
{ "region_filter_clip", "region_filter_clip_enabled" }, // Sprite2D
{ "reverb_bus_enable", "reverb_bus_enabled" }, // Area3D
{ "scancode", "keycode" }, // InputEventKey
Copy link
Member Author

Choose a reason for hiding this comment

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

Seems safe enough?

@@ -1170,49 +1134,29 @@ const char *RenamesMap3To4::gdscript_properties_renames[][2] = {
{ "tab_align", "tab_alignment" }, // TabContainer
{ "table_hseparation", "table_h_separation" }, // Theme
{ "table_vseparation", "table_v_separation" }, // Theme
{ "translation", "position" }, // Node3D -- Breaks GLTFNode
{ "toplevel", "top_level" }, // Node
Copy link
Member Author

Choose a reason for hiding this comment

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

Seems safe enough?

{ "ExtraSpacingBottom", "SpacingBottom" }, // Font
{ "ExtraSpacingTop", "SpacingTop" }, // Font
{ "FocusNeighbourBottom", "FocusNeighborBottom" }, // Control
{ "FocusNeighbourLeft", "FocusNeighborLeft" }, // Control
{ "FocusNeighbourRight", "FocusNeighborRight" }, // Control
{ "FocusNeighbourTop", "FocusNeighborTop" }, // Control
{ "FollowViewportEnable", "FollowViewportEnabled" }, // CanvasItem
{ "FileIconModulate", "FileIconColor" }, // Theme
Copy link
Member Author

Choose a reason for hiding this comment

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

I don't know if theme properties are actually capitalized or if they're used with their core snake_case identifier.
Either way, these shouldn't hurt as it will do nothing if they're not capitalized.

Comment on lines 1381 to 1389
// Too common.
// { "Area", "Area3D" },
// { "Camera", "Camera3D" },
// { "World", "World3D" },
// { "Particles", "GPUParticles3D" },
// { "Reference", "RefCounted" },
// { "Tabs", "TabBar" },
// { "Shape", "Shape3D" },
// { "Path", "Path3D" },
Copy link
Member Author

Choose a reason for hiding this comment

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

This will lead to more manual work for users, as Reference, Area, Camera, Shape and Path are quite used. But those are also potential clashes with user comments and strings.

Comment on lines -1642 to -1647
// Portal and room occlusion culling was replaced by raster occlusion culling.
{ "CullInstance", "Node3D" },
{ "RoomGroup", "Node3D" },
{ "Room", "Node3D" },
{ "RoomManager", "Node3D" },
{ "Portal", "Node3D" },
Copy link
Member Author

Choose a reason for hiding this comment

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

This kind of renames was added as aliases in register_scene_types.cpp to avoid scenes getting corrupted, but it makes no sense to do the same in scripts.

@YuriSizov
Copy link
Contributor

Removing Reference is a big downgrade, IMO. There is a decent possibility for conflicts, but it's also a core class in Godot, and can be used quite a lot. Not sure if it's better to avoid converting it and have users update it manually.

@akien-mga
Copy link
Member Author

That's fair. What about the others?

	// { "Area", "Area3D" },
	// { "Camera", "Camera3D" },
	// { "Particles", "GPUParticles3D" },
	// { "Path", "Path3D" },
	// { "Reference", "RefCounted" },
	// { "Shape", "Shape3D" },
	// { "Tabs", "TabBar" },
	// { "World", "World3D" },

I think at least "World" can be kept commented out, currently it would replace stuff like using World as node name in a node path ($Game/World/0/StartPosition, etc.).

"Particles" probably doesn't make sense to convert like this because it's not going to be compatible anyway.

The rest might be still worth it even if there's a high risk of doing wrong replacements in e.g. comments, strings and node paths?

Copy link
Contributor

@YuriSizov YuriSizov left a comment

Choose a reason for hiding this comment

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

Aside from the two notes above, LGTM. We can give it a go.

The rest might be still worth it even if there's a high risk of doing wrong replacements in e.g. comments, strings and node paths?

I agree that World is too commonplace (I have it in practically every project, and it's never the World node). For the rest, it's a toss. We can go on with a safer option and re-evaluate later. I wouldn't worry too much about comments though.

@akien-mga
Copy link
Member Author

That's fair. What about the others?

	// { "Area", "Area3D" },
	// { "Camera", "Camera3D" },
	// { "Particles", "GPUParticles3D" },
	// { "Path", "Path3D" },
	// { "Reference", "RefCounted" },
	// { "Shape", "Shape3D" },
	// { "Tabs", "TabBar" },
	// { "World", "World3D" },

Alright, re-added those aside from "World" (too common) and "Particles" (too common, and incompatible class).

@YuriSizov
Copy link
Contributor

Feels good!

@akien-mga akien-mga force-pushed the safer-renames branch 2 times, most recently from 72e2ea4 to b02cbd0 Compare February 27, 2023 12:06
In the ConfigFile format, the first subpath is the category and is not part
of the line that the regex would match.

Fixes godotengine#66125.
@akien-mga
Copy link
Member Author

Added a second commit to fix #66125 too, with a much simpler approach than #66251.

@akien-mga akien-mga changed the title Cleanup 3-to-4 renames, prevent common words replacements Cleanup 3-to-4 renames, prevent common words replacements, handle project.godot settings Feb 27, 2023
@akien-mga akien-mga merged commit 8208060 into godotengine:master Feb 27, 2023
@akien-mga akien-mga deleted the safer-renames branch February 27, 2023 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants