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

@ -2768,48 +2768,38 @@ Point2i TextEdit::get_next_visible_line_index_offset_from(int p_line_from, int p
// Overridable actions
void TextEdit::handle_unicode_input(const uint32_t p_unicode) {
ScriptInstance *si = get_script_instance();
if (si && si->has_method("_handle_unicode_input")) {
si->call("_handle_unicode_input", p_unicode);
if (GDVIRTUAL_CALL(_handle_unicode_input, p_unicode)) {
return;
}
_handle_unicode_input(p_unicode);
_handle_unicode_input_internal(p_unicode);
}
void TextEdit::backspace() {
ScriptInstance *si = get_script_instance();
if (si && si->has_method("_backspace")) {
si->call("_backspace");
if (GDVIRTUAL_CALL(_backspace)) {
return;
}
_backspace();
_backspace_internal();
}
void TextEdit::cut() {
ScriptInstance *si = get_script_instance();
if (si && si->has_method("_cut")) {
si->call("_cut");
if (GDVIRTUAL_CALL(_cut)) {
return;
}
_cut();
_cut_internal();
}
void TextEdit::copy() {
ScriptInstance *si = get_script_instance();
if (si && si->has_method("_copy")) {
si->call("_copy");
if (GDVIRTUAL_CALL(_copy)) {
return;
}
_copy();
_copy_internal();
}
void TextEdit::paste() {
ScriptInstance *si = get_script_instance();
if (si && si->has_method("_paste")) {
si->call("_paste");
if (GDVIRTUAL_CALL(_paste)) {
return;
}
_paste();
_paste_internal();
}
// Context menu.
@ -4452,12 +4442,11 @@ void TextEdit::_bind_methods() {
ClassDB::bind_method(D_METHOD("copy"), &TextEdit::copy);
ClassDB::bind_method(D_METHOD("paste"), &TextEdit::paste);
BIND_VMETHOD(MethodInfo("_handle_unicode_input", PropertyInfo(Variant::INT, "unicode")))
BIND_VMETHOD(MethodInfo("_backspace"));
BIND_VMETHOD(MethodInfo("_cut"));
BIND_VMETHOD(MethodInfo("_copy"));
BIND_VMETHOD(MethodInfo("_paste"));
GDVIRTUAL_BIND(_handle_unicode_input, "unicode_char")
GDVIRTUAL_BIND(_backspace)
GDVIRTUAL_BIND(_cut)
GDVIRTUAL_BIND(_copy)
GDVIRTUAL_BIND(_paste)
// Context Menu
BIND_ENUM_CONSTANT(MENU_CUT);
@ -4884,7 +4873,7 @@ void TextEdit::_set_symbol_lookup_word(const String &p_symbol) {
/* Text manipulation */
// Overridable actions
void TextEdit::_handle_unicode_input(const uint32_t p_unicode) {
void TextEdit::_handle_unicode_input_internal(const uint32_t p_unicode) {
if (!editable) {
return;
}
@ -4915,7 +4904,7 @@ void TextEdit::_handle_unicode_input(const uint32_t p_unicode) {
}
}
void TextEdit::_backspace() {
void TextEdit::_backspace_internal() {
if (!editable) {
return;
}
@ -4946,7 +4935,7 @@ void TextEdit::_backspace() {
set_caret_column(prev_column);
}
void TextEdit::_cut() {
void TextEdit::_cut_internal() {
if (!editable) {
return;
}
@ -4976,7 +4965,7 @@ void TextEdit::_cut() {
cut_copy_line = clipboard;
}
void TextEdit::_copy() {
void TextEdit::_copy_internal() {
if (has_selection()) {
DisplayServer::get_singleton()->clipboard_set(get_selected_text());
cut_copy_line = "";
@ -4991,7 +4980,7 @@ void TextEdit::_copy() {
}
}
void TextEdit::_paste() {
void TextEdit::_paste_internal() {
if (!editable) {
return;
}