Fix codegen for C++ RPS with Array ParameterDefinition

#1209
This commit is contained in:
Wojtek Figat
2023-06-28 20:08:35 +02:00
parent 70ab159dd4
commit 04c1cf469d
3 changed files with 6 additions and 6 deletions

View File

@@ -1204,7 +1204,7 @@ namespace Flax.Build.Bindings
if (apiType != null)
{
if (parameterInfo.IsOut)
contents.Append(indent).AppendFormat("{1} {0}Temp;", parameterInfo.Name, new TypeInfo(parameterInfo.Type) { IsRef = false }.GetFullNameNative(buildData, caller)).AppendLine();
contents.Append(indent).AppendFormat("{1} {0}Temp;", parameterInfo.Name, parameterInfo.Type.GetFullNameNative(buildData, caller, false)).AppendLine();
else
contents.Append(indent).AppendFormat("auto {0}Temp = {1};", parameterInfo.Name, param).AppendLine();
if (parameterInfo.Type.IsPtr && !parameterInfo.Type.IsRef)

View File

@@ -144,7 +144,7 @@ namespace Flax.Build.Bindings
GenericArgs = BindingsGenerator.Read(reader, GenericArgs);
}
public string GetFullNameNative(Builder.BuildData buildData, ApiTypeInfo caller)
public string GetFullNameNative(Builder.BuildData buildData, ApiTypeInfo caller, bool canRef = true, bool canConst = true)
{
var type = BindingsGenerator.FindApiTypeInfo(buildData, this, caller);
if (type == null)
@@ -155,7 +155,7 @@ namespace Flax.Build.Bindings
return type.FullNameNative;
var sb = new StringBuilder(64);
if (IsConst)
if (IsConst && canConst)
sb.Append("const ");
sb.Append(type.FullNameNative);
if (GenericArgs != null)
@@ -171,7 +171,7 @@ namespace Flax.Build.Bindings
}
if (IsPtr)
sb.Append('*');
if (IsRef)
if (IsRef && canRef)
sb.Append('&');
return sb.ToString();
}

View File

@@ -241,7 +241,7 @@ namespace Flax.Build.Plugins
// Deserialize arguments
argNames += arg.Name;
contents.AppendLine($" {arg.Type.Type} {arg.Name};");
contents.AppendLine($" {arg.Type.GetFullNameNative(buildData, typeInfo, false, false)} {arg.Name};");
contents.AppendLine($" stream->Read({arg.Name});");
}
@@ -270,7 +270,7 @@ namespace Flax.Build.Plugins
}
// Serialize arguments
contents.AppendLine($" stream->Write(*({arg.Type.Type}*)args[{i}]);");
contents.AppendLine($" stream->Write(*(const {arg.Type.GetFullNameNative(buildData, typeInfo, false, false)}*)args[{i}]);");
}
// Invoke RPC