From b4e08eb752cca0135208ed0729479e1d9c87773d Mon Sep 17 00:00:00 2001 From: George Marques Date: Wed, 17 Jan 2024 11:27:40 -0300 Subject: Allow `free()` to be used as Callable This method is registered in a special way so ClassDB doesn't naturally know about its existence. Here it is hardcoded if any other option fail to check if it is about the `free()` method and, if so, say it exists and return a Callable. --- .../tests/scripts/runtime/features/free_is_callable.gd | 10 ++++++++++ .../tests/scripts/runtime/features/free_is_callable.out | 3 +++ 2 files changed, 13 insertions(+) create mode 100644 modules/gdscript/tests/scripts/runtime/features/free_is_callable.gd create mode 100644 modules/gdscript/tests/scripts/runtime/features/free_is_callable.out (limited to 'modules/gdscript/tests/scripts/runtime') diff --git a/modules/gdscript/tests/scripts/runtime/features/free_is_callable.gd b/modules/gdscript/tests/scripts/runtime/features/free_is_callable.gd new file mode 100644 index 0000000000..b9746a8207 --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/free_is_callable.gd @@ -0,0 +1,10 @@ +func test(): + var node := Node.new() + var callable: Callable = node.free + callable.call() + print(node) + + node = Node.new() + callable = node["free"] + callable.call() + print(node) diff --git a/modules/gdscript/tests/scripts/runtime/features/free_is_callable.out b/modules/gdscript/tests/scripts/runtime/features/free_is_callable.out new file mode 100644 index 0000000000..97bfc46d96 --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/free_is_callable.out @@ -0,0 +1,3 @@ +GDTEST_OK + + -- cgit v1.2.3