Merge pull request #91660 from AThousandShips/methodinfo_vec
[Core] Use `Vector` for `MethodInfo::arguments`
This commit is contained in:
commit
b377562b52
18 changed files with 107 additions and 124 deletions
|
|
@ -2011,9 +2011,8 @@ void ClassDB::add_virtual_method(const StringName &p_class, const MethodInfo &p_
|
|||
if (p_arg_names.size() != mi.arguments.size()) {
|
||||
WARN_PRINT(vformat("Mismatch argument name count for virtual method: '%s::%s'.", String(p_class), p_method.name));
|
||||
} else {
|
||||
List<PropertyInfo>::Iterator itr = mi.arguments.begin();
|
||||
for (int i = 0; i < p_arg_names.size(); ++itr, ++i) {
|
||||
itr->name = p_arg_names[i];
|
||||
for (int64_t i = 0; i < p_arg_names.size(); ++i) {
|
||||
mi.arguments.write[i].name = p_arg_names[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ public:
|
|||
if (p_arg < 0) {
|
||||
return _gen_return_type_info();
|
||||
} else if (p_arg < method_info.arguments.size()) {
|
||||
return method_info.arguments.get(p_arg);
|
||||
return method_info.arguments[p_arg];
|
||||
} else {
|
||||
return PropertyInfo(Variant::NIL, "arg_" + itos(p_arg), PROPERTY_HINT_NONE, String(), PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_NIL_IS_VARIANT);
|
||||
}
|
||||
|
|
@ -192,11 +192,10 @@ public:
|
|||
Vector<StringName> names;
|
||||
names.resize(method_info.arguments.size());
|
||||
#endif
|
||||
int i = 0;
|
||||
for (List<PropertyInfo>::ConstIterator itr = method_info.arguments.begin(); itr != method_info.arguments.end(); ++itr, ++i) {
|
||||
at[i + 1] = itr->type;
|
||||
for (int64_t i = 0; i < method_info.arguments.size(); ++i) {
|
||||
at[i + 1] = method_info.arguments[i].type;
|
||||
#ifdef DEBUG_METHODS_ENABLED
|
||||
names.write[i] = itr->name;
|
||||
names.write[i] = method_info.arguments[i].name;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -115,10 +115,19 @@ TypedArray<Dictionary> convert_property_list(const List<PropertyInfo> *p_list) {
|
|||
return va;
|
||||
}
|
||||
|
||||
TypedArray<Dictionary> convert_property_list(const Vector<PropertyInfo> &p_vector) {
|
||||
TypedArray<Dictionary> va;
|
||||
for (const PropertyInfo &E : p_vector) {
|
||||
va.push_back(Dictionary(E));
|
||||
}
|
||||
|
||||
return va;
|
||||
}
|
||||
|
||||
MethodInfo::operator Dictionary() const {
|
||||
Dictionary d;
|
||||
d["name"] = name;
|
||||
d["args"] = convert_property_list(&arguments);
|
||||
d["args"] = convert_property_list(arguments);
|
||||
Array da;
|
||||
for (int i = 0; i < default_arguments.size(); i++) {
|
||||
da.push_back(default_arguments[i]);
|
||||
|
|
|
|||
|
|
@ -208,6 +208,7 @@ struct PropertyInfo {
|
|||
};
|
||||
|
||||
TypedArray<Dictionary> convert_property_list(const List<PropertyInfo> *p_list);
|
||||
TypedArray<Dictionary> convert_property_list(const Vector<PropertyInfo> &p_vector);
|
||||
|
||||
enum MethodFlags {
|
||||
METHOD_FLAG_NORMAL = 1,
|
||||
|
|
@ -226,7 +227,7 @@ struct MethodInfo {
|
|||
PropertyInfo return_val;
|
||||
uint32_t flags = METHOD_FLAGS_DEFAULT;
|
||||
int id = 0;
|
||||
List<PropertyInfo> arguments;
|
||||
Vector<PropertyInfo> arguments;
|
||||
Vector<Variant> default_arguments;
|
||||
int return_val_metadata = 0;
|
||||
Vector<int> arguments_metadata;
|
||||
|
|
@ -255,8 +256,8 @@ struct MethodInfo {
|
|||
return_val(PropertyInfo(pinfo.return_value)),
|
||||
flags(pinfo.flags),
|
||||
id(pinfo.id) {
|
||||
for (uint32_t j = 0; j < pinfo.argument_count; j++) {
|
||||
arguments.push_back(PropertyInfo(pinfo.arguments[j]));
|
||||
for (uint32_t i = 0; i < pinfo.argument_count; i++) {
|
||||
arguments.push_back(PropertyInfo(pinfo.arguments[i]));
|
||||
}
|
||||
const Variant *def_values = (const Variant *)pinfo.default_arguments;
|
||||
for (uint32_t j = 0; j < pinfo.default_argument_count; j++) {
|
||||
|
|
@ -264,22 +265,12 @@ struct MethodInfo {
|
|||
}
|
||||
}
|
||||
|
||||
void _push_params(const PropertyInfo &p_param) {
|
||||
arguments.push_back(p_param);
|
||||
}
|
||||
|
||||
template <typename... VarArgs>
|
||||
void _push_params(const PropertyInfo &p_param, VarArgs... p_params) {
|
||||
arguments.push_back(p_param);
|
||||
_push_params(p_params...);
|
||||
}
|
||||
|
||||
MethodInfo(const String &p_name) { name = p_name; }
|
||||
|
||||
template <typename... VarArgs>
|
||||
MethodInfo(const String &p_name, VarArgs... p_params) {
|
||||
name = p_name;
|
||||
_push_params(p_params...);
|
||||
arguments = Vector<PropertyInfo>{ p_params... };
|
||||
}
|
||||
|
||||
MethodInfo(Variant::Type ret) { return_val.type = ret; }
|
||||
|
|
@ -292,7 +283,7 @@ struct MethodInfo {
|
|||
MethodInfo(Variant::Type ret, const String &p_name, VarArgs... p_params) {
|
||||
name = p_name;
|
||||
return_val.type = ret;
|
||||
_push_params(p_params...);
|
||||
arguments = Vector<PropertyInfo>{ p_params... };
|
||||
}
|
||||
|
||||
MethodInfo(const PropertyInfo &p_ret, const String &p_name) {
|
||||
|
|
@ -304,7 +295,7 @@ struct MethodInfo {
|
|||
MethodInfo(const PropertyInfo &p_ret, const String &p_name, VarArgs... p_params) {
|
||||
return_val = p_ret;
|
||||
name = p_name;
|
||||
_push_params(p_params...);
|
||||
arguments = Vector<PropertyInfo>{ p_params... };
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue