* Integrate the KJ event loop into Python's asyncio event loop Fix #256 This PR attempts to remove the slow and expensive polling behavior for asyncio in favor of proper linking of the KJ event loop to the asyncio event loop. * Don't memcopy buffer * Improve promise cancellation and prepare for timer implementation * Add attribution for asyncProvider.cpp * Implement timeout * Cleanup * First round of simplifications * Add more a_wait functions and a shutdown function * Fix edge-cases with loop shutdown * Clean up calculator examples * Cleanup * Cleanup * Reformat * Fix warnings * Reformat again * Compatibility with macos * Inline the asyncio loop in some places where this is feasible * Add todo * Fix * Remove synchronous wait * Wrap fd listening callbacks in a class * Remove poll_forever * Remove the thread-local/thread-global optimization This will not matter much soon anyway, and simplifies things * Share promise code by using fused types * Improve refcounting of python objects in promises We replace many instances of PyObject* by Own<PyRefCounter> for more automatic reference management. * Code wrapPyFunc in a similar way to wrapPyFuncNoArg * Refactor capabilityHelper, fix several memory bugs for promises and add __await__ * Improve promise ownership, reduce memory leaks Promise wrappers now hold a Own<Promise<Own<PyRefCounter>>> object. This might seem like excessive nesting of objects (which to some degree it is, but with good reason): - The outer Own is needed because Cython cannot allocate objects without a nullary constructor on the stack (Promise doesn't have a nullary constructor). Additionally, I believe it would be difficult or impossible to detect when a promise is cancelled/moved if we use a bare Promise. - Every promise returns a Owned PyRefCounter. PyRefCounter makes sure that a reference to the returned object keeps existing until the promise is fulfilled or cancelled. Previously, this was attempted using attach, which is redundant and makes reasoning about PyINCREF and PyDECREF very difficult. - Because a promise holds a Own<Promise<...>>, when we perform any kind of action on that promise (a_wait, then, ...), we have to explicitly move() the ownership around. This will leave the original promise with a NULL-pointer, which we can easily detect as a cancelled promise. Promises now only hold references to their 'parents' when strictly needed. This should reduce memory pressure. * Simplify and test the promise joining functionality * Attach forgotten parent * Catch exceptions in add_reader and friends * Further cleanup of memory leaks * Get rid of a_wait() in examples * Cancel all fd read operations when the python asyncio loop is closed * Formatting * Remove support for capnp < 7000 * Bring asyncProvider.cpp more in line with upstream async-io-unix.c++ It was originally copied from the nodejs implementation, which in turn copied from async-io-unix.c++. But that copy is pretty old. * Fix a bug that caused file descriptors to never be closed * Implement AsyncIoStream based on Python transports and protocols * Get rid of asyncProvider All asyncio now goes through _AsyncIoStream * Formatting * Add __dict__ to PyAsyncIoStreamProtocol for python 3.7 * Reintroduce strange ipv4/ipv6 selection code to make ci happy * Extra pause_reading() * Work around more python bugs * Be careful to only close transport when this is still possible * Move pause_reading() workaround
567 lines
23 KiB
Cython
567 lines
23 KiB
Cython
# schema.capnp.cpp.pyx
|
|
# distutils: language = c++
|
|
cdef extern from "capnp/helpers/checkCompiler.h":
|
|
pass
|
|
|
|
from libcpp cimport bool
|
|
from capnp.helpers.non_circular cimport (
|
|
PythonInterfaceDynamicImpl, reraise_kj_exception, PyRefCounter, ErrorHandler,
|
|
)
|
|
from capnp.includes.schema_cpp cimport (
|
|
Node, Data, StructNode, EnumNode, InterfaceNode, MessageBuilder, MessageReader, ReaderOptions,
|
|
)
|
|
from capnp.includes.types cimport *
|
|
|
|
cdef extern from "capnp/common.h" namespace " ::capnp":
|
|
enum Void:
|
|
VOID " ::capnp::VOID"
|
|
cdef cppclass MessageSize nogil:
|
|
uint64_t wordCount
|
|
uint capCount
|
|
|
|
cdef extern from "capnp/common.h":
|
|
int CAPNP_VERSION_MAJOR
|
|
int CAPNP_VERSION_MINOR
|
|
int CAPNP_VERSION_MICRO
|
|
int CAPNP_VERSION
|
|
|
|
cdef extern from "kj/string.h" namespace " ::kj":
|
|
cdef cppclass StringPtr nogil:
|
|
StringPtr()
|
|
StringPtr(char *)
|
|
StringPtr(char *, size_t)
|
|
char* cStr()
|
|
size_t size()
|
|
char* begin()
|
|
cdef cppclass String nogil:
|
|
char* cStr()
|
|
size_t size()
|
|
char* begin()
|
|
|
|
cdef extern from "kj/exception.h" namespace " ::kj":
|
|
cdef cppclass Exception nogil:
|
|
Exception(Exception)
|
|
char* getFile()
|
|
int getLine()
|
|
int getType()
|
|
StringPtr getDescription()
|
|
|
|
cdef extern from "kj/memory.h" namespace " ::kj":
|
|
cdef cppclass Own[T] nogil:
|
|
Own()
|
|
T& operator*()
|
|
T* get()
|
|
Own[T] heap[T](...)
|
|
Own[TwoPartyVatNetwork] makeTwoPartyVatNetwork" ::kj::heap< ::capnp::TwoPartyVatNetwork>"(
|
|
AsyncIoStream& stream, Side, ReaderOptions)
|
|
Own[PromiseFulfillerPair] copyPromiseFulfillerPair" ::kj::heap< ::kj::PromiseFulfillerPair<void> >"(
|
|
PromiseFulfillerPair&)
|
|
|
|
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
|
|
|
|
cdef extern from "kj/string-tree.h" namespace " ::kj":
|
|
cdef cppclass StringTree nogil:
|
|
String flatten()
|
|
|
|
cdef extern from "kj/common.h" namespace " ::kj":
|
|
cdef cppclass Maybe[T] nogil:
|
|
T& orDefault(T&)
|
|
cdef cppclass ArrayPtr[T] nogil:
|
|
ArrayPtr()
|
|
ArrayPtr(T *, size_t size)
|
|
T* begin()
|
|
size_t size()
|
|
T& operator[](size_t index)
|
|
|
|
cdef extern from "kj/array.h" namespace " ::kj":
|
|
cdef cppclass Array[T] nogil:
|
|
T* begin()
|
|
size_t size()
|
|
T& operator[](size_t index)
|
|
cdef cppclass ArrayBuilder[T] nogil:
|
|
T* begin()
|
|
size_t size()
|
|
T& operator[](size_t index)
|
|
T& add(T&)
|
|
Array[T] finish()
|
|
|
|
ArrayBuilder[PyPromise] heapArrayBuilderPyPromise"::kj::heapArrayBuilder< ::kj::Promise<kj::Own<PyRefCounter>> >"(size_t) nogil
|
|
|
|
ctypedef Array[Own[PyRefCounter]] PyArray' ::kj::Array<kj::Own<PyRefCounter>>'
|
|
|
|
ctypedef Promise[PyArray] PyPromiseArray
|
|
|
|
cdef extern from "kj/time.h" namespace " ::kj":
|
|
cdef cppclass Duration nogil:
|
|
Duration operator*(int64_t)
|
|
Duration NANOSECONDS
|
|
Duration MICROSECONDS
|
|
Duration MILLISECONDS
|
|
Duration SECONDS
|
|
Duration MINUTES
|
|
Duration HOURS
|
|
Duration DAYS
|
|
cdef cppclass TimePoint:
|
|
TimePoint(Duration)
|
|
cdef cppclass MonotonicClock nogil:
|
|
MonotonicClock(MonotonicClock&)
|
|
TimePoint now()
|
|
MonotonicClock systemPreciseMonotonicClock()
|
|
|
|
cdef extern from "kj/timer.h" namespace " ::kj":
|
|
cdef cppclass Timer nogil:
|
|
# int64_t now()
|
|
# VoidPromise atTime(TimePoint time)
|
|
VoidPromise afterDelay(Duration delay)
|
|
cdef cppclass TimerImpl(Timer) nogil:
|
|
TimerImpl(TimePoint startTime)
|
|
Maybe[TimePoint] nextEvent()
|
|
Maybe[uint64_t] timeoutToNextEvent(TimePoint start, Duration unit, uint64_t max)
|
|
void advanceTo(TimePoint newTime)
|
|
|
|
cdef inline Duration Nanoseconds(int64_t nanos):
|
|
return NANOSECONDS * nanos
|
|
|
|
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)
|
|
|
|
cdef cppclass LowLevelAsyncIoProvider:
|
|
# Own[AsyncInputStream] wrapInputFd(int)
|
|
# Own[AsyncOutputStream] wrapOutputFd(int)
|
|
Own[AsyncIoStream] wrapSocketFd(int)
|
|
Timer& getTimer() except +reraise_kj_exception
|
|
|
|
cdef cppclass AsyncIoProvider nogil:
|
|
TwoWayPipe newTwoWayPipe()
|
|
|
|
cdef cppclass AsyncIoContext nogil:
|
|
AsyncIoContext(AsyncIoContext&)
|
|
Own[LowLevelAsyncIoProvider] lowLevelProvider
|
|
Own[AsyncIoProvider] provider
|
|
WaitScope waitScope
|
|
|
|
cdef cppclass TaskSet nogil:
|
|
TaskSet(ErrorHandler &)
|
|
|
|
cdef cppclass TwoWayPipe nogil:
|
|
Own[AsyncIoStream] ends[2]
|
|
|
|
AsyncIoContext setupAsyncIo() nogil
|
|
Own[AsyncIoProvider] newAsyncIoProvider(LowLevelAsyncIoProvider& lowLevel);
|
|
|
|
cdef extern from "capnp/schema.capnp.h" namespace " ::capnp":
|
|
enum TypeWhich" ::capnp::schema::Type::Which":
|
|
TypeWhichVOID " ::capnp::schema::Type::Which::VOID"
|
|
TypeWhichBOOL " ::capnp::schema::Type::Which::BOOL"
|
|
TypeWhichINT8 " ::capnp::schema::Type::Which::INT8"
|
|
TypeWhichINT16 " ::capnp::schema::Type::Which::INT16"
|
|
TypeWhichINT32 " ::capnp::schema::Type::Which::INT32"
|
|
TypeWhichINT64 " ::capnp::schema::Type::Which::INT64"
|
|
TypeWhichUINT8 " ::capnp::schema::Type::Which::UINT8"
|
|
TypeWhichUINT16 " ::capnp::schema::Type::Which::UINT16"
|
|
TypeWhichUINT32 " ::capnp::schema::Type::Which::UINT32"
|
|
TypeWhichUINT64 " ::capnp::schema::Type::Which::UINT64"
|
|
TypeWhichFLOAT32 " ::capnp::schema::Type::Which::FLOAT32"
|
|
TypeWhichFLOAT64 " ::capnp::schema::Type::Which::FLOAT64"
|
|
TypeWhichTEXT " ::capnp::schema::Type::Which::TEXT"
|
|
TypeWhichDATA " ::capnp::schema::Type::Which::DATA"
|
|
TypeWhichLIST " ::capnp::schema::Type::Which::LIST"
|
|
TypeWhichENUM " ::capnp::schema::Type::Which::ENUM"
|
|
TypeWhichSTRUCT " ::capnp::schema::Type::Which::STRUCT"
|
|
TypeWhichINTERFACE " ::capnp::schema::Type::Which::INTERFACE"
|
|
TypeWhichANY_POINTER " ::capnp::schema::Type::Which::ANY_POINTER"
|
|
|
|
cdef extern from "capnp/schema.h" namespace " ::capnp":
|
|
cdef cppclass SchemaType" ::capnp::Type" nogil:
|
|
SchemaType()
|
|
SchemaType(TypeWhich)
|
|
cbool isList()
|
|
cbool isEnum()
|
|
cbool isStruct()
|
|
cbool isInterface()
|
|
|
|
StructSchema asStruct() except +reraise_kj_exception
|
|
EnumSchema asEnum() except +reraise_kj_exception
|
|
InterfaceSchema asInterface() except +reraise_kj_exception
|
|
ListSchema asList() except +reraise_kj_exception
|
|
|
|
cdef cppclass Schema nogil:
|
|
Node.Reader getProto() except +reraise_kj_exception
|
|
StructSchema asStruct() except +reraise_kj_exception
|
|
EnumSchema asEnum() except +reraise_kj_exception
|
|
ConstSchema asConst() except +reraise_kj_exception
|
|
Schema getDependency(uint64_t id) except +reraise_kj_exception
|
|
InterfaceSchema asInterface() except +reraise_kj_exception
|
|
|
|
cdef cppclass InterfaceSchema(Schema) nogil:
|
|
cppclass SuperclassList nogil:
|
|
uint size()
|
|
InterfaceSchema operator[](uint index)
|
|
|
|
cppclass Method nogil:
|
|
InterfaceNode.Method.Reader getProto()
|
|
InterfaceSchema getContainingInterface()
|
|
uint16_t getOrdinal()
|
|
uint getIndex()
|
|
StructSchema getParamType()
|
|
StructSchema getResultType()
|
|
|
|
cppclass MethodList nogil:
|
|
uint size()
|
|
Method operator[](uint index)
|
|
|
|
MethodList getMethods()
|
|
Maybe[Method] findMethodByName(StringPtr name)
|
|
Method getMethodByName(StringPtr name)
|
|
bint extends(InterfaceSchema other)
|
|
SuperclassList getSuperclasses()
|
|
# kj::Maybe<InterfaceSchema> findSuperclass(uint64_t typeId) const;
|
|
|
|
cdef cppclass StructSchema(Schema) nogil:
|
|
cppclass Field nogil:
|
|
StructNode.Member.Reader getProto()
|
|
StructSchema getContainingStruct()
|
|
uint getIndex()
|
|
SchemaType getType()
|
|
|
|
cppclass FieldList nogil:
|
|
uint size()
|
|
Field operator[](uint index)
|
|
|
|
cppclass FieldSubset nogil:
|
|
uint size()
|
|
Field operator[](uint index)
|
|
|
|
FieldList getFields()
|
|
FieldSubset getUnionFields()
|
|
FieldSubset getNonUnionFields()
|
|
|
|
Field getFieldByName(char * name)
|
|
|
|
cbool operator == (StructSchema)
|
|
|
|
cdef cppclass EnumSchema nogil:
|
|
cppclass Enumerant nogil:
|
|
EnumNode.Enumerant.Reader getProto()
|
|
EnumSchema getContainingEnum()
|
|
uint16_t getOrdinal()
|
|
|
|
cppclass EnumerantList nogil:
|
|
uint size()
|
|
Enumerant operator[](uint index)
|
|
|
|
EnumerantList getEnumerants()
|
|
Enumerant getEnumerantByName(char * name)
|
|
Node.Reader getProto()
|
|
|
|
cdef cppclass ListSchema nogil:
|
|
SchemaType getElementType()
|
|
|
|
ListSchema listSchemaOfStruct" ::capnp::ListSchema::of"(StructSchema) nogil
|
|
ListSchema listSchemaOfEnum" ::capnp::ListSchema::of"(EnumSchema) nogil
|
|
ListSchema listSchemaOfInterface" ::capnp::ListSchema::of"(InterfaceSchema) nogil
|
|
ListSchema listSchemaOfList" ::capnp::ListSchema::of"(ListSchema) nogil
|
|
ListSchema listSchemaOfType" ::capnp::ListSchema::of"(SchemaType) nogil
|
|
|
|
cdef cppclass ConstSchema:
|
|
pass
|
|
|
|
cdef extern from "capnp/dynamic.h" namespace " ::capnp":
|
|
cdef cppclass DynamicValueForward" ::capnp::DynamicValue" nogil:
|
|
cppclass Reader nogil:
|
|
pass
|
|
cppclass Builder nogil:
|
|
pass
|
|
cppclass Pipeline nogil:
|
|
pass
|
|
|
|
enum Type:
|
|
TYPE_UNKNOWN " ::capnp::DynamicValue::UNKNOWN"
|
|
TYPE_VOID " ::capnp::DynamicValue::VOID"
|
|
TYPE_BOOL " ::capnp::DynamicValue::BOOL"
|
|
TYPE_INT " ::capnp::DynamicValue::INT"
|
|
TYPE_UINT " ::capnp::DynamicValue::UINT"
|
|
TYPE_FLOAT " ::capnp::DynamicValue::FLOAT"
|
|
TYPE_TEXT " ::capnp::DynamicValue::TEXT"
|
|
TYPE_DATA " ::capnp::DynamicValue::DATA"
|
|
TYPE_LIST " ::capnp::DynamicValue::LIST"
|
|
TYPE_ENUM " ::capnp::DynamicValue::ENUM"
|
|
TYPE_STRUCT " ::capnp::DynamicValue::STRUCT"
|
|
TYPE_CAPABILITY " ::capnp::DynamicValue::CAPABILITY"
|
|
TYPE_ANY_POINTER " ::capnp::DynamicValue::ANY_POINTER"
|
|
|
|
cdef cppclass DynamicStruct nogil:
|
|
cppclass Reader nogil:
|
|
DynamicValueForward.Reader get(char *) except +reraise_kj_exception
|
|
DynamicValueForward.Reader getByField"get"(StructSchema.Field) except +reraise_kj_exception
|
|
bint has(char *) except +reraise_kj_exception
|
|
bint hasByField"has"(StructSchema.Field) except +reraise_kj_exception
|
|
StructSchema getSchema()
|
|
uint64_t getId"getSchema().getProto().getId"()
|
|
Maybe[StructSchema.Field] which()
|
|
MessageSize totalSize()
|
|
cppclass Pipeline nogil:
|
|
Pipeline()
|
|
Pipeline(Pipeline &)
|
|
DynamicValueForward.Pipeline get(char *)
|
|
StructSchema getSchema()
|
|
|
|
cdef cppclass DynamicStruct_Builder" ::capnp::DynamicStruct::Builder" nogil:
|
|
# Need to flatten this class out, since nested C++ classes cause havoc with cython fused types
|
|
DynamicStruct_Builder()
|
|
DynamicStruct_Builder(DynamicStruct_Builder &)
|
|
DynamicValueForward.Builder get(char *) except +reraise_kj_exception
|
|
DynamicValueForward.Builder getByField"get"(StructSchema.Field) except +reraise_kj_exception
|
|
bint has(char *) except +reraise_kj_exception
|
|
bint hasByField"has"(StructSchema.Field) except +reraise_kj_exception
|
|
void set(char *, DynamicValueForward.Reader) except +reraise_kj_exception
|
|
void setByField"set"(StructSchema.Field, DynamicValueForward.Reader) except +reraise_kj_exception
|
|
DynamicValueForward.Builder init(char *, uint size) except +reraise_kj_exception
|
|
DynamicValueForward.Builder init(char *) except +reraise_kj_exception
|
|
DynamicValueForward.Builder initByField"init"(StructSchema.Field, uint size) except +reraise_kj_exception
|
|
DynamicValueForward.Builder initByField"init"(StructSchema.Field) except +reraise_kj_exception
|
|
StructSchema getSchema()
|
|
uint64_t getId"getSchema().getProto().getId"()
|
|
Maybe[StructSchema.Field] which()
|
|
void adopt(char *, DynamicOrphan) except +reraise_kj_exception
|
|
DynamicOrphan disown(char *)
|
|
DynamicStruct.Reader asReader()
|
|
MessageSize totalSize()
|
|
|
|
cdef extern from "capnp/dynamic.h" namespace " ::capnp":
|
|
cdef cppclass DynamicCapability nogil:
|
|
cppclass Client nogil:
|
|
Client()
|
|
Client(Client&)
|
|
Client upcast(InterfaceSchema requestedSchema)
|
|
DynamicCapability.Client castAs"castAs< ::capnp::DynamicCapability>"(InterfaceSchema)
|
|
InterfaceSchema getSchema()
|
|
Request newRequest(char * methodName)
|
|
# Request newRequest(char * methodName, MessageSize)
|
|
|
|
cdef extern from "capnp/capability.h" namespace " ::capnp":
|
|
cdef cppclass Response" ::capnp::Response< ::capnp::DynamicStruct>"(DynamicStruct.Reader) nogil:
|
|
Response(Response)
|
|
cdef cppclass RemotePromise" ::capnp::RemotePromise< ::capnp::DynamicStruct>"(
|
|
Promise[Response], DynamicStruct.Pipeline) nogil:
|
|
RemotePromise(RemotePromise)
|
|
cdef cppclass Capability nogil:
|
|
cppclass Client nogil:
|
|
Client(Client&)
|
|
DynamicCapability.Client castAs"castAs< ::capnp::DynamicCapability>"(InterfaceSchema)
|
|
|
|
cdef extern from "capnp/rpc-twoparty.h" namespace " ::capnp":
|
|
cdef cppclass RpcSystem" ::capnp::RpcSystem<capnp::rpc::twoparty::SturdyRefHostId>" nogil:
|
|
RpcSystem(RpcSystem&&)
|
|
|
|
cdef cppclass Side" ::capnp::rpc::twoparty::Side" nogil:
|
|
pass
|
|
cdef Side CLIENT" ::capnp::rpc::twoparty::Side::CLIENT"
|
|
cdef Side SERVER" ::capnp::rpc::twoparty::Side::SERVER"
|
|
|
|
cdef cppclass TwoPartyVatNetwork nogil:
|
|
TwoPartyVatNetwork(EventLoop &, AsyncIoStream& stream, Side, ReaderOptions)
|
|
VoidPromise onDisconnect()
|
|
VoidPromise onDrained()
|
|
RpcSystem makeRpcServerBootstrap"makeRpcServer"(TwoPartyVatNetwork&, Capability.Client) nogil
|
|
RpcSystem makeRpcClient(TwoPartyVatNetwork&) nogil
|
|
|
|
cdef extern from "capnp/dynamic.h" namespace " ::capnp":
|
|
cdef cppclass Request" ::capnp::Request< ::capnp::DynamicStruct, ::capnp::DynamicStruct>" nogil:
|
|
Request()
|
|
Request(Request &)
|
|
DynamicValueForward.Builder get(char *) except +reraise_kj_exception
|
|
bint has(char *) except +reraise_kj_exception
|
|
void set(char *, DynamicValueForward.Reader) except +reraise_kj_exception
|
|
DynamicValueForward.Builder init(char *, uint size) except +reraise_kj_exception
|
|
DynamicValueForward.Builder init(char *) except +reraise_kj_exception
|
|
StructSchema getSchema()
|
|
Maybe[StructSchema.Field] which()
|
|
RemotePromise send()
|
|
|
|
cdef extern from "capnp/dynamic.h" namespace " ::capnp":
|
|
cdef cppclass DynamicEnum nogil:
|
|
uint16_t getRaw()
|
|
Maybe[EnumSchema.Enumerant] getEnumerant()
|
|
|
|
cdef cppclass DynamicList nogil:
|
|
cppclass Reader nogil:
|
|
DynamicValueForward.Reader operator[](uint) except +reraise_kj_exception
|
|
uint size()
|
|
cppclass Builder nogil:
|
|
Builder()
|
|
Builder(Builder &)
|
|
DynamicValueForward.Builder operator[](uint) except +reraise_kj_exception
|
|
uint size()
|
|
void set(uint index, DynamicValueForward.Reader value) except +reraise_kj_exception
|
|
DynamicValueForward.Builder init(uint index, uint size) except +reraise_kj_exception
|
|
void adopt(uint, DynamicOrphan) except +reraise_kj_exception
|
|
DynamicOrphan disown(uint)
|
|
StructSchema getStructElementType'getSchema().getStructElementType'()
|
|
|
|
cdef extern from "capnp/any.h" namespace " ::capnp":
|
|
cdef cppclass AnyPointer nogil:
|
|
cppclass Reader nogil:
|
|
DynamicStruct.Reader getAs"getAs< ::capnp::DynamicStruct>"(StructSchema) except +reraise_kj_exception
|
|
DynamicCapability.Client getAsCapability"getAs< ::capnp::DynamicCapability>"(
|
|
InterfaceSchema) except +reraise_kj_exception
|
|
DynamicList.Reader getAsList"getAs< ::capnp::DynamicList>"(ListSchema) except +reraise_kj_exception
|
|
StringPtr getAsText"getAs< ::capnp::Text>"() except +reraise_kj_exception
|
|
cppclass Builder nogil:
|
|
Builder(Builder)
|
|
DynamicStruct_Builder getAs"getAs< ::capnp::DynamicStruct>"(StructSchema) except +reraise_kj_exception
|
|
DynamicCapability.Client getAsCapability"getAs< ::capnp::DynamicCapability>"(
|
|
InterfaceSchema) except +reraise_kj_exception
|
|
DynamicList.Builder getAsList"getAs< ::capnp::DynamicList>"(ListSchema) except +reraise_kj_exception
|
|
StringPtr getAsText"getAs< ::capnp::Text>"() except +reraise_kj_exception
|
|
void setAsStruct"setAs< ::capnp::DynamicStruct>"(DynamicStruct.Reader&) except +reraise_kj_exception
|
|
void setAsText"setAs< ::capnp::Text>"(char*) except +reraise_kj_exception
|
|
AnyPointer.Reader asReader() except +reraise_kj_exception
|
|
void set(AnyPointer.Reader) except +reraise_kj_exception
|
|
DynamicStruct_Builder initAsStruct"initAs< ::capnp::DynamicStruct>"(
|
|
StructSchema) except +reraise_kj_exception
|
|
DynamicList.Builder initAsList"initAs< ::capnp::DynamicList>"(ListSchema, uint) except +reraise_kj_exception
|
|
|
|
|
|
cdef extern from "capnp/dynamic.h" namespace " ::capnp":
|
|
cdef cppclass DynamicValue nogil:
|
|
cppclass Reader nogil:
|
|
Reader()
|
|
Reader(Void value)
|
|
Reader(cbool value)
|
|
Reader(char value)
|
|
Reader(short value)
|
|
Reader(int value)
|
|
Reader(long value)
|
|
Reader(long long value)
|
|
Reader(unsigned char value)
|
|
Reader(unsigned short value)
|
|
Reader(unsigned int value)
|
|
Reader(unsigned long value)
|
|
Reader(unsigned long long value)
|
|
Reader(float value)
|
|
Reader(double value)
|
|
Reader(char* value)
|
|
Reader(StringPtr value)
|
|
Reader(DynamicList.Reader& value)
|
|
Reader(DynamicEnum value)
|
|
Reader(DynamicStruct.Reader& value)
|
|
Reader(DynamicCapability.Client& value)
|
|
Reader(PythonInterfaceDynamicImpl& value)
|
|
Reader(AnyPointer.Reader& value)
|
|
Type getType()
|
|
int64_t asInt"as<int64_t>"()
|
|
uint64_t asUint"as<uint64_t>"()
|
|
bint asBool"as<bool>"()
|
|
double asDouble"as<double>"()
|
|
StringPtr asText"as< ::capnp::Text>"()
|
|
DynamicList.Reader asList"as< ::capnp::DynamicList>"()
|
|
DynamicStruct.Reader asStruct"as< ::capnp::DynamicStruct>"()
|
|
AnyPointer.Reader asObject"as< ::capnp::AnyPointer>"()
|
|
DynamicCapability.Client asCapability"as< ::capnp::DynamicCapability>"()
|
|
DynamicEnum asEnum"as< ::capnp::DynamicEnum>"()
|
|
Data.Reader asData"as< ::capnp::Data>"()
|
|
|
|
cppclass Builder nogil:
|
|
Type getType()
|
|
int64_t asInt"as<int64_t>"()
|
|
uint64_t asUint"as<uint64_t>"()
|
|
bint asBool"as<bool>"()
|
|
double asDouble"as<double>"()
|
|
StringPtr asText"as< ::capnp::Text>"()
|
|
DynamicList.Builder asList"as< ::capnp::DynamicList>"()
|
|
DynamicStruct_Builder asStruct"as< ::capnp::DynamicStruct>"()
|
|
AnyPointer.Builder asObject"as< ::capnp::AnyPointer>"()
|
|
DynamicCapability.Client asCapability"as< ::capnp::DynamicCapability>"()
|
|
DynamicEnum asEnum"as< ::capnp::DynamicEnum>"()
|
|
Data.Builder asData"as< ::capnp::Data>"()
|
|
|
|
cppclass Pipeline nogil:
|
|
Pipeline(Pipeline)
|
|
DynamicCapability.Client asCapability"releaseAs< ::capnp::DynamicCapability>"()
|
|
DynamicStruct.Pipeline asStruct"releaseAs< ::capnp::DynamicStruct>"()
|
|
Type getType()
|
|
|
|
cdef extern from "capnp/schema-parser.h" namespace " ::capnp":
|
|
cdef cppclass ParsedSchema(Schema) nogil:
|
|
ParsedSchema getNested(char * name) except +reraise_kj_exception
|
|
cdef cppclass SchemaParser nogil:
|
|
SchemaParser()
|
|
ParsedSchema parseDiskFile(char * displayName, char * diskPath, ArrayPtr[StringPtr] importPath)
|
|
|
|
cdef extern from "capnp/orphan.h" namespace " ::capnp":
|
|
cdef cppclass DynamicOrphan" ::capnp::Orphan< ::capnp::DynamicValue>" nogil:
|
|
DynamicValue.Builder get()
|
|
DynamicValue.Reader getReader()
|
|
|
|
cdef extern from "capnp/capability.h" namespace " ::capnp":
|
|
cdef cppclass CallContext' ::capnp::CallContext< ::capnp::DynamicStruct, ::capnp::DynamicStruct>' nogil:
|
|
CallContext(CallContext&)
|
|
DynamicStruct.Reader getParams() except +reraise_kj_exception
|
|
void releaseParams() except +reraise_kj_exception
|
|
|
|
DynamicStruct_Builder getResults()
|
|
DynamicStruct_Builder initResults()
|
|
void setResults(DynamicStruct.Reader value)
|
|
# void adoptResults(Orphan<Results>&& value);
|
|
# Orphanage getResultsOrphanage(uint firstSegmentWordSize = 0);
|
|
VoidPromise tailCall(Request & tailRequest)
|
|
void allowCancellation() except +reraise_kj_exception
|
|
|
|
cdef extern from "kj/async.h" namespace " ::kj":
|
|
cdef cppclass EventPort:
|
|
bool wait() except* with gil
|
|
bool poll() except* with gil
|
|
void setRunnable(bool runnable) except* with gil
|
|
cdef cppclass EventLoop nogil:
|
|
EventLoop()
|
|
EventLoop(EventPort &)
|
|
void run()
|
|
cdef cppclass WaitScope nogil:
|
|
WaitScope(EventLoop &)
|
|
void poll()
|
|
cdef cppclass PromiseFulfiller[T] nogil:
|
|
void fulfill(T&& value)
|
|
void reject(Exception&& exception)
|
|
cdef cppclass VoidPromiseFulfiller"::kj::PromiseFulfiller<void>" nogil:
|
|
void fulfill()
|
|
void reject(Exception&& exception)
|
|
cdef cppclass PromiseFulfillerPair" ::kj::PromiseFulfillerPair<void>" nogil:
|
|
VoidPromise promise
|
|
Own[VoidPromiseFulfiller] fulfiller
|
|
PromiseFulfillerPair newPromiseAndFulfiller" ::kj::newPromiseAndFulfiller<void>"() nogil
|
|
PyPromiseArray joinPromises(Array[PyPromise]) nogil
|
|
|
|
cdef extern from "capnp/helpers/capabilityHelper.h":
|
|
cdef cppclass PyAsyncIoStream(AsyncIoStream):
|
|
PyAsyncIoStream(PyObject* thisptr)
|
|
void rejectDisconnected[T](PromiseFulfiller[T]& fulfiller, StringPtr message)
|
|
void rejectVoidDisconnected(VoidPromiseFulfiller& fulfiller, StringPtr message)
|