Fix missing Variant marshalling for scripting structures bindings

#1395
This commit is contained in:
Wojtek Figat
2023-09-27 13:04:14 +02:00
parent e5e37f3a41
commit 523a14af56

View File

@@ -1512,8 +1512,8 @@ namespace Flax.Build.Bindings
type = "IntPtr";
else if (type == "bool")
type = "byte";
else if (type == "object")
type = "NativeVariant";
else if (fieldInfo.Type.Type == "Variant")
type = "IntPtr";
else if (internalType)
{
internalTypeMarshaller = type + "Marshaller";
@@ -1530,9 +1530,6 @@ namespace Flax.Build.Bindings
if (fieldInfo.NoArray && fieldInfo.Type.IsArray)
continue;
if (type == "NativeVariant")
continue; // TODO: FIXME
if (useSeparator)
{
toManagedContent.Append(", ");
@@ -1634,6 +1631,12 @@ namespace Flax.Build.Bindings
toManagedContent.Append($"managed.{fieldInfo.Name} != 0");
toNativeContent.Append($"managed.{fieldInfo.Name} ? (byte)1 : (byte)0");
}
else if (fieldInfo.Type.Type == "Variant")
{
// Variant passed as boxed object handle
toManagedContent.Append($"ManagedHandleMarshaller.NativeToManaged.ConvertToManaged(managed.{fieldInfo.Name})");
toNativeContent.Append($"ManagedHandleMarshaller.NativeToManaged.ConvertToUnmanaged(managed.{fieldInfo.Name})");
}
else if (internalType)
{
toManagedContent.Append($"{internalTypeMarshaller}.ToManaged(managed.{fieldInfo.Name})");