mirror of
https://github.com/capnproto/pycapnp.git
synced 2025-03-04 00:14:45 +01:00
Remove some more c++ helper functions
This commit is contained in:
parent
0483596da1
commit
83d610c116
5 changed files with 15 additions and 22 deletions
|
@ -89,17 +89,6 @@ public:
|
|||
capnp::CallContext< capnp::DynamicStruct, capnp::DynamicStruct> context);
|
||||
};
|
||||
|
||||
inline capnp::DynamicCapability::Client new_client(capnp::InterfaceSchema & schema, PyObject * server) {
|
||||
return capnp::DynamicCapability::Client(kj::heap<PythonInterfaceDynamicImpl>(schema, server));
|
||||
}
|
||||
inline capnp::DynamicValue::Reader new_server(capnp::InterfaceSchema & schema, PyObject * server) {
|
||||
return capnp::DynamicValue::Reader(kj::heap<PythonInterfaceDynamicImpl>(schema, server));
|
||||
}
|
||||
|
||||
inline capnp::Capability::Client server_to_client(capnp::InterfaceSchema & schema, PyObject * server) {
|
||||
return kj::heap<PythonInterfaceDynamicImpl>(schema, server);
|
||||
}
|
||||
|
||||
class PyAsyncIoStream: public kj::AsyncIoStream {
|
||||
public:
|
||||
kj::Own<PyRefCounter> protocol;
|
||||
|
|
|
@ -2,8 +2,6 @@ from cpython.ref cimport PyObject
|
|||
from libcpp cimport bool
|
||||
|
||||
cdef extern from "capnp/helpers/capabilityHelper.h":
|
||||
cppclass PythonInterfaceDynamicImpl:
|
||||
PythonInterfaceDynamicImpl(PyObject *)
|
||||
void reraise_kj_exception()
|
||||
cdef cppclass PyRefCounter:
|
||||
PyRefCounter(PyObject *)
|
||||
|
|
|
@ -5,7 +5,7 @@ cdef extern from "capnp/helpers/checkCompiler.h":
|
|||
|
||||
from libcpp cimport bool
|
||||
from capnp.helpers.non_circular cimport (
|
||||
PythonInterfaceDynamicImpl, reraise_kj_exception, PyRefCounter,
|
||||
reraise_kj_exception, PyRefCounter,
|
||||
)
|
||||
from capnp.includes.schema_cpp cimport (
|
||||
Node, Data, StructNode, EnumNode, InterfaceNode, MessageBuilder, MessageReader, ReaderOptions,
|
||||
|
@ -296,6 +296,7 @@ cdef extern from "capnp/dynamic.h" namespace " ::capnp":
|
|||
cppclass Client nogil:
|
||||
Client()
|
||||
Client(Client&)
|
||||
Client(Own[PythonInterfaceDynamicImpl])
|
||||
Client upcast(InterfaceSchema requestedSchema)
|
||||
DynamicCapability.Client castAs"castAs< ::capnp::DynamicCapability>"(InterfaceSchema)
|
||||
InterfaceSchema getSchema()
|
||||
|
@ -326,7 +327,7 @@ cdef extern from "capnp/rpc-twoparty.h" namespace " ::capnp":
|
|||
TwoPartyVatNetwork(EventLoop &, AsyncIoStream& stream, Side, ReaderOptions)
|
||||
VoidPromise onDisconnect()
|
||||
VoidPromise onDrained()
|
||||
RpcSystem makeRpcServerBootstrap"makeRpcServer"(TwoPartyVatNetwork&, Capability.Client) nogil
|
||||
RpcSystem makeRpcServer(TwoPartyVatNetwork&, Capability.Client) nogil
|
||||
RpcSystem makeRpcClient(TwoPartyVatNetwork&) nogil
|
||||
|
||||
cdef extern from "capnp/dynamic.h" namespace " ::capnp":
|
||||
|
@ -410,7 +411,7 @@ cdef extern from "capnp/dynamic.h" namespace " ::capnp":
|
|||
Reader(DynamicEnum value)
|
||||
Reader(DynamicStruct.Reader& value)
|
||||
Reader(DynamicCapability.Client& value)
|
||||
Reader(PythonInterfaceDynamicImpl& value)
|
||||
Reader(Own[PythonInterfaceDynamicImpl] value)
|
||||
Reader(AnyPointer.Reader& value)
|
||||
Type getType()
|
||||
int64_t asInt"as<int64_t>"()
|
||||
|
@ -497,6 +498,8 @@ cdef extern from "capnp/helpers/capabilityHelper.h":
|
|||
void rejectVoidDisconnected(VoidPromiseFulfiller& fulfiller, StringPtr message)
|
||||
Exception makeException(StringPtr message)
|
||||
PyPromise tryReadMessage(AsyncIoStream& stream, ReaderOptions opts)
|
||||
cppclass PythonInterfaceDynamicImpl:
|
||||
PythonInterfaceDynamicImpl(InterfaceSchema&, PyObject *)
|
||||
|
||||
cdef extern from "capnp/serialize-async.h" namespace " ::capnp":
|
||||
VoidPromise writeMessage(AsyncIoStream& output, MessageBuilder& builder)
|
||||
|
|
|
@ -9,7 +9,7 @@ from capnp.includes.capnp_cpp cimport (
|
|||
SchemaParser as C_SchemaParser, ParsedSchema as C_ParsedSchema, VOID, ArrayPtr, StringPtr,
|
||||
String, StringTree, DynamicOrphan as C_DynamicOrphan, AnyPointer as C_DynamicObject,
|
||||
DynamicCapability as C_DynamicCapability, Request, Response, RemotePromise, Promise,
|
||||
CallContext, RpcSystem, makeRpcServerBootstrap, makeRpcClient, Capability as C_Capability,
|
||||
CallContext, RpcSystem, makeRpcServer, makeRpcClient, Capability as C_Capability,
|
||||
TwoPartyVatNetwork as C_TwoPartyVatNetwork, Side, AsyncIoStream, Own,
|
||||
DynamicStruct_Builder, PyRefCounter, PyAsyncIoStream
|
||||
)
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
cimport cython # noqa: E402
|
||||
|
||||
from capnp.helpers.helpers cimport init_capnp_api
|
||||
from capnp.includes.capnp_cpp cimport AsyncIoStream, WaitScope, PyPromise, VoidPromise, EventPort, EventLoop, Canceler, PyAsyncIoStream, PromiseFulfiller, VoidPromiseFulfiller, tryReadMessage, writeMessage, makeException
|
||||
from capnp.includes.capnp_cpp cimport AsyncIoStream, WaitScope, PyPromise, VoidPromise, EventPort, EventLoop, Canceler, PyAsyncIoStream, PromiseFulfiller, VoidPromiseFulfiller, tryReadMessage, writeMessage, makeException, PythonInterfaceDynamicImpl
|
||||
from capnp.includes.schema_cpp cimport (MessageReader,)
|
||||
|
||||
from cpython cimport array, Py_buffer, PyObject_CheckBuffer, memoryview, buffer
|
||||
|
@ -702,7 +702,7 @@ cdef C_DynamicValue.Reader _extract_dynamic_client(_DynamicCapabilityClient valu
|
|||
|
||||
cdef C_DynamicValue.Reader _extract_dynamic_server(object value):
|
||||
cdef _InterfaceSchema schema = value.schema
|
||||
return helpers.new_server(schema.thisptr, <PyObject *>value)
|
||||
return C_DynamicValue.Reader(capnp.heap[PythonInterfaceDynamicImpl](schema.thisptr, <PyObject*> value))
|
||||
|
||||
|
||||
cdef C_DynamicValue.Reader _extract_dynamic_enum(_DynamicEnum value):
|
||||
|
@ -2056,7 +2056,8 @@ cdef class _DynamicCapabilityClient:
|
|||
else:
|
||||
s = schema
|
||||
|
||||
self.thisptr = helpers.new_client(s.thisptr, <PyObject *>server)
|
||||
self.thisptr = C_DynamicCapability.Client(
|
||||
capnp.heap[PythonInterfaceDynamicImpl](s.thisptr, <PyObject *>server))
|
||||
self._parent = server
|
||||
return self
|
||||
|
||||
|
@ -2250,8 +2251,10 @@ cdef class TwoPartyServer:
|
|||
raise ValueError(f"Argument socket should be a AsyncIoStream, was {type(socket)}")
|
||||
|
||||
cdef _InterfaceSchema schema = bootstrap.schema
|
||||
self.thisptr = capnp.heap[RpcSystem](makeRpcServerBootstrap(
|
||||
deref(self._network.thisptr), helpers.server_to_client(schema.thisptr, <PyObject *>bootstrap)))
|
||||
self.thisptr = capnp.heap[RpcSystem](makeRpcServer(
|
||||
deref(self._network.thisptr),
|
||||
C_DynamicCapability.Client(capnp.heap[PythonInterfaceDynamicImpl](
|
||||
schema.thisptr, <PyObject *>bootstrap))))
|
||||
|
||||
cpdef bootstrap(self) except +reraise_kj_exception:
|
||||
return _CapabilityClient()._init(helpers.bootstrapHelperServer(deref(self.thisptr)), self)
|
||||
|
|
Loading…
Add table
Reference in a new issue