-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #82122 from dalexeev/gds-add-export-hidden-annotation
GDScript: Add `@export_storage` annotation
- Loading branch information
Showing
16 changed files
with
178 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
modules/gdscript/tests/scripts/analyzer/features/export_enum_as_dictionary.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
GDTEST_OK | ||
@export var x1: Dictionary | ||
var test_1: Dictionary | ||
hint=NONE hint_string="" usage=DEFAULT|SCRIPT_VARIABLE | ||
@export var x2: TestExportEnumAsDictionary.MyEnum | ||
var test_2: TestExportEnumAsDictionary.MyEnum | ||
hint=ENUM hint_string="A:0,B:1,C:2" usage=DEFAULT|SCRIPT_VARIABLE|CLASS_IS_ENUM | ||
@export var x3: Dictionary | ||
var test_3: Dictionary | ||
hint=NONE hint_string="" usage=DEFAULT|SCRIPT_VARIABLE | ||
@export var x4: TestExportEnumAsDictionary.MyEnum | ||
var test_4: TestExportEnumAsDictionary.MyEnum | ||
hint=ENUM hint_string="A:0,B:1,C:2" usage=DEFAULT|SCRIPT_VARIABLE|CLASS_IS_ENUM | ||
@export var x5: TestExportEnumAsDictionary.MyEnum | ||
var test_5: TestExportEnumAsDictionary.MyEnum | ||
hint=ENUM hint_string="A:0,B:1,C:2" usage=DEFAULT|SCRIPT_VARIABLE|CLASS_IS_ENUM |
31 changes: 16 additions & 15 deletions
31
modules/gdscript/tests/scripts/parser/features/annotations.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,49 @@ | ||
extends Node | ||
|
||
@export_enum("A", "B", "C") var a0 | ||
@export_enum("A", "B", "C",) var a1 | ||
const Utils = preload("../../utils.notest.gd") | ||
|
||
@export_enum("A", "B", "C") var test_1 | ||
@export_enum("A", "B", "C",) var test_2 | ||
|
||
@export_enum( | ||
"A", | ||
"B", | ||
"C" | ||
) var a2 | ||
) var test_3 | ||
|
||
@export_enum( | ||
"A", | ||
"B", | ||
"C", | ||
) var a3 | ||
) var test_4 | ||
|
||
@export | ||
var a4: int | ||
var test_5: int | ||
|
||
@export() | ||
var a5: int | ||
var test_6: int | ||
|
||
@export() var a6: int | ||
@warning_ignore("onready_with_export") @onready @export var a7: int | ||
@warning_ignore("onready_with_export") @onready() @export() var a8: int | ||
@export() var test_7: int = 42 | ||
@warning_ignore("onready_with_export") @onready @export var test_8: int = 42 | ||
@warning_ignore("onready_with_export") @onready() @export() var test_9: int = 42 | ||
|
||
@warning_ignore("onready_with_export") | ||
@onready | ||
@export | ||
var a9: int | ||
var test_10: int = 42 | ||
|
||
@warning_ignore("onready_with_export") | ||
@onready() | ||
@export() | ||
var a10: int | ||
var test_11: int = 42 | ||
|
||
@warning_ignore("onready_with_export") | ||
@onready() | ||
@export() | ||
|
||
var a11: int | ||
|
||
var test_12: int = 42 | ||
|
||
func test(): | ||
for property in get_property_list(): | ||
if property.usage & PROPERTY_USAGE_SCRIPT_VARIABLE: | ||
print(property) | ||
if str(property.name).begins_with("test_"): | ||
Utils.print_property_extended_info(property, self) |
36 changes: 24 additions & 12 deletions
36
modules/gdscript/tests/scripts/parser/features/annotations.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,25 @@ | ||
GDTEST_OK | ||
{ "name": "a0", "class_name": &"", "type": 2, "hint": 2, "hint_string": "A,B,C", "usage": 4102 } | ||
{ "name": "a1", "class_name": &"", "type": 2, "hint": 2, "hint_string": "A,B,C", "usage": 4102 } | ||
{ "name": "a2", "class_name": &"", "type": 2, "hint": 2, "hint_string": "A,B,C", "usage": 4102 } | ||
{ "name": "a3", "class_name": &"", "type": 2, "hint": 2, "hint_string": "A,B,C", "usage": 4102 } | ||
{ "name": "a4", "class_name": &"", "type": 2, "hint": 0, "hint_string": "int", "usage": 4102 } | ||
{ "name": "a5", "class_name": &"", "type": 2, "hint": 0, "hint_string": "int", "usage": 4102 } | ||
{ "name": "a6", "class_name": &"", "type": 2, "hint": 0, "hint_string": "int", "usage": 4102 } | ||
{ "name": "a7", "class_name": &"", "type": 2, "hint": 0, "hint_string": "int", "usage": 4102 } | ||
{ "name": "a8", "class_name": &"", "type": 2, "hint": 0, "hint_string": "int", "usage": 4102 } | ||
{ "name": "a9", "class_name": &"", "type": 2, "hint": 0, "hint_string": "int", "usage": 4102 } | ||
{ "name": "a10", "class_name": &"", "type": 2, "hint": 0, "hint_string": "int", "usage": 4102 } | ||
{ "name": "a11", "class_name": &"", "type": 2, "hint": 0, "hint_string": "int", "usage": 4102 } | ||
var test_1: int = null | ||
hint=ENUM hint_string="A,B,C" usage=DEFAULT|SCRIPT_VARIABLE | ||
var test_2: int = null | ||
hint=ENUM hint_string="A,B,C" usage=DEFAULT|SCRIPT_VARIABLE | ||
var test_3: int = null | ||
hint=ENUM hint_string="A,B,C" usage=DEFAULT|SCRIPT_VARIABLE | ||
var test_4: int = null | ||
hint=ENUM hint_string="A,B,C" usage=DEFAULT|SCRIPT_VARIABLE | ||
var test_5: int = 0 | ||
hint=NONE hint_string="int" usage=DEFAULT|SCRIPT_VARIABLE | ||
var test_6: int = 0 | ||
hint=NONE hint_string="int" usage=DEFAULT|SCRIPT_VARIABLE | ||
var test_7: int = 42 | ||
hint=NONE hint_string="int" usage=DEFAULT|SCRIPT_VARIABLE | ||
var test_8: int = 0 | ||
hint=NONE hint_string="int" usage=DEFAULT|SCRIPT_VARIABLE | ||
var test_9: int = 0 | ||
hint=NONE hint_string="int" usage=DEFAULT|SCRIPT_VARIABLE | ||
var test_10: int = 0 | ||
hint=NONE hint_string="int" usage=DEFAULT|SCRIPT_VARIABLE | ||
var test_11: int = 0 | ||
hint=NONE hint_string="int" usage=DEFAULT|SCRIPT_VARIABLE | ||
var test_12: int = 0 | ||
hint=NONE hint_string="int" usage=DEFAULT|SCRIPT_VARIABLE |
19 changes: 10 additions & 9 deletions
19
modules/gdscript/tests/scripts/parser/features/export_enum.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
@export_enum("Red", "Green", "Blue") var untyped | ||
const Utils = preload("../../utils.notest.gd") | ||
|
||
@export_enum("Red", "Green", "Blue") var weak_int = 0 | ||
@export_enum("Red", "Green", "Blue") var weak_string = "" | ||
@export_enum("Red", "Green", "Blue") var test_untyped | ||
|
||
@export_enum("Red", "Green", "Blue") var hard_int: int | ||
@export_enum("Red", "Green", "Blue") var hard_string: String | ||
@export_enum("Red", "Green", "Blue") var test_weak_int = 0 | ||
@export_enum("Red", "Green", "Blue") var test_weak_string = "" | ||
|
||
@export_enum("Red:10", "Green:20", "Blue:30") var with_values | ||
@export_enum("Red", "Green", "Blue") var test_hard_int: int | ||
@export_enum("Red", "Green", "Blue") var test_hard_string: String | ||
|
||
@export_enum("Red:10", "Green:20", "Blue:30") var test_with_values | ||
|
||
func test(): | ||
for property in get_property_list(): | ||
if property.name in ["untyped", "weak_int", "weak_string", "hard_int", | ||
"hard_string", "with_values"]: | ||
prints(property.name, property.type, property.hint_string) | ||
if str(property.name).begins_with("test_"): | ||
Utils.print_property_extended_info(property, self) |
18 changes: 12 additions & 6 deletions
18
modules/gdscript/tests/scripts/parser/features/export_enum.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
GDTEST_OK | ||
untyped 2 Red,Green,Blue | ||
weak_int 2 Red,Green,Blue | ||
weak_string 4 Red,Green,Blue | ||
hard_int 2 Red,Green,Blue | ||
hard_string 4 Red,Green,Blue | ||
with_values 2 Red:10,Green:20,Blue:30 | ||
var test_untyped: int = null | ||
hint=ENUM hint_string="Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE | ||
var test_weak_int: int = 0 | ||
hint=ENUM hint_string="Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE | ||
var test_weak_string: String = "" | ||
hint=ENUM hint_string="Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE | ||
var test_hard_int: int = 0 | ||
hint=ENUM hint_string="Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE | ||
var test_hard_string: String = "" | ||
hint=ENUM hint_string="Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE | ||
var test_with_values: int = null | ||
hint=ENUM hint_string="Red:10,Green:20,Blue:30" usage=DEFAULT|SCRIPT_VARIABLE |
35 changes: 17 additions & 18 deletions
35
modules/gdscript/tests/scripts/parser/features/export_variable.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,22 @@ | ||
extends Node | ||
|
||
@export var example = 99 | ||
@export_range(0, 100) var example_range = 100 | ||
@export_range(0, 100, 1) var example_range_step = 101 | ||
@export_range(0, 100, 1, "or_greater") var example_range_step_or_greater = 102 | ||
const Utils = preload("../../utils.notest.gd") | ||
|
||
@export var color: Color | ||
@export_color_no_alpha var color_no_alpha: Color | ||
@export_node_path("Sprite2D", "Sprite3D", "Control", "Node") var nodepath := ^"hello" | ||
@export var node: Node | ||
@export var node_array: Array[Node] | ||
@export var test_weak_int = 1 | ||
@export var test_hard_int: int = 2 | ||
@export_storage var test_storage_untyped | ||
@export_storage var test_storage_weak_int = 3 # Property info still `Variant`, unlike `@export`. | ||
@export_storage var test_storage_hard_int: int = 4 | ||
@export_range(0, 100) var test_range = 100 | ||
@export_range(0, 100, 1) var test_range_step = 101 | ||
@export_range(0, 100, 1, "or_greater") var test_range_step_or_greater = 102 | ||
@export var test_color: Color | ||
@export_color_no_alpha var test_color_no_alpha: Color | ||
@export_node_path("Sprite2D", "Sprite3D", "Control", "Node") var test_node_path := ^"hello" | ||
@export var test_node: Node | ||
@export var test_node_array: Array[Node] | ||
|
||
func test(): | ||
print(example) | ||
print(example_range) | ||
print(example_range_step) | ||
print(example_range_step_or_greater) | ||
print(color) | ||
print(color_no_alpha) | ||
print(nodepath) | ||
print(node) | ||
print(var_to_str(node_array)) | ||
for property in get_property_list(): | ||
if str(property.name).begins_with("test_"): | ||
Utils.print_property_extended_info(property, self) |
35 changes: 26 additions & 9 deletions
35
modules/gdscript/tests/scripts/parser/features/export_variable.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,27 @@ | ||
GDTEST_OK | ||
99 | ||
100 | ||
101 | ||
102 | ||
(0, 0, 0, 1) | ||
(0, 0, 0, 1) | ||
hello | ||
<null> | ||
Array[Node]([]) | ||
var test_weak_int: int = 1 | ||
hint=NONE hint_string="int" usage=DEFAULT|SCRIPT_VARIABLE | ||
var test_hard_int: int = 2 | ||
hint=NONE hint_string="int" usage=DEFAULT|SCRIPT_VARIABLE | ||
var test_storage_untyped: Variant = null | ||
hint=NONE hint_string="" usage=STORAGE|SCRIPT_VARIABLE|NIL_IS_VARIANT | ||
var test_storage_weak_int: Variant = 3 | ||
hint=NONE hint_string="" usage=STORAGE|SCRIPT_VARIABLE|NIL_IS_VARIANT | ||
var test_storage_hard_int: int = 4 | ||
hint=NONE hint_string="" usage=STORAGE|SCRIPT_VARIABLE | ||
var test_range: int = 100 | ||
hint=RANGE hint_string="0,100" usage=DEFAULT|SCRIPT_VARIABLE | ||
var test_range_step: int = 101 | ||
hint=RANGE hint_string="0,100,1" usage=DEFAULT|SCRIPT_VARIABLE | ||
var test_range_step_or_greater: int = 102 | ||
hint=RANGE hint_string="0,100,1,or_greater" usage=DEFAULT|SCRIPT_VARIABLE | ||
var test_color: Color = Color(0, 0, 0, 1) | ||
hint=NONE hint_string="Color" usage=DEFAULT|SCRIPT_VARIABLE | ||
var test_color_no_alpha: Color = Color(0, 0, 0, 1) | ||
hint=COLOR_NO_ALPHA hint_string="" usage=DEFAULT|SCRIPT_VARIABLE | ||
var test_node_path: NodePath = NodePath("hello") | ||
hint=NODE_PATH_VALID_TYPES hint_string="Sprite2D,Sprite3D,Control,Node" usage=DEFAULT|SCRIPT_VARIABLE | ||
var test_node: Node = null | ||
hint=NODE_TYPE hint_string="Node" usage=DEFAULT|SCRIPT_VARIABLE | ||
var test_node_array: Array = Array[Node]([]) | ||
hint=TYPE_STRING hint_string="24/34:Node" usage=DEFAULT|SCRIPT_VARIABLE |
12 changes: 6 additions & 6 deletions
12
.../gdscript/tests/scripts/runtime/features/export_group_no_name_conflict_with_properties.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
extends RefCounted # TODO: Fix standalone annotations parsing. | ||
const Utils = preload("../../utils.notest.gd") | ||
|
||
# GH-73843 | ||
@export_group("Resource") | ||
|
||
# GH-78252 | ||
@export var prop_1: int | ||
@export_category("prop_1") | ||
@export var prop_2: int | ||
@export var test_1: int | ||
@export_category("test_1") | ||
@export var test_2: int | ||
|
||
func test(): | ||
var resource := Resource.new() | ||
prints("Not shadowed:", resource.get_class()) | ||
|
||
for property in get_property_list(): | ||
if property.name in ["prop_1", "prop_2"]: | ||
print(property) | ||
if str(property.name).begins_with("test_"): | ||
Utils.print_property_extended_info(property, self) |
9 changes: 6 additions & 3 deletions
9
...gdscript/tests/scripts/runtime/features/export_group_no_name_conflict_with_properties.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
GDTEST_OK | ||
Not shadowed: Resource | ||
{ "name": "prop_1", "class_name": &"", "type": 2, "hint": 0, "hint_string": "int", "usage": 4102 } | ||
{ "name": "prop_1", "class_name": &"", "type": 0, "hint": 0, "hint_string": "", "usage": 128 } | ||
{ "name": "prop_2", "class_name": &"", "type": 2, "hint": 0, "hint_string": "int", "usage": 4102 } | ||
var test_1: int = 0 | ||
hint=NONE hint_string="int" usage=DEFAULT|SCRIPT_VARIABLE | ||
@export_category("test_1") | ||
hint=NONE hint_string="" usage=CATEGORY | ||
var test_2: int = 0 | ||
hint=NONE hint_string="int" usage=DEFAULT|SCRIPT_VARIABLE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.