[Yunq] Move method numbers to a scheme set by the parser.

This commit is contained in:
Drew Galbraith 2024-01-11 21:00:51 -08:00
parent 3b91819a4b
commit 9e12531651
3 changed files with 5 additions and 2 deletions

View File

@ -31,7 +31,7 @@ glcr::Status {{interface.name}}Client::{{method.name}}(const {{method.request}}&
const uint32_t kSentinel = 0xBEEFDEAD;
buffer_.WriteAt<uint32_t>(0, kSentinel);
buffer_.WriteAt<uint64_t>(8, {{loop.index0}});
buffer_.WriteAt<uint64_t>(8, {{method.number}});
cap_buffer_.Reset();
{% if method.request == None %}

View File

@ -215,8 +215,11 @@ class Parser():
methods: list[Method] = []
method_names = set()
next_method_number = 0
while self.peektype() != LexemeType.RIGHT_BRACE:
m = self.method()
m.number = next_method_number
next_method_number += 1
if m.name in method_names:
sys.exit("Method %s declared twice on %s" % (m.name, name))
method_names.add(m.name)

View File

@ -103,7 +103,7 @@ glcr::Status {{interface.name}}ServerBase::HandleRequest(const glcr::ByteBuffer&
switch(method_select) {
{%- for method in interface.methods %}
case {{loop.index0}}: {
case {{method.number}}: {
{% if method.request != None %}
{{method.request}} yunq_request;