Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Cython to version 3 #334

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions capnp/helpers/helpers.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,17 @@ cdef extern from "capnp/helpers/fixMaybe.h":

cdef extern from "capnp/helpers/capabilityHelper.h":
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(VoidPromise)
VoidPromise taskToPromise(Own[PyRefCounter] coroutine, PyObject* callback)
void init_capnp_api()

cdef extern from "capnp/helpers/rpcHelper.h":
Capability.Client bootstrapHelper(RpcSystem&)
Capability.Client bootstrapHelperServer(RpcSystem&)
Own[Capability.Client] bootstrapHelper(RpcSystem&) except +reraise_kj_exception
Own[Capability.Client] bootstrapHelperServer(RpcSystem&) except +reraise_kj_exception

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":
Node.Reader toReader(DynamicStruct.Reader reader) except +reraise_kj_exception
Expand Down
8 changes: 4 additions & 4 deletions capnp/helpers/rpcHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
#include "Python.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);
auto hostId = hostIdMessage.initRoot<capnp::rpc::twoparty::SturdyRefHostId>();
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);
auto hostId = hostIdMessage.initRoot<capnp::rpc::twoparty::SturdyRefHostId>();
hostId.setSide(capnp::rpc::twoparty::Side::CLIENT);
return client.bootstrap(hostId);
return kj::heap<capnp::Capability::Client>(client.bootstrap(hostId));
}
22 changes: 4 additions & 18 deletions capnp/includes/capnp_cpp.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -57,26 +57,12 @@ cdef extern from "kj/async.h" namespace " ::kj":
cdef cppclass Promise[T] nogil:
Promise(Promise)
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()
Promise[T] attach(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] &, 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[void] VoidPromise

Expand Down Expand Up @@ -109,8 +95,8 @@ cdef extern from "kj/array.h" namespace " ::kj":

cdef extern from "kj/async-io.h" namespace " ::kj":
cdef cppclass AsyncIoStream nogil:
Promise[size_t] read(void*, size_t, size_t)
Promise[void] write(const void*, size_t)
Promise[size_t] read(void*, size_t, size_t) except +reraise_kj_exception
Promise[void] write(const void*, size_t) except +reraise_kj_exception

cdef extern from "capnp/schema.capnp.h" namespace " ::capnp":
enum TypeWhich" ::capnp::schema::Type::Which":
Expand Down Expand Up @@ -297,7 +283,7 @@ cdef extern from "capnp/dynamic.h" namespace " ::capnp":
Client()
Client(Client&)
Client(Own[PythonInterfaceDynamicImpl])
Client upcast(InterfaceSchema requestedSchema)
Client upcast(InterfaceSchema requestedSchema) except +reraise_kj_exception
DynamicCapability.Client castAs"castAs< ::capnp::DynamicCapability>"(InterfaceSchema)
InterfaceSchema getSchema()
Request newRequest(char * methodName)
Expand Down Expand Up @@ -447,7 +433,7 @@ cdef extern from "capnp/dynamic.h" namespace " ::capnp":
Type getType()

cdef extern from "capnp/schema-loader.h" namespace " ::capnp":
cdef cppclass SchemaLoader:
cdef cppclass SchemaLoader nogil:
SchemaLoader()
Schema load(Node.Reader reader) except +reraise_kj_exception
Schema get(uint64_t id_) except +reraise_kj_exception
Expand Down
12 changes: 6 additions & 6 deletions capnp/includes/schema_cpp.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ cdef extern from "capnp/message.h" namespace " ::capnp":
Annotation.Builder getRootAnnotation'getRoot< ::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)
void setRootDynamicStruct'setRoot< ::capnp::DynamicStruct::Reader>'(DynamicStruct.Reader)

Expand All @@ -696,7 +696,7 @@ cdef extern from "capnp/message.h" namespace " ::capnp":
StructNode.Reader getRootStructNode'getRoot< ::capnp::schema::StructNode>'()
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>'()

