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:
@@ -606,8 +606,7 @@ public:
|
||||
} break;
|
||||
case Animation::TYPE_METHOD: {
|
||||
p_list->push_back(PropertyInfo(Variant::STRING_NAME, "name"));
|
||||
static_assert(VARIANT_ARG_MAX == 8, "PROPERTY_HINT_RANGE needs to be updated if VARIANT_ARG_MAX != 8");
|
||||
p_list->push_back(PropertyInfo(Variant::INT, "arg_count", PROPERTY_HINT_RANGE, "0,8,1"));
|
||||
p_list->push_back(PropertyInfo(Variant::INT, "arg_count", PROPERTY_HINT_RANGE, "0,32,1,or_greater"));
|
||||
|
||||
Dictionary d = animation->track_get_key_value(track, key);
|
||||
ERR_FAIL_COND(!d.has("args"));
|
||||
@@ -1287,8 +1286,8 @@ public:
|
||||
} break;
|
||||
case Animation::TYPE_METHOD: {
|
||||
p_list->push_back(PropertyInfo(Variant::STRING_NAME, "name"));
|
||||
static_assert(VARIANT_ARG_MAX == 8, "PROPERTY_HINT_RANGE needs to be updated if VARIANT_ARG_MAX != 8");
|
||||
p_list->push_back(PropertyInfo(Variant::INT, "arg_count", PROPERTY_HINT_RANGE, "0,8,1"));
|
||||
|
||||
p_list->push_back(PropertyInfo(Variant::INT, "arg_count", PROPERTY_HINT_RANGE, "0,32,1,or_greater"));
|
||||
|
||||
Dictionary d = animation->track_get_key_value(first_track, first_key);
|
||||
ERR_FAIL_COND(!d.has("args"));
|
||||
@@ -3189,7 +3188,7 @@ AnimationTrackEdit *AnimationTrackEditPlugin::create_value_track_edit(Object *p_
|
||||
};
|
||||
|
||||
Callable::CallError ce;
|
||||
return Object::cast_to<AnimationTrackEdit>(get_script_instance()->call("create_value_track_edit", (const Variant **)&argptrs, 6, ce).operator Object *());
|
||||
return Object::cast_to<AnimationTrackEdit>(get_script_instance()->callp("create_value_track_edit", (const Variant **)&argptrs, 6, ce).operator Object *());
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -180,9 +180,6 @@ void ConnectDialog::_unbind_count_changed(double p_count) {
|
||||
* Adds a new parameter bind to connection.
|
||||
*/
|
||||
void ConnectDialog::_add_bind() {
|
||||
if (cdbinds->params.size() >= VARIANT_ARG_MAX) {
|
||||
return;
|
||||
}
|
||||
Variant::Type vt = (Variant::Type)type_list->get_item_id(type_list->get_selected());
|
||||
|
||||
Variant value;
|
||||
|
||||
@@ -610,12 +610,12 @@ void EditorDebuggerNode::_save_node_requested(ObjectID p_id, const String &p_fil
|
||||
}
|
||||
|
||||
// Remote inspector/edit.
|
||||
void EditorDebuggerNode::_method_changeds(void *p_ud, Object *p_base, const StringName &p_name, VARIANT_ARG_DECLARE) {
|
||||
void EditorDebuggerNode::_method_changeds(void *p_ud, Object *p_base, const StringName &p_name, const Variant **p_args, int p_argcount) {
|
||||
if (!singleton) {
|
||||
return;
|
||||
}
|
||||
_for_all(singleton->tabs, [&](ScriptEditorDebugger *dbg) {
|
||||
dbg->_method_changed(p_base, p_name, VARIANT_ARG_PASS);
|
||||
dbg->_method_changed(p_base, p_name, p_args, p_argcount);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -171,7 +171,7 @@ public:
|
||||
|
||||
// Remote inspector/edit.
|
||||
void request_remote_tree();
|
||||
static void _method_changeds(void *p_ud, Object *p_base, const StringName &p_name, VARIANT_ARG_DECLARE);
|
||||
static void _method_changeds(void *p_ud, Object *p_base, const StringName &p_name, const Variant **p_args, int p_argcount);
|
||||
static void _property_changeds(void *p_ud, Object *p_base, const StringName &p_property, const Variant &p_value);
|
||||
|
||||
// LiveDebug
|
||||
|
||||
@@ -1064,18 +1064,16 @@ int ScriptEditorDebugger::_get_res_path_cache(const String &p_path) {
|
||||
return last_path_id;
|
||||
}
|
||||
|
||||
void ScriptEditorDebugger::_method_changed(Object *p_base, const StringName &p_name, VARIANT_ARG_DECLARE) {
|
||||
void ScriptEditorDebugger::_method_changed(Object *p_base, const StringName &p_name, const Variant **p_args, int p_argcount) {
|
||||
if (!p_base || !live_debug || !is_session_active() || !EditorNode::get_singleton()->get_edited_scene()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Node *node = Object::cast_to<Node>(p_base);
|
||||
|
||||
VARIANT_ARGPTRS
|
||||
|
||||
for (int i = 0; i < VARIANT_ARG_MAX; i++) {
|
||||
for (int i = 0; i < p_argcount; i++) {
|
||||
//no pointers, sorry
|
||||
if (argptr[i] && (argptr[i]->get_type() == Variant::OBJECT || argptr[i]->get_type() == Variant::RID)) {
|
||||
if (p_args[i]->get_type() == Variant::OBJECT || p_args[i]->get_type() == Variant::RID) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1087,9 +1085,9 @@ void ScriptEditorDebugger::_method_changed(Object *p_base, const StringName &p_n
|
||||
Array msg;
|
||||
msg.push_back(pathid);
|
||||
msg.push_back(p_name);
|
||||
for (int i = 0; i < VARIANT_ARG_MAX; i++) {
|
||||
for (int i = 0; i < p_argcount; i++) {
|
||||
//no pointers, sorry
|
||||
msg.push_back(*argptr[i]);
|
||||
msg.push_back(*p_args[i]);
|
||||
}
|
||||
_put_msg("scene:live_node_call", msg);
|
||||
|
||||
@@ -1105,9 +1103,9 @@ void ScriptEditorDebugger::_method_changed(Object *p_base, const StringName &p_n
|
||||
Array msg;
|
||||
msg.push_back(pathid);
|
||||
msg.push_back(p_name);
|
||||
for (int i = 0; i < VARIANT_ARG_MAX; i++) {
|
||||
for (int i = 0; i < p_argcount; i++) {
|
||||
//no pointers, sorry
|
||||
msg.push_back(*argptr[i]);
|
||||
msg.push_back(*p_args[i]);
|
||||
}
|
||||
_put_msg("scene:live_res_call", msg);
|
||||
|
||||
|
||||
@@ -187,7 +187,7 @@ private:
|
||||
void _live_edit_set();
|
||||
void _live_edit_clear();
|
||||
|
||||
void _method_changed(Object *p_base, const StringName &p_name, VARIANT_ARG_DECLARE);
|
||||
void _method_changed(Object *p_base, const StringName &p_name, const Variant **p_args, int p_argcount);
|
||||
void _property_changed(Object *p_base, const StringName &p_property, const Variant &p_value);
|
||||
|
||||
void _error_activated();
|
||||
|
||||
@@ -99,7 +99,7 @@ void EditorProperty::emit_changed(const StringName &p_property, const Variant &p
|
||||
const Variant *argptrs[4] = { &args[0], &args[1], &args[2], &args[3] };
|
||||
|
||||
cache[p_property] = p_value;
|
||||
emit_signal(SNAME("property_changed"), (const Variant **)argptrs, 4);
|
||||
emit_signalp(SNAME("property_changed"), (const Variant **)argptrs, 4);
|
||||
}
|
||||
|
||||
void EditorProperty::_notification(int p_what) {
|
||||
@@ -3314,7 +3314,7 @@ void EditorInspector::_property_keyed(const String &p_path, bool p_advance) {
|
||||
// The second parameter could be null, causing the event to fire with less arguments, so use the pointer call which preserves it.
|
||||
const Variant args[3] = { p_path, object->get(p_path), p_advance };
|
||||
const Variant *argp[3] = { &args[0], &args[1], &args[2] };
|
||||
emit_signal(SNAME("property_keyed"), argp, 3);
|
||||
emit_signalp(SNAME("property_keyed"), argp, 3);
|
||||
}
|
||||
|
||||
void EditorInspector::_property_deleted(const String &p_path) {
|
||||
@@ -3333,7 +3333,7 @@ void EditorInspector::_property_keyed_with_value(const String &p_path, const Var
|
||||
// The second parameter could be null, causing the event to fire with less arguments, so use the pointer call which preserves it.
|
||||
const Variant args[3] = { p_path, p_value, p_advance };
|
||||
const Variant *argp[3] = { &args[0], &args[1], &args[2] };
|
||||
emit_signal(SNAME("property_keyed"), argp, 3);
|
||||
emit_signalp(SNAME("property_keyed"), argp, 3);
|
||||
}
|
||||
|
||||
void EditorInspector::_property_checked(const String &p_path, bool p_checked) {
|
||||
|
||||
@@ -3059,7 +3059,7 @@ void EditorPropertyResource::_sub_inspector_property_keyed(const String &p_prope
|
||||
// The second parameter could be null, causing the event to fire with less arguments, so use the pointer call which preserves it.
|
||||
const Variant args[3] = { String(get_edited_property()) + ":" + p_property, p_value, p_advance };
|
||||
const Variant *argp[3] = { &args[0], &args[1], &args[2] };
|
||||
emit_signal(SNAME("property_keyed_with_value"), argp, 3);
|
||||
emit_signalp(SNAME("property_keyed_with_value"), argp, 3);
|
||||
}
|
||||
|
||||
void EditorPropertyResource::_sub_inspector_resource_selected(const RES &p_resource, const String &p_property) {
|
||||
|
||||
Reference in New Issue
Block a user