mirror of
https://github.com/FabInfra/capnproto-dotnetcore_Runtime.git
synced 2025-03-13 07:11:44 +01:00
Implement TypeId const member.
This commit is contained in:
parent
cb02be3896
commit
64203d1638
@ -93,5 +93,20 @@ namespace CapnpC.Generator
|
||||
LiteralExpression(
|
||||
SyntaxKind.NumericLiteralExpression,
|
||||
Literal($"0x{id:x}UL", id));
|
||||
|
||||
public static FieldDeclarationSyntax MakeTypeIdConst(ulong id, GenNames names) =>
|
||||
FieldDeclaration(
|
||||
VariableDeclaration(
|
||||
IdentifierName("UInt64"))
|
||||
.WithVariables(
|
||||
SingletonSeparatedList<VariableDeclaratorSyntax>(
|
||||
VariableDeclarator(names.TypeIdField.Identifier)
|
||||
.WithInitializer(
|
||||
EqualsValueClause(HexLiteral(id))))))
|
||||
.WithModifiers(
|
||||
TokenList(
|
||||
new[]{
|
||||
Token(SyntaxKind.PublicKeyword),
|
||||
Token(SyntaxKind.ConstKeyword)}));
|
||||
}
|
||||
}
|
||||
|
@ -63,6 +63,7 @@ namespace CapnpC.Generator
|
||||
public string MemberAccessPathNameFormat { get; }
|
||||
public Name TaskParameter { get; }
|
||||
public Name EagerMethod { get; }
|
||||
public Name TypeIdField { get; }
|
||||
|
||||
public GenNames(GeneratorOptions options)
|
||||
{
|
||||
@ -98,6 +99,7 @@ namespace CapnpC.Generator
|
||||
MemberAccessPathNameFormat = options.MemberAccessPathNameFormat;
|
||||
TaskParameter = new Name(options.TaskParameterName);
|
||||
EagerMethod = new Name(options.EagerMethodName);
|
||||
TypeIdField = new Name(options.TypeIdFieldName);
|
||||
}
|
||||
|
||||
public Name MakeTypeName(TypeDefinition def, NameUsage usage = NameUsage.Default)
|
||||
|
@ -38,5 +38,6 @@ namespace CapnpC.Generator
|
||||
public string MemberAccessPathNameFormat { get; set; } = "Path_{0}_{1}";
|
||||
public string TaskParameterName { get; set; } = "task";
|
||||
public string EagerMethodName { get; set; } = "Eager";
|
||||
public string TypeIdFieldName { get; set; } = "TypeId";
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user