[Yunq] Move method numbers to a scheme set by the parser.
This commit is contained in:
parent
3b91819a4b
commit
9e12531651
|
@ -31,7 +31,7 @@ glcr::Status {{interface.name}}Client::{{method.name}}(const {{method.request}}&
|
||||||
|
|
||||||
const uint32_t kSentinel = 0xBEEFDEAD;
|
const uint32_t kSentinel = 0xBEEFDEAD;
|
||||||
buffer_.WriteAt<uint32_t>(0, kSentinel);
|
buffer_.WriteAt<uint32_t>(0, kSentinel);
|
||||||
buffer_.WriteAt<uint64_t>(8, {{loop.index0}});
|
buffer_.WriteAt<uint64_t>(8, {{method.number}});
|
||||||
|
|
||||||
cap_buffer_.Reset();
|
cap_buffer_.Reset();
|
||||||
{% if method.request == None %}
|
{% if method.request == None %}
|
||||||
|
|
|
@ -215,8 +215,11 @@ class Parser():
|
||||||
|
|
||||||
methods: list[Method] = []
|
methods: list[Method] = []
|
||||||
method_names = set()
|
method_names = set()
|
||||||
|
next_method_number = 0
|
||||||
while self.peektype() != LexemeType.RIGHT_BRACE:
|
while self.peektype() != LexemeType.RIGHT_BRACE:
|
||||||
m = self.method()
|
m = self.method()
|
||||||
|
m.number = next_method_number
|
||||||
|
next_method_number += 1
|
||||||
if m.name in method_names:
|
if m.name in method_names:
|
||||||
sys.exit("Method %s declared twice on %s" % (m.name, name))
|
sys.exit("Method %s declared twice on %s" % (m.name, name))
|
||||||
method_names.add(m.name)
|
method_names.add(m.name)
|
||||||
|
|
|
@ -103,7 +103,7 @@ glcr::Status {{interface.name}}ServerBase::HandleRequest(const glcr::ByteBuffer&
|
||||||
|
|
||||||
switch(method_select) {
|
switch(method_select) {
|
||||||
{%- for method in interface.methods %}
|
{%- for method in interface.methods %}
|
||||||
case {{loop.index0}}: {
|
case {{method.number}}: {
|
||||||
|
|
||||||
{% if method.request != None %}
|
{% if method.request != None %}
|
||||||
{{method.request}} yunq_request;
|
{{method.request}} yunq_request;
|
||||||
|
|
Loading…
Reference in New Issue