Upgrade Cython to version 3
While looking at #333, I hypothesized that upgrading Cython might solve the issue. It didn't. But upgrading should still happen at some point. This is my work in progress on that. The tests pass, but there are two main things missing: Problem (1): Starting with Cython 3, you can only do `except+` or `except +reraise_kj_exception` on `extern` functions coming from C++. (This makes sense, and the way things were declared in Pycapnp wasn't too good.) As a result, I had to remove a lot of these declaration. This results in some segmentation faults, because Cython no longer detects C++ exceptions and converts them to Python exceptions in some places. To solve this, all `extern` declarations in `.pxd` files have to be examined and `except +reraise_kj_exception` clauses need to be added to anything that might throw. Previously, this was done really inconsistently. The lazy solution would be to just add the clause everywhere, but I'm not sure what the performance implications are. Problem (2): The compilation output of `python setup.py build_ext --inplace` is now full of messages like these: ``` capnp/lib/capnp.cpp: In function ‘PyObject* __pyx_f_5capnp_3lib_5capnp_18_DynamicListReader__get(__pyx_obj_5capnp_3lib_5capnp__DynamicListReader*, int64_t, int)’: capnp/lib/capnp.cpp:4871:51: warning: moving a temporary object prevents copy elision [-Wpessimizing-move] 4871 | #define __PYX_STD_MOVE_IF_SUPPORTED(x) std::move(x) | ~~~~~~~~~^~~ capnp/lib/capnp.cpp:20944:59: note: in expansion of macro ‘__PYX_STD_MOVE_IF_SUPPORTED’ 20944 | __pyx_t_2 = __pyx_f_5capnp_3lib_5capnp_to_python_reader(__PYX_STD_MOVE_IF_SUPPORTED((( ::capnp::DynamicValue::Reader)__pyx_t_7)), __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 419, __pyx_L1_error) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ capnp/lib/capnp.cpp:4871:51: note: remove ‘std::move’ call 4871 | #define __PYX_STD_MOVE_IF_SUPPORTED(x) std::move(x) | ~~~~~~~~~^~~ capnp/lib/capnp.cpp:20944:59: note: in expansion of macro ‘__PYX_STD_MOVE_IF_SUPPORTED’ 20944 | __pyx_t_2 = __pyx_f_5capnp_3lib_5capnp_to_python_reader(__PYX_STD_MOVE_IF_SUPPORTED((( ::capnp::DynamicValue::Reader)__pyx_t_7)), __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 419, __pyx_L1_error) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` There are to many `move` calls inserted. I'm not sure if this is a Cython issue, or if we are somehow annotating things wrong. Might be worth asking the Cython people. I'm not planning on working on this further in the short term. If someone wants to take over on this, feel free.
This commit is contained in:
committed by
Jacob Alexander
parent
59a639fa97
commit
983719fde9
@@ -16,9 +16,6 @@ cdef extern from "capnp/helpers/fixMaybe.h":
|
|||||||
|
|
||||||
cdef extern from "capnp/helpers/capabilityHelper.h":
|
cdef extern from "capnp/helpers/capabilityHelper.h":
|
||||||
PyPromise then(PyPromise promise, Own[PyRefCounter] func, Own[PyRefCounter] error_func)
|
PyPromise then(PyPromise promise, Own[PyRefCounter] func, Own[PyRefCounter] error_func)
|
||||||
DynamicCapability.Client new_client(InterfaceSchema&, PyObject *)
|
|
||||||
DynamicValue.Reader new_server(InterfaceSchema&, PyObject *)
|
|
||||||
Capability.Client server_to_client(InterfaceSchema&, PyObject *)
|
|
||||||
PyPromise convert_to_pypromise(RemotePromise)
|
PyPromise convert_to_pypromise(RemotePromise)
|
||||||
PyPromise convert_to_pypromise(VoidPromise)
|
PyPromise convert_to_pypromise(VoidPromise)
|
||||||
VoidPromise taskToPromise(Own[PyRefCounter] coroutine, PyObject* callback)
|
VoidPromise taskToPromise(Own[PyRefCounter] coroutine, PyObject* callback)
|
||||||
@@ -26,11 +23,11 @@ cdef extern from "capnp/helpers/capabilityHelper.h":
|
|||||||
void init_capnp_api()
|
void init_capnp_api()
|
||||||
|
|
||||||
cdef extern from "capnp/helpers/rpcHelper.h":
|
cdef extern from "capnp/helpers/rpcHelper.h":
|
||||||
Capability.Client bootstrapHelper(RpcSystem&)
|
Own[Capability.Client] bootstrapHelper(RpcSystem&) except +reraise_kj_exception
|
||||||
Capability.Client bootstrapHelperServer(RpcSystem&)
|
Own[Capability.Client] bootstrapHelperServer(RpcSystem&) except +reraise_kj_exception
|
||||||
|
|
||||||
cdef extern from "capnp/helpers/serialize.h":
|
cdef extern from "capnp/helpers/serialize.h":
|
||||||
ByteArray messageToPackedBytes(MessageBuilder &, size_t wordCount)
|
ByteArray messageToPackedBytes(MessageBuilder &, size_t wordCount) except +reraise_kj_exception
|
||||||
|
|
||||||
cdef extern from "capnp/helpers/deserialize.h":
|
cdef extern from "capnp/helpers/deserialize.h":
|
||||||
Node.Reader toReader(DynamicStruct.Reader reader) except +reraise_kj_exception
|
Node.Reader toReader(DynamicStruct.Reader reader) except +reraise_kj_exception
|
||||||
|
|||||||
@@ -6,16 +6,16 @@
|
|||||||
#include "Python.h"
|
#include "Python.h"
|
||||||
#include "capabilityHelper.h"
|
#include "capabilityHelper.h"
|
||||||
|
|
||||||
capnp::Capability::Client bootstrapHelper(capnp::RpcSystem<capnp::rpc::twoparty::SturdyRefHostId>& client) {
|
kj::Own<capnp::Capability::Client> bootstrapHelper(capnp::RpcSystem<capnp::rpc::twoparty::SturdyRefHostId>& client) {
|
||||||
capnp::MallocMessageBuilder hostIdMessage(8);
|
capnp::MallocMessageBuilder hostIdMessage(8);
|
||||||
auto hostId = hostIdMessage.initRoot<capnp::rpc::twoparty::SturdyRefHostId>();
|
auto hostId = hostIdMessage.initRoot<capnp::rpc::twoparty::SturdyRefHostId>();
|
||||||
hostId.setSide(capnp::rpc::twoparty::Side::SERVER);
|
hostId.setSide(capnp::rpc::twoparty::Side::SERVER);
|
||||||
return client.bootstrap(hostId);
|
return kj::heap<capnp::Capability::Client>(client.bootstrap(hostId));
|
||||||
}
|
}
|
||||||
|
|
||||||
capnp::Capability::Client bootstrapHelperServer(capnp::RpcSystem<capnp::rpc::twoparty::SturdyRefHostId>& client) {
|
kj::Own<capnp::Capability::Client> bootstrapHelperServer(capnp::RpcSystem<capnp::rpc::twoparty::SturdyRefHostId>& client) {
|
||||||
capnp::MallocMessageBuilder hostIdMessage(8);
|
capnp::MallocMessageBuilder hostIdMessage(8);
|
||||||
auto hostId = hostIdMessage.initRoot<capnp::rpc::twoparty::SturdyRefHostId>();
|
auto hostId = hostIdMessage.initRoot<capnp::rpc::twoparty::SturdyRefHostId>();
|
||||||
hostId.setSide(capnp::rpc::twoparty::Side::CLIENT);
|
hostId.setSide(capnp::rpc::twoparty::Side::CLIENT);
|
||||||
return client.bootstrap(hostId);
|
return kj::heap<capnp::Capability::Client>(client.bootstrap(hostId));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,26 +57,12 @@ cdef extern from "kj/async.h" namespace " ::kj":
|
|||||||
cdef cppclass Promise[T] nogil:
|
cdef cppclass Promise[T] nogil:
|
||||||
Promise(Promise)
|
Promise(Promise)
|
||||||
Promise(T)
|
Promise(T)
|
||||||
T wait(WaitScope) except +reraise_kj_exception
|
|
||||||
bool poll(WaitScope) except +reraise_kj_exception
|
|
||||||
# ForkedPromise<T> fork()
|
|
||||||
# Promise<T> exclusiveJoin(Promise<T>&& other)
|
|
||||||
# Promise[T] eagerlyEvaluate()
|
|
||||||
# void detach(ErrorFunc)
|
|
||||||
String trace()
|
String trace()
|
||||||
Promise[T] attach(Own[PyRefCounter] &)
|
Promise[T] attach(Own[PyRefCounter] &)
|
||||||
Promise[T] attach(Own[PyRefCounter] &, Own[PyRefCounter] &)
|
Promise[T] attach(Own[PyRefCounter] &, Own[PyRefCounter] &)
|
||||||
Promise[T] attach(Own[PyRefCounter] &, Own[PyRefCounter] &, Own[PyRefCounter] &)
|
Promise[T] attach(Own[PyRefCounter] &, Own[PyRefCounter] &, Own[PyRefCounter] &)
|
||||||
Promise[T] attach(Own[PyRefCounter] &, Own[PyRefCounter] &, Own[PyRefCounter] &, Own[PyRefCounter] &)
|
Promise[T] attach(Own[PyRefCounter] &, Own[PyRefCounter] &, Own[PyRefCounter] &, Own[PyRefCounter] &)
|
||||||
|
|
||||||
cdef cppclass Canceler nogil:
|
|
||||||
Canceler()
|
|
||||||
Promise[T] wrap[T](Promise[T] promise)
|
|
||||||
void cancel(StringPtr cancelReason)
|
|
||||||
void cancel(Exception& exception)
|
|
||||||
void release()
|
|
||||||
bool isEmpty()
|
|
||||||
|
|
||||||
ctypedef Promise[Own[PyRefCounter]] PyPromise
|
ctypedef Promise[Own[PyRefCounter]] PyPromise
|
||||||
ctypedef Promise[void] VoidPromise
|
ctypedef Promise[void] VoidPromise
|
||||||
|
|
||||||
@@ -109,8 +95,8 @@ cdef extern from "kj/array.h" namespace " ::kj":
|
|||||||
|
|
||||||
cdef extern from "kj/async-io.h" namespace " ::kj":
|
cdef extern from "kj/async-io.h" namespace " ::kj":
|
||||||
cdef cppclass AsyncIoStream nogil:
|
cdef cppclass AsyncIoStream nogil:
|
||||||
Promise[size_t] read(void*, size_t, size_t)
|
Promise[size_t] read(void*, size_t, size_t) except +reraise_kj_exception
|
||||||
Promise[void] write(const void*, size_t)
|
Promise[void] write(const void*, size_t) except +reraise_kj_exception
|
||||||
|
|
||||||
cdef extern from "capnp/schema.capnp.h" namespace " ::capnp":
|
cdef extern from "capnp/schema.capnp.h" namespace " ::capnp":
|
||||||
enum TypeWhich" ::capnp::schema::Type::Which":
|
enum TypeWhich" ::capnp::schema::Type::Which":
|
||||||
@@ -297,7 +283,7 @@ cdef extern from "capnp/dynamic.h" namespace " ::capnp":
|
|||||||
Client()
|
Client()
|
||||||
Client(Client&)
|
Client(Client&)
|
||||||
Client(Own[PythonInterfaceDynamicImpl])
|
Client(Own[PythonInterfaceDynamicImpl])
|
||||||
Client upcast(InterfaceSchema requestedSchema)
|
Client upcast(InterfaceSchema requestedSchema) except +reraise_kj_exception
|
||||||
DynamicCapability.Client castAs"castAs< ::capnp::DynamicCapability>"(InterfaceSchema)
|
DynamicCapability.Client castAs"castAs< ::capnp::DynamicCapability>"(InterfaceSchema)
|
||||||
InterfaceSchema getSchema()
|
InterfaceSchema getSchema()
|
||||||
Request newRequest(char * methodName)
|
Request newRequest(char * methodName)
|
||||||
@@ -448,7 +434,7 @@ cdef extern from "capnp/dynamic.h" namespace " ::capnp":
|
|||||||
Type getType()
|
Type getType()
|
||||||
|
|
||||||
cdef extern from "capnp/schema-loader.h" namespace " ::capnp":
|
cdef extern from "capnp/schema-loader.h" namespace " ::capnp":
|
||||||
cdef cppclass SchemaLoader:
|
cdef cppclass SchemaLoader nogil:
|
||||||
SchemaLoader()
|
SchemaLoader()
|
||||||
Schema load(Node.Reader reader) except +reraise_kj_exception
|
Schema load(Node.Reader reader) except +reraise_kj_exception
|
||||||
Schema get(uint64_t id_) except +reraise_kj_exception
|
Schema get(uint64_t id_) except +reraise_kj_exception
|
||||||
|
|||||||
@@ -673,7 +673,7 @@ cdef extern from "capnp/message.h" namespace " ::capnp":
|
|||||||
Annotation.Builder getRootAnnotation'getRoot< ::capnp::schema::Annotation>'()
|
Annotation.Builder getRootAnnotation'getRoot< ::capnp::schema::Annotation>'()
|
||||||
Annotation.Builder initRootAnnotation'initRoot< ::capnp::schema::Annotation>'()
|
Annotation.Builder initRootAnnotation'initRoot< ::capnp::schema::Annotation>'()
|
||||||
|
|
||||||
DynamicStruct_Builder getRootDynamicStruct'getRoot< ::capnp::DynamicStruct>'(StructSchema)
|
DynamicStruct_Builder getRootDynamicStruct'getRoot< ::capnp::DynamicStruct>'(StructSchema) except +reraise_kj_exception
|
||||||
DynamicStruct_Builder initRootDynamicStruct'initRoot< ::capnp::DynamicStruct>'(StructSchema)
|
DynamicStruct_Builder initRootDynamicStruct'initRoot< ::capnp::DynamicStruct>'(StructSchema)
|
||||||
void setRootDynamicStruct'setRoot< ::capnp::DynamicStruct::Reader>'(DynamicStruct.Reader)
|
void setRootDynamicStruct'setRoot< ::capnp::DynamicStruct::Reader>'(DynamicStruct.Reader)
|
||||||
|
|
||||||
@@ -696,7 +696,7 @@ cdef extern from "capnp/message.h" namespace " ::capnp":
|
|||||||
StructNode.Reader getRootStructNode'getRoot< ::capnp::schema::StructNode>'()
|
StructNode.Reader getRootStructNode'getRoot< ::capnp::schema::StructNode>'()
|
||||||
Annotation.Reader getRootAnnotation'getRoot< ::capnp::schema::Annotation>'()
|
Annotation.Reader getRootAnnotation'getRoot< ::capnp::schema::Annotation>'()
|
||||||
|
|
||||||
DynamicStruct.Reader getRootDynamicStruct'getRoot< ::capnp::DynamicStruct>'(StructSchema)
|
DynamicStruct.Reader getRootDynamicStruct'getRoot< ::capnp::DynamicStruct>'(StructSchema) except +reraise_kj_exception
|
||||||
AnyPointer.Reader getRootAnyPointer'getRoot< ::capnp::AnyPointer>'()
|
AnyPointer.Reader getRootAnyPointer'getRoot< ::capnp::AnyPointer>'()
|
||||||
|
|
||||||
cdef cppclass MallocMessageBuilder(MessageBuilder) nogil:
|
cdef cppclass MallocMessageBuilder(MessageBuilder) nogil:
|
||||||
@@ -798,7 +798,7 @@ cdef extern from "capnp/serialize.h" namespace " ::capnp":
|
|||||||
FlatArrayMessageReader(WordArrayPtr array, ReaderOptions) except +reraise_kj_exception
|
FlatArrayMessageReader(WordArrayPtr array, ReaderOptions) except +reraise_kj_exception
|
||||||
const word* getEnd() const
|
const word* getEnd() const
|
||||||
|
|
||||||
void writeMessageToFd(int, MessageBuilder&) nogil except +reraise_kj_exception
|
void writeMessageToFd(int, MessageBuilder&) except +reraise_kj_exception nogil
|
||||||
|
|
||||||
WordArray messageToFlatArray(MessageBuilder &) nogil
|
WordArray messageToFlatArray(MessageBuilder &) nogil
|
||||||
|
|
||||||
@@ -816,6 +816,6 @@ cdef extern from "capnp/serialize-packed.h" namespace " ::capnp":
|
|||||||
PackedFdMessageReader(int) except +reraise_kj_exception
|
PackedFdMessageReader(int) except +reraise_kj_exception
|
||||||
PackedFdMessageReader(int, ReaderOptions) except +reraise_kj_exception
|
PackedFdMessageReader(int, ReaderOptions) except +reraise_kj_exception
|
||||||
|
|
||||||
void writePackedMessage(BufferedOutputStream&, MessageBuilder&) nogil except +reraise_kj_exception
|
void writePackedMessage(BufferedOutputStream&, MessageBuilder&) except +reraise_kj_exception nogil
|
||||||
void writePackedMessage(OutputStream&, MessageBuilder&) nogil except +reraise_kj_exception
|
void writePackedMessage(OutputStream&, MessageBuilder&) except +reraise_kj_exception nogil
|
||||||
void writePackedMessageToFd(int, MessageBuilder&) nogil except +reraise_kj_exception
|
void writePackedMessageToFd(int, MessageBuilder&) except +reraise_kj_exception nogil
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ cdef class _StringArrayPtr:
|
|||||||
cdef StringPtr * thisptr
|
cdef StringPtr * thisptr
|
||||||
cdef object parent
|
cdef object parent
|
||||||
cdef size_t size
|
cdef size_t size
|
||||||
cdef ArrayPtr[StringPtr] asArrayPtr(self) except +reraise_kj_exception
|
cdef ArrayPtr[StringPtr] asArrayPtr(self)
|
||||||
|
|
||||||
cdef class SchemaLoader:
|
cdef class SchemaLoader:
|
||||||
cdef C_SchemaLoader * thisptr
|
cdef C_SchemaLoader * thisptr
|
||||||
@@ -38,7 +38,7 @@ cdef class SchemaParser:
|
|||||||
cdef public dict modules_by_id
|
cdef public dict modules_by_id
|
||||||
cdef list _all_imports
|
cdef list _all_imports
|
||||||
cdef _StringArrayPtr _last_import_array
|
cdef _StringArrayPtr _last_import_array
|
||||||
cpdef _parse_disk_file(self, displayName, diskPath, imports) except +reraise_kj_exception
|
cpdef _parse_disk_file(self, displayName, diskPath, imports)
|
||||||
|
|
||||||
cdef class _DynamicOrphan:
|
cdef class _DynamicOrphan:
|
||||||
cdef C_DynamicOrphan thisptr
|
cdef C_DynamicOrphan thisptr
|
||||||
@@ -79,10 +79,10 @@ cdef class _DynamicStructBuilder:
|
|||||||
cdef _init(self, DynamicStruct_Builder other, object parent, bint isRoot=?, bint tryRegistry=?)
|
cdef _init(self, DynamicStruct_Builder other, object parent, bint isRoot=?, bint tryRegistry=?)
|
||||||
|
|
||||||
cdef _check_write(self)
|
cdef _check_write(self)
|
||||||
cpdef to_bytes(_DynamicStructBuilder self) except +reraise_kj_exception
|
cpdef to_bytes(_DynamicStructBuilder self)
|
||||||
cpdef to_segments(_DynamicStructBuilder self) except +reraise_kj_exception
|
cpdef to_segments(_DynamicStructBuilder self)
|
||||||
cpdef _to_bytes_packed_helper(_DynamicStructBuilder self, word_count) except +reraise_kj_exception
|
cpdef _to_bytes_packed_helper(_DynamicStructBuilder self, word_count)
|
||||||
cpdef to_bytes_packed(_DynamicStructBuilder self) except +reraise_kj_exception
|
cpdef to_bytes_packed(_DynamicStructBuilder self)
|
||||||
|
|
||||||
cpdef _get(self, field)
|
cpdef _get(self, field)
|
||||||
cpdef _set(self, field, value)
|
cpdef _set(self, field, value)
|
||||||
@@ -128,7 +128,7 @@ cdef class _DynamicEnum:
|
|||||||
cdef public object _parent
|
cdef public object _parent
|
||||||
|
|
||||||
cdef _init(self, capnp.DynamicEnum other, object parent)
|
cdef _init(self, capnp.DynamicEnum other, object parent)
|
||||||
cpdef _as_str(self) except +reraise_kj_exception
|
cpdef _as_str(self)
|
||||||
|
|
||||||
cdef class _DynamicListBuilder:
|
cdef class _DynamicListBuilder:
|
||||||
cdef C_DynamicList.Builder thisptr
|
cdef C_DynamicList.Builder thisptr
|
||||||
@@ -146,11 +146,11 @@ cdef class _DynamicListBuilder:
|
|||||||
cdef class _MessageBuilder:
|
cdef class _MessageBuilder:
|
||||||
cdef schema_cpp.MessageBuilder * thisptr
|
cdef schema_cpp.MessageBuilder * thisptr
|
||||||
cpdef init_root(self, schema)
|
cpdef init_root(self, schema)
|
||||||
cpdef get_root(self, schema) except +reraise_kj_exception
|
cpdef get_root(self, schema)
|
||||||
cpdef get_root_as_any(self) except +reraise_kj_exception
|
cpdef get_root_as_any(self)
|
||||||
cpdef set_root(self, value) except +reraise_kj_exception
|
cpdef set_root(self, value)
|
||||||
cpdef get_segments_for_output(self) except +reraise_kj_exception
|
cpdef get_segments_for_output(self)
|
||||||
cpdef new_orphan(self, schema) except +reraise_kj_exception
|
cpdef new_orphan(self, schema)
|
||||||
|
|
||||||
cdef to_python_reader(C_DynamicValue.Reader self, object parent)
|
cdef to_python_reader(C_DynamicValue.Reader self, object parent)
|
||||||
cdef to_python_builder(C_DynamicValue.Builder self, object parent)
|
cdef to_python_builder(C_DynamicValue.Builder self, object parent)
|
||||||
|
|||||||
@@ -10,11 +10,12 @@
|
|||||||
cimport cython # noqa: E402
|
cimport cython # noqa: E402
|
||||||
|
|
||||||
from capnp.helpers.helpers cimport init_capnp_api
|
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, PythonInterfaceDynamicImpl
|
from capnp.includes.capnp_cpp cimport AsyncIoStream, WaitScope, PyPromise, VoidPromise, EventPort, EventLoop, PyAsyncIoStream, PromiseFulfiller, VoidPromiseFulfiller, tryReadMessage, writeMessage, makeException, PythonInterfaceDynamicImpl
|
||||||
from capnp.includes.schema_cpp cimport (MessageReader,)
|
from capnp.includes.schema_cpp cimport (MessageReader,)
|
||||||
|
|
||||||
from cpython cimport array, Py_buffer, PyObject_CheckBuffer, memoryview, buffer
|
from cpython cimport array, Py_buffer, PyObject_CheckBuffer
|
||||||
from cpython.buffer cimport PyBUF_SIMPLE, PyBUF_WRITABLE
|
from cpython.buffer cimport PyBUF_SIMPLE, PyBUF_WRITABLE, PyBUF_WRITE, PyBUF_READ
|
||||||
|
from cpython.memoryview cimport PyMemoryView_FromMemory
|
||||||
from cpython.exc cimport PyErr_Clear
|
from cpython.exc cimport PyErr_Clear
|
||||||
from cython.operator cimport dereference as deref
|
from cython.operator cimport dereference as deref
|
||||||
from libc.stdlib cimport malloc, free
|
from libc.stdlib cimport malloc, free
|
||||||
@@ -129,7 +130,7 @@ def fill_context(method_name, context, returned_data):
|
|||||||
for arg_name, arg_val in zip(names, returned_data):
|
for arg_name, arg_val in zip(names, returned_data):
|
||||||
setattr(results, arg_name, arg_val)
|
setattr(results, arg_name, arg_val)
|
||||||
|
|
||||||
cdef api VoidPromise * call_server_method(object server,
|
cdef api Promise[void]* call_server_method(object server,
|
||||||
char * _method_name,
|
char * _method_name,
|
||||||
CallContext & _context,
|
CallContext & _context,
|
||||||
object _kj_loop) except* with gil:
|
object _kj_loop) except* with gil:
|
||||||
@@ -303,7 +304,7 @@ cdef api object get_exception_info(object exc_type, object exc_obj, object exc_t
|
|||||||
return (b'', 0, b"Couldn't determine python exception")
|
return (b'', 0, b"Couldn't determine python exception")
|
||||||
|
|
||||||
|
|
||||||
cdef schema_cpp.ReaderOptions make_reader_opts(traversal_limit_in_words, nesting_limit) with gil:
|
cdef schema_cpp.ReaderOptions make_reader_opts(traversal_limit_in_words, nesting_limit):
|
||||||
cdef schema_cpp.ReaderOptions opts
|
cdef schema_cpp.ReaderOptions opts
|
||||||
if traversal_limit_in_words is not None:
|
if traversal_limit_in_words is not None:
|
||||||
opts.traversalLimitInWords = traversal_limit_in_words
|
opts.traversalLimitInWords = traversal_limit_in_words
|
||||||
@@ -1029,7 +1030,7 @@ cdef class _DynamicEnum:
|
|||||||
self._parent = parent
|
self._parent = parent
|
||||||
return self
|
return self
|
||||||
|
|
||||||
cpdef _as_str(self) except +reraise_kj_exception:
|
cpdef _as_str(self):
|
||||||
return <char*>helpers.fixMaybe(self.thisptr.getEnumerant()).getProto().getName().cStr()
|
return <char*>helpers.fixMaybe(self.thisptr.getEnumerant()).getProto().getName().cStr()
|
||||||
|
|
||||||
property raw:
|
property raw:
|
||||||
@@ -1339,7 +1340,7 @@ cdef class _DynamicStructBuilder:
|
|||||||
_write_packed_message_to_fd(file.fileno(), self._parent)
|
_write_packed_message_to_fd(file.fileno(), self._parent)
|
||||||
self._is_written = True
|
self._is_written = True
|
||||||
|
|
||||||
cpdef to_bytes(_DynamicStructBuilder self) except +reraise_kj_exception:
|
cpdef to_bytes(_DynamicStructBuilder self):
|
||||||
"""Returns the struct's containing message as a Python bytes object in the unpacked binary format.
|
"""Returns the struct's containing message as a Python bytes object in the unpacked binary format.
|
||||||
|
|
||||||
This is inefficient; it makes several copies.
|
This is inefficient; it makes several copies.
|
||||||
@@ -1356,7 +1357,7 @@ cdef class _DynamicStructBuilder:
|
|||||||
self._is_written = True
|
self._is_written = True
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
cpdef to_segments(_DynamicStructBuilder self) except +reraise_kj_exception:
|
cpdef to_segments(_DynamicStructBuilder self):
|
||||||
"""Returns the struct's containing message as a Python list of Python bytes objects.
|
"""Returns the struct's containing message as a Python list of Python bytes objects.
|
||||||
|
|
||||||
This avoids making copies.
|
This avoids making copies.
|
||||||
@@ -1370,14 +1371,14 @@ cdef class _DynamicStructBuilder:
|
|||||||
segments = builder.get_segments_for_output()
|
segments = builder.get_segments_for_output()
|
||||||
return segments
|
return segments
|
||||||
|
|
||||||
cpdef _to_bytes_packed_helper(_DynamicStructBuilder self, word_count) except +reraise_kj_exception:
|
cpdef _to_bytes_packed_helper(_DynamicStructBuilder self, word_count):
|
||||||
cdef _MessageBuilder builder = self._parent
|
cdef _MessageBuilder builder = self._parent
|
||||||
array = helpers.messageToPackedBytes(deref(builder.thisptr), word_count)
|
array = helpers.messageToPackedBytes(deref(builder.thisptr), word_count)
|
||||||
cdef const char* ptr = <const char *>array.begin()
|
cdef const char* ptr = <const char *>array.begin()
|
||||||
cdef bytes ret = ptr[:array.size()]
|
cdef bytes ret = ptr[:array.size()]
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
cpdef to_bytes_packed(_DynamicStructBuilder self) except +reraise_kj_exception:
|
cpdef to_bytes_packed(_DynamicStructBuilder self):
|
||||||
self._check_write()
|
self._check_write()
|
||||||
word_count = self.total_size.word_count + 2
|
word_count = self.total_size.word_count + 2
|
||||||
|
|
||||||
@@ -1649,7 +1650,7 @@ cdef class _DynamicStructPipeline:
|
|||||||
def __dealloc__(self):
|
def __dealloc__(self):
|
||||||
del self.thisptr
|
del self.thisptr
|
||||||
|
|
||||||
cpdef _get(self, field) except +reraise_kj_exception:
|
cpdef _get(self, field):
|
||||||
cdef int type = (<C_DynamicValue.Pipeline>self.thisptr.get(field)).getType()
|
cdef int type = (<C_DynamicValue.Pipeline>self.thisptr.get(field)).getType()
|
||||||
if type == capnp.TYPE_CAPABILITY:
|
if type == capnp.TYPE_CAPABILITY:
|
||||||
return _DynamicCapabilityClient()._init(
|
return _DynamicCapabilityClient()._init(
|
||||||
@@ -1719,7 +1720,7 @@ cdef class _DynamicObjectReader:
|
|||||||
self._parent = parent
|
self._parent = parent
|
||||||
return self
|
return self
|
||||||
|
|
||||||
cpdef as_struct(self, schema) except +reraise_kj_exception:
|
cpdef as_struct(self, schema):
|
||||||
cdef _StructSchema s
|
cdef _StructSchema s
|
||||||
if hasattr(schema, 'schema'):
|
if hasattr(schema, 'schema'):
|
||||||
s = schema.schema
|
s = schema.schema
|
||||||
@@ -1728,7 +1729,7 @@ cdef class _DynamicObjectReader:
|
|||||||
|
|
||||||
return _DynamicStructReader()._init(self.thisptr.getAs(s._thisptr()), self._parent)
|
return _DynamicStructReader()._init(self.thisptr.getAs(s._thisptr()), self._parent)
|
||||||
|
|
||||||
cpdef as_interface(self, schema) except +reraise_kj_exception:
|
cpdef as_interface(self, schema):
|
||||||
cdef _InterfaceSchema s
|
cdef _InterfaceSchema s
|
||||||
if hasattr(schema, 'schema'):
|
if hasattr(schema, 'schema'):
|
||||||
s = schema.schema
|
s = schema.schema
|
||||||
@@ -1737,7 +1738,7 @@ cdef class _DynamicObjectReader:
|
|||||||
|
|
||||||
return _DynamicCapabilityClient()._init(self.thisptr.getAsCapability(s.thisptr), self._parent)
|
return _DynamicCapabilityClient()._init(self.thisptr.getAsCapability(s.thisptr), self._parent)
|
||||||
|
|
||||||
cpdef as_list(self, schema) except +reraise_kj_exception:
|
cpdef as_list(self, schema):
|
||||||
cdef _ListSchema s
|
cdef _ListSchema s
|
||||||
if hasattr(schema, 'schema'):
|
if hasattr(schema, 'schema'):
|
||||||
s = schema.schema
|
s = schema.schema
|
||||||
@@ -1746,7 +1747,7 @@ cdef class _DynamicObjectReader:
|
|||||||
|
|
||||||
return _DynamicListReader()._init(self.thisptr.getAsList(s.thisptr), self._parent)
|
return _DynamicListReader()._init(self.thisptr.getAsList(s.thisptr), self._parent)
|
||||||
|
|
||||||
cpdef as_text(self) except +reraise_kj_exception:
|
cpdef as_text(self):
|
||||||
return (<char*>self.thisptr.getAsText().cStr())[:]
|
return (<char*>self.thisptr.getAsText().cStr())[:]
|
||||||
|
|
||||||
|
|
||||||
@@ -1762,7 +1763,7 @@ cdef class _DynamicObjectBuilder:
|
|||||||
def __dealloc__(self):
|
def __dealloc__(self):
|
||||||
del self.thisptr
|
del self.thisptr
|
||||||
|
|
||||||
cpdef as_struct(self, schema) except +reraise_kj_exception:
|
cpdef as_struct(self, schema):
|
||||||
cdef _StructSchema s
|
cdef _StructSchema s
|
||||||
if hasattr(schema, 'schema'):
|
if hasattr(schema, 'schema'):
|
||||||
s = schema.schema
|
s = schema.schema
|
||||||
@@ -1771,7 +1772,7 @@ cdef class _DynamicObjectBuilder:
|
|||||||
|
|
||||||
return _DynamicStructBuilder()._init(self.thisptr.getAs(s._thisptr()), self._parent)
|
return _DynamicStructBuilder()._init(self.thisptr.getAs(s._thisptr()), self._parent)
|
||||||
|
|
||||||
cpdef as_interface(self, schema) except +reraise_kj_exception:
|
cpdef as_interface(self, schema):
|
||||||
cdef _InterfaceSchema s
|
cdef _InterfaceSchema s
|
||||||
if hasattr(schema, 'schema'):
|
if hasattr(schema, 'schema'):
|
||||||
s = schema.schema
|
s = schema.schema
|
||||||
@@ -1780,7 +1781,7 @@ cdef class _DynamicObjectBuilder:
|
|||||||
|
|
||||||
return _DynamicCapabilityClient()._init(self.thisptr.getAsCapability(s.thisptr), self._parent)
|
return _DynamicCapabilityClient()._init(self.thisptr.getAsCapability(s.thisptr), self._parent)
|
||||||
|
|
||||||
cpdef as_list(self, schema) except +reraise_kj_exception:
|
cpdef as_list(self, schema):
|
||||||
cdef _ListSchema s
|
cdef _ListSchema s
|
||||||
if hasattr(schema, 'schema'):
|
if hasattr(schema, 'schema'):
|
||||||
s = schema.schema
|
s = schema.schema
|
||||||
@@ -1806,13 +1807,13 @@ cdef class _DynamicObjectBuilder:
|
|||||||
|
|
||||||
return _DynamicListBuilder()._init(self.thisptr.initAsList(s.thisptr, size), self._parent)
|
return _DynamicListBuilder()._init(self.thisptr.initAsList(s.thisptr, size), self._parent)
|
||||||
|
|
||||||
cpdef as_text(self) except +reraise_kj_exception:
|
cpdef as_text(self):
|
||||||
return (<char*>self.thisptr.getAsText().cStr())[:]
|
return (<char*>self.thisptr.getAsText().cStr())[:]
|
||||||
|
|
||||||
cpdef as_reader(self):
|
cpdef as_reader(self):
|
||||||
return _DynamicObjectReader()._init(self.thisptr.asReader(), self._parent)
|
return _DynamicObjectReader()._init(self.thisptr.asReader(), self._parent)
|
||||||
|
|
||||||
cdef void kjloop_runnable_callback(void* data) with gil:
|
cdef kjloop_runnable_callback(void* data):
|
||||||
cdef AsyncIoEventPort *port = <AsyncIoEventPort*>data
|
cdef AsyncIoEventPort *port = <AsyncIoEventPort*>data
|
||||||
assert port.runHandle is not None
|
assert port.runHandle is not None
|
||||||
port.kjLoop.run()
|
port.kjLoop.run()
|
||||||
@@ -1872,7 +1873,7 @@ cdef class _EventLoop:
|
|||||||
cdef object active_tasks
|
cdef object active_tasks
|
||||||
cdef cbool closed
|
cdef cbool closed
|
||||||
|
|
||||||
cdef _init(self, asyncio_loop) except +reraise_kj_exception:
|
cdef _init(self, asyncio_loop):
|
||||||
self.event_port = capnp.heap[AsyncIoEventPort](<PyObject*>asyncio_loop)
|
self.event_port = capnp.heap[AsyncIoEventPort](<PyObject*>asyncio_loop)
|
||||||
kj_loop = deref(self.event_port).getKjLoop()
|
kj_loop = deref(self.event_port).getKjLoop()
|
||||||
self.wait_scope = capnp.heap[WaitScope](deref(kj_loop))
|
self.wait_scope = capnp.heap[WaitScope](deref(kj_loop))
|
||||||
@@ -2007,7 +2008,7 @@ cdef class _Promise:
|
|||||||
self.thisptr = capnp.heap[PyPromise](move(other))
|
self.thisptr = capnp.heap[PyPromise](move(other))
|
||||||
return self
|
return self
|
||||||
|
|
||||||
cpdef cancel(self) except +reraise_kj_exception:
|
cpdef cancel(self):
|
||||||
self.thisptr = Own[PyPromise]()
|
self.thisptr = Own[PyPromise]()
|
||||||
|
|
||||||
|
|
||||||
@@ -2022,7 +2023,7 @@ cdef class _RemotePromise:
|
|||||||
self._parent = parent
|
self._parent = parent
|
||||||
return self
|
return self
|
||||||
|
|
||||||
cdef void _check_consumed(self) except*:
|
cdef _check_consumed(self):
|
||||||
if self.thisptr.get() == NULL:
|
if self.thisptr.get() == NULL:
|
||||||
raise KjException(
|
raise KjException(
|
||||||
"Promise was already used in a consuming operation. You can no longer use this Promise object")
|
"Promise was already used in a consuming operation. You can no longer use this Promise object")
|
||||||
@@ -2035,7 +2036,7 @@ cdef class _RemotePromise:
|
|||||||
.attach(capnp.heap[PyRefCounter](<PyObject*>self._parent))
|
.attach(capnp.heap[PyRefCounter](<PyObject*>self._parent))
|
||||||
).__await__()
|
).__await__()
|
||||||
|
|
||||||
cpdef _get(self, field) except +reraise_kj_exception:
|
cpdef _get(self, field):
|
||||||
self._check_consumed()
|
self._check_consumed()
|
||||||
cdef int type = (<C_DynamicValue.Pipeline>self.thisptr.get().get(field)).getType()
|
cdef int type = (<C_DynamicValue.Pipeline>self.thisptr.get().get(field)).getType()
|
||||||
if type == capnp.TYPE_CAPABILITY:
|
if type == capnp.TYPE_CAPABILITY:
|
||||||
@@ -2068,7 +2069,7 @@ cdef class _RemotePromise:
|
|||||||
def to_dict(self, verbose=False, ordered=False):
|
def to_dict(self, verbose=False, ordered=False):
|
||||||
return _to_dict(self, verbose, ordered)
|
return _to_dict(self, verbose, ordered)
|
||||||
|
|
||||||
cpdef cancel(self) except +reraise_kj_exception:
|
cpdef cancel(self):
|
||||||
self.thisptr = Own[RemotePromise]()
|
self.thisptr = Own[RemotePromise]()
|
||||||
self._parent = None # We don't need parent anymore. Setting to none allows quicker garbage collection
|
self._parent = None # We don't need parent anymore. Setting to none allows quicker garbage collection
|
||||||
|
|
||||||
@@ -2171,7 +2172,7 @@ cdef class _DynamicCapabilityClient:
|
|||||||
for key, val in kwargs.items():
|
for key, val in kwargs.items():
|
||||||
_setDynamicField(<DynamicStruct_Builder>deref(request), key, val, self)
|
_setDynamicField(<DynamicStruct_Builder>deref(request), key, val, self)
|
||||||
|
|
||||||
cpdef _send_helper(self, name, word_count, args, kwargs) except +reraise_kj_exception:
|
cpdef _send_helper(self, name, word_count, args, kwargs):
|
||||||
# if word_count is None:
|
# if word_count is None:
|
||||||
# word_count = 0
|
# word_count = 0
|
||||||
C_DEFAULT_EVENT_LOOP_GETTER() # Make sure the event loop is running
|
C_DEFAULT_EVENT_LOOP_GETTER() # Make sure the event loop is running
|
||||||
@@ -2181,7 +2182,7 @@ cdef class _DynamicCapabilityClient:
|
|||||||
|
|
||||||
return _RemotePromise()._init(request.send(), self)
|
return _RemotePromise()._init(request.send(), self)
|
||||||
|
|
||||||
cpdef _request_helper(self, name, firstSegmentWordSize, args, kwargs) except +reraise_kj_exception:
|
cpdef _request_helper(self, name, firstSegmentWordSize, args, kwargs):
|
||||||
# if word_count is None:
|
# if word_count is None:
|
||||||
# word_count = 0
|
# word_count = 0
|
||||||
cdef _Request req = _Request()._init_child(self.thisptr.newRequest(name), self)
|
cdef _Request req = _Request()._init_child(self.thisptr.newRequest(name), self)
|
||||||
@@ -2210,7 +2211,7 @@ cdef class _DynamicCapabilityClient:
|
|||||||
except KjException as e:
|
except KjException as e:
|
||||||
raise e._to_python() from None
|
raise e._to_python() from None
|
||||||
|
|
||||||
cpdef upcast(self, schema) except +reraise_kj_exception:
|
cpdef upcast(self, schema):
|
||||||
cdef _InterfaceSchema s
|
cdef _InterfaceSchema s
|
||||||
if hasattr(schema, 'schema'):
|
if hasattr(schema, 'schema'):
|
||||||
s = schema.schema
|
s = schema.schema
|
||||||
@@ -2219,7 +2220,7 @@ cdef class _DynamicCapabilityClient:
|
|||||||
|
|
||||||
return _DynamicCapabilityClient()._init(self.thisptr.upcast(s.thisptr), self._parent)
|
return _DynamicCapabilityClient()._init(self.thisptr.upcast(s.thisptr), self._parent)
|
||||||
|
|
||||||
cpdef cast_as(self, schema) except +reraise_kj_exception:
|
cpdef cast_as(self, schema):
|
||||||
cdef _InterfaceSchema s
|
cdef _InterfaceSchema s
|
||||||
if hasattr(schema, 'schema'):
|
if hasattr(schema, 'schema'):
|
||||||
s = schema.schema
|
s = schema.schema
|
||||||
@@ -2239,24 +2240,21 @@ cdef class _DynamicCapabilityClient:
|
|||||||
|
|
||||||
|
|
||||||
cdef class _CapabilityClient:
|
cdef class _CapabilityClient:
|
||||||
cdef C_Capability.Client * thisptr
|
cdef Own[C_Capability.Client] thisptr
|
||||||
cdef public object _parent
|
cdef public object _parent
|
||||||
|
|
||||||
cdef _init(self, C_Capability.Client other, object parent):
|
cdef _init(self, Own[C_Capability.Client] other, object parent):
|
||||||
self.thisptr = new C_Capability.Client(other)
|
self.thisptr = move(other)
|
||||||
self._parent = parent
|
self._parent = parent
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def __dealloc__(self):
|
|
||||||
del self.thisptr
|
|
||||||
|
|
||||||
cpdef cast_as(self, schema):
|
cpdef cast_as(self, schema):
|
||||||
cdef _InterfaceSchema s
|
cdef _InterfaceSchema s
|
||||||
if hasattr(schema, 'schema'):
|
if hasattr(schema, 'schema'):
|
||||||
s = schema.schema
|
s = schema.schema
|
||||||
else:
|
else:
|
||||||
s = schema
|
s = schema
|
||||||
return _DynamicCapabilityClient()._init(self.thisptr.castAs(s.thisptr), self._parent)
|
return _DynamicCapabilityClient()._init(deref(self.thisptr).castAs(s.thisptr), self._parent)
|
||||||
|
|
||||||
|
|
||||||
cdef class _TwoPartyVatNetwork:
|
cdef class _TwoPartyVatNetwork:
|
||||||
@@ -2271,7 +2269,7 @@ cdef class _TwoPartyVatNetwork:
|
|||||||
self.thisptr = capnp.heap[C_TwoPartyVatNetwork](deref(stream.thisptr), side, opts)
|
self.thisptr = capnp.heap[C_TwoPartyVatNetwork](deref(stream.thisptr), side, opts)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
cpdef on_disconnect(self) except +reraise_kj_exception:
|
cpdef on_disconnect(self):
|
||||||
return _voidpromise_to_asyncio(deref(self.thisptr).onDisconnect())
|
return _voidpromise_to_asyncio(deref(self.thisptr).onDisconnect())
|
||||||
|
|
||||||
|
|
||||||
@@ -2310,12 +2308,12 @@ cdef class TwoPartyClient:
|
|||||||
|
|
||||||
self.thisptr = capnp.heap[RpcSystem](makeRpcClient(deref(self._network.thisptr)))
|
self.thisptr = capnp.heap[RpcSystem](makeRpcClient(deref(self._network.thisptr)))
|
||||||
|
|
||||||
cpdef bootstrap(self) except +reraise_kj_exception:
|
cpdef bootstrap(self):
|
||||||
if self.closed:
|
if self.closed:
|
||||||
raise RuntimeError("This client is closed")
|
raise RuntimeError("This client is closed")
|
||||||
return _CapabilityClient()._init(helpers.bootstrapHelper(deref(self.thisptr)), self)
|
return _CapabilityClient()._init(helpers.bootstrapHelper(deref(self.thisptr)), self)
|
||||||
|
|
||||||
cpdef on_disconnect(self) except +reraise_kj_exception:
|
cpdef on_disconnect(self):
|
||||||
if self.closed:
|
if self.closed:
|
||||||
raise RuntimeError("This client is closed")
|
raise RuntimeError("This client is closed")
|
||||||
return self._network.on_disconnect()
|
return self._network.on_disconnect()
|
||||||
@@ -2365,12 +2363,12 @@ cdef class TwoPartyServer:
|
|||||||
capnp.heap[PyRefCounter](<PyObject*>bootstrap),
|
capnp.heap[PyRefCounter](<PyObject*>bootstrap),
|
||||||
capnp.heap[PyRefCounter](<PyObject*>loop)))))
|
capnp.heap[PyRefCounter](<PyObject*>loop)))))
|
||||||
|
|
||||||
cpdef bootstrap(self) except +reraise_kj_exception:
|
cpdef bootstrap(self):
|
||||||
if self.closed:
|
if self.closed:
|
||||||
raise RuntimeError("This server is closed")
|
raise RuntimeError("This server is closed")
|
||||||
return _CapabilityClient()._init(helpers.bootstrapHelperServer(deref(self.thisptr)), self)
|
return _CapabilityClient()._init(helpers.bootstrapHelperServer(deref(self.thisptr)), self)
|
||||||
|
|
||||||
cpdef on_disconnect(self) except +reraise_kj_exception:
|
cpdef on_disconnect(self):
|
||||||
if self.closed:
|
if self.closed:
|
||||||
raise RuntimeError("This server is closed")
|
raise RuntimeError("This server is closed")
|
||||||
return _voidpromise_to_asyncio(deref(self._network.thisptr).onDisconnect()
|
return _voidpromise_to_asyncio(deref(self._network.thisptr).onDisconnect()
|
||||||
@@ -2581,7 +2579,7 @@ cdef class _PyAsyncIoStreamProtocol(DummyBaseClass, asyncio.BufferedProtocol):
|
|||||||
self.read_overflow_buffer_current = bytearray(size)
|
self.read_overflow_buffer_current = bytearray(size)
|
||||||
return self.read_overflow_buffer_current
|
return self.read_overflow_buffer_current
|
||||||
else:
|
else:
|
||||||
return memoryview.PyMemoryView_FromMemory(self.read_buffer, self.read_max_bytes, buffer.PyBUF_WRITE)
|
return PyMemoryView_FromMemory(self.read_buffer, self.read_max_bytes, PyBUF_WRITE)
|
||||||
|
|
||||||
def buffer_updated(self, size):
|
def buffer_updated(self, size):
|
||||||
if self.read_buffer == NULL: # Should not happen, but for SSL it does, see comment above
|
if self.read_buffer == NULL: # Should not happen, but for SSL it does, see comment above
|
||||||
@@ -2613,7 +2611,7 @@ cdef class _PyAsyncIoStreamProtocol(DummyBaseClass, asyncio.BufferedProtocol):
|
|||||||
cdef const ArrayPtr[const uint8_t]* piece
|
cdef const ArrayPtr[const uint8_t]* piece
|
||||||
for i in range(self.write_index, self.write_pieces.size()):
|
for i in range(self.write_index, self.write_pieces.size()):
|
||||||
piece = &self.write_pieces[i]
|
piece = &self.write_pieces[i]
|
||||||
view = memoryview.PyMemoryView_FromMemory(<char*>piece.begin(), piece.size(), buffer.PyBUF_READ)
|
view = PyMemoryView_FromMemory(<char*>piece.begin(), piece.size(), PyBUF_READ)
|
||||||
self.transport.write(view)
|
self.transport.write(view)
|
||||||
if self.write_paused:
|
if self.write_paused:
|
||||||
self.write_index = i+1
|
self.write_index = i+1
|
||||||
@@ -2667,7 +2665,7 @@ cdef api void _asyncio_stream_read_start(
|
|||||||
# Begin of draining the overflow buffer, which is created because of a bug in SSL, see comment above.
|
# Begin of draining the overflow buffer, which is created because of a bug in SSL, see comment above.
|
||||||
# Can be removed once Python < 3.11 is not longer supported.
|
# Can be removed once Python < 3.11 is not longer supported.
|
||||||
if self.read_overflow_buffer:
|
if self.read_overflow_buffer:
|
||||||
to_copy = min(len(self.read_overflow_buffer), max_bytes)
|
to_copy = min(<size_t>len(self.read_overflow_buffer), max_bytes)
|
||||||
memcpy(buffer, <char*>self.read_overflow_buffer, to_copy)
|
memcpy(buffer, <char*>self.read_overflow_buffer, to_copy)
|
||||||
del self.read_overflow_buffer[:to_copy]
|
del self.read_overflow_buffer[:to_copy]
|
||||||
self.read_buffer += to_copy
|
self.read_buffer += to_copy
|
||||||
@@ -3401,7 +3399,7 @@ cdef class _StringArrayPtr:
|
|||||||
def __dealloc__(self):
|
def __dealloc__(self):
|
||||||
free(self.thisptr)
|
free(self.thisptr)
|
||||||
|
|
||||||
cdef ArrayPtr[StringPtr] asArrayPtr(self) except +reraise_kj_exception:
|
cdef ArrayPtr[StringPtr] asArrayPtr(self):
|
||||||
return ArrayPtr[StringPtr](self.thisptr, self.size)
|
return ArrayPtr[StringPtr](self.thisptr, self.size)
|
||||||
|
|
||||||
|
|
||||||
@@ -3448,7 +3446,7 @@ cdef class SchemaParser:
|
|||||||
def __dealloc__(self):
|
def __dealloc__(self):
|
||||||
del self.thisptr
|
del self.thisptr
|
||||||
|
|
||||||
cpdef _parse_disk_file(self, displayName, diskPath, imports) except +reraise_kj_exception:
|
cpdef _parse_disk_file(self, displayName, diskPath, imports):
|
||||||
cdef _StringArrayPtr importArray
|
cdef _StringArrayPtr importArray
|
||||||
|
|
||||||
if self._last_import_array and self._last_import_array.parent == imports:
|
if self._last_import_array and self._last_import_array.parent == imports:
|
||||||
@@ -3616,7 +3614,7 @@ cdef class _MessageBuilder:
|
|||||||
s = schema
|
s = schema
|
||||||
return _DynamicStructBuilder()._init(self.thisptr.initRootDynamicStruct(s._thisptr()), self, True)
|
return _DynamicStructBuilder()._init(self.thisptr.initRootDynamicStruct(s._thisptr()), self, True)
|
||||||
|
|
||||||
cpdef get_root(self, schema) except +reraise_kj_exception:
|
cpdef get_root(self, schema):
|
||||||
"""A method for instantiating Cap'n Proto structs, from an already pre-written buffer
|
"""A method for instantiating Cap'n Proto structs, from an already pre-written buffer
|
||||||
|
|
||||||
Don't use this method unless you know what you're doing. You probably
|
Don't use this method unless you know what you're doing. You probably
|
||||||
@@ -3641,7 +3639,7 @@ cdef class _MessageBuilder:
|
|||||||
s = schema
|
s = schema
|
||||||
return _DynamicStructBuilder()._init(self.thisptr.getRootDynamicStruct(s._thisptr()), self, True)
|
return _DynamicStructBuilder()._init(self.thisptr.getRootDynamicStruct(s._thisptr()), self, True)
|
||||||
|
|
||||||
cpdef get_root_as_any(self) except +reraise_kj_exception:
|
cpdef get_root_as_any(self):
|
||||||
"""A method for getting a Cap'n Proto AnyPointer, from an already pre-written buffer
|
"""A method for getting a Cap'n Proto AnyPointer, from an already pre-written buffer
|
||||||
|
|
||||||
Don't use this method unless you know what you're doing.
|
Don't use this method unless you know what you're doing.
|
||||||
@@ -3651,7 +3649,7 @@ cdef class _MessageBuilder:
|
|||||||
"""
|
"""
|
||||||
return _DynamicObjectBuilder()._init(self.thisptr.getRootAnyPointer(), self)
|
return _DynamicObjectBuilder()._init(self.thisptr.getRootAnyPointer(), self)
|
||||||
|
|
||||||
cpdef set_root(self, value) except +reraise_kj_exception:
|
cpdef set_root(self, value):
|
||||||
"""A method for instantiating Cap'n Proto structs by copying from an existing struct
|
"""A method for instantiating Cap'n Proto structs by copying from an existing struct
|
||||||
|
|
||||||
:type value: :class:`_DynamicStructReader`
|
:type value: :class:`_DynamicStructReader`
|
||||||
@@ -3667,7 +3665,7 @@ cdef class _MessageBuilder:
|
|||||||
self.thisptr.setRootDynamicStruct((<_DynamicStructReader>value).thisptr)
|
self.thisptr.setRootDynamicStruct((<_DynamicStructReader>value).thisptr)
|
||||||
return self.get_root(value.schema)
|
return self.get_root(value.schema)
|
||||||
|
|
||||||
cpdef get_segments_for_output(self) except +reraise_kj_exception:
|
cpdef get_segments_for_output(self):
|
||||||
segments = self.thisptr.getSegmentsForOutput()
|
segments = self.thisptr.getSegmentsForOutput()
|
||||||
res = []
|
res = []
|
||||||
cdef const char* ptr
|
cdef const char* ptr
|
||||||
@@ -3679,7 +3677,7 @@ cdef class _MessageBuilder:
|
|||||||
res.append(segment_bytes)
|
res.append(segment_bytes)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
cpdef new_orphan(self, schema) except +reraise_kj_exception:
|
cpdef new_orphan(self, schema):
|
||||||
"""A method for instantiating Cap'n Proto orphans
|
"""A method for instantiating Cap'n Proto orphans
|
||||||
|
|
||||||
Don't use this method unless you know what you're doing.
|
Don't use this method unless you know what you're doing.
|
||||||
@@ -3737,7 +3735,7 @@ cdef class _MessageReader:
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
raise NotImplementedError("This is an abstract base class")
|
raise NotImplementedError("This is an abstract base class")
|
||||||
|
|
||||||
cpdef get_root(self, schema) except +reraise_kj_exception:
|
cpdef get_root(self, schema):
|
||||||
"""A method for instantiating Cap'n Proto structs
|
"""A method for instantiating Cap'n Proto structs
|
||||||
|
|
||||||
You will need to pass in a schema to specify which struct to
|
You will need to pass in a schema to specify which struct to
|
||||||
@@ -3761,7 +3759,7 @@ cdef class _MessageReader:
|
|||||||
s = schema
|
s = schema
|
||||||
return _DynamicStructReader()._init(self.thisptr.getRootDynamicStruct(s._thisptr()), self)
|
return _DynamicStructReader()._init(self.thisptr.getRootDynamicStruct(s._thisptr()), self)
|
||||||
|
|
||||||
cpdef get_root_as_any(self) except +reraise_kj_exception:
|
cpdef get_root_as_any(self):
|
||||||
"""A method for getting a Cap'n Proto AnyPointer, from an already pre-written buffer
|
"""A method for getting a Cap'n Proto AnyPointer, from an already pre-written buffer
|
||||||
|
|
||||||
Don't use this method unless you know what you're doing.
|
Don't use this method unless you know what you're doing.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[build-system]
|
[build-system]
|
||||||
requires = ["setuptools", "wheel", "pkgconfig", "cython<3"]
|
requires = ["setuptools", "wheel", "pkgconfig", "cython>=3.0"]
|
||||||
build-backend = "backend"
|
build-backend = "backend"
|
||||||
backend-path = ["_custom_build"]
|
backend-path = ["_custom_build"]
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
jinja2
|
jinja2
|
||||||
black
|
black
|
||||||
cython<3
|
cython>=3
|
||||||
flake8
|
flake8
|
||||||
setuptools
|
setuptools
|
||||||
pkgconfig
|
pkgconfig
|
||||||
|
|||||||
Reference in New Issue
Block a user