Merge pull request #73590 from vnen/gdscript-global-scope-enums

Make global scope enums accessible as types in GDScript
This commit is contained in:
Rémi Verschelde
2023-02-20 15:41:45 +01:00
21 changed files with 355 additions and 87 deletions

View File

@@ -1,2 +1,2 @@
GDTEST_ANALYZER_ERROR
Cannot find member "V3" in base "enum_bad_value.gd::Enum".
Cannot find member "V3" in base "enum_bad_value.gd.Enum".

View File

@@ -1,2 +1,2 @@
GDTEST_ANALYZER_ERROR
Cannot assign a value of type "enum_class_var_assign_with_wrong_enum_type.gd::MyOtherEnum" as "enum_class_var_assign_with_wrong_enum_type.gd::MyEnum".
Cannot assign a value of type "enum_class_var_assign_with_wrong_enum_type.gd.MyOtherEnum" as "enum_class_var_assign_with_wrong_enum_type.gd.MyEnum".

View File

@@ -1,2 +1,2 @@
GDTEST_ANALYZER_ERROR
Cannot assign a value of type "enum_class_var_init_with_wrong_enum_type.gd::MyOtherEnum" as "enum_class_var_init_with_wrong_enum_type.gd::MyEnum".
Cannot assign a value of type "enum_class_var_init_with_wrong_enum_type.gd.MyOtherEnum" as "enum_class_var_init_with_wrong_enum_type.gd.MyEnum".

View File

@@ -1,2 +1,2 @@
GDTEST_ANALYZER_ERROR
Cannot pass a value of type "enum_function_parameter_wrong_type.gd::MyOtherEnum" as "enum_function_parameter_wrong_type.gd::MyEnum".
Cannot pass a value of type "enum_function_parameter_wrong_type.gd.MyOtherEnum" as "enum_function_parameter_wrong_type.gd.MyEnum".

View File

@@ -1,2 +1,2 @@
GDTEST_ANALYZER_ERROR
Cannot return a value of type "enum_function_return_wrong_type.gd::MyOtherEnum" as "enum_function_return_wrong_type.gd::MyEnum".
Cannot return a value of type "enum_function_return_wrong_type.gd.MyOtherEnum" as "enum_function_return_wrong_type.gd.MyEnum".

View File

@@ -1,2 +1,2 @@
GDTEST_ANALYZER_ERROR
Cannot assign a value of type "enum_local_var_assign_outer_with_wrong_enum_type.gd::InnerClass::MyEnum" as "enum_local_var_assign_outer_with_wrong_enum_type.gd::MyEnum".
Cannot assign a value of type "enum_local_var_assign_outer_with_wrong_enum_type.gd::InnerClass.MyEnum" as "enum_local_var_assign_outer_with_wrong_enum_type.gd.MyEnum".

View File

@@ -1,2 +1,2 @@
GDTEST_ANALYZER_ERROR
Cannot assign a value of type "enum_local_var_assign_with_wrong_enum_type.gd::MyOtherEnum" as "enum_local_var_assign_with_wrong_enum_type.gd::MyEnum".
Cannot assign a value of type "enum_local_var_assign_with_wrong_enum_type.gd.MyOtherEnum" as "enum_local_var_assign_with_wrong_enum_type.gd.MyEnum".

View File

@@ -1,2 +1,2 @@
GDTEST_ANALYZER_ERROR
Cannot assign a value of type "enum_local_var_init_with_wrong_enum_type.gd::MyOtherEnum" as "enum_local_var_init_with_wrong_enum_type.gd::MyEnum".
Cannot assign a value of type "enum_local_var_init_with_wrong_enum_type.gd.MyOtherEnum" as "enum_local_var_init_with_wrong_enum_type.gd.MyEnum".

View File

@@ -1,2 +1,2 @@
GDTEST_ANALYZER_ERROR
Cannot find member "THIS_DOES_NOT_EXIST" in base "TileSet::TileShape".
Cannot find member "THIS_DOES_NOT_EXIST" in base "TileSet.TileShape".

View File

@@ -1,2 +1,2 @@
GDTEST_ANALYZER_ERROR
Cannot assign a value of type "enum_value_from_parent.gd::<anonymous enum>" as "enum_preload_unnamed_assign_to_named.gd::MyEnum".
Cannot assign a value of type "enum_value_from_parent.gd.<anonymous enum>" as "enum_preload_unnamed_assign_to_named.gd.MyEnum".

View File

@@ -1,2 +1,2 @@
GDTEST_ANALYZER_ERROR
Cannot assign a value of type "enum_unnamed_assign_to_named.gd::<anonymous enum>" as "enum_unnamed_assign_to_named.gd::MyEnum".
Cannot assign a value of type "enum_unnamed_assign_to_named.gd.<anonymous enum>" as "enum_unnamed_assign_to_named.gd.MyEnum".

View File

@@ -1,2 +1,2 @@
GDTEST_ANALYZER_ERROR
Cannot assign a value of type "enum_from_outer.gd::Named" as "preload_enum_error.gd::LocalNamed".
Cannot assign a value of type "enum_from_outer.gd.Named" as "preload_enum_error.gd.LocalNamed".

View File

@@ -0,0 +1,30 @@
func test():
var type: Variant.Type
type = Variant.Type.TYPE_INT
print(type)
type = TYPE_FLOAT
print(type)
var direction: ClockDirection
direction = ClockDirection.CLOCKWISE
print(direction)
direction = COUNTERCLOCKWISE
print(direction)
var duper := Duper.new()
duper.set_type(Variant.Type.TYPE_INT)
duper.set_type(TYPE_FLOAT)
duper.set_direction(ClockDirection.CLOCKWISE)
duper.set_direction(COUNTERCLOCKWISE)
class Super:
func set_type(type: Variant.Type) -> void:
print(type)
func set_direction(dir: ClockDirection) -> void:
print(dir)
class Duper extends Super:
func set_type(type: Variant.Type) -> void:
print(type)
func set_direction(dir: ClockDirection) -> void:
print(dir)

View File

@@ -0,0 +1,9 @@
GDTEST_OK
2
3
0
1
2
3
0
1

View File

@@ -2,5 +2,5 @@ GDTEST_OK
>> WARNING
>> Line: 5
>> INT_AS_ENUM_WITHOUT_MATCH
>> Cannot cast 2 as Enum "cast_enum_bad_enum.gd::MyEnum": no enum member has matching value.
>> Cannot cast 2 as Enum "cast_enum_bad_enum.gd.MyEnum": no enum member has matching value.
2

View File

@@ -2,5 +2,5 @@ GDTEST_OK
>> WARNING
>> Line: 4
>> INT_AS_ENUM_WITHOUT_MATCH
>> Cannot cast 2 as Enum "cast_enum_bad_int.gd::MyEnum": no enum member has matching value.
>> Cannot cast 2 as Enum "cast_enum_bad_int.gd.MyEnum": no enum member has matching value.
2