You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
[Core] Use Vector for MethodInfo::arguments
This commit is contained in:
@@ -1640,13 +1640,12 @@ void GDScriptAnalyzer::resolve_annotation(GDScriptParser::AnnotationNode *p_anno
|
||||
|
||||
const MethodInfo &annotation_info = parser->valid_annotations[p_annotation->name].info;
|
||||
|
||||
const List<PropertyInfo>::Element *E = annotation_info.arguments.front();
|
||||
for (int i = 0; i < p_annotation->arguments.size(); i++) {
|
||||
for (int64_t i = 0, j = 0; i < p_annotation->arguments.size(); i++) {
|
||||
GDScriptParser::ExpressionNode *argument = p_annotation->arguments[i];
|
||||
const PropertyInfo &argument_info = E->get();
|
||||
const PropertyInfo &argument_info = annotation_info.arguments[j];
|
||||
|
||||
if (E->next() != nullptr) {
|
||||
E = E->next();
|
||||
if (j + 1 < annotation_info.arguments.size()) {
|
||||
++j;
|
||||
}
|
||||
|
||||
reduce_expression(argument);
|
||||
@@ -3323,28 +3322,24 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool p_is_a
|
||||
|
||||
bool types_match = true;
|
||||
|
||||
{
|
||||
List<PropertyInfo>::ConstIterator arg_itr = info.arguments.begin();
|
||||
for (int i = 0; i < p_call->arguments.size(); ++arg_itr, ++i) {
|
||||
GDScriptParser::DataType par_type = type_from_property(*arg_itr, true);
|
||||
GDScriptParser::DataType arg_type = p_call->arguments[i]->get_datatype();
|
||||
if (!is_type_compatible(par_type, arg_type, true)) {
|
||||
types_match = false;
|
||||
break;
|
||||
for (int64_t i = 0; i < p_call->arguments.size(); ++i) {
|
||||
GDScriptParser::DataType par_type = type_from_property(info.arguments[i], true);
|
||||
GDScriptParser::DataType arg_type = p_call->arguments[i]->get_datatype();
|
||||
if (!is_type_compatible(par_type, arg_type, true)) {
|
||||
types_match = false;
|
||||
break;
|
||||
#ifdef DEBUG_ENABLED
|
||||
} else {
|
||||
if (par_type.builtin_type == Variant::INT && arg_type.builtin_type == Variant::FLOAT && builtin_type != Variant::INT) {
|
||||
parser->push_warning(p_call, GDScriptWarning::NARROWING_CONVERSION, function_name);
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
if (par_type.builtin_type == Variant::INT && arg_type.builtin_type == Variant::FLOAT && builtin_type != Variant::INT) {
|
||||
parser->push_warning(p_call, GDScriptWarning::NARROWING_CONVERSION, function_name);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (types_match) {
|
||||
List<PropertyInfo>::ConstIterator arg_itr = info.arguments.begin();
|
||||
for (int i = 0; i < p_call->arguments.size(); ++arg_itr, ++i) {
|
||||
GDScriptParser::DataType par_type = type_from_property(*arg_itr, true);
|
||||
for (int64_t i = 0; i < p_call->arguments.size(); ++i) {
|
||||
GDScriptParser::DataType par_type = type_from_property(info.arguments[i], true);
|
||||
if (p_call->arguments[i]->is_constant) {
|
||||
update_const_expression_builtin_type(p_call->arguments[i], par_type, "pass");
|
||||
}
|
||||
|
||||
@@ -243,9 +243,8 @@ static bool _can_use_validate_call(const MethodBind *p_method, const Vector<GDSc
|
||||
}
|
||||
MethodInfo info;
|
||||
ClassDB::get_method_info(p_method->get_instance_class(), p_method->get_name(), &info);
|
||||
int i = 0;
|
||||
for (List<PropertyInfo>::ConstIterator itr = info.arguments.begin(); itr != info.arguments.end(); ++itr, ++i) {
|
||||
if (!_is_exact_type(*itr, p_arguments[i].type)) {
|
||||
for (int64_t i = 0; i < info.arguments.size(); ++i) {
|
||||
if (!_is_exact_type(info.arguments[i], p_arguments[i].type)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2839,9 +2839,9 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
|
||||
// Handle user preference.
|
||||
if (opt.is_quoted()) {
|
||||
opt = opt.unquote().quote(quote_style);
|
||||
if (use_string_names && info.arguments.get(p_argidx).type == Variant::STRING_NAME) {
|
||||
if (use_string_names && info.arguments[p_argidx].type == Variant::STRING_NAME) {
|
||||
opt = "&" + opt;
|
||||
} else if (use_node_paths && info.arguments.get(p_argidx).type == Variant::NODE_PATH) {
|
||||
} else if (use_node_paths && info.arguments[p_argidx].type == Variant::NODE_PATH) {
|
||||
opt = "^" + opt;
|
||||
}
|
||||
}
|
||||
@@ -2852,7 +2852,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
|
||||
}
|
||||
|
||||
if (p_argidx < method_args) {
|
||||
const PropertyInfo &arg_info = info.arguments.get(p_argidx);
|
||||
const PropertyInfo &arg_info = info.arguments[p_argidx];
|
||||
if (arg_info.usage & (PROPERTY_USAGE_CLASS_IS_ENUM | PROPERTY_USAGE_CLASS_IS_BITFIELD)) {
|
||||
_find_enumeration_candidates(p_context, arg_info.class_name, r_result);
|
||||
}
|
||||
@@ -3495,17 +3495,17 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
|
||||
}
|
||||
method_hint += "(";
|
||||
|
||||
for (List<PropertyInfo>::ConstIterator arg_itr = mi.arguments.begin(); arg_itr != mi.arguments.end(); ++arg_itr) {
|
||||
if (arg_itr != mi.arguments.begin()) {
|
||||
for (int64_t i = 0; i < mi.arguments.size(); ++i) {
|
||||
if (i > 0) {
|
||||
method_hint += ", ";
|
||||
}
|
||||
String arg = arg_itr->name;
|
||||
String arg = mi.arguments[i].name;
|
||||
if (arg.contains_char(':')) {
|
||||
arg = arg.substr(0, arg.find_char(':'));
|
||||
}
|
||||
method_hint += arg;
|
||||
if (use_type_hint) {
|
||||
method_hint += ": " + _get_visual_datatype(*arg_itr, true, class_name);
|
||||
method_hint += ": " + _get_visual_datatype(mi.arguments[i], true, class_name);
|
||||
}
|
||||
}
|
||||
method_hint += ")";
|
||||
|
||||
@@ -624,8 +624,8 @@ StringName GDScriptUtilityFunctions::get_function_return_class(const StringName
|
||||
Variant::Type GDScriptUtilityFunctions::get_function_argument_type(const StringName &p_function, int p_arg) {
|
||||
GDScriptUtilityFunctionInfo *info = utility_function_table.lookup_ptr(p_function);
|
||||
ERR_FAIL_NULL_V(info, Variant::NIL);
|
||||
ERR_FAIL_COND_V(p_arg >= info->info.arguments.size(), Variant::NIL);
|
||||
return info->info.arguments.get(p_arg).type;
|
||||
ERR_FAIL_INDEX_V(p_arg, info->info.arguments.size(), Variant::NIL);
|
||||
return info->info.arguments[p_arg].type;
|
||||
}
|
||||
|
||||
int GDScriptUtilityFunctions::get_function_argument_count(const StringName &p_function) {
|
||||
|
||||
@@ -80,9 +80,8 @@ TEST_CASE("[Modules][GDScript] Validate built-in API") {
|
||||
|
||||
SUBCASE("[Modules][GDScript] Validate built-in methods") {
|
||||
for (const MethodInfo &mi : builtin_methods) {
|
||||
int i = 0;
|
||||
for (List<PropertyInfo>::ConstIterator itr = mi.arguments.begin(); itr != mi.arguments.end(); ++itr, ++i) {
|
||||
TEST_COND((itr->name.is_empty() || itr->name.begins_with("_unnamed_arg")),
|
||||
for (int64_t i = 0; i < mi.arguments.size(); ++i) {
|
||||
TEST_COND((mi.arguments[i].name.is_empty() || mi.arguments[i].name.begins_with("_unnamed_arg")),
|
||||
vformat("Unnamed argument in position %d of built-in method '%s'.", i, mi.name));
|
||||
}
|
||||
}
|
||||
@@ -94,9 +93,8 @@ TEST_CASE("[Modules][GDScript] Validate built-in API") {
|
||||
|
||||
SUBCASE("[Modules][GDScript] Validate built-in annotations") {
|
||||
for (const MethodInfo &ai : builtin_annotations) {
|
||||
int i = 0;
|
||||
for (List<PropertyInfo>::ConstIterator itr = ai.arguments.begin(); itr != ai.arguments.end(); ++itr, ++i) {
|
||||
TEST_COND((itr->name.is_empty() || itr->name.begins_with("_unnamed_arg")),
|
||||
for (int64_t i = 0; i < ai.arguments.size(); ++i) {
|
||||
TEST_COND((ai.arguments[i].name.is_empty() || ai.arguments[i].name.begins_with("_unnamed_arg")),
|
||||
vformat("Unnamed argument in position %d of built-in annotation '%s'.", i, ai.name));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user