Add support for using API_TYPEDEF macro on using typedefs

This commit is contained in:
Wojtek Figat
2024-12-02 23:35:39 +01:00
parent 57628c3d5f
commit 81737083a0

View File

@@ -273,7 +273,6 @@ namespace Flax.Build.Bindings
type.GenericArgs.Add(argType); type.GenericArgs.Add(argType);
token = context.Tokenizer.NextToken(); token = context.Tokenizer.NextToken();
} while (token.Type != TokenType.RightAngleBracket); } while (token.Type != TokenType.RightAngleBracket);
token = context.Tokenizer.NextToken(); token = context.Tokenizer.NextToken();
} }
@@ -405,7 +404,7 @@ namespace Flax.Build.Bindings
currentParam.Attributes += ", Optional"; currentParam.Attributes += ", Optional";
currentParam.Name = $"namelessArg{parameters.Count}"; currentParam.Name = $"namelessArg{parameters.Count}";
} }
if (currentParam.IsOut && (currentParam.Type.IsPtr || currentParam.Type.IsRef) && currentParam.Type.Type.EndsWith("*")) if (currentParam.IsOut && (currentParam.Type.IsPtr || currentParam.Type.IsRef) && currentParam.Type.Type.EndsWith("*"))
{ {
// Pointer to value passed as output pointer // Pointer to value passed as output pointer
@@ -1590,16 +1589,30 @@ namespace Flax.Build.Bindings
// Read parameters from the tag // Read parameters from the tag
var tagParams = ParseTagParameters(ref context); var tagParams = ParseTagParameters(ref context);
// Read 'typedef' keyword // Read 'typedef' or 'using' keyword
var token = context.Tokenizer.NextToken(); var token = context.Tokenizer.NextToken();
if (token.Value != "typedef") var isUsing = token.Value == "using";
throw new ParseException(ref context, $"Invalid {ApiTokens.Typedef} usage (expected 'typedef' keyword but got '{token.Value} {context.Tokenizer.NextToken().Value}')."); if (token.Value != "typedef" && !isUsing)
throw new ParseException(ref context, $"Invalid {ApiTokens.Typedef} usage (expected 'typedef' or 'using' keyword but got '{token.Value} {context.Tokenizer.NextToken().Value}').");
// Read type definition if (isUsing)
desc.Type = ParseType(ref context); {
// Read name
desc.Name = ParseName(ref context);
// Read name context.Tokenizer.ExpectToken(TokenType.Equal);
desc.Name = ParseName(ref context);
// Read type definition
desc.Type = ParseType(ref context);
}
else
{
// Read type definition
desc.Type = ParseType(ref context);
// Read name
desc.Name = ParseName(ref context);
}
// Read ';' // Read ';'
context.Tokenizer.ExpectToken(TokenType.SemiColon); context.Tokenizer.ExpectToken(TokenType.SemiColon);