1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-10 13:00:37 +00:00

Add vararg call() method to C++ Callable

This commit is contained in:
kobewi
2023-07-11 16:18:10 +02:00
parent c7ed5d795e
commit 09b30be86d
27 changed files with 96 additions and 332 deletions

View File

@@ -3738,15 +3738,8 @@ void DisplayServerX11::_window_changed(XEvent *event) {
}
#endif
if (!wd.rect_changed_callback.is_null()) {
Rect2i r = new_rect;
Variant rect = r;
Variant *rectp = ▭
Variant ret;
Callable::CallError ce;
wd.rect_changed_callback.callp((const Variant **)&rectp, 1, ret, ce);
if (wd.rect_changed_callback.is_valid()) {
wd.rect_changed_callback.call(new_rect);
}
}
@@ -3764,11 +3757,6 @@ void DisplayServerX11::_dispatch_input_events(const Ref<InputEvent> &p_event) {
}
void DisplayServerX11::_dispatch_input_event(const Ref<InputEvent> &p_event) {
Variant ev = p_event;
Variant *evp = &ev;
Variant ret;
Callable::CallError ce;
{
List<WindowID>::Element *E = popup_list.back();
if (E && Object::cast_to<InputEventKey>(*p_event)) {
@@ -3776,7 +3764,7 @@ void DisplayServerX11::_dispatch_input_event(const Ref<InputEvent> &p_event) {
if (windows.has(E->get())) {
Callable callable = windows[E->get()].input_event_callback;
if (callable.is_valid()) {
callable.callp((const Variant **)&evp, 1, ret, ce);
callable.call(p_event);
}
}
return;
@@ -3789,7 +3777,7 @@ void DisplayServerX11::_dispatch_input_event(const Ref<InputEvent> &p_event) {
if (windows.has(event_from_window->get_window_id())) {
Callable callable = windows[event_from_window->get_window_id()].input_event_callback;
if (callable.is_valid()) {
callable.callp((const Variant **)&evp, 1, ret, ce);
callable.call(p_event);
}
}
} else {
@@ -3797,19 +3785,16 @@ void DisplayServerX11::_dispatch_input_event(const Ref<InputEvent> &p_event) {
for (KeyValue<WindowID, WindowData> &E : windows) {
Callable callable = E.value.input_event_callback;
if (callable.is_valid()) {
callable.callp((const Variant **)&evp, 1, ret, ce);
callable.call(p_event);
}
}
}
}
void DisplayServerX11::_send_window_event(const WindowData &wd, WindowEvent p_event) {
if (!wd.event_callback.is_null()) {
if (wd.event_callback.is_valid()) {
Variant event = int(p_event);
Variant *eventp = &event;
Variant ret;
Callable::CallError ce;
wd.event_callback.callp((const Variant **)&eventp, 1, ret, ce);
wd.event_callback.call(event);
}
}
@@ -4754,11 +4739,7 @@ void DisplayServerX11::process_events() {
}
if (!windows[window_id].drop_files_callback.is_null()) {
Variant v = files;
Variant *vp = &v;
Variant ret;
Callable::CallError ce;
windows[window_id].drop_files_callback.callp((const Variant **)&vp, 1, ret, ce);
windows[window_id].drop_files_callback.call(files);
}
//Reply that all is well.