summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs14
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathLocator.cs8
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs14
-rw-r--r--modules/mono/editor/bindings_generator.cpp133
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs222
-rw-r--r--modules/visual_script/visual_script_editor.cpp2
6 files changed, 299 insertions, 94 deletions
diff --git a/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs b/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs
index 270be8b6bf..0b5aa72a81 100644
--- a/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs
@@ -76,9 +76,9 @@ namespace GodotTools.Export
GlobalDef("mono/export/aot/use_interpreter", true);
// --aot or --aot=opt1,opt2 (use 'mono --aot=help AuxAssembly.dll' to list AOT options)
- GlobalDef("mono/export/aot/extra_aot_options", new string[] { });
+ GlobalDef("mono/export/aot/extra_aot_options", Array.Empty<string>());
// --optimize/-O=opt1,opt2 (use 'mono --list-opt'' to list optimize options)
- GlobalDef("mono/export/aot/extra_optimizer_options", new string[] { });
+ GlobalDef("mono/export/aot/extra_optimizer_options", Array.Empty<string>());
GlobalDef("mono/export/aot/android_toolchain_path", "");
}
@@ -188,7 +188,7 @@ namespace GodotTools.Export
// However, at least in the case of 'WebAssembly.Net.Http' for some reason the BCL assemblies
// reference a different version even though the assembly is the same, for some weird reason.
- var wasmFrameworkAssemblies = new[] {"WebAssembly.Bindings", "WebAssembly.Net.WebSockets"};
+ var wasmFrameworkAssemblies = new[] { "WebAssembly.Bindings", "WebAssembly.Net.WebSockets" };
foreach (string thisWasmFrameworkAssemblyName in wasmFrameworkAssemblies)
{
@@ -298,8 +298,8 @@ namespace GodotTools.Export
LLVMOutputPath = "",
FullAot = platform == OS.Platforms.iOS || (bool)(ProjectSettings.GetSetting("mono/export/aot/full_aot") ?? false),
UseInterpreter = (bool)ProjectSettings.GetSetting("mono/export/aot/use_interpreter"),
- ExtraAotOptions = (string[])ProjectSettings.GetSetting("mono/export/aot/extra_aot_options") ?? new string[] { },
- ExtraOptimizerOptions = (string[])ProjectSettings.GetSetting("mono/export/aot/extra_optimizer_options") ?? new string[] { },
+ ExtraAotOptions = (string[])ProjectSettings.GetSetting("mono/export/aot/extra_aot_options") ?? Array.Empty<string>(),
+ ExtraOptimizerOptions = (string[])ProjectSettings.GetSetting("mono/export/aot/extra_optimizer_options") ?? Array.Empty<string>(),
ToolchainPath = aotToolchainPath
};
@@ -381,7 +381,7 @@ namespace GodotTools.Export
private static bool PlatformHasTemplateDir(string platform)
{
// OSX export templates are contained in a zip, so we place our custom template inside it and let Godot do the rest.
- return !new[] {OS.Platforms.MacOS, OS.Platforms.Android, OS.Platforms.iOS, OS.Platforms.HTML5}.Contains(platform);
+ return !new[] { OS.Platforms.MacOS, OS.Platforms.Android, OS.Platforms.iOS, OS.Platforms.HTML5 }.Contains(platform);
}
private static bool DeterminePlatformFromFeatures(IEnumerable<string> features, out string platform)
@@ -430,7 +430,7 @@ namespace GodotTools.Export
/// </summary>
private static bool PlatformRequiresCustomBcl(string platform)
{
- if (new[] {OS.Platforms.Android, OS.Platforms.iOS, OS.Platforms.HTML5}.Contains(platform))
+ if (new[] { OS.Platforms.Android, OS.Platforms.iOS, OS.Platforms.HTML5 }.Contains(platform))
return true;
// The 'net_4_x' BCL is not compatible between Windows and the other platforms.
diff --git a/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathLocator.cs b/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathLocator.cs
index 94fc5da425..821532f759 100644
--- a/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathLocator.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathLocator.cs
@@ -47,7 +47,7 @@ namespace GodotTools.Ides.Rider
GD.PushWarning(e.Message);
}
- return new RiderInfo[0];
+ return Array.Empty<RiderInfo>();
}
private static RiderInfo[] CollectAllRiderPathsLinux()
@@ -249,7 +249,7 @@ namespace GodotTools.Ides.Rider
bool isMac)
{
if (!Directory.Exists(toolboxRiderRootPath))
- return new string[0];
+ return Array.Empty<string>();
var channelDirs = Directory.GetDirectories(toolboxRiderRootPath);
var paths = channelDirs.SelectMany(channelDir =>
@@ -295,7 +295,7 @@ namespace GodotTools.Ides.Rider
Logger.Warn($"Failed to get RiderPath from {channelDir}", e);
}
- return new string[0];
+ return Array.Empty<string>();
})
.Where(c => !string.IsNullOrEmpty(c))
.ToArray();
@@ -306,7 +306,7 @@ namespace GodotTools.Ides.Rider
{
var folder = new DirectoryInfo(Path.Combine(buildDir, dirName));
if (!folder.Exists)
- return new string[0];
+ return Array.Empty<string>();
if (!isMac)
return new[] { Path.Combine(folder.FullName, searchPattern) }.Where(File.Exists).ToArray();
diff --git a/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs b/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs
index e745966435..ee4e7ba9d4 100644
--- a/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs
@@ -74,10 +74,10 @@ namespace GodotTools.Utils
}
private static readonly IEnumerable<string> LinuxBSDPlatforms =
- new[] {Names.Linux, Names.FreeBSD, Names.NetBSD, Names.BSD};
+ new[] { Names.Linux, Names.FreeBSD, Names.NetBSD, Names.BSD };
private static readonly IEnumerable<string> UnixLikePlatforms =
- new[] {Names.MacOS, Names.Server, Names.Haiku, Names.Android, Names.iOS}
+ new[] { Names.MacOS, Names.Server, Names.Haiku, Names.Android, Names.iOS }
.Concat(LinuxBSDPlatforms).ToArray();
private static readonly Lazy<bool> _isWindows = new Lazy<bool>(() => IsOS(Names.Windows));
@@ -111,7 +111,7 @@ namespace GodotTools.Utils
private static string PathWhichWindows([NotNull] string name)
{
- string[] windowsExts = Environment.GetEnvironmentVariable("PATHEXT")?.Split(PathSep) ?? new string[] { };
+ string[] windowsExts = Environment.GetEnvironmentVariable("PATHEXT")?.Split(PathSep) ?? Array.Empty<string>();
string[] pathDirs = Environment.GetEnvironmentVariable("PATH")?.Split(PathSep);
var searchDirs = new List<string>();
@@ -128,10 +128,10 @@ namespace GodotTools.Utils
return searchDirs.Select(dir => Path.Combine(dir, name)).FirstOrDefault(File.Exists);
return (from dir in searchDirs
- select Path.Combine(dir, name)
+ select Path.Combine(dir, name)
into path
- from ext in windowsExts
- select path + ext).FirstOrDefault(File.Exists);
+ from ext in windowsExts
+ select path + ext).FirstOrDefault(File.Exists);
}
private static string PathWhichUnix([NotNull] string name)
@@ -196,7 +196,7 @@ namespace GodotTools.Utils
startInfo.UseShellExecute = false;
- using (var process = new Process {StartInfo = startInfo})
+ using (var process = new Process { StartInfo = startInfo })
{
process.Start();
process.WaitForExit();
diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp
index 6ea0b56908..c134136e1c 100644
--- a/modules/mono/editor/bindings_generator.cpp
+++ b/modules/mono/editor/bindings_generator.cpp
@@ -416,8 +416,8 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf
// Try to find as global enum constant
const EnumInterface *target_ienum = nullptr;
- for (const EnumInterface &E : global_enums) {
- target_ienum = &E;
+ for (const EnumInterface &ienum : global_enums) {
+ target_ienum = &ienum;
target_iconst = find_constant_by_name(target_name, target_ienum->constants);
if (target_iconst) {
break;
@@ -455,8 +455,8 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf
// Try to find as enum constant in the current class
const EnumInterface *target_ienum = nullptr;
- for (const EnumInterface &E : target_itype->enums) {
- target_ienum = &E;
+ for (const EnumInterface &ienum : target_itype->enums) {
+ target_ienum = &ienum;
target_iconst = find_constant_by_name(target_name, target_ienum->constants);
if (target_iconst) {
break;
@@ -682,12 +682,10 @@ int BindingsGenerator::_determine_enum_prefix(const EnumInterface &p_ienum) {
void BindingsGenerator::_apply_prefix_to_enum_constants(BindingsGenerator::EnumInterface &p_ienum, int p_prefix_length) {
if (p_prefix_length > 0) {
- for (const ConstantInterface &E : p_ienum.constants) {
+ for (ConstantInterface &iconstant : p_ienum.constants) {
int curr_prefix_length = p_prefix_length;
- ConstantInterface &curr_const = E;
-
- String constant_name = curr_const.name;
+ String constant_name = iconstant.name;
Vector<String> parts = constant_name.split("_", /* p_allow_empty: */ true);
@@ -713,7 +711,7 @@ void BindingsGenerator::_apply_prefix_to_enum_constants(BindingsGenerator::EnumI
constant_name += parts[i];
}
- curr_const.proxy_name = snake_to_pascal_case(constant_name, true);
+ iconstant.proxy_name = snake_to_pascal_case(constant_name, true);
}
}
}
@@ -733,8 +731,8 @@ void BindingsGenerator::_generate_method_icalls(const TypeInterface &p_itype) {
// Get arguments information
int i = 0;
- for (const ArgumentInterface &F : imethod.arguments) {
- const TypeInterface *arg_type = _get_type_or_placeholder(F.type);
+ for (const ArgumentInterface &iarg : imethod.arguments) {
+ const TypeInterface *arg_type = _get_type_or_placeholder(iarg.type);
im_sig += ", ";
im_sig += arg_type->im_type_in;
@@ -774,10 +772,10 @@ void BindingsGenerator::_generate_method_icalls(const TypeInterface &p_itype) {
if (p_itype.api_type != ClassDB::API_EDITOR) {
match->get().editor_only = false;
}
- method_icalls_map.insert(&E, &match->get());
+ method_icalls_map.insert(&imethod, &match->get());
} else {
List<InternalCall>::Element *added = method_icalls.push_back(im_icall);
- method_icalls_map.insert(&E, &added->get());
+ method_icalls_map.insert(&imethod, &added->get());
}
}
}
@@ -915,9 +913,8 @@ void BindingsGenerator::_generate_global_constants(StringBuilder &p_output) {
p_output.append(enum_proxy_name);
p_output.append("\n" INDENT1 OPEN_BLOCK);
- for (const ConstantInterface &F : ienum.constants) {
- const ConstantInterface &iconstant = F;
-
+ const ConstantInterface &last = ienum.constants.back()->get();
+ for (const ConstantInterface &iconstant : ienum.constants) {
if (iconstant.const_doc && iconstant.const_doc->description.size()) {
String xml_summary = bbcode_to_xml(fix_doc_description(iconstant.const_doc->description), nullptr);
Vector<String> summary_lines = xml_summary.length() ? xml_summary.split("\n") : Vector<String>();
@@ -939,7 +936,7 @@ void BindingsGenerator::_generate_global_constants(StringBuilder &p_output) {
p_output.append(iconstant.proxy_name);
p_output.append(" = ");
p_output.append(itos(iconstant.value));
- p_output.append(F != ienum.constants.back() ? ",\n" : "\n");
+ p_output.append(&iconstant != &last ? ",\n" : "\n");
}
p_output.append(INDENT1 CLOSE_BLOCK);
@@ -1047,11 +1044,11 @@ Error BindingsGenerator::generate_cs_core_project(const String &p_proj_dir) {
cs_icalls_content.append(m_icall.im_sig + ");\n"); \
}
- for (const InternalCall &E : core_custom_icalls) {
- ADD_INTERNAL_CALL(E);
+ for (const InternalCall &internal_call : core_custom_icalls) {
+ ADD_INTERNAL_CALL(internal_call);
}
- for (const InternalCall &E : method_icalls) {
- ADD_INTERNAL_CALL(E);
+ for (const InternalCall &internal_call : method_icalls) {
+ ADD_INTERNAL_CALL(internal_call);
}
#undef ADD_INTERNAL_CALL
@@ -1155,11 +1152,11 @@ Error BindingsGenerator::generate_cs_editor_project(const String &p_proj_dir) {
cs_icalls_content.append(m_icall.im_sig + ");\n"); \
}
- for (const InternalCall &E : editor_custom_icalls) {
- ADD_INTERNAL_CALL(E);
+ for (const InternalCall &internal_call : editor_custom_icalls) {
+ ADD_INTERNAL_CALL(internal_call);
}
- for (const InternalCall &E : method_icalls) {
- ADD_INTERNAL_CALL(E);
+ for (const InternalCall &internal_call : method_icalls) {
+ ADD_INTERNAL_CALL(internal_call);
}
#undef ADD_INTERNAL_CALL
@@ -1359,9 +1356,8 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str
output.append(ienum.cname.operator String());
output.append(MEMBER_BEGIN OPEN_BLOCK);
- for (const ConstantInterface &F : ienum.constants) {
- const ConstantInterface &iconstant = F;
-
+ const ConstantInterface &last = ienum.constants.back()->get();
+ for (const ConstantInterface &iconstant : ienum.constants) {
if (iconstant.const_doc && iconstant.const_doc->description.size()) {
String xml_summary = bbcode_to_xml(fix_doc_description(iconstant.const_doc->description), &itype);
Vector<String> summary_lines = xml_summary.length() ? xml_summary.split("\n") : Vector<String>();
@@ -1383,7 +1379,7 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str
output.append(iconstant.proxy_name);
output.append(" = ");
output.append(itos(iconstant.value));
- output.append(F != ienum.constants.back() ? ",\n" : "\n");
+ output.append(&iconstant != &last ? ",\n" : "\n");
}
output.append(INDENT2 CLOSE_BLOCK);
@@ -1665,8 +1661,8 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf
StringBuilder default_args_doc;
// Retrieve information from the arguments
- for (const ArgumentInterface &F : p_imethod.arguments) {
- const ArgumentInterface &iarg = F;
+ const ArgumentInterface &first = p_imethod.arguments.front()->get();
+ for (const ArgumentInterface &iarg : p_imethod.arguments) {
const TypeInterface *arg_type = _get_type_or_placeholder(iarg.type);
ERR_FAIL_COND_V_MSG(arg_type->is_singleton, ERR_BUG,
@@ -1686,7 +1682,7 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf
// Add the current arguments to the signature
// If the argument has a default value which is not a constant, we will make it Nullable
{
- if (F != p_imethod.arguments.front()) {
+ if (&iarg != &first) {
arguments_sig += ", ";
}
@@ -1741,7 +1737,12 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf
cs_in_statements += " : ";
}
- String def_arg = sformat(iarg.default_argument, arg_type->cs_type);
+ String cs_type = arg_type->cs_type;
+ if (cs_type.ends_with("[]")) {
+ cs_type = cs_type.substr(0, cs_type.length() - 2);
+ }
+
+ String def_arg = sformat(iarg.default_argument, cs_type);
cs_in_statements += def_arg;
cs_in_statements += ";\n" INDENT3;
@@ -1750,8 +1751,10 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf
// Apparently the name attribute must not include the @
String param_tag_name = iarg.name.begins_with("@") ? iarg.name.substr(1, iarg.name.length()) : iarg.name;
+ // Escape < and > in the attribute default value
+ String param_def_arg = def_arg.replacen("<", "&lt;").replacen(">", "&gt;");
- default_args_doc.append(MEMBER_BEGIN "/// <param name=\"" + param_tag_name + "\">If the parameter is null, then the default value is " + def_arg + "</param>");
+ default_args_doc.append(MEMBER_BEGIN "/// <param name=\"" + param_tag_name + "\">If the parameter is null, then the default value is " + param_def_arg + "</param>");
} else {
icall_params += arg_type->cs_in.is_empty() ? iarg.name : sformat(arg_type->cs_in, iarg.name);
}
@@ -1842,9 +1845,9 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf
p_output.append(p_imethod.name);
p_output.append("\"");
- for (const ArgumentInterface &F : p_imethod.arguments) {
+ for (const ArgumentInterface &iarg : p_imethod.arguments) {
p_output.append(", ");
- p_output.append(F.name);
+ p_output.append(iarg.name);
}
p_output.append(");\n" CLOSE_BLOCK_L2);
@@ -1886,8 +1889,8 @@ Error BindingsGenerator::_generate_cs_signal(const BindingsGenerator::TypeInterf
String arguments_sig;
// Retrieve information from the arguments
- for (const ArgumentInterface &F : p_isignal.arguments) {
- const ArgumentInterface &iarg = F;
+ const ArgumentInterface &first = p_isignal.arguments.front()->get();
+ for (const ArgumentInterface &iarg : p_isignal.arguments) {
const TypeInterface *arg_type = _get_type_or_placeholder(iarg.type);
ERR_FAIL_COND_V_MSG(arg_type->is_singleton, ERR_BUG,
@@ -1901,7 +1904,7 @@ Error BindingsGenerator::_generate_cs_signal(const BindingsGenerator::TypeInterf
// Add the current arguments to the signature
- if (F != p_isignal.arguments.front()) {
+ if (&iarg != &first) {
arguments_sig += ", ";
}
@@ -2100,20 +2103,20 @@ Error BindingsGenerator::generate_glue(const String &p_output_dir) {
}
bool tools_sequence = false;
- for (const InternalCall &E : core_custom_icalls) {
+ for (const InternalCall &internal_call : core_custom_icalls) {
if (tools_sequence) {
- if (!E.editor_only) {
+ if (!internal_call.editor_only) {
tools_sequence = false;
output.append("#endif\n");
}
} else {
- if (E.editor_only) {
+ if (internal_call.editor_only) {
output.append("#ifdef TOOLS_ENABLED\n");
tools_sequence = true;
}
}
- ADD_INTERNAL_CALL_REGISTRATION(E);
+ ADD_INTERNAL_CALL_REGISTRATION(internal_call);
}
if (tools_sequence) {
@@ -2122,24 +2125,24 @@ Error BindingsGenerator::generate_glue(const String &p_output_dir) {
}
output.append("#ifdef TOOLS_ENABLED\n");
- for (const InternalCall &E : editor_custom_icalls)
- ADD_INTERNAL_CALL_REGISTRATION(E);
+ for (const InternalCall &internal_call : editor_custom_icalls)
+ ADD_INTERNAL_CALL_REGISTRATION(internal_call);
output.append("#endif // TOOLS_ENABLED\n");
- for (const InternalCall &E : method_icalls) {
+ for (const InternalCall &internal_call : method_icalls) {
if (tools_sequence) {
- if (!E.editor_only) {
+ if (!internal_call.editor_only) {
tools_sequence = false;
output.append("#endif\n");
}
} else {
- if (E.editor_only) {
+ if (internal_call.editor_only) {
output.append("#ifdef TOOLS_ENABLED\n");
tools_sequence = true;
}
}
- ADD_INTERNAL_CALL_REGISTRATION(E);
+ ADD_INTERNAL_CALL_REGISTRATION(internal_call);
}
if (tools_sequence) {
@@ -2195,8 +2198,7 @@ Error BindingsGenerator::_generate_glue_method(const BindingsGenerator::TypeInte
// Get arguments information
int i = 0;
- for (const ArgumentInterface &F : p_imethod.arguments) {
- const ArgumentInterface &iarg = F;
+ for (const ArgumentInterface &iarg : p_imethod.arguments) {
const TypeInterface *arg_type = _get_type_or_placeholder(iarg.type);
String c_param_name = "arg" + itos(i + 1);
@@ -2668,9 +2670,7 @@ bool BindingsGenerator::_populate_object_type_interfaces() {
ClassDB::get_method_list(type_cname, &method_list, true);
method_list.sort();
- for (const MethodInfo &E : method_list) {
- const MethodInfo &method_info = E;
-
+ for (const MethodInfo &method_info : method_list) {
int argc = method_info.arguments.size();
if (method_info.name.is_empty()) {
@@ -2824,9 +2824,7 @@ bool BindingsGenerator::_populate_object_type_interfaces() {
// Classes starting with an underscore are ignored unless they're used as a property setter or getter
if (!imethod.is_virtual && imethod.name[0] == '_') {
- for (const PropertyInterface &F : itype.properties) {
- const PropertyInterface &iprop = F;
-
+ for (const PropertyInterface &iprop : itype.properties) {
if (iprop.setter == imethod.name || iprop.getter == imethod.name) {
imethod.is_internal = true;
itype.methods.push_back(imethod);
@@ -2936,8 +2934,7 @@ bool BindingsGenerator::_populate_object_type_interfaces() {
}
EnumInterface ienum(enum_proxy_cname);
const List<StringName> &enum_constants = enum_map.get(*k);
- for (const StringName &E : enum_constants) {
- const StringName &constant_cname = E;
+ for (const StringName &constant_cname : enum_constants) {
String constant_name = constant_cname.operator String();
int *value = class_info->constant_map.getptr(constant_cname);
ERR_FAIL_NULL_V(value, false);
@@ -2973,9 +2970,8 @@ bool BindingsGenerator::_populate_object_type_interfaces() {
enum_types.insert(enum_itype.cname, enum_itype);
}
- for (const String &E : constants) {
- const String &constant_name = E;
- int *value = class_info->constant_map.getptr(StringName(E));
+ for (const String &constant_name : constants) {
+ int *value = class_info->constant_map.getptr(StringName(constant_name));
ERR_FAIL_NULL_V(value, false);
ConstantInterface iconstant(constant_name, snake_to_pascal_case(constant_name, true), *value);
@@ -3083,6 +3079,9 @@ bool BindingsGenerator::_arg_default_value_from_variant(const Variant &p_val, Ar
r_iarg.default_argument = "null";
break;
case Variant::ARRAY:
+ r_iarg.default_argument = "new %s { }";
+ r_iarg.def_param_mode = ArgumentInterface::NULLABLE_REF;
+ break;
case Variant::PACKED_BYTE_ARRAY:
case Variant::PACKED_INT32_ARRAY:
case Variant::PACKED_INT64_ARRAY:
@@ -3092,7 +3091,7 @@ bool BindingsGenerator::_arg_default_value_from_variant(const Variant &p_val, Ar
case Variant::PACKED_VECTOR2_ARRAY:
case Variant::PACKED_VECTOR3_ARRAY:
case Variant::PACKED_COLOR_ARRAY:
- r_iarg.default_argument = "new %s {}";
+ r_iarg.default_argument = "Array.Empty<%s>()";
r_iarg.def_param_mode = ArgumentInterface::NULLABLE_REF;
break;
case Variant::TRANSFORM2D: {
@@ -3523,7 +3522,7 @@ void BindingsGenerator::_populate_global_constants() {
}
}
- for (const EnumInterface &ienum : global_enums) {
+ for (EnumInterface &ienum : global_enums) {
TypeInterface enum_itype;
enum_itype.is_enum = true;
enum_itype.name = ienum.cname.operator String();
@@ -3553,13 +3552,13 @@ void BindingsGenerator::_populate_global_constants() {
hardcoded_enums.push_back("Vector2i.Axis");
hardcoded_enums.push_back("Vector3.Axis");
hardcoded_enums.push_back("Vector3i.Axis");
- for (const StringName &E : hardcoded_enums) {
+ for (const StringName &enum_cname : hardcoded_enums) {
// These enums are not generated and must be written manually (e.g.: Vector3.Axis)
// Here, we assume core types do not begin with underscore
TypeInterface enum_itype;
enum_itype.is_enum = true;
- enum_itype.name = E.operator String();
- enum_itype.cname = E;
+ enum_itype.name = enum_cname.operator String();
+ enum_itype.cname = enum_cname;
enum_itype.proxy_name = enum_itype.name;
TypeInterface::postsetup_enum_type(enum_itype);
enum_types.insert(enum_itype.cname, enum_itype);
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs
index ce613f7ef9..f52a767018 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs
@@ -25,16 +25,30 @@ namespace Godot.Collections
}
}
+ /// <summary>
+ /// Wrapper around Godot's Array class, an array of Variant
+ /// typed elements allocated in the engine in C++. Useful when
+ /// interfacing with the engine. Otherwise prefer .NET collections
+ /// such as <see cref="System.Array"/> or <see cref="List{T}"/>.
+ /// </summary>
public class Array : IList, IDisposable
{
ArraySafeHandle safeHandle;
bool disposed = false;
+ /// <summary>
+ /// Constructs a new empty <see cref="Array"/>.
+ /// </summary>
public Array()
{
safeHandle = new ArraySafeHandle(godot_icall_Array_Ctor());
}
+ /// <summary>
+ /// Constructs a new <see cref="Array"/> from the given collection's elements.
+ /// </summary>
+ /// <param name="collection">The collection of elements to construct from.</param>
+ /// <returns>A new Godot Array.</returns>
public Array(IEnumerable collection) : this()
{
if (collection == null)
@@ -44,6 +58,11 @@ namespace Godot.Collections
Add(element);
}
+ /// <summary>
+ /// Constructs a new <see cref="Array"/> from the given objects.
+ /// </summary>
+ /// <param name="array">The objects to put in the new array.</param>
+ /// <returns>A new Godot Array.</returns>
public Array(params object[] array) : this()
{
if (array == null)
@@ -71,21 +90,40 @@ namespace Godot.Collections
return safeHandle.DangerousGetHandle();
}
+ /// <summary>
+ /// Duplicates this <see cref="Array"/>.
+ /// </summary>
+ /// <param name="deep">If true, performs a deep copy.</param>
+ /// <returns>A new Godot Array.</returns>
public Array Duplicate(bool deep = false)
{
return new Array(godot_icall_Array_Duplicate(GetPtr(), deep));
}
+ /// <summary>
+ /// Resizes this <see cref="Array"/> to the given size.
+ /// </summary>
+ /// <param name="newSize">The new size of the array.</param>
+ /// <returns><see cref="Error.Ok"/> if successful, or an error code.</returns>
public Error Resize(int newSize)
{
return godot_icall_Array_Resize(GetPtr(), newSize);
}
+ /// <summary>
+ /// Shuffles the contents of this <see cref="Array"/> into a random order.
+ /// </summary>
public void Shuffle()
{
godot_icall_Array_Shuffle(GetPtr());
}
+ /// <summary>
+ /// Concatenates these two <see cref="Array"/>s.
+ /// </summary>
+ /// <param name="left">The first array.</param>
+ /// <param name="right">The second array.</param>
+ /// <returns>A new Godot Array with the contents of both arrays.</returns>
public static Array operator +(Array left, Array right)
{
return new Array(godot_icall_Array_Concatenate(left.GetPtr(), right.GetPtr()));
@@ -93,6 +131,9 @@ namespace Godot.Collections
// IDisposable
+ /// <summary>
+ /// Disposes of this <see cref="Array"/>.
+ /// </summary>
public void Dispose()
{
if (disposed)
@@ -109,38 +150,90 @@ namespace Godot.Collections
// IList
- public bool IsReadOnly => false;
+ bool IList.IsReadOnly => false;
- public bool IsFixedSize => false;
+ bool IList.IsFixedSize => false;
+ /// <summary>
+ /// Returns the object at the given index.
+ /// </summary>
+ /// <value>The object at the given index.</value>
public object this[int index]
{
get => godot_icall_Array_At(GetPtr(), index);
set => godot_icall_Array_SetAt(GetPtr(), index, value);
}
+ /// <summary>
+ /// Adds an object to the end of this <see cref="Array"/>.
+ /// This is the same as `append` or `push_back` in GDScript.
+ /// </summary>
+ /// <param name="value">The object to add.</param>
+ /// <returns>The new size after adding the object.</returns>
public int Add(object value) => godot_icall_Array_Add(GetPtr(), value);
+ /// <summary>
+ /// Checks if this <see cref="Array"/> contains the given object.
+ /// </summary>
+ /// <param name="value">The item to look for.</param>
+ /// <returns>Whether or not this array contains the given object.</returns>
public bool Contains(object value) => godot_icall_Array_Contains(GetPtr(), value);
+ /// <summary>
+ /// Erases all items from this <see cref="Array"/>.
+ /// </summary>
public void Clear() => godot_icall_Array_Clear(GetPtr());
+ /// <summary>
+ /// Searches this <see cref="Array"/> for an object
+ /// and returns its index or -1 if not found.
+ /// </summary>
+ /// <param name="value">The object to search for.</param>
+ /// <returns>The index of the object, or -1 if not found.</returns>
public int IndexOf(object value) => godot_icall_Array_IndexOf(GetPtr(), value);
+ /// <summary>
+ /// Inserts a new object at a given position in the array.
+ /// The position must be a valid position of an existing item,
+ /// or the position at the end of the array.
+ /// Existing items will be moved to the right.
+ /// </summary>
+ /// <param name="index">The index to insert at.</param>
+ /// <param name="value">The object to insert.</param>
public void Insert(int index, object value) => godot_icall_Array_Insert(GetPtr(), index, value);
+ /// <summary>
+ /// Removes the first occurrence of the specified value
+ /// from this <see cref="Array"/>.
+ /// </summary>
+ /// <param name="value">The value to remove.</param>
public void Remove(object value) => godot_icall_Array_Remove(GetPtr(), value);
+ /// <summary>
+ /// Removes an element from this <see cref="Array"/> by index.
+ /// </summary>
+ /// <param name="index">The index of the element to remove.</param>
public void RemoveAt(int index) => godot_icall_Array_RemoveAt(GetPtr(), index);
// ICollection
+ /// <summary>
+ /// Returns the number of elements in this <see cref="Array"/>.
+ /// This is also known as the size or length of the array.
+ /// </summary>
+ /// <returns>The number of elements.</returns>
public int Count => godot_icall_Array_Count(GetPtr());
- public object SyncRoot => this;
+ object ICollection.SyncRoot => this;
- public bool IsSynchronized => false;
+ bool ICollection.IsSynchronized => false;
+ /// <summary>
+ /// Copies the elements of this <see cref="Array"/> to the given
+ /// untyped C# array, starting at the given index.
+ /// </summary>
+ /// <param name="array">The array to copy to.</param>
+ /// <param name="index">The index to start at.</param>
public void CopyTo(System.Array array, int index)
{
if (array == null)
@@ -155,6 +248,10 @@ namespace Godot.Collections
// IEnumerable
+ /// <summary>
+ /// Gets an enumerator for this <see cref="Array"/>.
+ /// </summary>
+ /// <returns>An enumerator.</returns>
public IEnumerator GetEnumerator()
{
int count = Count;
@@ -165,6 +262,10 @@ namespace Godot.Collections
}
}
+ /// <summary>
+ /// Converts this <see cref="Array"/> to a string.
+ /// </summary>
+ /// <returns>A string representation of this array.</returns>
public override string ToString()
{
return godot_icall_Array_ToString(GetPtr());
@@ -234,6 +335,13 @@ namespace Godot.Collections
internal extern static string godot_icall_Array_ToString(IntPtr ptr);
}
+ /// <summary>
+ /// Typed wrapper around Godot's Array class, an array of Variant
+ /// typed elements allocated in the engine in C++. Useful when
+ /// interfacing with the engine. Otherwise prefer .NET collections
+ /// such as arrays or <see cref="List{T}"/>.
+ /// </summary>
+ /// <typeparam name="T">The type of the array.</typeparam>
public class Array<T> : IList<T>, ICollection<T>, IEnumerable<T>
{
Array objectArray;
@@ -246,11 +354,19 @@ namespace Godot.Collections
Array.godot_icall_Array_Generic_GetElementTypeInfo(typeof(T), out elemTypeEncoding, out elemTypeClass);
}
+ /// <summary>
+ /// Constructs a new empty <see cref="Array{T}"/>.
+ /// </summary>
public Array()
{
objectArray = new Array();
}
+ /// <summary>
+ /// Constructs a new <see cref="Array{T}"/> from the given collection's elements.
+ /// </summary>
+ /// <param name="collection">The collection of elements to construct from.</param>
+ /// <returns>A new Godot Array.</returns>
public Array(IEnumerable<T> collection)
{
if (collection == null)
@@ -259,6 +375,11 @@ namespace Godot.Collections
objectArray = new Array(collection);
}
+ /// <summary>
+ /// Constructs a new <see cref="Array{T}"/> from the given items.
+ /// </summary>
+ /// <param name="array">The items to put in the new array.</param>
+ /// <returns>A new Godot Array.</returns>
public Array(params T[] array) : this()
{
if (array == null)
@@ -268,6 +389,10 @@ namespace Godot.Collections
objectArray = new Array(array);
}
+ /// <summary>
+ /// Constructs a typed <see cref="Array{T}"/> from an untyped <see cref="Array"/>.
+ /// </summary>
+ /// <param name="array">The untyped array to construct from.</param>
public Array(Array array)
{
objectArray = array;
@@ -288,26 +413,49 @@ namespace Godot.Collections
return objectArray.GetPtr();
}
+ /// <summary>
+ /// Converts this typed <see cref="Array{T}"/> to an untyped <see cref="Array"/>.
+ /// </summary>
+ /// <param name="from">The typed array to convert.</param>
public static explicit operator Array(Array<T> from)
{
return from.objectArray;
}
+ /// <summary>
+ /// Duplicates this <see cref="Array{T}"/>.
+ /// </summary>
+ /// <param name="deep">If true, performs a deep copy.</param>
+ /// <returns>A new Godot Array.</returns>
public Array<T> Duplicate(bool deep = false)
{
return new Array<T>(objectArray.Duplicate(deep));
}
+ /// <summary>
+ /// Resizes this <see cref="Array{T}"/> to the given size.
+ /// </summary>
+ /// <param name="newSize">The new size of the array.</param>
+ /// <returns><see cref="Error.Ok"/> if successful, or an error code.</returns>
public Error Resize(int newSize)
{
return objectArray.Resize(newSize);
}
+ /// <summary>
+ /// Shuffles the contents of this <see cref="Array{T}"/> into a random order.
+ /// </summary>
public void Shuffle()
{
objectArray.Shuffle();
}
+ /// <summary>
+ /// Concatenates these two <see cref="Array{T}"/>s.
+ /// </summary>
+ /// <param name="left">The first array.</param>
+ /// <param name="right">The second array.</param>
+ /// <returns>A new Godot Array with the contents of both arrays.</returns>
public static Array<T> operator +(Array<T> left, Array<T> right)
{
return new Array<T>(left.objectArray + right.objectArray);
@@ -315,22 +463,44 @@ namespace Godot.Collections
// IList<T>
+ /// <summary>
+ /// Returns the value at the given index.
+ /// </summary>
+ /// <value>The value at the given index.</value>
public T this[int index]
{
get { return (T)Array.godot_icall_Array_At_Generic(GetPtr(), index, elemTypeEncoding, elemTypeClass); }
set { objectArray[index] = value; }
}
+ /// <summary>
+ /// Searches this <see cref="Array{T}"/> for an item
+ /// and returns its index or -1 if not found.
+ /// </summary>
+ /// <param name="item">The item to search for.</param>
+ /// <returns>The index of the item, or -1 if not found.</returns>
public int IndexOf(T item)
{
return objectArray.IndexOf(item);
}
+ /// <summary>
+ /// Inserts a new item at a given position in the <see cref="Array{T}"/>.
+ /// The position must be a valid position of an existing item,
+ /// or the position at the end of the array.
+ /// Existing items will be moved to the right.
+ /// </summary>
+ /// <param name="index">The index to insert at.</param>
+ /// <param name="item">The item to insert.</param>
public void Insert(int index, T item)
{
objectArray.Insert(index, item);
}
+ /// <summary>
+ /// Removes an element from this <see cref="Array{T}"/> by index.
+ /// </summary>
+ /// <param name="index">The index of the element to remove.</param>
public void RemoveAt(int index)
{
objectArray.RemoveAt(index);
@@ -338,31 +508,53 @@ namespace Godot.Collections
// ICollection<T>
+ /// <summary>
+ /// Returns the number of elements in this <see cref="Array{T}"/>.
+ /// This is also known as the size or length of the array.
+ /// </summary>
+ /// <returns>The number of elements.</returns>
public int Count
{
get { return objectArray.Count; }
}
- public bool IsReadOnly
- {
- get { return objectArray.IsReadOnly; }
- }
+ bool ICollection<T>.IsReadOnly => false;
+ /// <summary>
+ /// Adds an item to the end of this <see cref="Array{T}"/>.
+ /// This is the same as `append` or `push_back` in GDScript.
+ /// </summary>
+ /// <param name="item">The item to add.</param>
+ /// <returns>The new size after adding the item.</returns>
public void Add(T item)
{
objectArray.Add(item);
}
+ /// <summary>
+ /// Erases all items from this <see cref="Array{T}"/>.
+ /// </summary>
public void Clear()
{
objectArray.Clear();
}
+ /// <summary>
+ /// Checks if this <see cref="Array{T}"/> contains the given item.
+ /// </summary>
+ /// <param name="item">The item to look for.</param>
+ /// <returns>Whether or not this array contains the given item.</returns>
public bool Contains(T item)
{
return objectArray.Contains(item);
}
+ /// <summary>
+ /// Copies the elements of this <see cref="Array{T}"/> to the given
+ /// C# array, starting at the given index.
+ /// </summary>
+ /// <param name="array">The C# array to copy to.</param>
+ /// <param name="arrayIndex">The index to start at.</param>
public void CopyTo(T[] array, int arrayIndex)
{
if (array == null)
@@ -386,6 +578,12 @@ namespace Godot.Collections
}
}
+ /// <summary>
+ /// Removes the first occurrence of the specified value
+ /// from this <see cref="Array{T}"/>.
+ /// </summary>
+ /// <param name="item">The value to remove.</param>
+ /// <returns>A bool indicating success or failure.</returns>
public bool Remove(T item)
{
return Array.godot_icall_Array_Remove(GetPtr(), item);
@@ -393,6 +591,10 @@ namespace Godot.Collections
// IEnumerable<T>
+ /// <summary>
+ /// Gets an enumerator for this <see cref="Array{T}"/>.
+ /// </summary>
+ /// <returns>An enumerator.</returns>
public IEnumerator<T> GetEnumerator()
{
int count = objectArray.Count;
@@ -408,6 +610,10 @@ namespace Godot.Collections
return GetEnumerator();
}
+ /// <summary>
+ /// Converts this <see cref="Array{T}"/> to a string.
+ /// </summary>
+ /// <returns>A string representation of this array.</returns>
public override string ToString() => objectArray.ToString();
}
}
diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp
index 00dba117fb..fca7985b74 100644
--- a/modules/visual_script/visual_script_editor.cpp
+++ b/modules/visual_script/visual_script_editor.cpp
@@ -2186,7 +2186,7 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
int new_id = script->get_available_id();
if (files.size()) {
- undo_redo->create_action(TTR("Add Preload Node"));
+ undo_redo->create_action(TTR("Add Node(s)"));
for (int i = 0; i < files.size(); i++) {
Ref<Resource> res = ResourceLoader::load(files[i]);