Add support for mutable keyword on API_FIELD

This commit is contained in:
Wojtek Figat
2021-02-10 11:29:07 +01:00
parent 191694725a
commit adbb467206

View File

@@ -1022,11 +1022,30 @@ namespace Flax.Build.Bindings
// Read parameters from the tag
var tagParams = ParseTagParameters(ref context);
context.Tokenizer.SkipUntil(TokenType.Identifier);
// Read 'static' keyword
desc.IsStatic = context.Tokenizer.NextToken().Value == "static";
if (!desc.IsStatic)
context.Tokenizer.PreviousToken();
// Read 'static' or 'mutable'
Token token;
var isMutable = false;
while (true)
{
token = context.Tokenizer.CurrentToken;
if (!desc.IsStatic && token.Value == "static")
{
desc.IsStatic = true;
context.Tokenizer.NextToken();
}
else if (!isMutable && token.Value == "mutable")
{
isMutable = true;
context.Tokenizer.NextToken();
}
else
{
context.Tokenizer.PreviousToken();
break;
}
}
// Read type
desc.Type = ParseType(ref context);
@@ -1035,7 +1054,7 @@ namespace Flax.Build.Bindings
desc.Name = ParseName(ref context);
// Read ';' or default value or array size or bit-field size
var token = context.Tokenizer.ExpectAnyTokens(new[] { TokenType.SemiColon, TokenType.Equal, TokenType.LeftBracket, TokenType.Colon });
token = context.Tokenizer.ExpectAnyTokens(new[] { TokenType.SemiColon, TokenType.Equal, TokenType.LeftBracket, TokenType.Colon });
if (token.Type == TokenType.Equal)
{
context.Tokenizer.SkipUntil(TokenType.SemiColon, out desc.DefaultValue, false);