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
@@ -10,11 +10,12 @@
|
||||
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, 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 cpython cimport array, Py_buffer, PyObject_CheckBuffer, memoryview, buffer
|
||||
from cpython.buffer cimport PyBUF_SIMPLE, PyBUF_WRITABLE
|
||||
from cpython cimport array, Py_buffer, PyObject_CheckBuffer
|
||||
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 cython.operator cimport dereference as deref
|
||||
from libc.stdlib cimport malloc, free
|
||||
@@ -129,10 +130,10 @@ def fill_context(method_name, context, returned_data):
|
||||
for arg_name, arg_val in zip(names, returned_data):
|
||||
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,
|
||||
CallContext & _context,
|
||||
object _kj_loop) except * with gil:
|
||||
object _kj_loop) except* with gil:
|
||||
method_name = <object>_method_name
|
||||
kj_loop = <_EventLoop>_kj_loop
|
||||
kj_loop.check()
|
||||
@@ -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")
|
||||
|
||||
|
||||
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
|
||||
if traversal_limit_in_words is not None:
|
||||
opts.traversalLimitInWords = traversal_limit_in_words
|
||||
@@ -1029,7 +1030,7 @@ cdef class _DynamicEnum:
|
||||
self._parent = parent
|
||||
return self
|
||||
|
||||
cpdef _as_str(self) except +reraise_kj_exception:
|
||||
cpdef _as_str(self):
|
||||
return <char*>helpers.fixMaybe(self.thisptr.getEnumerant()).getProto().getName().cStr()
|
||||
|
||||
property raw:
|
||||
@@ -1339,7 +1340,7 @@ cdef class _DynamicStructBuilder:
|
||||
_write_packed_message_to_fd(file.fileno(), self._parent)
|
||||
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.
|
||||
|
||||
This is inefficient; it makes several copies.
|
||||
@@ -1356,7 +1357,7 @@ cdef class _DynamicStructBuilder:
|
||||
self._is_written = True
|
||||
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.
|
||||
|
||||
This avoids making copies.
|
||||
@@ -1370,14 +1371,14 @@ cdef class _DynamicStructBuilder:
|
||||
segments = builder.get_segments_for_output()
|
||||
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
|
||||
array = helpers.messageToPackedBytes(deref(builder.thisptr), word_count)
|
||||
cdef const char* ptr = <const char *>array.begin()
|
||||
cdef bytes ret = ptr[:array.size()]
|
||||
return ret
|
||||
|
||||
cpdef to_bytes_packed(_DynamicStructBuilder self) except +reraise_kj_exception:
|
||||
cpdef to_bytes_packed(_DynamicStructBuilder self):
|
||||
self._check_write()
|
||||
word_count = self.total_size.word_count + 2
|
||||
|
||||
@@ -1649,7 +1650,7 @@ cdef class _DynamicStructPipeline:
|
||||
def __dealloc__(self):
|
||||
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()
|
||||
if type == capnp.TYPE_CAPABILITY:
|
||||
return _DynamicCapabilityClient()._init(
|
||||
@@ -1719,7 +1720,7 @@ cdef class _DynamicObjectReader:
|
||||
self._parent = parent
|
||||
return self
|
||||
|
||||
cpdef as_struct(self, schema) except +reraise_kj_exception:
|
||||
cpdef as_struct(self, schema):
|
||||
cdef _StructSchema s
|
||||
if hasattr(schema, 'schema'):
|
||||
s = schema.schema
|
||||
@@ -1728,7 +1729,7 @@ cdef class _DynamicObjectReader:
|
||||
|
||||
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
|
||||
if hasattr(schema, 'schema'):
|
||||
s = schema.schema
|
||||
@@ -1737,7 +1738,7 @@ cdef class _DynamicObjectReader:
|
||||
|
||||
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
|
||||
if hasattr(schema, 'schema'):
|
||||
s = schema.schema
|
||||
@@ -1746,7 +1747,7 @@ cdef class _DynamicObjectReader:
|
||||
|
||||
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())[:]
|
||||
|
||||
|
||||
@@ -1762,7 +1763,7 @@ cdef class _DynamicObjectBuilder:
|
||||
def __dealloc__(self):
|
||||
del self.thisptr
|
||||
|
||||
cpdef as_struct(self, schema) except +reraise_kj_exception:
|
||||
cpdef as_struct(self, schema):
|
||||
cdef _StructSchema s
|
||||
if hasattr(schema, 'schema'):
|
||||
s = schema.schema
|
||||
@@ -1771,7 +1772,7 @@ cdef class _DynamicObjectBuilder:
|
||||
|
||||
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
|
||||
if hasattr(schema, 'schema'):
|
||||
s = schema.schema
|
||||
@@ -1780,7 +1781,7 @@ cdef class _DynamicObjectBuilder:
|
||||
|
||||
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
|
||||
if hasattr(schema, 'schema'):
|
||||
s = schema.schema
|
||||
@@ -1806,13 +1807,13 @@ cdef class _DynamicObjectBuilder:
|
||||
|
||||
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())[:]
|
||||
|
||||
cpdef as_reader(self):
|
||||
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
|
||||
assert port.runHandle is not None
|
||||
port.kjLoop.run()
|
||||
@@ -1872,7 +1873,7 @@ cdef class _EventLoop:
|
||||
cdef object active_tasks
|
||||
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)
|
||||
kj_loop = deref(self.event_port).getKjLoop()
|
||||
self.wait_scope = capnp.heap[WaitScope](deref(kj_loop))
|
||||
@@ -2007,7 +2008,7 @@ cdef class _Promise:
|
||||
self.thisptr = capnp.heap[PyPromise](move(other))
|
||||
return self
|
||||
|
||||
cpdef cancel(self) except +reraise_kj_exception:
|
||||
cpdef cancel(self):
|
||||
self.thisptr = Own[PyPromise]()
|
||||
|
||||
|
||||
@@ -2022,7 +2023,7 @@ cdef class _RemotePromise:
|
||||
self._parent = parent
|
||||
return self
|
||||
|
||||
cdef void _check_consumed(self) except*:
|
||||
cdef _check_consumed(self):
|
||||
if self.thisptr.get() == NULL:
|
||||
raise KjException(
|
||||
"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))
|
||||
).__await__()
|
||||
|
||||
cpdef _get(self, field) except +reraise_kj_exception:
|
||||
cpdef _get(self, field):
|
||||
self._check_consumed()
|
||||
cdef int type = (<C_DynamicValue.Pipeline>self.thisptr.get().get(field)).getType()
|
||||
if type == capnp.TYPE_CAPABILITY:
|
||||
@@ -2068,7 +2069,7 @@ cdef class _RemotePromise:
|
||||
def to_dict(self, verbose=False, ordered=False):
|
||||
return _to_dict(self, verbose, ordered)
|
||||
|
||||
cpdef cancel(self) except +reraise_kj_exception:
|
||||
cpdef cancel(self):
|
||||
self.thisptr = Own[RemotePromise]()
|
||||
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():
|
||||
_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:
|
||||
# word_count = 0
|
||||
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)
|
||||
|
||||
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:
|
||||
# word_count = 0
|
||||
cdef _Request req = _Request()._init_child(self.thisptr.newRequest(name), self)
|
||||
@@ -2210,7 +2211,7 @@ cdef class _DynamicCapabilityClient:
|
||||
except KjException as e:
|
||||
raise e._to_python() from None
|
||||
|
||||
cpdef upcast(self, schema) except +reraise_kj_exception:
|
||||
cpdef upcast(self, schema):
|
||||
cdef _InterfaceSchema s
|
||||
if hasattr(schema, 'schema'):
|
||||
s = schema.schema
|
||||
@@ -2219,7 +2220,7 @@ cdef class _DynamicCapabilityClient:
|
||||
|
||||
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
|
||||
if hasattr(schema, 'schema'):
|
||||
s = schema.schema
|
||||
@@ -2239,24 +2240,21 @@ cdef class _DynamicCapabilityClient:
|
||||
|
||||
|
||||
cdef class _CapabilityClient:
|
||||
cdef C_Capability.Client * thisptr
|
||||
cdef Own[C_Capability.Client] thisptr
|
||||
cdef public object _parent
|
||||
|
||||
cdef _init(self, C_Capability.Client other, object parent):
|
||||
self.thisptr = new C_Capability.Client(other)
|
||||
cdef _init(self, Own[C_Capability.Client] other, object parent):
|
||||
self.thisptr = move(other)
|
||||
self._parent = parent
|
||||
return self
|
||||
|
||||
def __dealloc__(self):
|
||||
del self.thisptr
|
||||
|
||||
cpdef cast_as(self, schema):
|
||||
cdef _InterfaceSchema s
|
||||
if hasattr(schema, 'schema'):
|
||||
s = schema.schema
|
||||
else:
|
||||
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:
|
||||
@@ -2271,7 +2269,7 @@ cdef class _TwoPartyVatNetwork:
|
||||
self.thisptr = capnp.heap[C_TwoPartyVatNetwork](deref(stream.thisptr), side, opts)
|
||||
return self
|
||||
|
||||
cpdef on_disconnect(self) except +reraise_kj_exception:
|
||||
cpdef on_disconnect(self):
|
||||
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)))
|
||||
|
||||
cpdef bootstrap(self) except +reraise_kj_exception:
|
||||
cpdef bootstrap(self):
|
||||
if self.closed:
|
||||
raise RuntimeError("This client is closed")
|
||||
return _CapabilityClient()._init(helpers.bootstrapHelper(deref(self.thisptr)), self)
|
||||
|
||||
cpdef on_disconnect(self) except +reraise_kj_exception:
|
||||
cpdef on_disconnect(self):
|
||||
if self.closed:
|
||||
raise RuntimeError("This client is closed")
|
||||
return self._network.on_disconnect()
|
||||
@@ -2365,12 +2363,12 @@ cdef class TwoPartyServer:
|
||||
capnp.heap[PyRefCounter](<PyObject*>bootstrap),
|
||||
capnp.heap[PyRefCounter](<PyObject*>loop)))))
|
||||
|
||||
cpdef bootstrap(self) except +reraise_kj_exception:
|
||||
cpdef bootstrap(self):
|
||||
if self.closed:
|
||||
raise RuntimeError("This server is closed")
|
||||
return _CapabilityClient()._init(helpers.bootstrapHelperServer(deref(self.thisptr)), self)
|
||||
|
||||
cpdef on_disconnect(self) except +reraise_kj_exception:
|
||||
cpdef on_disconnect(self):
|
||||
if self.closed:
|
||||
raise RuntimeError("This server is closed")
|
||||
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)
|
||||
return self.read_overflow_buffer_current
|
||||
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):
|
||||
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
|
||||
for i in range(self.write_index, self.write_pieces.size()):
|
||||
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)
|
||||
if self.write_paused:
|
||||
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.
|
||||
# Can be removed once Python < 3.11 is not longer supported.
|
||||
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)
|
||||
del self.read_overflow_buffer[:to_copy]
|
||||
self.read_buffer += to_copy
|
||||
@@ -3401,7 +3399,7 @@ cdef class _StringArrayPtr:
|
||||
def __dealloc__(self):
|
||||
free(self.thisptr)
|
||||
|
||||
cdef ArrayPtr[StringPtr] asArrayPtr(self) except +reraise_kj_exception:
|
||||
cdef ArrayPtr[StringPtr] asArrayPtr(self):
|
||||
return ArrayPtr[StringPtr](self.thisptr, self.size)
|
||||
|
||||
|
||||
@@ -3448,7 +3446,7 @@ cdef class SchemaParser:
|
||||
def __dealloc__(self):
|
||||
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
|
||||
|
||||
if self._last_import_array and self._last_import_array.parent == imports:
|
||||
@@ -3616,7 +3614,7 @@ cdef class _MessageBuilder:
|
||||
s = schema
|
||||
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
|
||||
|
||||
Don't use this method unless you know what you're doing. You probably
|
||||
@@ -3641,7 +3639,7 @@ cdef class _MessageBuilder:
|
||||
s = schema
|
||||
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
|
||||
|
||||
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)
|
||||
|
||||
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
|
||||
|
||||
:type value: :class:`_DynamicStructReader`
|
||||
@@ -3667,7 +3665,7 @@ cdef class _MessageBuilder:
|
||||
self.thisptr.setRootDynamicStruct((<_DynamicStructReader>value).thisptr)
|
||||
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()
|
||||
res = []
|
||||
cdef const char* ptr
|
||||
@@ -3679,7 +3677,7 @@ cdef class _MessageBuilder:
|
||||
res.append(segment_bytes)
|
||||
return res
|
||||
|
||||
cpdef new_orphan(self, schema) except +reraise_kj_exception:
|
||||
cpdef new_orphan(self, schema):
|
||||
"""A method for instantiating Cap'n Proto orphans
|
||||
|
||||
Don't use this method unless you know what you're doing.
|
||||
@@ -3737,7 +3735,7 @@ cdef class _MessageReader:
|
||||
def __init__(self):
|
||||
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
|
||||
|
||||
You will need to pass in a schema to specify which struct to
|
||||
@@ -3761,7 +3759,7 @@ cdef class _MessageReader:
|
||||
s = schema
|
||||
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
|
||||
|
||||
Don't use this method unless you know what you're doing.
|
||||
|
||||
Reference in New Issue
Block a user