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:
reduz
2021-08-21 22:52:44 -03:00
parent 2a5c64f2a1
commit 3682978aee
104 changed files with 1389 additions and 1227 deletions

View File

@@ -59,42 +59,33 @@
#include "scene/scene_string_names.h"
void EditorResourceConversionPlugin::_bind_methods() {
MethodInfo mi;
mi.name = "_convert";
mi.return_val.type = Variant::OBJECT;
mi.return_val.class_name = "Resource";
mi.return_val.hint = PROPERTY_HINT_RESOURCE_TYPE;
mi.return_val.hint_string = "Resource";
mi.arguments.push_back(mi.return_val);
mi.arguments[0].name = "resource";
BIND_VMETHOD(mi)
mi.name = "_handles";
mi.return_val = PropertyInfo(Variant::BOOL, "");
BIND_VMETHOD(MethodInfo(Variant::STRING, "_converts_to"));
GDVIRTUAL_BIND(_converts_to);
GDVIRTUAL_BIND(_handles, "resource");
GDVIRTUAL_BIND(_convert, "resource");
}
String EditorResourceConversionPlugin::converts_to() const {
if (get_script_instance()) {
return get_script_instance()->call("_converts_to");
String ret;
if (GDVIRTUAL_CALL(_converts_to, ret)) {
return ret;
}
return "";
}
bool EditorResourceConversionPlugin::handles(const Ref<Resource> &p_resource) const {
if (get_script_instance()) {
return get_script_instance()->call("_handles", p_resource);
bool ret;
if (GDVIRTUAL_CALL(_handles, p_resource, ret)) {
return ret;
}
return false;
}
Ref<Resource> EditorResourceConversionPlugin::convert(const Ref<Resource> &p_resource) const {
if (get_script_instance()) {
return get_script_instance()->call("_convert", p_resource);
RES ret;
if (GDVIRTUAL_CALL(_convert, p_resource, ret)) {
return ret;
}
return Ref<Resource>();