mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
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.
This commit is contained in:
parent
352ebe9725
commit
0ba6048ad3
36 changed files with 689 additions and 86 deletions
|
@ -566,6 +566,14 @@ GDScriptTest::TestResult GDScriptTest::execute_test_code(bool p_is_generating) {
|
|||
ERR_FAIL_V_MSG(result, "\nCould not find test function on: '" + source_file + "'");
|
||||
}
|
||||
|
||||
// Setup output handlers.
|
||||
ErrorHandlerData error_data(&result, this);
|
||||
|
||||
_print_handler.userdata = &result;
|
||||
_error_handler.userdata = &error_data;
|
||||
add_print_handler(&_print_handler);
|
||||
add_error_handler(&_error_handler);
|
||||
|
||||
script->reload();
|
||||
|
||||
// Create object instance for test.
|
||||
|
@ -577,14 +585,6 @@ GDScriptTest::TestResult GDScriptTest::execute_test_code(bool p_is_generating) {
|
|||
obj->set_script(script);
|
||||
GDScriptInstance *instance = static_cast<GDScriptInstance *>(obj->get_script_instance());
|
||||
|
||||
// Setup output handlers.
|
||||
ErrorHandlerData error_data(&result, this);
|
||||
|
||||
_print_handler.userdata = &result;
|
||||
_error_handler.userdata = &error_data;
|
||||
add_print_handler(&_print_handler);
|
||||
add_error_handler(&_error_handler);
|
||||
|
||||
// Call test function.
|
||||
Callable::CallError call_err;
|
||||
instance->callp(GDScriptTestRunner::test_function_name, nullptr, 0, call_err);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue