diff options
Diffstat (limited to 'modules')
34 files changed, 416 insertions, 230 deletions
diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp index e54e5e4c48..7bde4e7c4b 100644 --- a/modules/gdscript/gdscript_analyzer.cpp +++ b/modules/gdscript/gdscript_analyzer.cpp @@ -2110,14 +2110,14 @@ void GDScriptAnalyzer::reduce_assignment(GDScriptParser::AssignmentNode *p_assig bool compatible = true; GDScriptParser::DataType op_type = assigned_value_type; - if (p_assignment->operation != GDScriptParser::AssignmentNode::OP_NONE) { + if (p_assignment->operation != GDScriptParser::AssignmentNode::OP_NONE && !op_type.is_variant()) { op_type = get_operation_type(p_assignment->variant_op, assignee_type, assigned_value_type, compatible, p_assignment->assigned_value); } p_assignment->set_datatype(op_type); // If Assignee is a variant, then you can assign anything // When the assigned value has a known type, further checks are possible. - if (assignee_type.is_hard_type() && !assignee_type.is_variant() && op_type.is_hard_type()) { + if (assignee_type.is_hard_type() && !assignee_type.is_variant() && op_type.is_hard_type() && !op_type.is_variant()) { if (compatible) { compatible = is_type_compatible(assignee_type, op_type, true, p_assignment->assigned_value); if (!compatible) { diff --git a/modules/gdscript/tests/scripts/analyzer/errors/enum_preload_unnamed_assign_to_named.gd b/modules/gdscript/tests/scripts/analyzer/errors/enum_preload_unnamed_assign_to_named.gd index 98f1f3ec2d..81d5d59ae8 100644 --- a/modules/gdscript/tests/scripts/analyzer/errors/enum_preload_unnamed_assign_to_named.gd +++ b/modules/gdscript/tests/scripts/analyzer/errors/enum_preload_unnamed_assign_to_named.gd @@ -1,4 +1,5 @@ enum MyEnum { VALUE_A, VALUE_B, VALUE_C = 42 } + func test(): const P = preload("../features/enum_value_from_parent.gd") var local_var: MyEnum diff --git a/modules/gdscript/tests/scripts/analyzer/errors/outer_class_lookup.gd b/modules/gdscript/tests/scripts/analyzer/errors/outer_class_lookup.gd index 65c0d9dabc..200c352223 100644 --- a/modules/gdscript/tests/scripts/analyzer/errors/outer_class_lookup.gd +++ b/modules/gdscript/tests/scripts/analyzer/errors/outer_class_lookup.gd @@ -1,12 +1,12 @@ class A: - class B: - func test(): - print(A.B.D) + class B: + func test(): + print(A.B.D) class C: - class D: - pass + class D: + pass func test(): - var inst = A.B.new() - inst.test() + var inst = A.B.new() + inst.test() diff --git a/modules/gdscript/tests/scripts/analyzer/errors/return_null_in_void_func.gd b/modules/gdscript/tests/scripts/analyzer/errors/return_null_in_void_func.gd index 63587942f7..393b66c9f0 100644 --- a/modules/gdscript/tests/scripts/analyzer/errors/return_null_in_void_func.gd +++ b/modules/gdscript/tests/scripts/analyzer/errors/return_null_in_void_func.gd @@ -1,2 +1,2 @@ func test() -> void: - return null + return null diff --git a/modules/gdscript/tests/scripts/analyzer/errors/return_variant_in_void_func.gd b/modules/gdscript/tests/scripts/analyzer/errors/return_variant_in_void_func.gd index 0ee4e7ea36..6be2730bab 100644 --- a/modules/gdscript/tests/scripts/analyzer/errors/return_variant_in_void_func.gd +++ b/modules/gdscript/tests/scripts/analyzer/errors/return_variant_in_void_func.gd @@ -1,4 +1,4 @@ func test() -> void: - var a - a = 1 - return a + var a + a = 1 + return a diff --git a/modules/gdscript/tests/scripts/analyzer/features/base_outer_resolution.gd b/modules/gdscript/tests/scripts/analyzer/features/base_outer_resolution.gd index 7881a0feb6..a94487d989 100644 --- a/modules/gdscript/tests/scripts/analyzer/features/base_outer_resolution.gd +++ b/modules/gdscript/tests/scripts/analyzer/features/base_outer_resolution.gd @@ -11,4 +11,3 @@ func test() -> void: Extend.InnerClass.InnerInnerClass.test_a_b_c(A.new(), B.new(), C.new()) Extend.InnerClass.InnerInnerClass.test_enum(C.TestEnum.HELLO_WORLD) Extend.InnerClass.InnerInnerClass.test_a_prime(A.APrime.new()) - diff --git a/modules/gdscript/tests/scripts/analyzer/features/class_from_parent.gd b/modules/gdscript/tests/scripts/analyzer/features/class_from_parent.gd index 30e7deb05a..7c846c59bd 100644 --- a/modules/gdscript/tests/scripts/analyzer/features/class_from_parent.gd +++ b/modules/gdscript/tests/scripts/analyzer/features/class_from_parent.gd @@ -1,19 +1,19 @@ class A: - var x = 3 + var x = 3 class B: - var x = 4 + var x = 4 class C: - var x = 5 + var x = 5 class Test: - var a = A.new() - var b: B = B.new() - var c := C.new() + var a = A.new() + var b: B = B.new() + var c := C.new() func test(): - var test_instance := Test.new() - prints(test_instance.a.x) - prints(test_instance.b.x) - prints(test_instance.c.x) + var test_instance := Test.new() + prints(test_instance.a.x) + prints(test_instance.b.x) + prints(test_instance.c.x) diff --git a/modules/gdscript/tests/scripts/analyzer/features/external_enum_as_constant.gd b/modules/gdscript/tests/scripts/analyzer/features/external_enum_as_constant.gd index 757744b6f1..0c740935b9 100644 --- a/modules/gdscript/tests/scripts/analyzer/features/external_enum_as_constant.gd +++ b/modules/gdscript/tests/scripts/analyzer/features/external_enum_as_constant.gd @@ -2,5 +2,5 @@ const External = preload("external_enum_as_constant_external.notest.gd") const MyEnum = External.MyEnum func test(): - print(MyEnum.WAITING == 0) - print(MyEnum.GODOT == 1) + print(MyEnum.WAITING == 0) + print(MyEnum.GODOT == 1) diff --git a/modules/gdscript/tests/scripts/analyzer/features/external_enum_as_constant_external.notest.gd b/modules/gdscript/tests/scripts/analyzer/features/external_enum_as_constant_external.notest.gd index 7c090844d0..24c1e41aab 100644 --- a/modules/gdscript/tests/scripts/analyzer/features/external_enum_as_constant_external.notest.gd +++ b/modules/gdscript/tests/scripts/analyzer/features/external_enum_as_constant_external.notest.gd @@ -1,4 +1,4 @@ enum MyEnum { - WAITING, - GODOT + WAITING, + GODOT } diff --git a/modules/gdscript/tests/scripts/analyzer/features/lookup_class.gd b/modules/gdscript/tests/scripts/analyzer/features/lookup_class.gd index 4a2ab7bcba..541da78332 100644 --- a/modules/gdscript/tests/scripts/analyzer/features/lookup_class.gd +++ b/modules/gdscript/tests/scripts/analyzer/features/lookup_class.gd @@ -1,50 +1,50 @@ # Inner-outer class lookup class A: - const Q: = "right one" + const Q: = "right one" class X: - const Q: = "wrong one" + const Q: = "wrong one" class Y extends X: - class B extends A: - static func check() -> void: - print(Q) + class B extends A: + static func check() -> void: + print(Q) # External class lookup const External: = preload("lookup_class_external.notest.gd") class Internal extends External.A: - static func check() -> void: - print(TARGET) + static func check() -> void: + print(TARGET) - class E extends External.E: - static func check() -> void: - print(TARGET) - print(WAITING) + class E extends External.E: + static func check() -> void: + print(TARGET) + print(WAITING) # Variable lookup class C: - var Q := 'right one' + var Q := 'right one' class D: - const Q := 'wrong one' + const Q := 'wrong one' class E extends D: - class F extends C: - func check() -> void: - print(Q) + class F extends C: + func check() -> void: + print(Q) # Test func test() -> void: - # Inner-outer class lookup - Y.B.check() - print("---") - - # External class lookup - Internal.check() - Internal.E.check() - print("---") - - # Variable lookup - var f: = E.F.new() - f.check() + # Inner-outer class lookup + Y.B.check() + print("---") + + # External class lookup + Internal.check() + Internal.E.check() + print("---") + + # Variable lookup + var f: = E.F.new() + f.check() diff --git a/modules/gdscript/tests/scripts/analyzer/features/lookup_signal.gd b/modules/gdscript/tests/scripts/analyzer/features/lookup_signal.gd index b19d5ee4f9..26cf6c7322 100644 --- a/modules/gdscript/tests/scripts/analyzer/features/lookup_signal.gd +++ b/modules/gdscript/tests/scripts/analyzer/features/lookup_signal.gd @@ -1,41 +1,41 @@ signal hello func get_signal() -> Signal: - return hello + return hello class A: - signal hello + signal hello - func get_signal() -> Signal: - return hello + func get_signal() -> Signal: + return hello - class B: - signal hello + class B: + signal hello - func get_signal() -> Signal: - return hello + func get_signal() -> Signal: + return hello class C extends A.B: - func get_signal() -> Signal: - return hello + func get_signal() -> Signal: + return hello func test(): - var a: = A.new() - var b: = A.B.new() - var c: = C.new() - - var hello_a_result: = hello == a.get_signal() - var hello_b_result: = hello == b.get_signal() - var hello_c_result: = hello == c.get_signal() - var a_b_result: = a.get_signal() == b.get_signal() - var a_c_result: = a.get_signal() == c.get_signal() - var b_c_result: = b.get_signal() == c.get_signal() - var c_c_result: = c.get_signal() == c.get_signal() - - print("hello == A.hello? %s" % hello_a_result) - print("hello == A.B.hello? %s" % hello_b_result) - print("hello == C.hello? %s" % hello_c_result) - print("A.hello == A.B.hello? %s" % a_b_result) - print("A.hello == C.hello? %s" % a_c_result) - print("A.B.hello == C.hello? %s" % b_c_result) - print("C.hello == C.hello? %s" % c_c_result) + var a: = A.new() + var b: = A.B.new() + var c: = C.new() + + var hello_a_result: = hello == a.get_signal() + var hello_b_result: = hello == b.get_signal() + var hello_c_result: = hello == c.get_signal() + var a_b_result: = a.get_signal() == b.get_signal() + var a_c_result: = a.get_signal() == c.get_signal() + var b_c_result: = b.get_signal() == c.get_signal() + var c_c_result: = c.get_signal() == c.get_signal() + + print("hello == A.hello? %s" % hello_a_result) + print("hello == A.B.hello? %s" % hello_b_result) + print("hello == C.hello? %s" % hello_c_result) + print("A.hello == A.B.hello? %s" % a_b_result) + print("A.hello == C.hello? %s" % a_c_result) + print("A.B.hello == C.hello? %s" % b_c_result) + print("C.hello == C.hello? %s" % c_c_result) diff --git a/modules/gdscript/tests/scripts/analyzer/features/return_variant_typed.gd b/modules/gdscript/tests/scripts/analyzer/features/return_variant_typed.gd index c9caef7d7c..95f04421d1 100644 --- a/modules/gdscript/tests/scripts/analyzer/features/return_variant_typed.gd +++ b/modules/gdscript/tests/scripts/analyzer/features/return_variant_typed.gd @@ -1,5 +1,5 @@ func variant() -> Variant: - return 'variant' + return 'variant' func test(): - print(variant()) + print(variant()) diff --git a/modules/gdscript/tests/scripts/parser/errors/class_name_after_annotation.gd b/modules/gdscript/tests/scripts/parser/errors/class_name_after_annotation.gd index ada6030132..179e454073 100644 --- a/modules/gdscript/tests/scripts/parser/errors/class_name_after_annotation.gd +++ b/modules/gdscript/tests/scripts/parser/errors/class_name_after_annotation.gd @@ -3,4 +3,4 @@ class_name HelloWorld func test(): - pass + pass diff --git a/modules/gdscript/tests/scripts/parser/errors/double_dictionary_comma.gd b/modules/gdscript/tests/scripts/parser/errors/double_dictionary_comma.gd index 92dfb2366d..816783f239 100644 --- a/modules/gdscript/tests/scripts/parser/errors/double_dictionary_comma.gd +++ b/modules/gdscript/tests/scripts/parser/errors/double_dictionary_comma.gd @@ -1,2 +1,2 @@ func test(): - var dictionary = { hello = "world",, } + var dictionary = { hello = "world",, } diff --git a/modules/gdscript/tests/scripts/parser/errors/match_multiple_variable_binds_in_branch.gd b/modules/gdscript/tests/scripts/parser/errors/match_multiple_variable_binds_in_branch.gd index 4608c778aa..7a745bd995 100644 --- a/modules/gdscript/tests/scripts/parser/errors/match_multiple_variable_binds_in_branch.gd +++ b/modules/gdscript/tests/scripts/parser/errors/match_multiple_variable_binds_in_branch.gd @@ -1,4 +1,4 @@ func test(): - match 1: - [[[var a]]], 2: - pass + match 1: + [[[var a]]], 2: + pass diff --git a/modules/gdscript/tests/scripts/parser/features/advanced_expression_matching.gd b/modules/gdscript/tests/scripts/parser/features/advanced_expression_matching.gd index 43b513045b..a7197bf68f 100644 --- a/modules/gdscript/tests/scripts/parser/features/advanced_expression_matching.gd +++ b/modules/gdscript/tests/scripts/parser/features/advanced_expression_matching.gd @@ -1,34 +1,34 @@ func foo(x): - match x: - 1 + 1: - print("1+1") - [1,2,[1,{1:2,2:var z,..}]]: - print("[1,2,[1,{1:2,2:var z,..}]]") - print(z) - 1 if true else 2: - print("1 if true else 2") - 1 < 2: - print("1 < 2") - 1 or 2 and 1: - print("1 or 2 and 1") - 6 | 1: - print("1 | 1") - 1 >> 1: - print("1 >> 1") - 1, 2 or 3, 4: - print("1, 2 or 3, 4") - _: - print("wildcard") + match x: + 1 + 1: + print("1+1") + [1,2,[1,{1:2,2:var z,..}]]: + print("[1,2,[1,{1:2,2:var z,..}]]") + print(z) + 1 if true else 2: + print("1 if true else 2") + 1 < 2: + print("1 < 2") + 1 or 2 and 1: + print("1 or 2 and 1") + 6 | 1: + print("1 | 1") + 1 >> 1: + print("1 >> 1") + 1, 2 or 3, 4: + print("1, 2 or 3, 4") + _: + print("wildcard") func test(): - foo(6 | 1) - foo(1 >> 1) - foo(2) - foo(1) - foo(1+1) - foo(1 < 2) - foo([2, 1]) - foo(4) - foo([1, 2, [1, {1 : 2, 2:3}]]) - foo([1, 2, [1, {1 : 2, 2:[1,3,5, "123"], 4:2}]]) - foo([1, 2, [1, {1 : 2}]]) + foo(6 | 1) + foo(1 >> 1) + foo(2) + foo(1) + foo(1+1) + foo(1 < 2) + foo([2, 1]) + foo(4) + foo([1, 2, [1, {1 : 2, 2:3}]]) + foo([1, 2, [1, {1 : 2, 2:[1,3,5, "123"], 4:2}]]) + foo([1, 2, [1, {1 : 2}]]) diff --git a/modules/gdscript/tests/scripts/parser/features/basic_expression_matching.gd b/modules/gdscript/tests/scripts/parser/features/basic_expression_matching.gd index 2b46f1e88a..c959c6c6af 100644 --- a/modules/gdscript/tests/scripts/parser/features/basic_expression_matching.gd +++ b/modules/gdscript/tests/scripts/parser/features/basic_expression_matching.gd @@ -1,27 +1,27 @@ func foo(x): - match x: - 1: - print("1") - 2: - print("2") - [1, 2]: - print("[1, 2]") - 3 or 4: - print("3 or 4") - 4: - print("4") - {1 : 2, 2 : 3}: - print("{1 : 2, 2 : 3}") - _: - print("wildcard") + match x: + 1: + print("1") + 2: + print("2") + [1, 2]: + print("[1, 2]") + 3 or 4: + print("3 or 4") + 4: + print("4") + {1 : 2, 2 : 3}: + print("{1 : 2, 2 : 3}") + _: + print("wildcard") func test(): - foo(0) - foo(1) - foo(2) - foo([1, 2]) - foo(3) - foo(4) - foo([4,4]) - foo({1 : 2, 2 : 3}) - foo({1 : 2, 4 : 3}) + foo(0) + foo(1) + foo(2) + foo([1, 2]) + foo(3) + foo(4) + foo([4,4]) + foo({1 : 2, 2 : 3}) + foo({1 : 2, 4 : 3}) diff --git a/modules/gdscript/tests/scripts/parser/features/lambda_callable.gd b/modules/gdscript/tests/scripts/parser/features/lambda_callable.gd index c3b2506156..17d00bce3c 100644 --- a/modules/gdscript/tests/scripts/parser/features/lambda_callable.gd +++ b/modules/gdscript/tests/scripts/parser/features/lambda_callable.gd @@ -1,4 +1,4 @@ func test(): - var my_lambda = func(x): - print(x) - my_lambda.call("hello") + var my_lambda = func(x): + print(x) + my_lambda.call("hello") diff --git a/modules/gdscript/tests/scripts/parser/features/match_dictionary.gd b/modules/gdscript/tests/scripts/parser/features/match_dictionary.gd index 377dd25e9e..75857fb8ff 100644 --- a/modules/gdscript/tests/scripts/parser/features/match_dictionary.gd +++ b/modules/gdscript/tests/scripts/parser/features/match_dictionary.gd @@ -1,43 +1,43 @@ func foo(x): - match x: - {"key1": "value1", "key2": "value2"}: - print('{"key1": "value1", "key2": "value2"}') - {"key1": "value1", "key2"}: - print('{"key1": "value1", "key2"}') - {"key1", "key2": "value2"}: - print('{"key1", "key2": "value2"}') - {"key1", "key2"}: - print('{"key1", "key2"}') - {"key1": "value1"}: - print('{"key1": "value1"}') - {"key1"}: - print('{"key1"}') - _: - print("wildcard") + match x: + {"key1": "value1", "key2": "value2"}: + print('{"key1": "value1", "key2": "value2"}') + {"key1": "value1", "key2"}: + print('{"key1": "value1", "key2"}') + {"key1", "key2": "value2"}: + print('{"key1", "key2": "value2"}') + {"key1", "key2"}: + print('{"key1", "key2"}') + {"key1": "value1"}: + print('{"key1": "value1"}') + {"key1"}: + print('{"key1"}') + _: + print("wildcard") func bar(x): - match x: - {0}: - print("0") - {1}: - print("1") - {2}: - print("2") - _: - print("wildcard") + match x: + {0}: + print("0") + {1}: + print("1") + {2}: + print("2") + _: + print("wildcard") func test(): - foo({"key1": "value1", "key2": "value2"}) - foo({"key1": "value1", "key2": ""}) - foo({"key1": "", "key2": "value2"}) - foo({"key1": "", "key2": ""}) - foo({"key1": "value1"}) - foo({"key1": ""}) - foo({"key1": "value1", "key2": "value2", "key3": "value3"}) - foo({"key1": "value1", "key3": ""}) - foo({"key2": "value2"}) - foo({"key3": ""}) - bar({0: "0"}) - bar({1: "1"}) - bar({2: "2"}) - bar({3: "3"}) + foo({"key1": "value1", "key2": "value2"}) + foo({"key1": "value1", "key2": ""}) + foo({"key1": "", "key2": "value2"}) + foo({"key1": "", "key2": ""}) + foo({"key1": "value1"}) + foo({"key1": ""}) + foo({"key1": "value1", "key2": "value2", "key3": "value3"}) + foo({"key1": "value1", "key3": ""}) + foo({"key2": "value2"}) + foo({"key3": ""}) + bar({0: "0"}) + bar({1: "1"}) + bar({2: "2"}) + bar({3: "3"}) diff --git a/modules/gdscript/tests/scripts/parser/features/match_multiple_patterns_with_array.gd b/modules/gdscript/tests/scripts/parser/features/match_multiple_patterns_with_array.gd index dbe223f5f5..a278ea1154 100644 --- a/modules/gdscript/tests/scripts/parser/features/match_multiple_patterns_with_array.gd +++ b/modules/gdscript/tests/scripts/parser/features/match_multiple_patterns_with_array.gd @@ -1,26 +1,26 @@ func foo(x): - match x: - 1, [2]: - print('1, [2]') - _: - print('wildcard') + match x: + 1, [2]: + print('1, [2]') + _: + print('wildcard') func bar(x): - match x: - [1], [2], [3]: - print('[1], [2], [3]') - [4]: - print('[4]') - _: - print('wildcard') + match x: + [1], [2], [3]: + print('[1], [2], [3]') + [4]: + print('[4]') + _: + print('wildcard') func test(): - foo(1) - foo([2]) - foo(2) - bar([1]) - bar([2]) - bar([3]) - bar([4]) - bar([5]) + foo(1) + foo([2]) + foo(2) + bar([1]) + bar([2]) + bar([3]) + bar([4]) + bar([5]) diff --git a/modules/gdscript/tests/scripts/parser/features/match_multiple_variable_binds_in_pattern.gd b/modules/gdscript/tests/scripts/parser/features/match_multiple_variable_binds_in_pattern.gd index a0ae7fb17c..0a71f33c25 100644 --- a/modules/gdscript/tests/scripts/parser/features/match_multiple_variable_binds_in_pattern.gd +++ b/modules/gdscript/tests/scripts/parser/features/match_multiple_variable_binds_in_pattern.gd @@ -1,6 +1,6 @@ func test(): - match [1, 2, 3]: - [var a, var b, var c]: - print(a == 1) - print(b == 2) - print(c == 3) + match [1, 2, 3]: + [var a, var b, var c]: + print(a == 1) + print(b == 2) + print(c == 3) diff --git a/modules/gdscript/tests/scripts/runtime/errors/constant_dictionary_erase.gd b/modules/gdscript/tests/scripts/runtime/errors/constant_dictionary_erase.gd index 935fb773dc..7b350e81ad 100644 --- a/modules/gdscript/tests/scripts/runtime/errors/constant_dictionary_erase.gd +++ b/modules/gdscript/tests/scripts/runtime/errors/constant_dictionary_erase.gd @@ -1,4 +1,4 @@ const dictionary := {} func test(): - dictionary.erase(0) + dictionary.erase(0) diff --git a/modules/gdscript/tests/scripts/runtime/features/array_string_stringname_equivalent.gd b/modules/gdscript/tests/scripts/runtime/features/array_string_stringname_equivalent.gd index 9b64084fa6..bd38259cec 100644 --- a/modules/gdscript/tests/scripts/runtime/features/array_string_stringname_equivalent.gd +++ b/modules/gdscript/tests/scripts/runtime/features/array_string_stringname_equivalent.gd @@ -9,7 +9,7 @@ func test(): array_sname.push_back(&"godot") print("String in Array: ", "godot" in array_sname) - # Not equal because the values are different types. + # Not equal because the values are different types. print("Arrays not equal: ", array_str != array_sname) var string_array: Array[String] = [] diff --git a/modules/gdscript/tests/scripts/runtime/features/dictionary_string_stringname_equivalent.gd b/modules/gdscript/tests/scripts/runtime/features/dictionary_string_stringname_equivalent.gd index 1f15026f17..94bac1974f 100644 --- a/modules/gdscript/tests/scripts/runtime/features/dictionary_string_stringname_equivalent.gd +++ b/modules/gdscript/tests/scripts/runtime/features/dictionary_string_stringname_equivalent.gd @@ -13,5 +13,5 @@ func test(): print("String gets StringName: ", stringname_dict.get("abc")) stringname_dict[&"abc"] = 42 - # They compare equal because StringName keys are converted to String. + # They compare equal because StringName keys are converted to String. print("String Dictionary == StringName Dictionary: ", string_dict == stringname_dict) diff --git a/modules/gdscript/tests/scripts/runtime/features/parameter_shadowing.gd b/modules/gdscript/tests/scripts/runtime/features/parameter_shadowing.gd index f33ba7dffd..252e100bda 100644 --- a/modules/gdscript/tests/scripts/runtime/features/parameter_shadowing.gd +++ b/modules/gdscript/tests/scripts/runtime/features/parameter_shadowing.gd @@ -3,23 +3,23 @@ var a: int = 1 func shadow_regular_assignment(a: Variant, b: Variant) -> void: - print(a) - print(self.a) - a = b - print(a) - print(self.a) + print(a) + print(self.a) + a = b + print(a) + print(self.a) var v := Vector2(0.0, 0.0) func shadow_subscript_assignment(v: Vector2, x: float) -> void: - print(v) - print(self.v) - v.x += x - print(v) - print(self.v) + print(v) + print(self.v) + v.x += x + print(v) + print(self.v) func test(): - shadow_regular_assignment('a', 'b') - shadow_subscript_assignment(Vector2(1.0, 1.0), 5.0) + shadow_regular_assignment('a', 'b') + shadow_subscript_assignment(Vector2(1.0, 1.0), 5.0) diff --git a/modules/gdscript/tests/scripts/runtime/features/use_conversion_assign_with_variant_value.gd b/modules/gdscript/tests/scripts/runtime/features/use_conversion_assign_with_variant_value.gd new file mode 100644 index 0000000000..af3f3cb941 --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/use_conversion_assign_with_variant_value.gd @@ -0,0 +1,9 @@ +# https://github.com/godotengine/godot/issues/71172 + +func test(): + @warning_ignore(narrowing_conversion) + var foo: int = 0.0 + print(typeof(foo) == TYPE_INT) + var dict : Dictionary = {"a":0.0} + foo = dict.get("a") + print(typeof(foo) == TYPE_INT) diff --git a/modules/gdscript/tests/scripts/runtime/features/use_conversion_assign_with_variant_value.out b/modules/gdscript/tests/scripts/runtime/features/use_conversion_assign_with_variant_value.out new file mode 100644 index 0000000000..9d111a8322 --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/use_conversion_assign_with_variant_value.out @@ -0,0 +1,3 @@ +GDTEST_OK +true +true diff --git a/modules/multiplayer/editor/replication_editor.cpp b/modules/multiplayer/editor/replication_editor.cpp index dbf1eecf0e..4ab41cfcb0 100644 --- a/modules/multiplayer/editor/replication_editor.cpp +++ b/modules/multiplayer/editor/replication_editor.cpp @@ -250,7 +250,7 @@ ReplicationEditor::ReplicationEditor() { tree->add_child(drop_label); drop_label->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT); - tree->set_drag_forwarding(this); + tree->set_drag_forwarding_compat(this); } void ReplicationEditor::_bind_methods() { diff --git a/modules/openxr/SCsub b/modules/openxr/SCsub index fefee9bb24..3b39967ba4 100644 --- a/modules/openxr/SCsub +++ b/modules/openxr/SCsub @@ -101,6 +101,7 @@ env_openxr.add_source_files(module_obj, "extensions/openxr_huawei_controller_ext env_openxr.add_source_files(module_obj, "extensions/openxr_hand_tracking_extension.cpp") env_openxr.add_source_files(module_obj, "extensions/openxr_fb_passthrough_extension_wrapper.cpp") env_openxr.add_source_files(module_obj, "extensions/openxr_fb_display_refresh_rate_extension.cpp") +env_openxr.add_source_files(module_obj, "extensions/openxr_pico_controller_extension.cpp") env_openxr.add_source_files(module_obj, "extensions/openxr_wmr_controller_extension.cpp") env.modules_sources += module_obj diff --git a/modules/openxr/action_map/openxr_action_map.cpp b/modules/openxr/action_map/openxr_action_map.cpp index e3ff1b4382..669c395b3e 100644 --- a/modules/openxr/action_map/openxr_action_map.cpp +++ b/modules/openxr/action_map/openxr_action_map.cpp @@ -307,6 +307,31 @@ void OpenXRActionMap::create_default_action_sets() { profile->add_new_binding(haptic, "/user/hand/left/output/haptic,/user/hand/right/output/haptic"); add_interaction_profile(profile); + // Create our Pico 4 / Neo 3 controller profile + profile = OpenXRInteractionProfile::new_profile("/interaction_profiles/pico/neo3_controller"); + profile->add_new_binding(default_pose, "/user/hand/left/input/aim/pose,/user/hand/right/input/aim/pose"); + profile->add_new_binding(aim_pose, "/user/hand/left/input/aim/pose,/user/hand/right/input/aim/pose"); + profile->add_new_binding(grip_pose, "/user/hand/left/input/grip/pose,/user/hand/right/input/grip/pose"); + profile->add_new_binding(palm_pose, "/user/hand/left/input/palm_ext/pose,/user/hand/right/input/palm_ext/pose"); + profile->add_new_binding(select_button, "/user/hand/left/input/system/click,/user/hand/right/input/system/click"); // system click may not be available + profile->add_new_binding(menu_button, "/user/hand/left/input/back/click,/user/hand/right/input/back/click"); // right hand back click may not be available + profile->add_new_binding(ax_button, "/user/hand/left/input/x/click,/user/hand/right/input/a/click"); // x on left hand, a on right hand + profile->add_new_binding(ax_touch, "/user/hand/left/input/x/touch,/user/hand/right/input/a/touch"); + profile->add_new_binding(by_button, "/user/hand/left/input/y/click,/user/hand/right/input/b/click"); // y on left hand, b on right hand + profile->add_new_binding(by_touch, "/user/hand/left/input/y/touch,/user/hand/right/input/b/touch"); + profile->add_new_binding(trigger, "/user/hand/left/input/trigger/value,/user/hand/right/input/trigger/value"); + profile->add_new_binding(trigger_click, "/user/hand/left/input/trigger/value,/user/hand/right/input/trigger/value"); // should be converted to boolean + profile->add_new_binding(trigger_touch, "/user/hand/left/input/trigger/touch,/user/hand/right/input/trigger/touch"); + profile->add_new_binding(grip, "/user/hand/left/input/squeeze/value,/user/hand/right/input/squeeze/value"); // should be converted to boolean + profile->add_new_binding(grip_click, "/user/hand/left/input/squeeze/value,/user/hand/right/input/squeeze/value"); + // primary on our pico controller is our thumbstick + profile->add_new_binding(primary, "/user/hand/left/input/thumbstick,/user/hand/right/input/thumbstick"); + profile->add_new_binding(primary_click, "/user/hand/left/input/thumbstick/click,/user/hand/right/input/thumbstick/click"); + profile->add_new_binding(primary_touch, "/user/hand/left/input/thumbstick/touch,/user/hand/right/input/thumbstick/touch"); + // pico controller has no secondary input + profile->add_new_binding(haptic, "/user/hand/left/output/haptic,/user/hand/right/output/haptic"); + add_interaction_profile(profile); + // Create our Valve index controller profile profile = OpenXRInteractionProfile::new_profile("/interaction_profiles/valve/index_controller"); profile->add_new_binding(default_pose, "/user/hand/left/input/aim/pose,/user/hand/right/input/aim/pose"); diff --git a/modules/openxr/extensions/openxr_pico_controller_extension.cpp b/modules/openxr/extensions/openxr_pico_controller_extension.cpp new file mode 100644 index 0000000000..f2fcf22ce2 --- /dev/null +++ b/modules/openxr/extensions/openxr_pico_controller_extension.cpp @@ -0,0 +1,98 @@ +/**************************************************************************/ +/* openxr_pico_controller_extension.cpp */ +/**************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/**************************************************************************/ + +#include "openxr_pico_controller_extension.h" +#include "../action_map/openxr_interaction_profile_meta_data.h" + +// Pico controllers are not part of the OpenXR spec at the time of writing this +// code. We'll hardcode the extension name that is used internally, verified by +// tests on the Pico 4. Note that later versions of the Pico 4 and OpenXR +// runtime on Pico might use a different, standardized extension name. +#ifndef XR_PICO_CONTROLLER_INTERACTION_EXTENSION_NAME +#define XR_PICO_CONTROLLER_INTERACTION_EXTENSION_NAME "XR_PICO_controller_interaction" +#endif + +HashMap<String, bool *> OpenXRPicoControllerExtension::get_requested_extensions() { + HashMap<String, bool *> request_extensions; + + request_extensions[XR_PICO_CONTROLLER_INTERACTION_EXTENSION_NAME] = &available; + + return request_extensions; +} + +bool OpenXRPicoControllerExtension::is_available() { + return available; +} + +void OpenXRPicoControllerExtension::on_register_metadata() { + OpenXRInteractionProfileMetaData *metadata = OpenXRInteractionProfileMetaData::get_singleton(); + ERR_FAIL_NULL(metadata); + + // Pico controller (Pico 4 and Pico Neo 3 controllers) + metadata->register_interaction_profile("Pico controller", "/interaction_profiles/pico/neo3_controller", XR_PICO_CONTROLLER_INTERACTION_EXTENSION_NAME); + metadata->register_io_path("/interaction_profiles/pico/neo3_controller", "Grip pose", "/user/hand/left", "/user/hand/left/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE); + metadata->register_io_path("/interaction_profiles/pico/neo3_controller", "Grip pose", "/user/hand/right", "/user/hand/right/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE); + metadata->register_io_path("/interaction_profiles/pico/neo3_controller", "Aim pose", "/user/hand/left", "/user/hand/left/input/aim/pose", "", OpenXRAction::OPENXR_ACTION_POSE); + metadata->register_io_path("/interaction_profiles/pico/neo3_controller", "Aim pose", "/user/hand/right", "/user/hand/right/input/aim/pose", "", OpenXRAction::OPENXR_ACTION_POSE); + metadata->register_io_path("/interaction_profiles/pico/neo3_controller", "Palm pose", "/user/hand/left", "/user/hand/left/input/palm_ext/pose", XR_EXT_PALM_POSE_EXTENSION_NAME, OpenXRAction::OPENXR_ACTION_POSE); + metadata->register_io_path("/interaction_profiles/pico/neo3_controller", "Palm pose", "/user/hand/right", "/user/hand/right/input/palm_ext/pose", XR_EXT_PALM_POSE_EXTENSION_NAME, OpenXRAction::OPENXR_ACTION_POSE); + + metadata->register_io_path("/interaction_profiles/pico/neo3_controller", "Menu click", "/user/hand/left", "/user/hand/left/input/back/click", "", OpenXRAction::OPENXR_ACTION_BOOL); + metadata->register_io_path("/interaction_profiles/pico/neo3_controller", "Screenshot click", "/user/hand/right", "/user/hand/right/input/back/click", "", OpenXRAction::OPENXR_ACTION_BOOL); + metadata->register_io_path("/interaction_profiles/pico/neo3_controller", "System click", "/user/hand/left", "/user/hand/left/input/system/click", "", OpenXRAction::OPENXR_ACTION_BOOL); + metadata->register_io_path("/interaction_profiles/pico/neo3_controller", "System click", "/user/hand/right", "/user/hand/right/input/system/click", "", OpenXRAction::OPENXR_ACTION_BOOL); + + metadata->register_io_path("/interaction_profiles/pico/neo3_controller", "X click", "/user/hand/left", "/user/hand/left/input/x/click", "", OpenXRAction::OPENXR_ACTION_BOOL); + metadata->register_io_path("/interaction_profiles/pico/neo3_controller", "X touch", "/user/hand/left", "/user/hand/left/input/x/touch", "", OpenXRAction::OPENXR_ACTION_BOOL); + metadata->register_io_path("/interaction_profiles/pico/neo3_controller", "Y click", "/user/hand/left", "/user/hand/left/input/y/click", "", OpenXRAction::OPENXR_ACTION_BOOL); + metadata->register_io_path("/interaction_profiles/pico/neo3_controller", "Y touch", "/user/hand/left", "/user/hand/left/input/y/touch", "", OpenXRAction::OPENXR_ACTION_BOOL); + metadata->register_io_path("/interaction_profiles/pico/neo3_controller", "A click", "/user/hand/right", "/user/hand/right/input/a/click", "", OpenXRAction::OPENXR_ACTION_BOOL); + metadata->register_io_path("/interaction_profiles/pico/neo3_controller", "A touch", "/user/hand/right", "/user/hand/right/input/a/touch", "", OpenXRAction::OPENXR_ACTION_BOOL); + metadata->register_io_path("/interaction_profiles/pico/neo3_controller", "B click", "/user/hand/right", "/user/hand/right/input/b/click", "", OpenXRAction::OPENXR_ACTION_BOOL); + metadata->register_io_path("/interaction_profiles/pico/neo3_controller", "B touch", "/user/hand/right", "/user/hand/right/input/b/touch", "", OpenXRAction::OPENXR_ACTION_BOOL); + + metadata->register_io_path("/interaction_profiles/pico/neo3_controller", "Trigger", "/user/hand/left", "/user/hand/left/input/trigger/value", "", OpenXRAction::OPENXR_ACTION_FLOAT); + metadata->register_io_path("/interaction_profiles/pico/neo3_controller", "Trigger touch", "/user/hand/left", "/user/hand/left/input/trigger/touch", "", OpenXRAction::OPENXR_ACTION_BOOL); + metadata->register_io_path("/interaction_profiles/pico/neo3_controller", "Trigger", "/user/hand/right", "/user/hand/right/input/trigger/value", "", OpenXRAction::OPENXR_ACTION_FLOAT); + metadata->register_io_path("/interaction_profiles/pico/neo3_controller", "Trigger touch", "/user/hand/right", "/user/hand/right/input/trigger/touch", "", OpenXRAction::OPENXR_ACTION_BOOL); + + metadata->register_io_path("/interaction_profiles/pico/neo3_controller", "Squeeze", "/user/hand/left", "/user/hand/left/input/squeeze/value", "", OpenXRAction::OPENXR_ACTION_FLOAT); + metadata->register_io_path("/interaction_profiles/pico/neo3_controller", "Squeeze", "/user/hand/right", "/user/hand/right/input/squeeze/value", "", OpenXRAction::OPENXR_ACTION_FLOAT); + + metadata->register_io_path("/interaction_profiles/pico/neo3_controller", "Thumbstick", "/user/hand/left", "/user/hand/left/input/thumbstick", "", OpenXRAction::OPENXR_ACTION_VECTOR2); + metadata->register_io_path("/interaction_profiles/pico/neo3_controller", "Thumbstick click", "/user/hand/left", "/user/hand/left/input/thumbstick/click", "", OpenXRAction::OPENXR_ACTION_BOOL); + metadata->register_io_path("/interaction_profiles/pico/neo3_controller", "Thumbstick touch", "/user/hand/left", "/user/hand/left/input/thumbstick/touch", "", OpenXRAction::OPENXR_ACTION_BOOL); + metadata->register_io_path("/interaction_profiles/pico/neo3_controller", "Thumbstick", "/user/hand/right", "/user/hand/right/input/thumbstick", "", OpenXRAction::OPENXR_ACTION_VECTOR2); + metadata->register_io_path("/interaction_profiles/pico/neo3_controller", "Thumbstick click", "/user/hand/right", "/user/hand/right/input/thumbstick/click", "", OpenXRAction::OPENXR_ACTION_BOOL); + metadata->register_io_path("/interaction_profiles/pico/neo3_controller", "Thumbstick touch", "/user/hand/right", "/user/hand/right/input/thumbstick/touch", "", OpenXRAction::OPENXR_ACTION_BOOL); + + metadata->register_io_path("/interaction_profiles/pico/neo3_controller", "Haptic output", "/user/hand/left", "/user/hand/left/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC); + metadata->register_io_path("/interaction_profiles/pico/neo3_controller", "Haptic output", "/user/hand/right", "/user/hand/right/output/haptic", "", OpenXRAction::OPENXR_ACTION_HAPTIC); +} diff --git a/modules/openxr/extensions/openxr_pico_controller_extension.h b/modules/openxr/extensions/openxr_pico_controller_extension.h new file mode 100644 index 0000000000..a2a1e2f3d3 --- /dev/null +++ b/modules/openxr/extensions/openxr_pico_controller_extension.h @@ -0,0 +1,48 @@ +/**************************************************************************/ +/* openxr_pico_controller_extension.h */ +/**************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/**************************************************************************/ + +#ifndef OPENXR_PICO_CONTROLLER_EXTENSION_H +#define OPENXR_PICO_CONTROLLER_EXTENSION_H + +#include "openxr_extension_wrapper.h" + +class OpenXRPicoControllerExtension : public OpenXRExtensionWrapper { +public: + virtual HashMap<String, bool *> get_requested_extensions() override; + + bool is_available(); + + virtual void on_register_metadata() override; + +private: + bool available = false; +}; + +#endif // OPENXR_PICO_CONTROLLER_EXTENSION_H diff --git a/modules/openxr/openxr_api.cpp b/modules/openxr/openxr_api.cpp index 550ed8052e..33b3c2967f 100644 --- a/modules/openxr/openxr_api.cpp +++ b/modules/openxr/openxr_api.cpp @@ -217,7 +217,7 @@ bool OpenXRAPI::is_top_level_path_supported(const String &p_toplevel_path) { String required_extension = OpenXRInteractionProfileMetaData::get_singleton()->get_top_level_extension(p_toplevel_path); // If unsupported is returned we likely have a misspelled interaction profile path in our action map. Always output that as an error. - ERR_FAIL_COND_V_MSG(required_extension == XR_PATH_UNSUPPORTED_NAME, false, "OpenXR: Unsupported interaction profile " + p_toplevel_path); + ERR_FAIL_COND_V_MSG(required_extension == XR_PATH_UNSUPPORTED_NAME, false, "OpenXR: Unsupported toplevel path " + p_toplevel_path); if (required_extension == "") { // no extension needed, core top level are always "supported", they just won't be used if not really supported diff --git a/modules/openxr/register_types.cpp b/modules/openxr/register_types.cpp index 56c31883e6..4e2fe3dab5 100644 --- a/modules/openxr/register_types.cpp +++ b/modules/openxr/register_types.cpp @@ -53,6 +53,7 @@ #include "extensions/openxr_htc_vive_tracker_extension.h" #include "extensions/openxr_huawei_controller_extension.h" #include "extensions/openxr_palm_pose_extension.h" +#include "extensions/openxr_pico_controller_extension.h" #include "extensions/openxr_wmr_controller_extension.h" static OpenXRAPI *openxr_api = nullptr; @@ -92,6 +93,7 @@ void initialize_openxr_module(ModuleInitializationLevel p_level) { // register our other extensions OpenXRAPI::register_extension_wrapper(memnew(OpenXRPalmPoseExtension)); + OpenXRAPI::register_extension_wrapper(memnew(OpenXRPicoControllerExtension)); OpenXRAPI::register_extension_wrapper(memnew(OpenXRCompositionLayerDepthExtension)); OpenXRAPI::register_extension_wrapper(memnew(OpenXRHTCControllerExtension)); OpenXRAPI::register_extension_wrapper(memnew(OpenXRHTCViveTrackerExtension)); |