summaryrefslogtreecommitdiffstats
path: root/modules/mono/editor
diff options
context:
space:
mode:
authorSpartan322 <Megacake1234@gmail.com>2024-11-26 12:56:19 -0500
committerSpartan322 <Megacake1234@gmail.com>2024-11-26 12:56:19 -0500
commite58e18261ea7ed3978146ef8d77a900be2601be3 (patch)
tree79c2a4c34f2d888ff962d76edf474c518d1abdea /modules/mono/editor
parentc5b1645e60a59c0292c04bece3fdb0715a61afea (diff)
parentd09d82d433b03bb3773fd2a8cc8d6ccc2f8739ce (diff)
downloadredot-engine-e58e18261ea7ed3978146ef8d77a900be2601be3.tar.gz
Merge commit godotengine/godot@d09d82d433b03bb3773fd2a8cc8d6ccc2f8739ce
Diffstat (limited to 'modules/mono/editor')
-rw-r--r--modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPropertiesGenerator.cs17
-rw-r--r--modules/mono/editor/bindings_generator.cpp35
2 files changed, 32 insertions, 20 deletions
diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPropertiesGenerator.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPropertiesGenerator.cs
index 9e88e81920..883a56f435 100644
--- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPropertiesGenerator.cs
+++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPropertiesGenerator.cs
@@ -781,8 +781,18 @@ namespace Godot.SourceGenerators
return false; // Non-generic Dictionary, so there's no hint to add
Debug.Assert(elementTypes.Length == 2);
- var keyElementMarshalType = MarshalUtils.ConvertManagedTypeToMarshalType(elementTypes[0], typeCache)!.Value;
- var keyElementVariantType = MarshalUtils.ConvertMarshalTypeToVariantType(keyElementMarshalType)!.Value;
+ var keyElementMarshalType = MarshalUtils.ConvertManagedTypeToMarshalType(elementTypes[0], typeCache);
+ var valueElementMarshalType = MarshalUtils.ConvertManagedTypeToMarshalType(elementTypes[1], typeCache);
+
+ if (keyElementMarshalType == null || valueElementMarshalType == null)
+ {
+ // To maintain compatibility with previous versions of Godot before 4.4,
+ // we must preserve the old behavior for generic dictionaries with non-marshallable
+ // generic type arguments.
+ return false;
+ }
+
+ var keyElementVariantType = MarshalUtils.ConvertMarshalTypeToVariantType(keyElementMarshalType.Value)!.Value;
var keyIsPresetHint = false;
var keyHintString = (string?)null;
@@ -809,8 +819,7 @@ namespace Godot.SourceGenerators
}
}
- var valueElementMarshalType = MarshalUtils.ConvertManagedTypeToMarshalType(elementTypes[1], typeCache)!.Value;
- var valueElementVariantType = MarshalUtils.ConvertMarshalTypeToVariantType(valueElementMarshalType)!.Value;
+ var valueElementVariantType = MarshalUtils.ConvertMarshalTypeToVariantType(valueElementMarshalType.Value)!.Value;
var valueIsPresetHint = false;
var valueHintString = (string?)null;
diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp
index efe03298b9..5d7e346453 100644
--- a/modules/mono/editor/bindings_generator.cpp
+++ b/modules/mono/editor/bindings_generator.cpp
@@ -5042,22 +5042,25 @@ void BindingsGenerator::_populate_global_constants() {
}
}
- // HARDCODED
- List<StringName> hardcoded_enums;
- hardcoded_enums.push_back("Vector2.Axis");
- hardcoded_enums.push_back("Vector2I.Axis");
- hardcoded_enums.push_back("Vector3.Axis");
- hardcoded_enums.push_back("Vector3I.Axis");
- 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 = enum_cname.operator String();
- enum_itype.cname = enum_cname;
- enum_itype.proxy_name = pascal_to_pascal_case(enum_itype.name);
- TypeInterface::postsetup_enum_type(enum_itype);
- enum_types.insert(enum_itype.cname, enum_itype);
+ for (int i = 0; i < Variant::VARIANT_MAX; i++) {
+ if (i == Variant::OBJECT) {
+ continue;
+ }
+
+ const Variant::Type type = Variant::Type(i);
+
+ List<StringName> enum_names;
+ Variant::get_enums_for_type(type, &enum_names);
+
+ for (const StringName &enum_name : enum_names) {
+ TypeInterface enum_itype;
+ enum_itype.is_enum = true;
+ enum_itype.name = Variant::get_type_name(type) + "." + enum_name;
+ enum_itype.cname = enum_itype.name;
+ enum_itype.proxy_name = pascal_to_pascal_case(enum_itype.name);
+ TypeInterface::postsetup_enum_type(enum_itype);
+ enum_types.insert(enum_itype.cname, enum_itype);
+ }
}
}