Merge pull request #74354 from rcorre/3to4-init
Correct superclass constructors in 3to4.
This commit is contained in:
commit
22ae1e499d
|
@ -889,7 +889,10 @@ bool ProjectConverter3To4::test_conversion(RegExContainer ®_container) {
|
|||
valid = valid && test_conversion_gdscript_builtin("(tween_callback(A,B,[C,D]).foo())", "(tween_callback(Callable(A, B).bind(C,D)).foo())", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
||||
|
||||
valid = valid && test_conversion_gdscript_builtin("func _init(", "func _init(", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
||||
valid = valid && test_conversion_gdscript_builtin("func _init(p_x:int)->void:", "func _init(p_x:int):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
||||
valid = valid && test_conversion_gdscript_builtin("func _init(a,b,c).(d,e,f):", "func _init(a,b,c):\n\tsuper(d,e,f)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
||||
valid = valid && test_conversion_gdscript_builtin("func _init(a,b,c).(a.b(),c.d()):", "func _init(a,b,c):\n\tsuper(a.b(),c.d())", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
||||
valid = valid && test_conversion_gdscript_builtin("func _init(p_x:int)->void:", "func _init(p_x:int)->void:", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
||||
valid = valid && test_conversion_gdscript_builtin("func _init(a: int).(d,e,f) -> void:", "func _init(a: int) -> void:\n\tsuper(d,e,f)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
||||
valid = valid && test_conversion_gdscript_builtin("q_PackedDataContainer._iter_init(variable1)", "q_PackedDataContainer._iter_init(variable1)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
||||
|
||||
valid = valid && test_conversion_gdscript_builtin("assert(speed < 20, str(randi()%10))", "assert(speed < 20) #,str(randi()%10))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
|
||||
|
@ -1943,17 +1946,18 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai
|
|||
}
|
||||
}
|
||||
}
|
||||
// -- func _init(p_x:int)->void: -> func _init(p_x:int): Object # https://github.com/godotengine/godot/issues/50589
|
||||
if (line.contains(" _init(")) {
|
||||
int start = line.find(" _init(");
|
||||
if (line.contains(":")) {
|
||||
int end = line.rfind(":") + 1;
|
||||
if (end > -1) {
|
||||
Vector<String> parts = parse_arguments(line.substr(start, end));
|
||||
line = line.substr(0, start) + " _init(" + connect_arguments(parts, 0) + "):" + line.substr(end + start);
|
||||
}
|
||||
// -- func _init(p_x:int).(p_x): -> func _init(p_x:int):\n\tsuper(p_x) Object # https://github.com/godotengine/godot/issues/70542
|
||||
if (line.contains(" _init(") && line.rfind(":") > 0) {
|
||||
// func _init(p_arg1).(super4, super5, super6)->void:
|
||||
// ^--^indent ^super_start super_end^
|
||||
int indent = line.count("\t", 0, line.find("func"));
|
||||
int super_start = line.find(".(");
|
||||
int super_end = line.rfind(")");
|
||||
if (super_start > 0 && super_end > super_start) {
|
||||
line = line.substr(0, super_start) + line.substr(super_end + 1) + "\n" + String("\t").repeat(indent + 1) + "super" + line.substr(super_start + 1, super_end - super_start);
|
||||
}
|
||||
}
|
||||
|
||||
// assert(speed < 20, str(randi()%10)) -> assert(speed < 20) #,str(randi()%10)) GDScript - GDScript bug constant message
|
||||
if (line.contains("assert(")) {
|
||||
int start = line.find("assert(");
|
||||
|
|
Loading…
Reference in New Issue