Allow async capability implementation methods to return a tuple

This commit is contained in:
Lasse Blaauwbroek
2023-04-19 18:49:19 +02:00
committed by Jacob Alexander
parent c037342615
commit d53aa24733
2 changed files with 22 additions and 16 deletions

View File

@@ -68,8 +68,7 @@ class FunctionImpl(calculator_capnp.Calculator.Function.Server):
another promise"""
assert len(params) == self.paramCount
value = await evaluate_impl(self.body, params)
_context.results.value = value
return await evaluate_impl(self.body, params)
class OperatorImpl(calculator_capnp.Calculator.Function.Server):
@@ -101,8 +100,7 @@ class CalculatorImpl(calculator_capnp.Calculator.Server):
"Implementation of the Calculator Cap'n Proto interface."
async def evaluate(self, expression, _context, **kwargs):
value = await evaluate_impl(expression)
_context.results.value = ValueImpl(value)
return ValueImpl(await evaluate_impl(expression))
def defFunction(self, paramCount, body, _context, **kwargs):
return FunctionImpl(paramCount, body)