cdef cppclass MallocMessageBuilder(MessageBuilder) nogil:
Expand Down Expand Up @@ -798,7 +798,7 @@ cdef extern from "capnp/serialize.h" namespace " ::capnp":
FlatArrayMessageReader(WordArrayPtr array, ReaderOptions) except +reraise_kj_exception
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

Expand All @@ -816,6 +816,6 @@ cdef extern from "capnp/serialize-packed.h" namespace " ::capnp":
PackedFdMessageReader(int) except +reraise_kj_exception
PackedFdMessageReader(int, ReaderOptions) except +reraise_kj_exception

void writePackedMessage(BufferedOutputStream&, MessageBuilder&) nogil except +reraise_kj_exception
void writePackedMessage(OutputStream&, MessageBuilder&) nogil except +reraise_kj_exception
void writePackedMessageToFd(int, MessageBuilder&) nogil except +reraise_kj_exception
void writePackedMessage(BufferedOutputStream&, MessageBuilder&) except +reraise_kj_exception nogil
void writePackedMessage(OutputStream&, MessageBuilder&) except +reraise_kj_exception nogil
void writePackedMessageToFd(int, MessageBuilder&) except +reraise_kj_exception nogil
24 changes: 12 additions & 12 deletions capnp/lib/capnp.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ cdef class _StringArrayPtr:
cdef StringPtr * thisptr
cdef object parent
cdef size_t size
cdef ArrayPtr[StringPtr] asArrayPtr(self) except +reraise_kj_exception
cdef ArrayPtr[StringPtr] asArrayPtr(self)

cdef class SchemaLoader:
cdef C_SchemaLoader * thisptr
Expand All @@ -38,7 +38,7 @@ cdef class SchemaParser:
cdef public dict modules_by_id
cdef list _all_imports
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 C_DynamicOrphan thisptr
Expand Down Expand Up @@ -79,10 +79,10 @@ cdef class _DynamicStructBuilder:
cdef _init(self, DynamicStruct_Builder other, object parent, bint isRoot=?, bint tryRegistry=?)

cdef _check_write(self)
cpdef to_bytes(_DynamicStructBuilder self) except +reraise_kj_exception
cpdef to_segments(_DynamicStructBuilder self) except +reraise_kj_exception
cpdef _to_bytes_packed_helper(_DynamicStructBuilder self, word_count) except +reraise_kj_exception
cpdef to_bytes_packed(_DynamicStructBuilder self) except +reraise_kj_exception
cpdef to_bytes(_DynamicStructBuilder self)
cpdef to_segments(_DynamicStructBuilder self)
cpdef _to_bytes_packed_helper(_DynamicStructBuilder self, word_count)
cpdef to_bytes_packed(_DynamicStructBuilder self)

cpdef _get(self, field)
cpdef _set(self, field, value)
Expand Down Expand Up @@ -128,7 +128,7 @@ cdef class _DynamicEnum:
cdef public 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 C_DynamicList.Builder thisptr
Expand All @@ -146,11 +146,11 @@ cdef class _DynamicListBuilder:
cdef class _MessageBuilder:
cdef schema_cpp.MessageBuilder * thisptr
cpdef init_root(self, schema)
cpdef get_root(self, schema) except +reraise_kj_exception
cpdef get_root_as_any(self) except +reraise_kj_exception
cpdef set_root(self, value) except +reraise_kj_exception
cpdef get_segments_for_output(self) except +reraise_kj_exception
cpdef new_orphan(self, schema) except +reraise_kj_exception
cpdef get_root(self, schema)
cpdef get_root_as_any(self)
cpdef set_root(self, value)
cpdef get_segments_for_output(self)
cpdef new_orphan(self, schema)

cdef to_python_reader(C_DynamicValue.Reader self, object parent)
cdef to_python_builder(C_DynamicValue.Builder self, object parent)
Expand Down
Loading
Loading