Add upcast/cast_as to DynamicCapability. Also changed EventLoop.
wait_remote -> wait
This commit is contained in:
@@ -1163,7 +1163,7 @@ cdef class EventLoop:
|
||||
Py_INCREF(func)
|
||||
return Promise()._init(capnp.evalLater(self.thisptr, <PyObject *>func))
|
||||
|
||||
cpdef wait_remote(self, _RemotePromise promise) except +:
|
||||
cpdef wait(self, _RemotePromise promise) except +:
|
||||
if promise.is_consumed:
|
||||
raise RuntimeError('Promise was already used in a consuming operation. You can no longer use this Promise object')
|
||||
|
||||
@@ -1263,6 +1263,28 @@ cdef class _DynamicCapabilityClient:
|
||||
return _partial(self._request, short_name)
|
||||
return _partial(self._send, name)
|
||||
|
||||
cpdef upcast(self, schema) except+:
|
||||
cdef _InterfaceSchema s
|
||||
if hasattr(schema, 'schema'):
|
||||
s = schema.schema
|
||||
else:
|
||||
s = schema
|
||||
|
||||
return _DynamicCapabilityClient()._init(self.thisptr.upcast(s.thisptr), self._parent)
|
||||
|
||||
cpdef cast_as(self, schema) except+:
|
||||
cdef _InterfaceSchema s
|
||||
if hasattr(schema, 'schema'):
|
||||
s = schema.schema
|
||||
else:
|
||||
s = schema
|
||||
return _DynamicCapabilityClient()._init(self.thisptr.castAs(s.thisptr), self._parent)
|
||||
|
||||
property schema:
|
||||
"""A property that returns the _InterfaceSchema object matching this client"""
|
||||
def __get__(self):
|
||||
return _InterfaceSchema()._init(self.thisptr.getSchema())
|
||||
|
||||
cdef class _CapabilityClient:
|
||||
cdef C_Capability.Client * thisptr
|
||||
cdef public object _parent
|
||||
|
||||
@@ -157,6 +157,7 @@ cdef extern from "capnp/dynamic.h" namespace " ::capnp":
|
||||
Client()
|
||||
Client(Client&)
|
||||
Client upcast(InterfaceSchema requestedSchema)
|
||||
DynamicCapability.Client castAs"castAs< ::capnp::DynamicCapability>"(InterfaceSchema)
|
||||
InterfaceSchema getSchema()
|
||||
Request newRequest(char * methodName, uint firstSegmentWordSize)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user