Support C++ nameless function arguments for C# gen.

This commit is contained in:
Chandler Cox
2024-10-30 12:18:03 -05:00
parent 7479c3a2fe
commit 379bccc421

View File

@@ -390,7 +390,22 @@ namespace Flax.Build.Bindings
// Read parameter type and name
currentParam.Type = ParseType(ref context);
currentParam.Name = context.Tokenizer.ExpectToken(TokenType.Identifier).Value;
token = context.Tokenizer.NextToken();
if (token.Type == TokenType.Identifier)
{
currentParam.Name = token.Value;
}
// Support nameless arguments. assume optional usage
else
{
context.Tokenizer.PreviousToken();
if (string.IsNullOrEmpty(currentParam.Attributes))
currentParam.Attributes = "Optional";
else
currentParam.Attributes += ", Optional";
currentParam.Name = $"namelessArg{parameters.Count}";
}
if (currentParam.IsOut && (currentParam.Type.IsPtr || currentParam.Type.IsRef) && currentParam.Type.Type.EndsWith("*"))
{
// Pointer to value passed as output pointer