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.
This commit is contained in:
+15
-14
@@ -33,11 +33,6 @@
|
||||
#include "core/object/script_language.h"
|
||||
|
||||
void MainLoop::_bind_methods() {
|
||||
BIND_VMETHOD(MethodInfo("_initialize"));
|
||||
BIND_VMETHOD(MethodInfo(Variant::BOOL, "_physics_process", PropertyInfo(Variant::FLOAT, "delta")));
|
||||
BIND_VMETHOD(MethodInfo(Variant::BOOL, "_process", PropertyInfo(Variant::FLOAT, "delta")));
|
||||
BIND_VMETHOD(MethodInfo("_finalize"));
|
||||
|
||||
BIND_CONSTANT(NOTIFICATION_OS_MEMORY_WARNING);
|
||||
BIND_CONSTANT(NOTIFICATION_TRANSLATION_CHANGED);
|
||||
BIND_CONSTANT(NOTIFICATION_WM_ABOUT);
|
||||
@@ -50,7 +45,12 @@ void MainLoop::_bind_methods() {
|
||||
BIND_CONSTANT(NOTIFICATION_TEXT_SERVER_CHANGED);
|
||||
|
||||
ADD_SIGNAL(MethodInfo("on_request_permissions_result", PropertyInfo(Variant::STRING, "permission"), PropertyInfo(Variant::BOOL, "granted")));
|
||||
};
|
||||
|
||||
GDVIRTUAL_BIND(_initialize);
|
||||
GDVIRTUAL_BIND(_physics_process, "delta");
|
||||
GDVIRTUAL_BIND(_process, "delta");
|
||||
GDVIRTUAL_BIND(_finalize);
|
||||
}
|
||||
|
||||
void MainLoop::set_initialize_script(const Ref<Script> &p_initialize_script) {
|
||||
initialize_script = p_initialize_script;
|
||||
@@ -61,30 +61,31 @@ void MainLoop::initialize() {
|
||||
set_script(initialize_script);
|
||||
}
|
||||
|
||||
if (get_script_instance()) {
|
||||
get_script_instance()->call("_initialize");
|
||||
}
|
||||
GDVIRTUAL_CALL(_initialize);
|
||||
}
|
||||
|
||||
bool MainLoop::physics_process(double p_time) {
|
||||
if (get_script_instance()) {
|
||||
return get_script_instance()->call("_physics_process", p_time);
|
||||
bool quit;
|
||||
if (GDVIRTUAL_CALL(_physics_process, p_time, quit)) {
|
||||
return quit;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MainLoop::process(double p_time) {
|
||||
if (get_script_instance()) {
|
||||
return get_script_instance()->call("_process", p_time);
|
||||
bool quit;
|
||||
if (GDVIRTUAL_CALL(_process, p_time, quit)) {
|
||||
return quit;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void MainLoop::finalize() {
|
||||
GDVIRTUAL_CALL(_finalize);
|
||||
|
||||
if (get_script_instance()) {
|
||||
get_script_instance()->call("_finalize");
|
||||
set_script(Variant()); //clear script
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user