mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
C#: Array, Dictionary and marshaling refactoring
- Array and Dictionary now store `Variant` instead of `System.Object`. - Removed generic Array and Dictionary. They cause too much issues, heavily relying on reflection and very limited by the lack of a generic specialization. - Removed support for non-Godot collections. Support for them also relied heavily on reflection for marshaling. Support for them will likely be re-introduced in the future, but it will have to rely on source generators instead of reflection. - Reduced our use of reflection. The remaining usages will be moved to source generators soon. The only usage that I'm not sure yet how to replace is dynamic invocation of delegates.
This commit is contained in:
parent
344f5028d4
commit
3123be2384
30 changed files with 766 additions and 1723 deletions
|
@ -160,8 +160,8 @@ namespace Godot.SourceGenerators
|
|||
|
||||
source.Append(" info.AddProperty(GodotInternal.PropName_")
|
||||
.Append(propertyName)
|
||||
.Append(", this.")
|
||||
.Append(propertyName)
|
||||
.Append(", ")
|
||||
.AppendManagedToVariantExpr(string.Concat("this.", propertyName), property.Type)
|
||||
.Append(");\n");
|
||||
}
|
||||
|
||||
|
@ -173,8 +173,8 @@ namespace Godot.SourceGenerators
|
|||
|
||||
source.Append(" info.AddProperty(GodotInternal.PropName_")
|
||||
.Append(fieldName)
|
||||
.Append(", this.")
|
||||
.Append(fieldName)
|
||||
.Append(", ")
|
||||
.AppendManagedToVariantExpr(string.Concat("this.", fieldName), field.Type)
|
||||
.Append(");\n");
|
||||
}
|
||||
|
||||
|
@ -202,19 +202,17 @@ namespace Godot.SourceGenerators
|
|||
foreach (var property in godotClassProperties)
|
||||
{
|
||||
string propertyName = property.PropertySymbol.Name;
|
||||
string propertyTypeQualifiedName = property.PropertySymbol.Type.FullQualifiedName();
|
||||
|
||||
source.Append(" if (info.TryGetProperty<")
|
||||
.Append(propertyTypeQualifiedName)
|
||||
.Append(">(GodotInternal.PropName_")
|
||||
source.Append(" if (info.TryGetProperty(GodotInternal.PropName_")
|
||||
.Append(propertyName)
|
||||
.Append(", out var _value_")
|
||||
.Append(propertyName)
|
||||
.Append("))\n")
|
||||
.Append(" this.")
|
||||
.Append(propertyName)
|
||||
.Append(" = _value_")
|
||||
.Append(propertyName)
|
||||
.Append(" = ")
|
||||
.AppendVariantToManagedExpr(string.Concat("_value_", propertyName),
|
||||
property.PropertySymbol.Type, property.Type)
|
||||
.Append(";\n");
|
||||
}
|
||||
|
||||
|
@ -223,19 +221,17 @@ namespace Godot.SourceGenerators
|
|||
foreach (var field in godotClassFields)
|
||||
{
|
||||
string fieldName = field.FieldSymbol.Name;
|
||||
string fieldTypeQualifiedName = field.FieldSymbol.Type.FullQualifiedName();
|
||||
|
||||
source.Append(" if (info.TryGetProperty<")
|
||||
.Append(fieldTypeQualifiedName)
|
||||
.Append(">(GodotInternal.PropName_")
|
||||
source.Append(" if (info.TryGetProperty(GodotInternal.PropName_")
|
||||
.Append(fieldName)
|
||||
.Append(", out var _value_")
|
||||
.Append(fieldName)
|
||||
.Append("))\n")
|
||||
.Append(" this.")
|
||||
.Append(fieldName)
|
||||
.Append(" = _value_")
|
||||
.Append(fieldName)
|
||||
.Append(" = ")
|
||||
.AppendVariantToManagedExpr(string.Concat("_value_", fieldName),
|
||||
field.FieldSymbol.Type, field.Type)
|
||||
.Append(";\n");
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue