mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Remove VARIANT_ARG* macros
* Very old macros from the time Godot was created. * Limited arguments to 5 (then later changed to 8) in many places. * They were replaced by C++11 Variadic Templates. * Renamed methods that take argument pointers to have a "p" suffix. This was used in some places and not in others, so made it standard. * Also added a dereference check for Variant*. Helped catch a couple of bugs.
This commit is contained in:
parent
922348f4c0
commit
21637dfc25
59 changed files with 417 additions and 467 deletions
|
@ -32,6 +32,7 @@
|
|||
|
||||
#include "core/config/project_settings.h"
|
||||
#include "core/core_string_names.h"
|
||||
#include "core/object/class_db.h"
|
||||
#include "core/object/script_language.h"
|
||||
|
||||
MessageQueue *MessageQueue::singleton = nullptr;
|
||||
|
@ -40,23 +41,8 @@ MessageQueue *MessageQueue::get_singleton() {
|
|||
return singleton;
|
||||
}
|
||||
|
||||
Error MessageQueue::push_call(ObjectID p_id, const StringName &p_method, const Variant **p_args, int p_argcount, bool p_show_error) {
|
||||
return push_callable(Callable(p_id, p_method), p_args, p_argcount, p_show_error);
|
||||
}
|
||||
|
||||
Error MessageQueue::push_call(ObjectID p_id, const StringName &p_method, VARIANT_ARG_DECLARE) {
|
||||
VARIANT_ARGPTRS;
|
||||
|
||||
int argc = 0;
|
||||
|
||||
for (int i = 0; i < VARIANT_ARG_MAX; i++) {
|
||||
if (argptr[i]->get_type() == Variant::NIL) {
|
||||
break;
|
||||
}
|
||||
argc++;
|
||||
}
|
||||
|
||||
return push_call(p_id, p_method, argptr, argc, false);
|
||||
Error MessageQueue::push_callp(ObjectID p_id, const StringName &p_method, const Variant **p_args, int p_argcount, bool p_show_error) {
|
||||
return push_callablep(Callable(p_id, p_method), p_args, p_argcount, p_show_error);
|
||||
}
|
||||
|
||||
Error MessageQueue::push_set(ObjectID p_id, const StringName &p_prop, const Variant &p_value) {
|
||||
|
@ -113,8 +99,8 @@ Error MessageQueue::push_notification(ObjectID p_id, int p_notification) {
|
|||
return OK;
|
||||
}
|
||||
|
||||
Error MessageQueue::push_call(Object *p_object, const StringName &p_method, VARIANT_ARG_DECLARE) {
|
||||
return push_call(p_object->get_instance_id(), p_method, VARIANT_ARG_PASS);
|
||||
Error MessageQueue::push_callp(Object *p_object, const StringName &p_method, const Variant **p_args, int p_argcount, bool p_show_error) {
|
||||
return push_callp(p_object->get_instance_id(), p_method, p_args, p_argcount, p_show_error);
|
||||
}
|
||||
|
||||
Error MessageQueue::push_notification(Object *p_object, int p_notification) {
|
||||
|
@ -125,7 +111,7 @@ Error MessageQueue::push_set(Object *p_object, const StringName &p_prop, const V
|
|||
return push_set(p_object->get_instance_id(), p_prop, p_value);
|
||||
}
|
||||
|
||||
Error MessageQueue::push_callable(const Callable &p_callable, const Variant **p_args, int p_argcount, bool p_show_error) {
|
||||
Error MessageQueue::push_callablep(const Callable &p_callable, const Variant **p_args, int p_argcount, bool p_show_error) {
|
||||
_THREAD_SAFE_METHOD_
|
||||
|
||||
int room_needed = sizeof(Message) + sizeof(Variant) * p_argcount;
|
||||
|
@ -155,21 +141,6 @@ Error MessageQueue::push_callable(const Callable &p_callable, const Variant **p_
|
|||
return OK;
|
||||
}
|
||||
|
||||
Error MessageQueue::push_callable(const Callable &p_callable, VARIANT_ARG_DECLARE) {
|
||||
VARIANT_ARGPTRS;
|
||||
|
||||
int argc = 0;
|
||||
|
||||
for (int i = 0; i < VARIANT_ARG_MAX; i++) {
|
||||
if (argptr[i]->get_type() == Variant::NIL) {
|
||||
break;
|
||||
}
|
||||
argc++;
|
||||
}
|
||||
|
||||
return push_callable(p_callable, argptr, argc);
|
||||
}
|
||||
|
||||
void MessageQueue::statistics() {
|
||||
Map<StringName, int> set_count;
|
||||
Map<int, int> notify_count;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue