Add vararg call() method to C++ Callable
This commit is contained in:
@ -3169,26 +3169,7 @@ AnimationTrackEdit::AnimationTrackEdit() {
|
||||
|
||||
AnimationTrackEdit *AnimationTrackEditPlugin::create_value_track_edit(Object *p_object, Variant::Type p_type, const String &p_property, PropertyHint p_hint, const String &p_hint_string, int p_usage) {
|
||||
if (get_script_instance()) {
|
||||
Variant args[6] = {
|
||||
p_object,
|
||||
p_type,
|
||||
p_property,
|
||||
p_hint,
|
||||
p_hint_string,
|
||||
p_usage
|
||||
};
|
||||
|
||||
Variant *argptrs[6] = {
|
||||
&args[0],
|
||||
&args[1],
|
||||
&args[2],
|
||||
&args[3],
|
||||
&args[4],
|
||||
&args[5]
|
||||
};
|
||||
|
||||
Callable::CallError ce;
|
||||
return Object::cast_to<AnimationTrackEdit>(get_script_instance()->callp("create_value_track_edit", (const Variant **)&argptrs, 6, ce).operator Object *());
|
||||
return Object::cast_to<AnimationTrackEdit>(get_script_instance()->call("create_value_track_edit", p_object, p_type, p_property, p_hint, p_hint_string, p_usage));
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -1726,11 +1726,7 @@ void EditorInspectorArray::_move_element(int p_element_index, int p_to_pos) {
|
||||
// Call the function.
|
||||
Callable move_function = EditorNode::get_editor_data().get_move_array_element_function(object->get_class_name());
|
||||
if (move_function.is_valid()) {
|
||||
Variant args[] = { undo_redo, object, array_element_prefix, p_element_index, p_to_pos };
|
||||
const Variant *args_p[] = { &args[0], &args[1], &args[2], &args[3], &args[4] };
|
||||
Variant return_value;
|
||||
Callable::CallError call_error;
|
||||
move_function.callp(args_p, 5, return_value, call_error);
|
||||
move_function.call(undo_redo, object, array_element_prefix, p_element_index, p_to_pos);
|
||||
} else {
|
||||
WARN_PRINT(vformat("Could not find a function to move arrays elements for class %s. Register a move element function using EditorData::add_move_array_element_function", object->get_class_name()));
|
||||
}
|
||||
@ -1875,11 +1871,7 @@ void EditorInspectorArray::_clear_array() {
|
||||
// Call the function.
|
||||
Callable move_function = EditorNode::get_editor_data().get_move_array_element_function(object->get_class_name());
|
||||
if (move_function.is_valid()) {
|
||||
Variant args[] = { undo_redo, object, array_element_prefix, i, -1 };
|
||||
const Variant *args_p[] = { &args[0], &args[1], &args[2], &args[3], &args[4] };
|
||||
Variant return_value;
|
||||
Callable::CallError call_error;
|
||||
move_function.callp(args_p, 5, return_value, call_error);
|
||||
move_function.call(undo_redo, object, array_element_prefix, i, -1);
|
||||
} else {
|
||||
WARN_PRINT(vformat("Could not find a function to move arrays elements for class %s. Register a move element function using EditorData::add_move_array_element_function", object->get_class_name()));
|
||||
}
|
||||
@ -1929,11 +1921,7 @@ void EditorInspectorArray::_resize_array(int p_size) {
|
||||
// Call the function.
|
||||
Callable move_function = EditorNode::get_editor_data().get_move_array_element_function(object->get_class_name());
|
||||
if (move_function.is_valid()) {
|
||||
Variant args[] = { undo_redo, object, array_element_prefix, -1, -1 };
|
||||
const Variant *args_p[] = { &args[0], &args[1], &args[2], &args[3], &args[4] };
|
||||
Variant return_value;
|
||||
Callable::CallError call_error;
|
||||
move_function.callp(args_p, 5, return_value, call_error);
|
||||
move_function.call(undo_redo, object, array_element_prefix, -1, -1);
|
||||
} else {
|
||||
WARN_PRINT(vformat("Could not find a function to move arrays elements for class %s. Register a move element function using EditorData::add_move_array_element_function", object->get_class_name()));
|
||||
}
|
||||
@ -1948,11 +1936,7 @@ void EditorInspectorArray::_resize_array(int p_size) {
|
||||
// Call the function.
|
||||
Callable move_function = EditorNode::get_editor_data().get_move_array_element_function(object->get_class_name());
|
||||
if (move_function.is_valid()) {
|
||||
Variant args[] = { undo_redo, object, array_element_prefix, i, -1 };
|
||||
const Variant *args_p[] = { &args[0], &args[1], &args[2], &args[3], &args[4] };
|
||||
Variant return_value;
|
||||
Callable::CallError call_error;
|
||||
move_function.callp(args_p, 5, return_value, call_error);
|
||||
move_function.call(undo_redo, object, array_element_prefix, i, -1);
|
||||
} else {
|
||||
WARN_PRINT(vformat("Could not find a function to move arrays elements for class %s. Register a move element function using EditorData::add_move_array_element_function", object->get_class_name()));
|
||||
}
|
||||
|
||||
@ -119,7 +119,7 @@ void PostImportPluginSkeletonRenamer::_internal_process(InternalImportCategory p
|
||||
|
||||
// Rename bones in all Nodes by calling method.
|
||||
{
|
||||
Vector<Variant> vargs;
|
||||
Array vargs;
|
||||
vargs.push_back(p_base_scene);
|
||||
vargs.push_back(skeleton);
|
||||
Dictionary rename_map_dict;
|
||||
@ -127,18 +127,11 @@ void PostImportPluginSkeletonRenamer::_internal_process(InternalImportCategory p
|
||||
rename_map_dict[E->key] = E->value;
|
||||
}
|
||||
vargs.push_back(rename_map_dict);
|
||||
const Variant **argptrs = (const Variant **)alloca(sizeof(const Variant **) * vargs.size());
|
||||
const Variant *args = vargs.ptr();
|
||||
uint32_t argcount = vargs.size();
|
||||
for (uint32_t i = 0; i < argcount; i++) {
|
||||
argptrs[i] = &args[i];
|
||||
}
|
||||
|
||||
TypedArray<Node> nodes = p_base_scene->find_children("*");
|
||||
while (nodes.size()) {
|
||||
Node *nd = Object::cast_to<Node>(nodes.pop_back());
|
||||
Callable::CallError ce;
|
||||
nd->callp("_notify_skeleton_bones_renamed", argptrs, argcount, ce);
|
||||
nd->callv("_notify_skeleton_bones_renamed", vargs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -134,11 +134,7 @@ void TilesEditorUtils::_thread() {
|
||||
Ref<Image> image = viewport->get_texture()->get_image();
|
||||
|
||||
// Find the index for the given pattern. TODO: optimize.
|
||||
Variant args[] = { item.pattern, ImageTexture::create_from_image(image) };
|
||||
const Variant *args_ptr[] = { &args[0], &args[1] };
|
||||
Variant r;
|
||||
Callable::CallError error;
|
||||
item.callback.callp(args_ptr, 2, r, error);
|
||||
item.callback.call(item.pattern, ImageTexture::create_from_image(image));
|
||||
|
||||
viewport->queue_free();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user