From 0ba6048ad3c945e2bd1d0114b5095535c22103ce Mon Sep 17 00:00:00 2001 From: George Marques Date: Wed, 19 Apr 2023 11:10:35 -0300 Subject: Add support for static variables in GDScript Which allows editable data associated with a particular class instead of the instance. Scripts with static variables are kept in memory indefinitely unless the `@static_unload` annotation is used or the `static_unload()` method is called on the GDScript. If the custom function `_static_init()` exists it will be called when the class is loaded, after the static variables are set. --- modules/gdscript/gdscript_warning.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'modules/gdscript/gdscript_warning.cpp') diff --git a/modules/gdscript/gdscript_warning.cpp b/modules/gdscript/gdscript_warning.cpp index 0cb8e3a2af..c7f72f4eed 100644 --- a/modules/gdscript/gdscript_warning.cpp +++ b/modules/gdscript/gdscript_warning.cpp @@ -185,6 +185,9 @@ String GDScriptWarning::get_message() const { case ONREADY_WITH_EXPORT: { return R"("@onready" will set the default value after "@export" takes effect and will override it.)"; } + case REDUNDANT_STATIC_UNLOAD: { + return R"(The "@static_unload" annotation is redundant because the file does not have a class with static variables.)"; + } case WARNING_MAX: break; // Can't happen, but silences warning } @@ -254,6 +257,7 @@ String GDScriptWarning::get_name_from_code(Code p_code) { "NATIVE_METHOD_OVERRIDE", "GET_NODE_DEFAULT_WITHOUT_ONREADY", "ONREADY_WITH_EXPORT", + "REDUNDANT_STATIC_UNLOAD", }; static_assert((sizeof(names) / sizeof(*names)) == WARNING_MAX, "Amount of warning types don't match the amount of warning names."); -- cgit v1.2.3