Add support for fixed-array fields in scripting

This commit is contained in:
Wojtek Figat
2021-04-22 21:03:40 +02:00
parent 3e945fbe34
commit 2b698ca8b0
2 changed files with 7 additions and 4 deletions

View File

@@ -1252,7 +1252,13 @@ namespace Flax.Build.Bindings
if (fieldInfo.Getter != null)
GenerateCppWrapperFunction(buildData, contents, classInfo, fieldInfo.Getter, "{0}");
if (fieldInfo.Setter != null)
GenerateCppWrapperFunction(buildData, contents, classInfo, fieldInfo.Setter, "{0} = {1}");
{
var callFormat = "{0} = {1}";
var type = fieldInfo.Setter.Parameters[0].Type;
if (type.IsArray)
callFormat = $"auto __tmp = {{1}}; for (int32 i = 0; i < {type.ArraySize}; i++) {{0}}[i] = __tmp[i]";
GenerateCppWrapperFunction(buildData, contents, classInfo, fieldInfo.Setter, callFormat);
}
}
// Properties

View File

@@ -623,9 +623,6 @@ namespace Flax.Build.Bindings
if (!fieldInfo.IsReadOnly)
{
if (fieldInfo.Type.IsArray)
throw new NotImplementedException("Use ReadOnly on field. TODO: add support for setter for fixed-array fields.");
fieldInfo.Setter = new FunctionInfo
{
Name = "Set" + fieldInfo.Name,