diff --git a/yunq/client.cpp.jinja b/yunq/client.cpp.jinja index 63721e0..e4e8102 100644 --- a/yunq/client.cpp.jinja +++ b/yunq/client.cpp.jinja @@ -31,7 +31,7 @@ glcr::Status {{interface.name}}Client::{{method.name}}(const {{method.request}}& const uint32_t kSentinel = 0xBEEFDEAD; buffer_.WriteAt(0, kSentinel); - buffer_.WriteAt(8, {{loop.index0}}); + buffer_.WriteAt(8, {{method.number}}); cap_buffer_.Reset(); {% if method.request == None %} diff --git a/yunq/parser.py b/yunq/parser.py index 5507880..403f27b 100644 --- a/yunq/parser.py +++ b/yunq/parser.py @@ -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) diff --git a/yunq/server.cpp.jinja b/yunq/server.cpp.jinja index 734166d..bee46b5 100644 --- a/yunq/server.cpp.jinja +++ b/yunq/server.cpp.jinja @@ -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;