summaryrefslogtreecommitdiffstats
path: root/editor/editor_run_script.cpp
diff options
context:
space:
mode:
authorreduz <reduzio@gmail.com>2021-08-21 22:52:44 -0300
committerreduz <reduzio@gmail.com>2021-08-22 08:23:58 -0300
commit3682978aee06cd5cf26ba462a4e44d352e9e0cd1 (patch)
treefee311b675144ae3a5fecc58857912ea250b1bb7 /editor/editor_run_script.cpp
parent2a5c64f2a188360d09f793c0dbd35e1911b4c073 (diff)
downloadredot-engine-3682978aee06cd5cf26ba462a4e44d352e9e0cd1.tar.gz
Replace BIND_VMETHOD by new GDVIRTUAL syntax
* New syntax is type safe. * New syntax allows for type safe virtuals in native extensions. * New syntax permits extremely fast calling. Note: Everything was replaced where possible except for `_gui_input` `_input` and `_unhandled_input`. These will require API rework on a separate PR as they work different than the rest of the functions. Added a new method flag METHOD_FLAG_OBJECT_CORE, used internally. Allows to not dump the core virtuals like `_notification` to the json API, since each language will implement those as it is best fits.
Diffstat (limited to 'editor/editor_run_script.cpp')
-rw-r--r--editor/editor_run_script.cpp16
1 files changed, 3 insertions, 13 deletions
diff --git a/editor/editor_run_script.cpp b/editor/editor_run_script.cpp
index 83ce50a9f9..27923ef413 100644
--- a/editor/editor_run_script.cpp
+++ b/editor/editor_run_script.cpp
@@ -60,18 +60,8 @@ Node *EditorScript::get_scene() {
}
void EditorScript::_run() {
- Ref<Script> s = get_script();
- ERR_FAIL_COND(!s.is_valid());
- if (!get_script_instance()) {
- EditorNode::add_io_error(TTR("Couldn't instance script:") + "\n " + s->get_path() + "\n" + TTR("Did you forget the 'tool' keyword?"));
- return;
- }
-
- Callable::CallError ce;
- ce.error = Callable::CallError::CALL_OK;
- get_script_instance()->call("_run", nullptr, 0, ce);
- if (ce.error != Callable::CallError::CALL_OK) {
- EditorNode::add_io_error(TTR("Couldn't run script:") + "\n " + s->get_path() + "\n" + TTR("Did you forget the '_run' method?"));
+ if (!GDVIRTUAL_CALL(_run)) {
+ EditorNode::add_io_error(TTR("Couldn't run editor script, did you forget to override the '_run' method?"));
}
}
@@ -83,7 +73,7 @@ void EditorScript::_bind_methods() {
ClassDB::bind_method(D_METHOD("add_root_node", "node"), &EditorScript::add_root_node);
ClassDB::bind_method(D_METHOD("get_scene"), &EditorScript::get_scene);
ClassDB::bind_method(D_METHOD("get_editor_interface"), &EditorScript::get_editor_interface);
- BIND_VMETHOD(MethodInfo("_run"));
+ GDVIRTUAL_BIND(_run);
}
EditorScript::EditorScript() {