Minimal pycapnp
This commit is contained in:
@@ -1,61 +1,17 @@
|
||||
"""A python library wrapping the Cap'n Proto C++ library
|
||||
|
||||
Example Usage::
|
||||
|
||||
import capnp
|
||||
|
||||
addressbook = capnp.load('addressbook.capnp')
|
||||
|
||||
# Building
|
||||
addresses = addressbook.AddressBook.newMessage()
|
||||
people = addresses.init('people', 1)
|
||||
|
||||
alice = people[0]
|
||||
alice.id = 123
|
||||
alice.name = 'Alice'
|
||||
alice.email = 'alice@example.com'
|
||||
alicePhone = alice.init('phones', 1)[0]
|
||||
alicePhone.type = 'mobile'
|
||||
|
||||
f = open('example.bin', 'w')
|
||||
addresses.write(f)
|
||||
f.close()
|
||||
|
||||
# Reading
|
||||
f = open('example.bin')
|
||||
|
||||
addresses = addressbook.AddressBook.read(f)
|
||||
|
||||
for person in addresses.people:
|
||||
print(person.name, ':', person.email)
|
||||
for phone in person.phones:
|
||||
print(phone.type, ':', phone.number)
|
||||
"""
|
||||
"""Dynamic Cap'n Proto serialization for openpilot."""
|
||||
|
||||
from .version import version as __version__
|
||||
from .lib.capnp import *
|
||||
from .lib.capnp import (
|
||||
_CapabilityClient,
|
||||
_DynamicCapabilityClient,
|
||||
_DynamicEnum,
|
||||
_DynamicListBuilder,
|
||||
_DynamicListReader,
|
||||
_DynamicOrphan,
|
||||
_DynamicResizableListBuilder,
|
||||
_DynamicStructBuilder,
|
||||
_DynamicStructReader,
|
||||
_EventLoop,
|
||||
_InterfaceModule,
|
||||
_ListSchema,
|
||||
_MallocMessageBuilder,
|
||||
_PyCustomMessageBuilder,
|
||||
_PackedFdMessageReader,
|
||||
_StreamFdMessageReader,
|
||||
_StructModule,
|
||||
_write_message_to_fd,
|
||||
_write_packed_message_to_fd,
|
||||
_AsyncIoStream as AsyncIoStream,
|
||||
_init_capnp_api,
|
||||
)
|
||||
|
||||
_init_capnp_api()
|
||||
add_import_hook() # enable import hook by default
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
from jinja2 import Environment, PackageLoader
|
||||
|
||||
import capnp
|
||||
import schema_capnp
|
||||
|
||||
|
||||
def find_type(code, id):
|
||||
for node in code["nodes"]:
|
||||
if node["id"] == id:
|
||||
return node
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def main():
|
||||
env = Environment(loader=PackageLoader("capnp", "templates"))
|
||||
env.filters["format_name"] = lambda name: name[name.find(":") + 1 :]
|
||||
|
||||
code = schema_capnp.CodeGeneratorRequest.read(sys.stdin)
|
||||
code = code.to_dict()
|
||||
code["nodes"] = [node for node in code["nodes"] if "struct" in node and node["scopeId"] != 0]
|
||||
for node in code["nodes"]:
|
||||
displayName = node["displayName"]
|
||||
parent, path = displayName.split(":")
|
||||
node["module_path"] = parent.replace(".", "_") + "." + ".".join([x[0].upper() + x[1:] for x in path.split(".")])
|
||||
node["module_name"] = path.replace(".", "_")
|
||||
node["c_module_path"] = "::".join([x[0].upper() + x[1:] for x in path.split(".")])
|
||||
node["schema"] = "_{}_Schema".format(node["module_name"])
|
||||
is_union = False
|
||||
for field in node["struct"]["fields"]:
|
||||
if field["discriminantValue"] != 65535:
|
||||
is_union = True
|
||||
field["c_name"] = field["name"][0].upper() + field["name"][1:]
|
||||
if "slot" in field:
|
||||
field["type"] = list(field["slot"]["type"].keys())[0]
|
||||
if not isinstance(field["slot"]["type"][field["type"]], dict):
|
||||
continue
|
||||
sub_type = field["slot"]["type"][field["type"]].get("typeId", None)
|
||||
if sub_type:
|
||||
field["sub_type"] = find_type(code, sub_type)
|
||||
sub_type = field["slot"]["type"][field["type"]].get("elementType", None)
|
||||
if sub_type:
|
||||
field["sub_type"] = sub_type
|
||||
else:
|
||||
field["type"] = find_type(code, field["group"]["typeId"])
|
||||
node["is_union"] = is_union
|
||||
|
||||
include_dir = os.path.abspath(os.path.join(os.path.dirname(capnp.__file__), ".."))
|
||||
module = env.get_template("module.pyx")
|
||||
|
||||
for f in code["requestedFiles"]:
|
||||
filename = f["filename"].replace(".", "_") + "_cython.pyx"
|
||||
|
||||
file_code = dict(code)
|
||||
file_code["nodes"] = [node for node in file_code["nodes"] if node["displayName"].startswith(f["filename"])]
|
||||
with open(filename, "w") as out:
|
||||
out.write(module.render(code=file_code, file=f, include_dir=include_dir))
|
||||
|
||||
setup = env.get_template("setup.py.tmpl")
|
||||
with open("setup_capnp.py", "w") as out:
|
||||
out.write(setup.render(code=code))
|
||||
print("You now need to build the cython module by running `python setup_capnp.py build_ext --inplace`.")
|
||||
print()
|
||||
@@ -1,199 +0,0 @@
|
||||
#include "capnp/helpers/capabilityHelper.h"
|
||||
#include "capnp/lib/capnp_api.h"
|
||||
|
||||
::kj::Promise<kj::Own<PyRefCounter>> convert_to_pypromise(capnp::RemotePromise<capnp::DynamicStruct> promise) {
|
||||
return promise.then([](capnp::Response<capnp::DynamicStruct>&& response) {
|
||||
return stealPyRef(wrap_dynamic_struct_reader(response)); } );
|
||||
}
|
||||
|
||||
void c_reraise_kj_exception() {
|
||||
GILAcquire gil;
|
||||
try {
|
||||
if (PyErr_Occurred())
|
||||
; // let the latest Python exn pass through and ignore the current one
|
||||
else
|
||||
throw;
|
||||
}
|
||||
catch (kj::Exception& exn) {
|
||||
auto obj = wrap_kj_exception_for_reraise(exn);
|
||||
if (obj == nullptr) {
|
||||
return;
|
||||
}
|
||||
PyErr_SetObject((PyObject*)obj->ob_type, obj);
|
||||
Py_DECREF(obj);
|
||||
}
|
||||
catch (const std::exception& exn) {
|
||||
PyErr_SetString(PyExc_RuntimeError, exn.what());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
PyErr_SetString(PyExc_RuntimeError, "Unknown exception");
|
||||
}
|
||||
}
|
||||
|
||||
void check_py_error() {
|
||||
GILAcquire gil;
|
||||
PyObject * err = PyErr_Occurred();
|
||||
if(err) {
|
||||
PyObject * ptype, *pvalue, *ptraceback;
|
||||
PyErr_Fetch(&ptype, &pvalue, &ptraceback);
|
||||
if(ptype == NULL || pvalue == NULL || ptraceback == NULL)
|
||||
throw kj::Exception(kj::Exception::Type::FAILED, kj::heapString("capabilityHelper.h"), 44, kj::heapString("Unknown error occurred"));
|
||||
|
||||
PyObject * info = get_exception_info(ptype, pvalue, ptraceback);
|
||||
|
||||
PyObject * py_filename = PyTuple_GetItem(info, 0);
|
||||
kj::String filename(kj::heapString(PyBytes_AsString(py_filename)));
|
||||
|
||||
PyObject * py_line = PyTuple_GetItem(info, 1);
|
||||
int line = PyLong_AsLong(py_line);
|
||||
|
||||
PyObject * py_description = PyTuple_GetItem(info, 2);
|
||||
kj::String description(kj::heapString(PyBytes_AsString(py_description)));
|
||||
|
||||
Py_DECREF(ptype);
|
||||
Py_DECREF(pvalue);
|
||||
Py_DECREF(ptraceback);
|
||||
Py_DECREF(info);
|
||||
PyErr_Clear();
|
||||
|
||||
throw kj::Exception(kj::Exception::Type::FAILED, kj::mv(filename), line, kj::mv(description));
|
||||
}
|
||||
}
|
||||
|
||||
kj::Promise<kj::Own<PyRefCounter>> wrapPyFunc(kj::Own<PyRefCounter> func, kj::Own<PyRefCounter> arg) {
|
||||
GILAcquire gil;
|
||||
PyObject * result = PyObject_CallFunctionObjArgs(func->obj, arg->obj, NULL);
|
||||
check_py_error();
|
||||
return stealPyRef(result);
|
||||
}
|
||||
|
||||
::kj::Promise<kj::Own<PyRefCounter>> then(kj::Promise<kj::Own<PyRefCounter>> promise,
|
||||
kj::Own<PyRefCounter> func, kj::Own<PyRefCounter> error_func) {
|
||||
if(error_func->obj == Py_None)
|
||||
return promise.then([func=kj::mv(func)](kj::Own<PyRefCounter> arg) mutable {
|
||||
return wrapPyFunc(kj::mv(func), kj::mv(arg)); } );
|
||||
else
|
||||
return promise.then
|
||||
([func=kj::mv(func)](kj::Own<PyRefCounter> arg) mutable {
|
||||
return wrapPyFunc(kj::mv(func), kj::mv(arg)); },
|
||||
[error_func=kj::mv(error_func)](kj::Exception arg) mutable {
|
||||
return wrapPyFunc(kj::mv(error_func), stealPyRef(wrap_kj_exception(arg))); } );
|
||||
}
|
||||
|
||||
kj::Promise<void> PythonInterfaceDynamicImpl::call(capnp::InterfaceSchema::Method method,
|
||||
capnp::CallContext< capnp::DynamicStruct,
|
||||
capnp::DynamicStruct> context) {
|
||||
auto methodName = method.getProto().getName();
|
||||
|
||||
kj::Promise<void> * promise = call_server_method(this->py_server->obj,
|
||||
const_cast<char *>(methodName.cStr()),
|
||||
context,
|
||||
this->kj_loop->obj);
|
||||
|
||||
check_py_error();
|
||||
|
||||
if(promise == nullptr)
|
||||
return kj::READY_NOW;
|
||||
|
||||
kj::Promise<void> ret(kj::mv(*promise));
|
||||
delete promise;
|
||||
return ret;
|
||||
};
|
||||
|
||||
|
||||
class ReadPromiseAdapter {
|
||||
public:
|
||||
ReadPromiseAdapter(kj::PromiseFulfiller<size_t>& fulfiller, PyObject* protocol,
|
||||
void* buffer, size_t minBytes, size_t maxBytes)
|
||||
: protocol(protocol) {
|
||||
_asyncio_stream_read_start(protocol, buffer, minBytes, maxBytes, fulfiller);
|
||||
}
|
||||
|
||||
~ReadPromiseAdapter() {
|
||||
_asyncio_stream_read_stop(protocol);
|
||||
}
|
||||
|
||||
private:
|
||||
PyObject* protocol;
|
||||
};
|
||||
|
||||
|
||||
class WritePromiseAdapter {
|
||||
public:
|
||||
WritePromiseAdapter(kj::PromiseFulfiller<void>& fulfiller, PyObject* protocol,
|
||||
kj::ArrayPtr<const kj::ArrayPtr<const kj::byte>> pieces)
|
||||
: protocol(protocol) {
|
||||
_asyncio_stream_write_start(protocol, pieces, fulfiller);
|
||||
}
|
||||
|
||||
~WritePromiseAdapter() {
|
||||
_asyncio_stream_write_stop(protocol);
|
||||
}
|
||||
|
||||
private:
|
||||
PyObject* protocol;
|
||||
|
||||
};
|
||||
|
||||
PyAsyncIoStream::~PyAsyncIoStream() {
|
||||
_asyncio_stream_close(protocol->obj);
|
||||
}
|
||||
|
||||
kj::Promise<size_t> PyAsyncIoStream::tryRead(void* buffer, size_t minBytes, size_t maxBytes) {
|
||||
return kj::newAdaptedPromise<size_t, ReadPromiseAdapter>(protocol->obj, buffer, minBytes, maxBytes);
|
||||
}
|
||||
|
||||
kj::Promise<void> PyAsyncIoStream::write(const void* buffer, size_t size) {
|
||||
KJ_UNIMPLEMENTED("No use-case AsyncIoStream::write was found yet.");
|
||||
}
|
||||
|
||||
kj::Promise<void> PyAsyncIoStream::write(kj::ArrayPtr<const kj::ArrayPtr<const kj::byte>> pieces) {
|
||||
return kj::newAdaptedPromise<void, WritePromiseAdapter>(protocol->obj, pieces);
|
||||
}
|
||||
|
||||
kj::Promise<void> PyAsyncIoStream::whenWriteDisconnected() {
|
||||
// TODO: Possibly connect this to protocol.connection_lost?
|
||||
return kj::NEVER_DONE;
|
||||
}
|
||||
|
||||
void PyAsyncIoStream::shutdownWrite() {
|
||||
_asyncio_stream_shutdown_write(protocol->obj);
|
||||
}
|
||||
|
||||
class TaskToPromiseAdapter {
|
||||
public:
|
||||
TaskToPromiseAdapter(kj::PromiseFulfiller<void>& fulfiller,
|
||||
kj::Own<PyRefCounter> task, PyObject* callback)
|
||||
: task(kj::mv(task)) {
|
||||
promise_task_add_done_callback(this->task->obj, callback, fulfiller);
|
||||
}
|
||||
|
||||
~TaskToPromiseAdapter() {
|
||||
promise_task_cancel(this->task->obj);
|
||||
}
|
||||
|
||||
private:
|
||||
kj::Own<PyRefCounter> task;
|
||||
};
|
||||
|
||||
kj::Promise<void> taskToPromise(kj::Own<PyRefCounter> task, PyObject* callback) {
|
||||
return kj::newAdaptedPromise<void, TaskToPromiseAdapter>(kj::mv(task), callback);
|
||||
}
|
||||
|
||||
::kj::Promise<kj::Own<PyRefCounter>> tryReadMessage(kj::AsyncIoStream& stream, capnp::ReaderOptions opts) {
|
||||
return capnp::tryReadMessage(stream, opts)
|
||||
.then([](kj::Maybe<kj::Own<capnp::MessageReader>> maybeReader) -> kj::Promise<kj::Own<PyRefCounter>> {
|
||||
KJ_IF_MAYBE(reader, maybeReader) {
|
||||
PyObject* pyreader = make_async_message_reader(kj::mv(*reader));
|
||||
check_py_error();
|
||||
return kj::heap<PyRefCounter>(pyreader);
|
||||
} else {
|
||||
return kj::heap<PyRefCounter>(Py_None);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void init_capnp_api() {
|
||||
import_capnp__lib__capnp();
|
||||
}
|
||||
@@ -1,139 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "capnp/dynamic.h"
|
||||
#include <kj/async-io.h>
|
||||
#include <capnp/serialize-async.h>
|
||||
#include <stdexcept>
|
||||
#include "Python.h"
|
||||
|
||||
class GILAcquire {
|
||||
public:
|
||||
GILAcquire() : gstate(PyGILState_Ensure()) {}
|
||||
~GILAcquire() {
|
||||
PyGILState_Release(gstate);
|
||||
}
|
||||
|
||||
PyGILState_STATE gstate;
|
||||
};
|
||||
|
||||
class GILRelease {
|
||||
public:
|
||||
GILRelease() {
|
||||
Py_UNBLOCK_THREADS
|
||||
}
|
||||
~GILRelease() {
|
||||
Py_BLOCK_THREADS
|
||||
}
|
||||
|
||||
PyThreadState *_save; // The macros above read/write from this variable
|
||||
};
|
||||
|
||||
class PyRefCounter {
|
||||
public:
|
||||
PyObject * obj;
|
||||
|
||||
PyRefCounter(PyObject * o) : obj(o) {
|
||||
GILAcquire gil;
|
||||
Py_INCREF(obj);
|
||||
}
|
||||
|
||||
PyRefCounter(const PyRefCounter & ref) : obj(ref.obj) {
|
||||
GILAcquire gil;
|
||||
Py_INCREF(obj);
|
||||
}
|
||||
|
||||
~PyRefCounter() {
|
||||
GILAcquire gil;
|
||||
Py_DECREF(obj);
|
||||
}
|
||||
};
|
||||
|
||||
inline kj::Own<PyRefCounter> stealPyRef(PyObject* o) {
|
||||
auto ret = kj::heap<PyRefCounter>(o);
|
||||
Py_DECREF(o);
|
||||
return ret;
|
||||
}
|
||||
|
||||
::kj::Promise<kj::Own<PyRefCounter>> convert_to_pypromise(capnp::RemotePromise<capnp::DynamicStruct> promise);
|
||||
|
||||
inline ::kj::Promise<kj::Own<PyRefCounter>> convert_to_pypromise(kj::Promise<void> promise) {
|
||||
return promise.then([]() {
|
||||
GILAcquire gil;
|
||||
return kj::heap<PyRefCounter>(Py_None);
|
||||
});
|
||||
}
|
||||
|
||||
void c_reraise_kj_exception();
|
||||
|
||||
void check_py_error();
|
||||
|
||||
::kj::Promise<kj::Own<PyRefCounter>> then(kj::Promise<kj::Own<PyRefCounter>> promise,
|
||||
kj::Own<PyRefCounter> func, kj::Own<PyRefCounter> error_func);
|
||||
|
||||
class PythonInterfaceDynamicImpl final: public capnp::DynamicCapability::Server {
|
||||
public:
|
||||
kj::Own<PyRefCounter> py_server;
|
||||
kj::Own<PyRefCounter> kj_loop;
|
||||
|
||||
#if (CAPNP_VERSION_MAJOR < 1)
|
||||
PythonInterfaceDynamicImpl(capnp::InterfaceSchema & schema,
|
||||
kj::Own<PyRefCounter> _py_server,
|
||||
kj::Own<PyRefCounter> kj_loop)
|
||||
: capnp::DynamicCapability::Server(schema),
|
||||
py_server(kj::mv(_py_server)), kj_loop(kj::mv(kj_loop)) { }
|
||||
#else
|
||||
PythonInterfaceDynamicImpl(capnp::InterfaceSchema & schema,
|
||||
kj::Own<PyRefCounter> _py_server,
|
||||
kj::Own<PyRefCounter> kj_loop)
|
||||
: capnp::DynamicCapability::Server(schema, { true }),
|
||||
py_server(kj::mv(_py_server)), kj_loop(kj::mv(kj_loop)) { }
|
||||
#endif
|
||||
|
||||
~PythonInterfaceDynamicImpl() {
|
||||
}
|
||||
|
||||
kj::Promise<void> call(capnp::InterfaceSchema::Method method,
|
||||
capnp::CallContext< capnp::DynamicStruct, capnp::DynamicStruct> context);
|
||||
};
|
||||
|
||||
inline void allowCancellation(capnp::CallContext<capnp::DynamicStruct, capnp::DynamicStruct> context) {
|
||||
#if (CAPNP_VERSION_MAJOR < 1)
|
||||
context.allowCancellation();
|
||||
#endif
|
||||
}
|
||||
|
||||
class PyAsyncIoStream: public kj::AsyncIoStream {
|
||||
public:
|
||||
kj::Own<PyRefCounter> protocol;
|
||||
|
||||
PyAsyncIoStream(kj::Own<PyRefCounter> protocol) : protocol(kj::mv(protocol)) {}
|
||||
~PyAsyncIoStream();
|
||||
|
||||
kj::Promise<size_t> tryRead(void* buffer, size_t minBytes, size_t maxBytes);
|
||||
|
||||
kj::Promise<void> write(const void* buffer, size_t size);
|
||||
|
||||
kj::Promise<void> write(kj::ArrayPtr<const kj::ArrayPtr<const kj::byte>> pieces);
|
||||
|
||||
kj::Promise<void> whenWriteDisconnected();
|
||||
|
||||
void shutdownWrite();
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
inline void rejectDisconnected(kj::PromiseFulfiller<T>& fulfiller, kj::StringPtr message) {
|
||||
fulfiller.reject(KJ_EXCEPTION(DISCONNECTED, message));
|
||||
}
|
||||
inline void rejectVoidDisconnected(kj::PromiseFulfiller<void>& fulfiller, kj::StringPtr message) {
|
||||
fulfiller.reject(KJ_EXCEPTION(DISCONNECTED, message));
|
||||
}
|
||||
|
||||
inline kj::Exception makeException(kj::StringPtr message) {
|
||||
return KJ_EXCEPTION(FAILED, message);
|
||||
}
|
||||
|
||||
kj::Promise<void> taskToPromise(kj::Own<PyRefCounter> coroutine, PyObject* callback);
|
||||
|
||||
::kj::Promise<kj::Own<PyRefCounter>> tryReadMessage(kj::AsyncIoStream& stream, capnp::ReaderOptions opts);
|
||||
|
||||
void init_capnp_api();
|
||||
@@ -1,8 +1,3 @@
|
||||
#ifdef _MSC_VER
|
||||
#pragma comment(lib, "Ws2_32.lib")
|
||||
#pragma comment(lib, "advapi32.lib")
|
||||
#endif
|
||||
|
||||
#include "capnp/dynamic.h"
|
||||
|
||||
static_assert(CAPNP_VERSION >= 8000, "Version of Cap'n Proto C++ Library is too old. Please upgrade to a version >= 0.8 and then re-install this python library");
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "capnp/dynamic.h"
|
||||
#include "capnp/schema.capnp.h"
|
||||
|
||||
/// @brief Convert the dynamic struct to a Node::Reader
|
||||
::capnp::schema::Node::Reader toReader(capnp::DynamicStruct::Reader reader)
|
||||
{
|
||||
// requires an intermediate step to AnyStruct before going directly to Node::Reader,
|
||||
// since there exists no direct conversion from DynamicStruct::Reader to Node::Reader.
|
||||
return reader.as<capnp::AnyStruct>().as<capnp::schema::Node>();
|
||||
}
|
||||
31
capnp/helpers/exception.cpp
Normal file
31
capnp/helpers/exception.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#include "capnp/helpers/exception.h"
|
||||
#include "capnp/lib/capnp_api.h"
|
||||
|
||||
void c_reraise_kj_exception() {
|
||||
GILAcquire gil;
|
||||
try {
|
||||
if (PyErr_Occurred())
|
||||
; // let the latest Python exn pass through and ignore the current one
|
||||
else
|
||||
throw;
|
||||
}
|
||||
catch (kj::Exception& exn) {
|
||||
auto obj = wrap_kj_exception_for_reraise(exn);
|
||||
if (obj == nullptr) {
|
||||
return;
|
||||
}
|
||||
PyErr_SetObject((PyObject*)obj->ob_type, obj);
|
||||
Py_DECREF(obj);
|
||||
}
|
||||
catch (const std::exception& exn) {
|
||||
PyErr_SetString(PyExc_RuntimeError, exn.what());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
PyErr_SetString(PyExc_RuntimeError, "Unknown exception");
|
||||
}
|
||||
}
|
||||
|
||||
void init_capnp_api() {
|
||||
import_capnp__lib__capnp();
|
||||
}
|
||||
18
capnp/helpers/exception.h
Normal file
18
capnp/helpers/exception.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include <Python.h>
|
||||
#include <kj/exception.h>
|
||||
#include <stdexcept>
|
||||
|
||||
class GILAcquire {
|
||||
public:
|
||||
GILAcquire() : gstate(PyGILState_Ensure()) {}
|
||||
~GILAcquire() {
|
||||
PyGILState_Release(gstate);
|
||||
}
|
||||
|
||||
PyGILState_STATE gstate;
|
||||
};
|
||||
|
||||
void c_reraise_kj_exception();
|
||||
void init_capnp_api();
|
||||
@@ -1,34 +1,9 @@
|
||||
from capnp.includes.capnp_cpp cimport (
|
||||
Maybe, PyPromise, VoidPromise, RemotePromise,
|
||||
DynamicCapability, InterfaceSchema, EnumSchema, StructSchema, DynamicValue, Capability,
|
||||
RpcSystem, MessageBuilder, Own, PyRefCounter, Node, DynamicStruct, CallContext
|
||||
)
|
||||
|
||||
from capnp.includes.schema_cpp cimport ByteArray
|
||||
|
||||
from capnp.includes.capnp_cpp cimport Maybe, EnumSchema, StructSchema
|
||||
from non_circular cimport c_reraise_kj_exception as reraise_kj_exception
|
||||
|
||||
from cpython.ref cimport PyObject
|
||||
|
||||
cdef extern from "capnp/helpers/fixMaybe.h":
|
||||
EnumSchema.Enumerant fixMaybe(Maybe[EnumSchema.Enumerant]) except +reraise_kj_exception
|
||||
StructSchema.Field fixMaybe(Maybe[StructSchema.Field]) except +reraise_kj_exception
|
||||
|
||||
cdef extern from "capnp/helpers/capabilityHelper.h":
|
||||
PyPromise then(PyPromise promise, Own[PyRefCounter] func, Own[PyRefCounter] error_func)
|
||||
PyPromise convert_to_pypromise(RemotePromise)
|
||||
PyPromise convert_to_pypromise(VoidPromise)
|
||||
VoidPromise taskToPromise(Own[PyRefCounter] coroutine, PyObject* callback)
|
||||
void allowCancellation(CallContext context) except +reraise_kj_exception nogil
|
||||
cdef extern from "capnp/helpers/exception.h":
|
||||
void init_capnp_api()
|
||||
|
||||
cdef extern from "capnp/helpers/rpcHelper.h":
|
||||
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) except +reraise_kj_exception
|
||||
|
||||
cdef extern from "capnp/helpers/deserialize.h":
|
||||
Node.Reader toReader(DynamicStruct.Reader reader) except +reraise_kj_exception
|
||||
|
||||
|
||||
@@ -1,8 +1,2 @@
|
||||
from cpython.ref cimport PyObject
|
||||
from libcpp cimport bool
|
||||
|
||||
cdef extern from "capnp/helpers/capabilityHelper.h":
|
||||
cdef extern from "capnp/helpers/exception.h":
|
||||
void c_reraise_kj_exception()
|
||||
cdef cppclass PyRefCounter:
|
||||
PyRefCounter(PyObject *)
|
||||
PyObject * obj
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "capnp/dynamic.h"
|
||||
#include <capnp/rpc.capnp.h>
|
||||
#include "capnp/rpc-twoparty.h"
|
||||
#include "Python.h"
|
||||
#include "capabilityHelper.h"
|
||||
|
||||
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 kj::heap<capnp::Capability::Client>(client.bootstrap(hostId));
|
||||
}
|
||||
|
||||
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 kj::heap<capnp::Capability::Client>(client.bootstrap(hostId));
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "kj/io.h"
|
||||
#include "capnp/dynamic.h"
|
||||
#include "capnp/serialize-packed.h"
|
||||
|
||||
kj::Array< ::capnp::byte> messageToPackedBytes(capnp::MessageBuilder & message, size_t wordCount)
|
||||
{
|
||||
|
||||
kj::Array<capnp::byte> result = kj::heapArray<capnp::byte>(wordCount * 8);
|
||||
kj::ArrayOutputStream out(result.asPtr());
|
||||
capnp::writePackedMessage(out, message);
|
||||
return heapArray(out.getArray()); // TODO: make this non-copying somehow
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
#include "PyCustomMessageBuilder.h"
|
||||
#include <stdexcept>
|
||||
|
||||
namespace capnp {
|
||||
|
||||
PyCustomMessageBuilder::PyCustomMessageBuilder(
|
||||
PyObject* allocateSegmentCallable, uint firstSegmentWords)
|
||||
: allocateSegmentCallable(allocateSegmentCallable), firstSize(firstSegmentWords)
|
||||
{
|
||||
KJ_REQUIRE(PyCallable_Check(allocateSegmentCallable),
|
||||
"allocateSegmentCallable must be callable");
|
||||
Py_INCREF(allocateSegmentCallable);
|
||||
}
|
||||
|
||||
PyCustomMessageBuilder::~PyCustomMessageBuilder() noexcept(false) {
|
||||
PyGILState_STATE gstate = PyGILState_Ensure();
|
||||
|
||||
for (auto* obj : allocatedBuffers) {
|
||||
Py_DECREF(obj);
|
||||
}
|
||||
allocatedBuffers.clear();
|
||||
|
||||
Py_DECREF(allocateSegmentCallable);
|
||||
PyGILState_Release(gstate);
|
||||
}
|
||||
|
||||
kj::ArrayPtr<capnp::word> PyCustomMessageBuilder::allocateSegment(capnp::uint minimumSize) {
|
||||
PyGILState_STATE gstate = PyGILState_Ensure();
|
||||
KJ_DEFER({ PyGILState_Release(gstate); });
|
||||
if (curSize == 0) {
|
||||
minimumSize = kj::max(minimumSize, firstSize);
|
||||
}
|
||||
PyObject* pyBufObj = PyObject_CallFunction(allocateSegmentCallable, "I", minimumSize);
|
||||
KJ_REQUIRE(pyBufObj, "PyCustomMessageBuilder: allocateSegment failed");
|
||||
allocatedBuffers.push_back(pyBufObj);
|
||||
|
||||
|
||||
Py_buffer view;
|
||||
int bufRes = PyObject_GetBuffer(pyBufObj, &view, PyBUF_SIMPLE);
|
||||
KJ_REQUIRE(bufRes == 0, "PyCustomMessageBuilder: object does not support buffer protocol");
|
||||
KJ_DEFER({ PyBuffer_Release(&view); });
|
||||
|
||||
size_t byteCount = view.len;
|
||||
size_t wordCount = byteCount / sizeof(capnp::word);
|
||||
KJ_REQUIRE(wordCount >= minimumSize, "PyCustomMessageBuilder: buffer too small for minimumSize");
|
||||
curSize += wordCount;
|
||||
return kj::arrayPtr(reinterpret_cast<capnp::word*>(view.buf), wordCount);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Python.h"
|
||||
#include <capnp/message.h>
|
||||
#include <capnp/serialize.h>
|
||||
#include <vector>
|
||||
|
||||
namespace capnp {
|
||||
|
||||
class PyCustomMessageBuilder : public capnp::MessageBuilder {
|
||||
public:
|
||||
explicit PyCustomMessageBuilder(PyObject* allocateSegmentCallable,
|
||||
uint firstSegmentWords = capnp::SUGGESTED_FIRST_SEGMENT_WORDS);
|
||||
|
||||
~PyCustomMessageBuilder() noexcept(false) override;
|
||||
|
||||
kj::ArrayPtr<capnp::word> allocateSegment(capnp::uint minimumSize) override;
|
||||
|
||||
private:
|
||||
PyObject* allocateSegmentCallable;
|
||||
|
||||
uint firstSize;
|
||||
uint curSize = 0;
|
||||
|
||||
std::vector<PyObject*> allocatedBuffers;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -3,12 +3,11 @@
|
||||
cdef extern from "capnp/helpers/checkCompiler.h":
|
||||
pass
|
||||
|
||||
from libcpp cimport bool
|
||||
from capnp.helpers.non_circular cimport (
|
||||
c_reraise_kj_exception as reraise_kj_exception, PyRefCounter,
|
||||
c_reraise_kj_exception as reraise_kj_exception,
|
||||
)
|
||||
from capnp.includes.schema_cpp cimport (
|
||||
Node, Data, StructNode, EnumNode, InterfaceNode, MessageBuilder, MessageReader, ReaderOptions,
|
||||
Node, Data, Field as SchemaField, Enumerant as SchemaEnumerant, MessageBuilder, MessageReader, ReaderOptions,
|
||||
)
|
||||
from capnp.includes.types cimport *
|
||||
|
||||
@@ -46,26 +45,6 @@ cdef extern from "kj/exception.h" namespace " ::kj":
|
||||
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](...)
|
||||
|
||||
cdef extern from "kj/async.h" namespace " ::kj":
|
||||
cdef cppclass Promise[T] nogil:
|
||||
Promise(Promise)
|
||||
Promise(T)
|
||||
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] &)
|
||||
|
||||
ctypedef Promise[Own[PyRefCounter]] PyPromise
|
||||
ctypedef Promise[void] VoidPromise
|
||||
|
||||
cdef extern from "kj/string-tree.h" namespace " ::kj":
|
||||
cdef cppclass StringTree nogil:
|
||||
String flatten()
|
||||
@@ -80,59 +59,15 @@ cdef extern from "kj/common.h" namespace " ::kj":
|
||||
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()
|
||||
|
||||
|
||||
cdef extern from "kj/async-io.h" namespace " ::kj":
|
||||
cdef cppclass AsyncIoStream nogil:
|
||||
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":
|
||||
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()
|
||||
cbool isData()
|
||||
|
||||
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:
|
||||
@@ -141,35 +76,10 @@ cdef extern from "capnp/schema.h" namespace " ::capnp":
|
||||
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()
|
||||
SchemaField.Reader getProto()
|
||||
StructSchema getContainingStruct()
|
||||
uint getIndex()
|
||||
SchemaType getType()
|
||||
@@ -192,7 +102,7 @@ cdef extern from "capnp/schema.h" namespace " ::capnp":
|
||||
|
||||
cdef cppclass EnumSchema nogil:
|
||||
cppclass Enumerant nogil:
|
||||
EnumNode.Enumerant.Reader getProto()
|
||||
SchemaEnumerant.Reader getProto()
|
||||
EnumSchema getContainingEnum()
|
||||
uint16_t getOrdinal()
|
||||
|
||||
@@ -207,11 +117,6 @@ cdef extern from "capnp/schema.h" namespace " ::capnp":
|
||||
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
|
||||
@@ -222,8 +127,6 @@ cdef extern from "capnp/dynamic.h" namespace " ::capnp":
|
||||
pass
|
||||
cppclass Builder nogil:
|
||||
pass
|
||||
cppclass Pipeline nogil:
|
||||
pass
|
||||
|
||||
enum Type:
|
||||
TYPE_UNKNOWN " ::capnp::DynamicValue::UNKNOWN"
|
||||
@@ -237,8 +140,6 @@ cdef extern from "capnp/dynamic.h" namespace " ::capnp":
|
||||
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:
|
||||
@@ -250,11 +151,6 @@ cdef extern from "capnp/dynamic.h" namespace " ::capnp":
|
||||
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
|
||||
@@ -273,63 +169,9 @@ cdef extern from "capnp/dynamic.h" namespace " ::capnp":
|
||||
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(Own[PythonInterfaceDynamicImpl])
|
||||
Client upcast(InterfaceSchema requestedSchema) except +reraise_kj_exception
|
||||
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 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()
|
||||
@@ -346,35 +188,9 @@ cdef extern from "capnp/dynamic.h" namespace " ::capnp":
|
||||
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'()
|
||||
DynamicList.Reader asReader() except +reraise_kj_exception
|
||||
|
||||
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:
|
||||
@@ -398,9 +214,6 @@ cdef extern from "capnp/dynamic.h" namespace " ::capnp":
|
||||
Reader(DynamicList.Reader& value)
|
||||
Reader(DynamicEnum value)
|
||||
Reader(DynamicStruct.Reader& value)
|
||||
Reader(DynamicCapability.Client& value)
|
||||
Reader(Own[PythonInterfaceDynamicImpl] value)
|
||||
Reader(AnyPointer.Reader& value)
|
||||
Type getType()
|
||||
int64_t asInt"as<int64_t>"()
|
||||
uint64_t asUint"as<uint64_t>"()
|
||||
@@ -409,8 +222,6 @@ cdef extern from "capnp/dynamic.h" namespace " ::capnp":
|
||||
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>"()
|
||||
|
||||
@@ -423,22 +234,9 @@ cdef extern from "capnp/dynamic.h" namespace " ::capnp":
|
||||
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-loader.h" namespace " ::capnp":
|
||||
cdef cppclass SchemaLoader nogil:
|
||||
SchemaLoader()
|
||||
Schema load(Node.Reader reader) except +reraise_kj_exception
|
||||
Schema get(uint64_t id_) except +reraise_kj_exception
|
||||
|
||||
cdef extern from "capnp/schema-parser.h" namespace " ::capnp":
|
||||
cdef cppclass ParsedSchema(Schema) nogil:
|
||||
@@ -446,53 +244,3 @@ cdef extern from "capnp/schema-parser.h" namespace " ::capnp":
|
||||
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)
|
||||
|
||||
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 extern from "capnp/helpers/capabilityHelper.h":
|
||||
cdef cppclass PyAsyncIoStream(AsyncIoStream):
|
||||
PyAsyncIoStream(Own[PyRefCounter] thisptr)
|
||||
void rejectDisconnected[T](PromiseFulfiller[T]& fulfiller, StringPtr message)
|
||||
void rejectVoidDisconnected(VoidPromiseFulfiller& fulfiller, StringPtr message)
|
||||
Exception makeException(StringPtr message)
|
||||
PyPromise tryReadMessage(AsyncIoStream& stream, ReaderOptions opts)
|
||||
cppclass PythonInterfaceDynamicImpl:
|
||||
PythonInterfaceDynamicImpl(InterfaceSchema&, Own[PyRefCounter] server, Own[PyRefCounter] kj_loop)
|
||||
|
||||
cdef extern from "capnp/serialize-async.h" namespace " ::capnp":
|
||||
VoidPromise writeMessage(AsyncIoStream& output, MessageBuilder& builder)
|
||||
|
||||
@@ -1,648 +1,71 @@
|
||||
# schema.capnp.cpp.pyx
|
||||
# distutils: language = c++
|
||||
|
||||
from libc.stdint cimport *
|
||||
from capnp.helpers.non_circular cimport c_reraise_kj_exception as reraise_kj_exception
|
||||
|
||||
from capnp.includes.types cimport *
|
||||
|
||||
cdef extern from "capnp/dynamic.h" namespace " ::capnp":
|
||||
cdef cppclass DynamicValue nogil:
|
||||
cppclass Reader nogil:
|
||||
pass
|
||||
cppclass Builder nogil:
|
||||
pass
|
||||
cdef cppclass DynamicStruct nogil:
|
||||
cppclass Reader nogil:
|
||||
pass
|
||||
|
||||
cdef cppclass DynamicStruct_Builder" ::capnp::DynamicStruct::Builder" nogil:
|
||||
cdef cppclass DynamicStruct_Builder " ::capnp::DynamicStruct::Builder" nogil:
|
||||
pass
|
||||
|
||||
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/schema.h" namespace " ::capnp":
|
||||
cdef cppclass Schema nogil:
|
||||
cdef cppclass StructSchema nogil:
|
||||
pass
|
||||
cdef cppclass StructSchema(Schema) nogil:
|
||||
pass
|
||||
|
||||
cdef extern from "capnp/any.h" namespace " ::capnp":
|
||||
cdef cppclass AnyPointer nogil:
|
||||
cppclass Reader nogil:
|
||||
pass
|
||||
cppclass Builder nogil:
|
||||
pass
|
||||
|
||||
cdef extern from "capnp/blob.h" namespace " ::capnp":
|
||||
cdef cppclass Data nogil:
|
||||
cppclass Reader nogil:
|
||||
char * begin()
|
||||
char* begin()
|
||||
size_t size()
|
||||
cppclass Builder nogil:
|
||||
char * begin()
|
||||
char* begin()
|
||||
size_t size()
|
||||
cdef cppclass Text nogil:
|
||||
cppclass Reader nogil:
|
||||
char * cStr()
|
||||
cppclass Builder nogil:
|
||||
char * cStr()
|
||||
cdef extern from "capnp/message.h" namespace " ::capnp":
|
||||
cdef cppclass List[T] nogil:
|
||||
cppclass Reader nogil:
|
||||
T operator[](uint)
|
||||
uint size()
|
||||
cppclass Builder nogil:
|
||||
T operator[](uint)
|
||||
uint size()
|
||||
char* cStr()
|
||||
|
||||
cdef extern from "capnp/schema.capnp.h" namespace " ::capnp::schema":
|
||||
enum:
|
||||
_ElementSize_inlineComposite " ::capnp::schema::ElementSize::INLINE_COMPOSITE"
|
||||
_ElementSize_eightBytes " ::capnp::schema::ElementSize::EIGHT_BYTES"
|
||||
_ElementSize_pointer " ::capnp::schema::ElementSize::POINTER"
|
||||
_ElementSize_bit " ::capnp::schema::ElementSize::BIT"
|
||||
_ElementSize_twoBytes " ::capnp::schema::ElementSize::TWO_BYTES"
|
||||
_ElementSize_fourBytes " ::capnp::schema::ElementSize::FOUR_BYTES"
|
||||
_ElementSize_byte " ::capnp::schema::ElementSize::BYTE"
|
||||
_ElementSize_empty " ::capnp::schema::ElementSize::EMPTY"
|
||||
enum _Value_Body_Which:
|
||||
_Value_Body_uint32Value " ::capnp::schema::Value::Body::Which::UINT32_VALUE"
|
||||
_Value_Body_float64Value " ::capnp::schema::Value::Body::Which::FLOAT64_VALUE"
|
||||
_Value_Body_voidValue " ::capnp::schema::Value::Body::Which::VOID_VALUE"
|
||||
_Value_Body_dataValue " ::capnp::schema::Value::Body::Which::DATA_VALUE"
|
||||
_Value_Body_listValue " ::capnp::schema::Value::Body::Which::LIST_VALUE"
|
||||
_Value_Body_int32Value " ::capnp::schema::Value::Body::Which::INT32_VALUE"
|
||||
_Value_Body_enumValue " ::capnp::schema::Value::Body::Which::ENUM_VALUE"
|
||||
_Value_Body_int8Value " ::capnp::schema::Value::Body::Which::INT8_VALUE"
|
||||
_Value_Body_boolValue " ::capnp::schema::Value::Body::Which::BOOL_VALUE"
|
||||
_Value_Body_int16Value " ::capnp::schema::Value::Body::Which::INT16_VALUE"
|
||||
_Value_Body_float32Value " ::capnp::schema::Value::Body::Which::FLOAT32_VALUE"
|
||||
_Value_Body_interfaceValue " ::capnp::schema::Value::Body::Which::INTERFACE_VALUE"
|
||||
_Value_Body_uint16Value " ::capnp::schema::Value::Body::Which::UINT16_VALUE"
|
||||
_Value_Body_uint8Value " ::capnp::schema::Value::Body::Which::UINT8_VALUE"
|
||||
_Value_Body_int64Value " ::capnp::schema::Value::Body::Which::INT64_VALUE"
|
||||
_Value_Body_structValue " ::capnp::schema::Value::Body::Which::STRUCT_VALUE"
|
||||
_Value_Body_textValue " ::capnp::schema::Value::Body::Which::TEXT_VALUE"
|
||||
_Value_Body_uint64Value " ::capnp::schema::Value::Body::Which::UINT64_VALUE"
|
||||
_Value_Body_objectValue " ::capnp::schema::Value::Body::Which::OBJECT_VALUE"
|
||||
enum _Type_Body_Which:
|
||||
_Type_Body_boolType " ::capnp::schema::Type::Body::Which::BOOL_TYPE"
|
||||
_Type_Body_structType " ::capnp::schema::Type::Body::Which::STRUCT_TYPE"
|
||||
_Type_Body_int32Type " ::capnp::schema::Type::Body::Which::INT32_TYPE"
|
||||
_Type_Body_voidType " ::capnp::schema::Type::Body::Which::VOID_TYPE"
|
||||
_Type_Body_uint16Type " ::capnp::schema::Type::Body::Which::UINT16_TYPE"
|
||||
_Type_Body_dataType " ::capnp::schema::Type::Body::Which::DATA_TYPE"
|
||||
_Type_Body_objectType " ::capnp::schema::Type::Body::Which::OBJECT_TYPE"
|
||||
_Type_Body_int64Type " ::capnp::schema::Type::Body::Which::INT64_TYPE"
|
||||
_Type_Body_float64Type " ::capnp::schema::Type::Body::Which::FLOAT64_TYPE"
|
||||
_Type_Body_interfaceType " ::capnp::schema::Type::Body::Which::INTERFACE_TYPE"
|
||||
_Type_Body_uint32Type " ::capnp::schema::Type::Body::Which::UINT32_TYPE"
|
||||
_Type_Body_uint8Type " ::capnp::schema::Type::Body::Which::UINT8_TYPE"
|
||||
_Type_Body_listType " ::capnp::schema::Type::Body::Which::LIST_TYPE"
|
||||
_Type_Body_int8Type " ::capnp::schema::Type::Body::Which::INT8_TYPE"
|
||||
_Type_Body_float32Type " ::capnp::schema::Type::Body::Which::FLOAT32_TYPE"
|
||||
_Type_Body_enumType " ::capnp::schema::Type::Body::Which::ENUM_TYPE"
|
||||
_Type_Body_uint64Type " ::capnp::schema::Type::Body::Which::UINT64_TYPE"
|
||||
_Type_Body_textType " ::capnp::schema::Type::Body::Which::TEXT_TYPE"
|
||||
_Type_Body_int16Type " ::capnp::schema::Type::Body::Which::INT16_TYPE"
|
||||
enum _Node_Body_Which:
|
||||
_Node_Body_annotationNode " ::capnp::schema::Node::Body::Which::ANNOTATION_NODE"
|
||||
_Node_Body_interfaceNode " ::capnp::schema::Node::Body::Which::INTERFACE_NODE"
|
||||
_Node_Body_enumNode " ::capnp::schema::Node::Body::Which::ENUM_NODE"
|
||||
_Node_Body_structNode " ::capnp::schema::Node::Body::Which::STRUCT_NODE"
|
||||
_Node_Body_constNode " ::capnp::schema::Node::Body::Which::CONST_NODE"
|
||||
_Node_Body_fileNode " ::capnp::schema::Node::Body::Which::FILE_NODE"
|
||||
enum _StructNode_Member_Body_Which:
|
||||
_StructNode_Member_Body_fieldMember " ::capnp::schema::StructNode::Member::Body::Which::FIELD_MEMBER"
|
||||
_StructNode_Member_Body_unionMember " ::capnp::schema::StructNode::Member::Body::Which::UNION_MEMBER"
|
||||
cdef cppclass CodeGeneratorRequest
|
||||
|
||||
cdef cppclass InterfaceNode
|
||||
cdef cppclass Value
|
||||
cdef cppclass ConstNode
|
||||
cdef cppclass Type
|
||||
cdef cppclass FileNode
|
||||
cdef cppclass Node
|
||||
cdef cppclass AnnotationNode
|
||||
cdef cppclass EnumNode
|
||||
cdef cppclass StructNode
|
||||
cdef cppclass Annotation
|
||||
cdef cppclass CodeGeneratorRequest nogil:
|
||||
|
||||
cppclass Reader nogil:
|
||||
|
||||
List[CodeGeneratorRequest.Node].Reader getNodes()
|
||||
List[UInt64].Reader getRequestedFiles()
|
||||
cppclass Builder nogil:
|
||||
|
||||
List[CodeGeneratorRequest.Node].Builder getNodes()
|
||||
List[CodeGeneratorRequest.Node].Builder initNodes(int)
|
||||
List[UInt64].Builder getRequestedFiles()
|
||||
List[UInt64].Builder initRequestedFiles(int)
|
||||
|
||||
cdef cppclass InterfaceNode nogil:
|
||||
cppclass Method
|
||||
|
||||
cppclass Method:
|
||||
cppclass Param
|
||||
|
||||
cppclass Param nogil:
|
||||
|
||||
cppclass Reader nogil:
|
||||
|
||||
Value getDefaultValue()
|
||||
Type getType()
|
||||
Text.Reader getName()
|
||||
List[InterfaceNode.Method.Param.Annotation].Reader getAnnotations()
|
||||
cppclass Builder nogil:
|
||||
|
||||
Value getDefaultValue()
|
||||
void setDefaultValue(Value)
|
||||
Type getType()
|
||||
void setType(Type)
|
||||
Text.Builder getName()
|
||||
void setName(Text)
|
||||
List[InterfaceNode.Method.Param.Annotation].Builder getAnnotations()
|
||||
List[InterfaceNode.Method.Param.Annotation].Builder initAnnotations(int)
|
||||
|
||||
cppclass Reader nogil:
|
||||
|
||||
UInt16 getCodeOrder()
|
||||
Text.Reader getName()
|
||||
List[InterfaceNode.Method.InterfaceNode.Method.Param].Reader getParams()
|
||||
UInt16 getRequiredParamCount()
|
||||
Type getReturnType()
|
||||
List[InterfaceNode.Method.Annotation].Reader getAnnotations()
|
||||
|
||||
cppclass Builder nogil:
|
||||
|
||||
UInt16 getCodeOrder()
|
||||
void setCodeOrder(UInt16)
|
||||
Text.Builder getName()
|
||||
void setName(Text)
|
||||
List[InterfaceNode.Method.InterfaceNode.Method.Param].Builder getParams()
|
||||
List[InterfaceNode.Method.InterfaceNode.Method.Param].Builder initParams(int)
|
||||
UInt16 getRequiredParamCount()
|
||||
void setRequiredParamCount(UInt16)
|
||||
Type getReturnType()
|
||||
void setReturnType(Type)
|
||||
List[InterfaceNode.Method.Annotation].Builder getAnnotations()
|
||||
List[InterfaceNode.Method.Annotation].Builder initAnnotations(int)
|
||||
|
||||
cppclass Reader nogil:
|
||||
|
||||
List[InterfaceNode.InterfaceNode.Method].Reader getMethods()
|
||||
|
||||
cppclass Builder nogil:
|
||||
|
||||
List[InterfaceNode.InterfaceNode.Method].Builder getMethods()
|
||||
List[InterfaceNode.InterfaceNode.Method].Builder initMethods(int)
|
||||
|
||||
cdef cppclass Value nogil:
|
||||
cppclass Body
|
||||
|
||||
cppclass Body nogil:
|
||||
|
||||
cppclass Reader nogil:
|
||||
int which()
|
||||
UInt32 getUint32Value()
|
||||
Float64 getFloat64Value()
|
||||
Void getVoidValue()
|
||||
Data.Reader getDataValue()
|
||||
Object getListValue()
|
||||
Int32 getInt32Value()
|
||||
UInt16 getEnumValue()
|
||||
Int8 getInt8Value()
|
||||
Bool getBoolValue()
|
||||
Int16 getInt16Value()
|
||||
Float32 getFloat32Value()
|
||||
Void getInterfaceValue()
|
||||
UInt16 getUint16Value()
|
||||
UInt8 getUint8Value()
|
||||
Int64 getInt64Value()
|
||||
Object getStructValue()
|
||||
Text.Reader getTextValue()
|
||||
UInt64 getUint64Value()
|
||||
Object getObjectValue()
|
||||
|
||||
cppclass Builder nogil:
|
||||
int which()
|
||||
UInt32 getUint32Value()
|
||||
void setUint32Value(UInt32)
|
||||
Float64 getFloat64Value()
|
||||
void setFloat64Value(Float64)
|
||||
Void getVoidValue()
|
||||
void setVoidValue(Void)
|
||||
Data.Builder getDataValue()
|
||||
void setDataValue(Data)
|
||||
Object getListValue()
|
||||
void setListValue(Object)
|
||||
Int32 getInt32Value()
|
||||
void setInt32Value(Int32)
|
||||
UInt16 getEnumValue()
|
||||
void setEnumValue(UInt16)
|
||||
Int8 getInt8Value()
|
||||
void setInt8Value(Int8)
|
||||
Bool getBoolValue()
|
||||
void setBoolValue(Bool)
|
||||
Int16 getInt16Value()
|
||||
void setInt16Value(Int16)
|
||||
Float32 getFloat32Value()
|
||||
void setFloat32Value(Float32)
|
||||
Void getInterfaceValue()
|
||||
void setInterfaceValue(Void)
|
||||
UInt16 getUint16Value()
|
||||
void setUint16Value(UInt16)
|
||||
UInt8 getUint8Value()
|
||||
void setUint8Value(UInt8)
|
||||
Int64 getInt64Value()
|
||||
void setInt64Value(Int64)
|
||||
Object getStructValue()
|
||||
void setStructValue(Object)
|
||||
Text.Builder getTextValue()
|
||||
void setTextValue(Text)
|
||||
UInt64 getUint64Value()
|
||||
void setUint64Value(UInt64)
|
||||
Object getObjectValue()
|
||||
void setObjectValue(Object)
|
||||
|
||||
cppclass Reader nogil:
|
||||
|
||||
Value.Body getBody()
|
||||
|
||||
cppclass Builder nogil:
|
||||
|
||||
Value.Body getBody()
|
||||
void setBody(Value.Body)
|
||||
|
||||
cdef cppclass ConstNode nogil:
|
||||
|
||||
cppclass Reader nogil:
|
||||
|
||||
Type getType()
|
||||
Value getValue()
|
||||
|
||||
cppclass Builder nogil:
|
||||
|
||||
Type getType()
|
||||
void setType(Type)
|
||||
Value getValue()
|
||||
void setValue(Value)
|
||||
|
||||
cdef cppclass Type nogil:
|
||||
cppclass Body
|
||||
|
||||
cppclass Body nogil:
|
||||
|
||||
cppclass Reader nogil:
|
||||
int which()
|
||||
Void getBoolType()
|
||||
UInt64 getStructType()
|
||||
Void getInt32Type()
|
||||
Void getVoidType()
|
||||
Void getUint16Type()
|
||||
Void getDataType()
|
||||
Void getObjectType()
|
||||
Void getInt64Type()
|
||||
Void getFloat64Type()
|
||||
UInt64 getInterfaceType()
|
||||
Void getUint32Type()
|
||||
Void getUint8Type()
|
||||
Type getListType()
|
||||
Void getInt8Type()
|
||||
Void getFloat32Type()
|
||||
UInt64 getEnumType()
|
||||
Void getUint64Type()
|
||||
Void getTextType()
|
||||
Void getInt16Type()
|
||||
|
||||
cppclass Builder nogil:
|
||||
int which()
|
||||
Void getBoolType()
|
||||
void setBoolType(Void)
|
||||
UInt64 getStructType()
|
||||
void setStructType(UInt64)
|
||||
Void getInt32Type()
|
||||
void setInt32Type(Void)
|
||||
Void getVoidType()
|
||||
void setVoidType(Void)
|
||||
Void getUint16Type()
|
||||
void setUint16Type(Void)
|
||||
Void getDataType()
|
||||
void setDataType(Void)
|
||||
Void getObjectType()
|
||||
void setObjectType(Void)
|
||||
Void getInt64Type()
|
||||
void setInt64Type(Void)
|
||||
Void getFloat64Type()
|
||||
void setFloat64Type(Void)
|
||||
UInt64 getInterfaceType()
|
||||
void setInterfaceType(UInt64)
|
||||
Void getUint32Type()
|
||||
void setUint32Type(Void)
|
||||
Void getUint8Type()
|
||||
void setUint8Type(Void)
|
||||
Type getListType()
|
||||
void setListType(Type)
|
||||
Void getInt8Type()
|
||||
void setInt8Type(Void)
|
||||
Void getFloat32Type()
|
||||
void setFloat32Type(Void)
|
||||
UInt64 getEnumType()
|
||||
void setEnumType(UInt64)
|
||||
Void getUint64Type()
|
||||
void setUint64Type(Void)
|
||||
Void getTextType()
|
||||
void setTextType(Void)
|
||||
Void getInt16Type()
|
||||
void setInt16Type(Void)
|
||||
|
||||
cppclass Reader nogil:
|
||||
|
||||
Type.Body getBody()
|
||||
|
||||
cppclass Builder nogil:
|
||||
|
||||
Type.Body getBody()
|
||||
void setBody(Type.Body)
|
||||
|
||||
cdef cppclass FileNode nogil:
|
||||
cppclass Import
|
||||
|
||||
cppclass Import nogil:
|
||||
|
||||
cppclass Reader nogil:
|
||||
|
||||
UInt64 getId()
|
||||
Text.Reader getName()
|
||||
|
||||
cppclass Builder nogil:
|
||||
|
||||
UInt64 getId()
|
||||
void setId(UInt64)
|
||||
Text.Builder getName()
|
||||
void setName(Text)
|
||||
|
||||
cppclass Reader nogil:
|
||||
|
||||
List[FileNode.FileNode.Import].Reader getImports()
|
||||
|
||||
cppclass Builder nogil:
|
||||
|
||||
List[FileNode.FileNode.Import].Builder getImports()
|
||||
List[FileNode.FileNode.Import].Builder initImports(int)
|
||||
|
||||
cdef cppclass Node nogil:
|
||||
cppclass Body
|
||||
cppclass NestedNode
|
||||
|
||||
cppclass Body nogil:
|
||||
|
||||
cppclass Reader nogil:
|
||||
int which()
|
||||
AnnotationNode getAnnotationNode()
|
||||
InterfaceNode getInterfaceNode()
|
||||
EnumNode getEnumNode()
|
||||
StructNode getStructNode()
|
||||
ConstNode getConstNode()
|
||||
FileNode getFileNode()
|
||||
cppclass Builder nogil:
|
||||
int which()
|
||||
AnnotationNode getAnnotationNode()
|
||||
void setAnnotationNode(AnnotationNode)
|
||||
InterfaceNode getInterfaceNode()
|
||||
void setInterfaceNode(InterfaceNode)
|
||||
EnumNode getEnumNode()
|
||||
void setEnumNode(EnumNode)
|
||||
StructNode getStructNode()
|
||||
void setStructNode(StructNode)
|
||||
ConstNode getConstNode()
|
||||
void setConstNode(ConstNode)
|
||||
FileNode getFileNode()
|
||||
void setFileNode(FileNode)
|
||||
|
||||
cppclass NestedNode nogil:
|
||||
|
||||
cppclass Reader nogil:
|
||||
|
||||
Text.Reader getName()
|
||||
UInt64 getId()
|
||||
cppclass Builder nogil:
|
||||
|
||||
Text.Builder getName()
|
||||
void setName(Text)
|
||||
UInt64 getId()
|
||||
void setId(UInt64)
|
||||
uint64_t getId()
|
||||
cppclass Reader nogil:
|
||||
|
||||
Node.Body getBody()
|
||||
Text.Reader getDisplayName()
|
||||
List[Node.Annotation].Reader getAnnotations()
|
||||
UInt64 getScopeId()
|
||||
List[Node.Node.NestedNode].Reader getNestedNodes()
|
||||
UInt64 getId()
|
||||
bint isFile()
|
||||
uint64_t getScopeId()
|
||||
uint64_t getId()
|
||||
ListNestedNodeReader getNestedNodes()
|
||||
bint isStruct()
|
||||
bint isEnum()
|
||||
bint isInterface()
|
||||
bint isConst()
|
||||
bint isAnnotation()
|
||||
|
||||
cppclass Builder nogil:
|
||||
|
||||
Node.Body getBody()
|
||||
void setBody(Node.Body)
|
||||
Text.Builder getDisplayName()
|
||||
void setDisplayName(Text)
|
||||
List[Node.Annotation].Builder getAnnotations()
|
||||
List[Node.Annotation].Builder initAnnotations(int)
|
||||
UInt64 getScopeId()
|
||||
void setScopeId(UInt64)
|
||||
List[Node.Node.NestedNode].Builder getNestedNodes()
|
||||
List[Node.Node.NestedNode].Builder initNestedNodes(int)
|
||||
UInt64 getId()
|
||||
void setId(UInt64)
|
||||
bint isFile()
|
||||
bint isStruct()
|
||||
bint isEnum()
|
||||
bint isInterface()
|
||||
bint isConst()
|
||||
bint isAnnotation()
|
||||
|
||||
cdef cppclass AnnotationNode nogil:
|
||||
|
||||
cdef cppclass Field nogil:
|
||||
cppclass Reader nogil:
|
||||
Text.Reader getName()
|
||||
|
||||
Bool getTargetsField()
|
||||
Bool getTargetsConst()
|
||||
Bool getTargetsFile()
|
||||
Bool getTargetsStruct()
|
||||
Bool getTargetsParam()
|
||||
Bool getTargetsUnion()
|
||||
Bool getTargetsAnnotation()
|
||||
Bool getTargetsEnumerant()
|
||||
Type getType()
|
||||
Bool getTargetsEnum()
|
||||
Bool getTargetsInterface()
|
||||
Bool getTargetsMethod()
|
||||
|
||||
cppclass Builder nogil:
|
||||
|
||||
Bool getTargetsField()
|
||||
void setTargetsField(Bool)
|
||||
Bool getTargetsConst()
|
||||
void setTargetsConst(Bool)
|
||||
Bool getTargetsFile()
|
||||
void setTargetsFile(Bool)
|
||||
Bool getTargetsStruct()
|
||||
void setTargetsStruct(Bool)
|
||||
Bool getTargetsParam()
|
||||
void setTargetsParam(Bool)
|
||||
Bool getTargetsUnion()
|
||||
void setTargetsUnion(Bool)
|
||||
Bool getTargetsAnnotation()
|
||||
void setTargetsAnnotation(Bool)
|
||||
Bool getTargetsEnumerant()
|
||||
void setTargetsEnumerant(Bool)
|
||||
Type getType()
|
||||
void setType(Type)
|
||||
Bool getTargetsEnum()
|
||||
void setTargetsEnum(Bool)
|
||||
Bool getTargetsInterface()
|
||||
void setTargetsInterface(Bool)
|
||||
Bool getTargetsMethod()
|
||||
void setTargetsMethod(Bool)
|
||||
|
||||
cdef cppclass EnumNode nogil:
|
||||
cppclass Enumerant
|
||||
|
||||
cppclass Enumerant nogil:
|
||||
|
||||
cppclass Reader nogil:
|
||||
|
||||
UInt16 getCodeOrder()
|
||||
Text.Reader getName()
|
||||
List[EnumNode.Enumerant.Annotation].Reader getAnnotations()
|
||||
|
||||
cppclass Builder nogil:
|
||||
|
||||
UInt16 getCodeOrder()
|
||||
void setCodeOrder(UInt16)
|
||||
Text.Builder getName()
|
||||
void setName(Text)
|
||||
List[EnumNode.Enumerant.Annotation].Builder getAnnotations()
|
||||
List[EnumNode.Enumerant.Annotation].Builder initAnnotations(int)
|
||||
|
||||
cdef cppclass Enumerant nogil:
|
||||
cppclass Reader nogil:
|
||||
Text.Reader getName()
|
||||
|
||||
List[EnumNode.EnumNode.Enumerant].Reader getEnumerants()
|
||||
|
||||
cppclass Builder nogil:
|
||||
|
||||
List[EnumNode.EnumNode.Enumerant].Builder getEnumerants()
|
||||
List[EnumNode.EnumNode.Enumerant].Builder initEnumerants(int)
|
||||
|
||||
cdef cppclass StructNode nogil:
|
||||
cppclass Union
|
||||
cppclass Member
|
||||
cppclass Field
|
||||
|
||||
cppclass Union nogil:
|
||||
|
||||
cppclass Reader nogil:
|
||||
|
||||
UInt32 getDiscriminantOffset()
|
||||
List[StructNode.Union.StructNode.Member].Reader getMembers()
|
||||
cppclass Builder nogil:
|
||||
|
||||
UInt32 getDiscriminantOffset()
|
||||
void setDiscriminantOffset(UInt32)
|
||||
List[StructNode.Union.StructNode.Member].Builder getMembers()
|
||||
List[StructNode.Union.StructNode.Member].Builder initMembers(int)
|
||||
cppclass Member nogil:
|
||||
cppclass Body
|
||||
|
||||
cppclass Body nogil:
|
||||
|
||||
cppclass Reader nogil:
|
||||
int which()
|
||||
Field getFieldMember()
|
||||
Union getUnionMember()
|
||||
cppclass Builder nogil:
|
||||
int which()
|
||||
Field getFieldMember()
|
||||
void setFieldMember(Field)
|
||||
Union getUnionMember()
|
||||
void setUnionMember(Union)
|
||||
cppclass Reader nogil:
|
||||
|
||||
UInt16 getOrdinal()
|
||||
StructNode.Member.Body getBody()
|
||||
UInt16 getCodeOrder()
|
||||
Text.Reader getName()
|
||||
List[StructNode.Member.Annotation].Reader getAnnotations()
|
||||
cppclass Builder nogil:
|
||||
|
||||
UInt16 getOrdinal()
|
||||
void setOrdinal(UInt16)
|
||||
StructNode.Member.Body getBody()
|
||||
void setBody(StructNode.Member.Body)
|
||||
UInt16 getCodeOrder()
|
||||
void setCodeOrder(UInt16)
|
||||
Text.Builder getName()
|
||||
void setName(Text)
|
||||
List[StructNode.Member.Annotation].Builder getAnnotations()
|
||||
List[StructNode.Member.Annotation].Builder initAnnotations(int)
|
||||
|
||||
cppclass Field nogil:
|
||||
|
||||
cppclass Reader nogil:
|
||||
|
||||
Value getDefaultValue()
|
||||
Type getType()
|
||||
UInt32 getOffset()
|
||||
cppclass Builder nogil:
|
||||
|
||||
Value getDefaultValue()
|
||||
void setDefaultValue(Value)
|
||||
Type getType()
|
||||
void setType(Type)
|
||||
UInt32 getOffset()
|
||||
void setOffset(UInt32)
|
||||
cppclass Reader nogil:
|
||||
|
||||
UInt16 getDataSectionWordSize()
|
||||
List[StructNode.StructNode.Member].Reader getMembers()
|
||||
UInt16 getPointerSectionSize()
|
||||
cppclass Builder nogil:
|
||||
|
||||
UInt16 getDataSectionWordSize()
|
||||
void setDataSectionWordSize(UInt16)
|
||||
List[StructNode.StructNode.Member].Builder getMembers()
|
||||
List[StructNode.StructNode.Member].Builder initMembers(int)
|
||||
UInt16 getPointerSectionSize()
|
||||
void setPointerSectionSize(UInt16)
|
||||
cdef cppclass Annotation nogil:
|
||||
|
||||
cppclass Reader nogil:
|
||||
|
||||
UInt64 getId()
|
||||
Value getValue()
|
||||
cppclass Builder nogil:
|
||||
|
||||
UInt64 getId()
|
||||
void setId(UInt64)
|
||||
Value getValue()
|
||||
void setValue(Value)
|
||||
cdef cppclass ListNestedNodeReader"capnp::List<capnp::schema::Node::NestedNode>::Reader" nogil:
|
||||
ListNestedNodeReader()
|
||||
ListNestedNodeReader(ListNestedNodeReader)
|
||||
Node.NestedNode.Reader operator[](uint)
|
||||
cdef cppclass ListNestedNodeReader "capnp::List<capnp::schema::Node::NestedNode>::Reader" nogil:
|
||||
uint size()
|
||||
Node.NestedNode.Reader operator[](uint)
|
||||
|
||||
cdef extern from "capnp/common.h" namespace " ::capnp":
|
||||
cdef cppclass word nogil:
|
||||
pass
|
||||
|
||||
cdef extern from "kj/common.h" namespace " ::kj":
|
||||
cdef cppclass WordArrayPtr " ::kj::ArrayPtr< ::capnp::word>" nogil:
|
||||
WordArrayPtr(word*, size_t)
|
||||
|
||||
cdef extern from "kj/array.h" namespace " ::kj":
|
||||
cdef cppclass WordArray " ::kj::Array< ::capnp::word>" nogil:
|
||||
word* begin()
|
||||
size_t size()
|
||||
|
||||
cdef extern from "capnp/message.h" namespace " ::capnp":
|
||||
cdef cppclass ReaderOptions nogil:
|
||||
@@ -650,177 +73,20 @@ cdef extern from "capnp/message.h" namespace " ::capnp":
|
||||
uint nestingLimit
|
||||
|
||||
cdef cppclass MessageBuilder nogil:
|
||||
CodeGeneratorRequest.Builder getRootCodeGeneratorRequest'getRoot< ::capnp::schema::CodeGeneratorRequest>'()
|
||||
CodeGeneratorRequest.Builder initRootCodeGeneratorRequest'initRoot< ::capnp::schema::CodeGeneratorRequest>'()
|
||||
InterfaceNode.Builder getRootInterfaceNode'getRoot< ::capnp::schema::InterfaceNode>'()
|
||||
InterfaceNode.Builder initRootInterfaceNode'initRoot< ::capnp::schema::InterfaceNode>'()
|
||||
Value.Builder getRootValue'getRoot< ::capnp::schema::Value>'()
|
||||
Value.Builder initRootValue'initRoot< ::capnp::schema::Value>'()
|
||||
ConstNode.Builder getRootConstNode'getRoot< ::capnp::schema::ConstNode>'()
|
||||
ConstNode.Builder initRootConstNode'initRoot< ::capnp::schema::ConstNode>'()
|
||||
Type.Builder getRootType'getRoot< ::capnp::schema::Type>'()
|
||||
Type.Builder initRootType'initRoot< ::capnp::schema::Type>'()
|
||||
FileNode.Builder getRootFileNode'getRoot< ::capnp::schema::FileNode>'()
|
||||
FileNode.Builder initRootFileNode'initRoot< ::capnp::schema::FileNode>'()
|
||||
Node.Builder getRootNode'getRoot< ::capnp::schema::Node>'()
|
||||
Node.Builder initRootNode'initRoot< ::capnp::schema::Node>'()
|
||||
AnnotationNode.Builder getRootAnnotationNode'getRoot< ::capnp::schema::AnnotationNode>'()
|
||||
AnnotationNode.Builder initRootAnnotationNode'initRoot< ::capnp::schema::AnnotationNode>'()
|
||||
EnumNode.Builder getRootEnumNode'getRoot< ::capnp::schema::EnumNode>'()
|
||||
EnumNode.Builder initRootEnumNode'initRoot< ::capnp::schema::EnumNode>'()
|
||||
StructNode.Builder getRootStructNode'getRoot< ::capnp::schema::StructNode>'()
|
||||
StructNode.Builder initRootStructNode'initRoot< ::capnp::schema::StructNode>'()
|
||||
Annotation.Builder getRootAnnotation'getRoot< ::capnp::schema::Annotation>'()
|
||||
Annotation.Builder initRootAnnotation'initRoot< ::capnp::schema::Annotation>'()
|
||||
|
||||
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)
|
||||
|
||||
ConstWordArrayArrayPtr getSegmentsForOutput'getSegmentsForOutput'()
|
||||
|
||||
AnyPointer.Builder getRootAnyPointer'getRoot< ::capnp::AnyPointer>'()
|
||||
|
||||
DynamicOrphan newOrphan'getOrphanage().newOrphan'(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)
|
||||
|
||||
cdef cppclass MessageReader nogil:
|
||||
CodeGeneratorRequest.Reader getRootCodeGeneratorRequest'getRoot< ::capnp::schema::CodeGeneratorRequest>'()
|
||||
InterfaceNode.Reader getRootInterfaceNode'getRoot< ::capnp::schema::InterfaceNode>'()
|
||||
Value.Reader getRootValue'getRoot< ::capnp::schema::Value>'()
|
||||
ConstNode.Reader getRootConstNode'getRoot< ::capnp::schema::ConstNode>'()
|
||||
Type.Reader getRootType'getRoot< ::capnp::schema::Type>'()
|
||||
FileNode.Reader getRootFileNode'getRoot< ::capnp::schema::FileNode>'()
|
||||
Node.Reader getRootNode'getRoot< ::capnp::schema::Node>'()
|
||||
AnnotationNode.Reader getRootAnnotationNode'getRoot< ::capnp::schema::AnnotationNode>'()
|
||||
EnumNode.Reader getRootEnumNode'getRoot< ::capnp::schema::EnumNode>'()
|
||||
StructNode.Reader getRootStructNode'getRoot< ::capnp::schema::StructNode>'()
|
||||
Annotation.Reader getRootAnnotation'getRoot< ::capnp::schema::Annotation>'()
|
||||
|
||||
DynamicStruct.Reader getRootDynamicStruct'getRoot< ::capnp::DynamicStruct>'(StructSchema) except +reraise_kj_exception
|
||||
AnyPointer.Reader getRootAnyPointer'getRoot< ::capnp::AnyPointer>'()
|
||||
DynamicStruct.Reader getRootDynamicStruct 'getRoot< ::capnp::DynamicStruct>'(StructSchema) except +reraise_kj_exception
|
||||
|
||||
cdef cppclass MallocMessageBuilder(MessageBuilder) nogil:
|
||||
MallocMessageBuilder()
|
||||
MallocMessageBuilder(int)
|
||||
|
||||
cdef cppclass SegmentArrayMessageReader(MessageReader) nogil:
|
||||
SegmentArrayMessageReader(ConstWordArrayArrayPtr array) except +reraise_kj_exception
|
||||
SegmentArrayMessageReader(ConstWordArrayArrayPtr array, ReaderOptions) except +reraise_kj_exception
|
||||
|
||||
cdef cppclass FlatMessageBuilder(MessageBuilder) nogil:
|
||||
FlatMessageBuilder(WordArrayPtr array)
|
||||
FlatMessageBuilder(WordArrayPtr array, ReaderOptions)
|
||||
|
||||
enum Void:
|
||||
VOID
|
||||
|
||||
cdef extern from "PyCustomMessageBuilder.h" namespace " ::capnp":
|
||||
cdef cppclass PyCustomMessageBuilder(MessageBuilder):
|
||||
PyCustomMessageBuilder(PyObject* allocateSegmentCallable)
|
||||
PyCustomMessageBuilder(PyObject* allocateSegmentCallable, int firstSegmentSize)
|
||||
|
||||
cdef extern from "capnp/common.h" namespace " ::capnp":
|
||||
cdef cppclass word nogil:
|
||||
pass
|
||||
|
||||
cdef extern from "kj/common.h" namespace " ::kj":
|
||||
# Cython can't handle ArrayPtr[word] as a function argument
|
||||
cdef cppclass WordArrayPtr " ::kj::ArrayPtr< ::capnp::word>" nogil:
|
||||
WordArrayPtr()
|
||||
WordArrayPtr(word *, size_t size)
|
||||
size_t size()
|
||||
word& operator[](size_t index)
|
||||
cdef cppclass ByteArrayPtr " ::kj::ArrayPtr< ::capnp::byte>" nogil:
|
||||
ByteArrayPtr()
|
||||
ByteArrayPtr(byte *, size_t size)
|
||||
size_t size()
|
||||
byte& operator[](size_t index)
|
||||
cdef cppclass ConstWordArrayPtr " ::kj::ArrayPtr< const ::capnp::word>" nogil:
|
||||
ConstWordArrayPtr()
|
||||
ConstWordArrayPtr(word *, size_t size)
|
||||
size_t size()
|
||||
const word* begin()
|
||||
cdef cppclass ConstWordArrayArrayPtr " ::kj::ArrayPtr< const ::kj::ArrayPtr< const ::capnp::word>>" nogil:
|
||||
ConstWordArrayArrayPtr()
|
||||
ConstWordArrayArrayPtr(ConstWordArrayPtr*, size_t size)
|
||||
size_t size()
|
||||
ConstWordArrayPtr& operator[](size_t index)
|
||||
|
||||
cdef extern from "kj/array.h" namespace " ::kj":
|
||||
# Cython can't handle Array[word] as a function argument
|
||||
cdef cppclass WordArray " ::kj::Array< ::capnp::word>" nogil:
|
||||
word* begin()
|
||||
size_t size()
|
||||
cdef cppclass ByteArray " ::kj::Array< ::capnp::byte>" nogil:
|
||||
char* begin()
|
||||
size_t size()
|
||||
|
||||
cdef extern from "kj/array.h" namespace " ::kj":
|
||||
cdef cppclass InputStream nogil:
|
||||
void read(void* buffer, size_t bytes) except +reraise_kj_exception
|
||||
size_t read(void* buffer, size_t minBytes, size_t maxBytes) except +reraise_kj_exception
|
||||
size_t tryRead(void* buffer, size_t minBytes, size_t maxBytes) except +reraise_kj_exception
|
||||
void skip(size_t bytes) except +reraise_kj_exception
|
||||
|
||||
cdef cppclass OutputStream nogil:
|
||||
void write(const void* buffer, size_t size) except +reraise_kj_exception
|
||||
# void write(ArrayPtr<const ArrayPtr<const byte>> pieces);
|
||||
|
||||
cdef cppclass BufferedInputStream(InputStream) nogil:
|
||||
pass
|
||||
cdef cppclass BufferedOutputStream(OutputStream) nogil:
|
||||
pass
|
||||
|
||||
cdef cppclass BufferedInputStreamWrapper(BufferedInputStream) nogil:
|
||||
BufferedInputStreamWrapper(InputStream&)
|
||||
cdef cppclass BufferedOutputStreamWrapper(BufferedOutputStream) nogil:
|
||||
BufferedOutputStreamWrapper(OutputStream&)
|
||||
|
||||
cdef cppclass ArrayInputStream(BufferedInputStream) nogil:
|
||||
ArrayInputStream(ByteArrayPtr)
|
||||
ByteArrayPtr getArray()
|
||||
# ByteArrayPtr tryGetReadBuffer() except +reraise_kj_exception
|
||||
cdef cppclass ArrayOutputStream(BufferedOutputStream) nogil:
|
||||
ArrayOutputStream(ByteArrayPtr)
|
||||
ByteArrayPtr getArray()
|
||||
ByteArrayPtr getWriteBuffer()
|
||||
|
||||
cdef cppclass FdInputStream(InputStream) nogil:
|
||||
FdInputStream(int)
|
||||
cdef cppclass FdOutputStream(OutputStream) nogil:
|
||||
FdOutputStream(int)
|
||||
|
||||
cdef extern from "capnp/serialize.h" namespace " ::capnp":
|
||||
cdef cppclass InputStreamMessageReader(MessageReader) nogil:
|
||||
InputStreamMessageReader(InputStream&) except +reraise_kj_exception
|
||||
InputStreamMessageReader(InputStream&, ReaderOptions) except +reraise_kj_exception
|
||||
cdef cppclass StreamFdMessageReader(MessageReader) nogil:
|
||||
StreamFdMessageReader(int) except +reraise_kj_exception
|
||||
StreamFdMessageReader(int, ReaderOptions) except +reraise_kj_exception
|
||||
|
||||
cdef cppclass FlatArrayMessageReader(MessageReader) nogil:
|
||||
FlatArrayMessageReader(WordArrayPtr array) except +reraise_kj_exception
|
||||
FlatArrayMessageReader(WordArrayPtr array, ReaderOptions) except +reraise_kj_exception
|
||||
FlatArrayMessageReader(WordArrayPtr, ReaderOptions) except +reraise_kj_exception
|
||||
const word* getEnd() const
|
||||
|
||||
void writeMessageToFd(int, MessageBuilder&) except +reraise_kj_exception nogil
|
||||
|
||||
WordArray messageToFlatArray(MessageBuilder &) nogil
|
||||
|
||||
cdef extern from "capnp/serialize-packed.h" namespace " ::capnp":
|
||||
cdef cppclass PackedInputStream(InputStream) nogil:
|
||||
PackedInputStream(BufferedInputStream&) except +reraise_kj_exception
|
||||
cdef cppclass PackedOutputStream(OutputStream) nogil:
|
||||
PackedOutputStream(BufferedOutputStream&) except +reraise_kj_exception
|
||||
|
||||
cdef cppclass PackedMessageReader(MessageReader) nogil:
|
||||
PackedMessageReader(BufferedInputStream&) except +reraise_kj_exception
|
||||
PackedMessageReader(BufferedInputStream&, ReaderOptions) except +reraise_kj_exception
|
||||
|
||||
cdef cppclass PackedFdMessageReader(MessageReader) nogil:
|
||||
PackedFdMessageReader(int) except +reraise_kj_exception
|
||||
PackedFdMessageReader(int, ReaderOptions) 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
|
||||
WordArray messageToFlatArray(MessageBuilder&) nogil
|
||||
|
||||
@@ -3,17 +3,13 @@
|
||||
from capnp.includes cimport capnp_cpp as capnp
|
||||
from capnp.includes cimport schema_cpp
|
||||
from capnp.includes.capnp_cpp cimport (
|
||||
Schema as C_Schema, StructSchema as C_StructSchema, InterfaceSchema as C_InterfaceSchema,
|
||||
Schema as C_Schema, StructSchema as C_StructSchema,
|
||||
EnumSchema as C_EnumSchema, ListSchema as C_ListSchema, DynamicStruct as C_DynamicStruct,
|
||||
DynamicValue as C_DynamicValue, Type as C_Type, DynamicList as C_DynamicList, SchemaLoader as C_SchemaLoader,
|
||||
DynamicValue as C_DynamicValue, Type as C_Type, DynamicList as C_DynamicList,
|
||||
SchemaParser as C_SchemaParser, ParsedSchema as C_ParsedSchema, VOID, ArrayPtr, StringPtr,
|
||||
String, StringTree, DynamicOrphan as C_DynamicOrphan, AnyPointer as C_DynamicObject,
|
||||
DynamicCapability as C_DynamicCapability, Request, Response, RemotePromise, Promise,
|
||||
CallContext, RpcSystem, makeRpcServer, makeRpcClient, Capability as C_Capability,
|
||||
TwoPartyVatNetwork as C_TwoPartyVatNetwork, Side, AsyncIoStream, Own,
|
||||
DynamicStruct_Builder, PyRefCounter, PyAsyncIoStream
|
||||
String, StringTree, DynamicStruct_Builder
|
||||
)
|
||||
from capnp.includes.schema_cpp cimport Node as C_Node, EnumNode as C_EnumNode
|
||||
from capnp.includes.schema_cpp cimport Node as C_Node
|
||||
from capnp.includes.types cimport *
|
||||
from capnp.helpers cimport helpers
|
||||
|
||||
@@ -30,9 +26,6 @@ cdef class _StringArrayPtr:
|
||||
cdef size_t size
|
||||
cdef ArrayPtr[StringPtr] asArrayPtr(self)
|
||||
|
||||
cdef class SchemaLoader:
|
||||
cdef C_SchemaLoader * thisptr
|
||||
|
||||
cdef class SchemaParser:
|
||||
cdef C_SchemaParser * thisptr
|
||||
cdef public dict modules_by_id
|
||||
@@ -40,16 +33,6 @@ cdef class SchemaParser:
|
||||
cdef _StringArrayPtr _last_import_array
|
||||
cpdef _parse_disk_file(self, displayName, diskPath, imports)
|
||||
|
||||
cdef class _DynamicOrphan:
|
||||
cdef C_DynamicOrphan thisptr
|
||||
cdef public object _parent
|
||||
|
||||
cdef _init(self, C_DynamicOrphan other, object parent)
|
||||
|
||||
cdef C_DynamicOrphan move(self)
|
||||
cpdef get(self)
|
||||
|
||||
|
||||
cdef class _DynamicStructReader:
|
||||
cdef C_DynamicStruct.Reader thisptr
|
||||
cdef public object _parent
|
||||
@@ -57,7 +40,7 @@ cdef class _DynamicStructReader:
|
||||
cdef object _obj_to_pin
|
||||
cdef object _schema
|
||||
|
||||
cdef _init(self, C_DynamicStruct.Reader other, object parent, bint isRoot=?, bint tryRegistry=?)
|
||||
cdef _init(self, C_DynamicStruct.Reader other, object parent, bint isRoot=?)
|
||||
|
||||
cpdef _get(self, field)
|
||||
cpdef _has(self, field)
|
||||
@@ -65,9 +48,7 @@ cdef class _DynamicStructReader:
|
||||
cpdef _which_str(self)
|
||||
cpdef _get_by_field(self, _StructSchemaField field)
|
||||
cpdef _has_by_field(self, _StructSchemaField field)
|
||||
cpdef get_data_as_view(self, field)
|
||||
|
||||
cpdef as_builder(self, num_first_segment_words=?, allocate_seg_callable=?)
|
||||
cpdef as_builder(self, num_first_segment_words=?)
|
||||
|
||||
|
||||
cdef class _DynamicStructBuilder:
|
||||
@@ -77,15 +58,10 @@ cdef class _DynamicStructBuilder:
|
||||
cdef public bint _is_written
|
||||
cdef object _schema
|
||||
|
||||
cdef _init(self, DynamicStruct_Builder other, object parent, bint isRoot=?, bint tryRegistry=?)
|
||||
cdef _init(self, DynamicStruct_Builder other, object parent, bint isRoot=?)
|
||||
|
||||
cdef _check_write(self)
|
||||
cpdef to_bytes(_DynamicStructBuilder self)
|
||||
cpdef to_segments(_DynamicStructBuilder self)
|
||||
cpdef to_segment_views(_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)
|
||||
cpdef _has(self, field)
|
||||
@@ -94,15 +70,10 @@ cdef class _DynamicStructBuilder:
|
||||
cpdef _set_by_field(self, _StructSchemaField field, value)
|
||||
cpdef _has_by_field(self, _StructSchemaField field)
|
||||
cpdef _init_by_field(self, _StructSchemaField field, size=?)
|
||||
cpdef init_resizable_list(self, field)
|
||||
cpdef _DynamicEnumField _which(self)
|
||||
cpdef _which_str(self)
|
||||
cpdef adopt(self, field, _DynamicOrphan orphan)
|
||||
cpdef disown(self, field)
|
||||
cpdef get_data_as_view(self, field)
|
||||
|
||||
cpdef as_reader(self)
|
||||
cpdef copy(self, num_first_segment_words=?, allocate_seg_callable=?)
|
||||
cpdef copy(self, num_first_segment_words=?)
|
||||
|
||||
cdef class _DynamicEnumField:
|
||||
cdef object thisptr
|
||||
@@ -117,15 +88,9 @@ cdef class _Schema:
|
||||
|
||||
cpdef as_const_value(self)
|
||||
cpdef as_struct(self)
|
||||
cpdef as_interface(self)
|
||||
cpdef as_enum(self)
|
||||
cpdef get_proto(self)
|
||||
|
||||
cdef class _InterfaceSchema:
|
||||
cdef C_InterfaceSchema thisptr
|
||||
cdef object __method_names, __method_names_inherited, __methods, __methods_inherited
|
||||
cdef _init(self, C_InterfaceSchema other)
|
||||
|
||||
cdef class _DynamicEnum:
|
||||
cdef capnp.DynamicEnum thisptr
|
||||
cdef public object _parent
|
||||
@@ -141,31 +106,19 @@ cdef class _DynamicListBuilder:
|
||||
cpdef _get(self, int64_t index)
|
||||
cpdef _set(self, index, value)
|
||||
|
||||
cpdef adopt(self, index, _DynamicOrphan orphan)
|
||||
cpdef disown(self, index)
|
||||
|
||||
cpdef init(self, index, size)
|
||||
|
||||
cdef class _MessageBuilder:
|
||||
cdef schema_cpp.MessageBuilder * thisptr
|
||||
cpdef init_root(self, schema)
|
||||
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)
|
||||
cdef _to_dict(msg, bint verbose, bint ordered)
|
||||
cdef _to_dict(msg, bint verbose, bint ordered, bint encode_bytes_as_base64=?)
|
||||
cdef _from_list(_DynamicListBuilder msg, list d)
|
||||
cdef _from_tuple(_DynamicListBuilder msg, tuple d)
|
||||
cdef _setDynamicFieldWithField(DynamicStruct_Builder thisptr, _StructSchemaField field, value, parent)
|
||||
cdef _setDynamicFieldStatic(DynamicStruct_Builder thisptr, field, value, parent)
|
||||
|
||||
cdef api object wrap_dynamic_struct_reader(Response & r) with gil
|
||||
cdef api Promise[void] * call_server_method(
|
||||
object server, char * _method_name, CallContext & _context, object kj_loop) except * with gil
|
||||
cdef api object wrap_kj_exception(capnp.Exception & exception) with gil
|
||||
cdef api object wrap_kj_exception_for_reraise(capnp.Exception & exception) with gil
|
||||
cdef api object get_exception_info(object exc_type, object exc_obj, object exc_tb) with gil
|
||||
|
||||
2929
capnp/lib/capnp.pyx
2929
capnp/lib/capnp.pyx
File diff suppressed because it is too large
Load Diff
@@ -1,7 +0,0 @@
|
||||
import capnp
|
||||
|
||||
|
||||
def _struct_reducer(schema_id, data):
|
||||
'Hack to deal with pypy not allowing reduce functions to be "built-in" methods (ie. compiled from a .pyx)'
|
||||
with capnp._global_schema_parser.modules_by_id[schema_id].from_bytes(data) as msg:
|
||||
return msg
|
||||
@@ -1,249 +0,0 @@
|
||||
# addressbook_fast.pyx
|
||||
# distutils: language = c++
|
||||
# distutils: include_dirs = {{include_dir}}
|
||||
# distutils: libraries = capnpc capnp capnp-rpc
|
||||
# distutils: sources = {{file.filename}}.cpp
|
||||
# cython: c_string_type = str
|
||||
# cython: c_string_encoding = default
|
||||
# cython: embedsignature = True
|
||||
|
||||
{% macro getter(field, type) -%}
|
||||
{% if 'uint' in field['type'] -%}
|
||||
uint64_t get{{field.c_name}}() except +reraise_kj_exception
|
||||
{% elif 'int' in field['type'] -%}
|
||||
int64_t get{{field.c_name}}() except +reraise_kj_exception
|
||||
{% elif 'void' == field['type'] -%}
|
||||
void get{{field.c_name}}() except +reraise_kj_exception
|
||||
{% elif 'bool' == field['type'] -%}
|
||||
cbool get{{field.c_name}}() except +reraise_kj_exception
|
||||
{% elif 'text' == field['type'] -%}
|
||||
StringPtr get{{field.c_name}}() except +reraise_kj_exception
|
||||
{% elif 'data' == field['type'] -%}
|
||||
Data.{{type}} get{{field.c_name}}() except +reraise_kj_exception
|
||||
{% else -%}
|
||||
DynamicValue.{{type}} get{{field.c_name}}() except +reraise_kj_exception
|
||||
{%- endif %}
|
||||
{%- endmacro %}
|
||||
# TODO: add struct/enum/list types
|
||||
|
||||
{% macro getfield(field, type) -%}
|
||||
cpdef _get_{{field.name}}(self):
|
||||
{% if 'int' in field['type'] -%}
|
||||
return self.thisptr_child.get{{field.c_name}}()
|
||||
{% elif 'void' == field['type'] -%}
|
||||
self.thisptr_child.get{{field.c_name}}()
|
||||
return None
|
||||
{% elif 'bool' == field['type'] -%}
|
||||
return self.thisptr_child.get{{field.c_name}}()
|
||||
{% elif 'text' == field['type'] -%}
|
||||
temp = self.thisptr_child.get{{field.c_name}}()
|
||||
return (<char*>temp.begin())[:temp.size()]
|
||||
{% elif 'data' == field['type'] -%}
|
||||
temp = self.thisptr_child.get{{field.c_name}}()
|
||||
return <bytes>((<char*>temp.begin())[:temp.size()])
|
||||
{% else -%}
|
||||
cdef DynamicValue.{{type}} temp = self.thisptr_child.get{{field.c_name}}()
|
||||
return to_python_{{type | lower}}(temp, self._parent)
|
||||
{% endif -%}
|
||||
{%- endmacro %}
|
||||
|
||||
{% macro setter(field) -%}
|
||||
{% if 'int' in field['type'] -%}
|
||||
void set{{field.c_name}}({{field.type}}_t) except +reraise_kj_exception
|
||||
{% elif 'bool' == field['type'] -%}
|
||||
void set{{field.c_name}}(cbool) except +reraise_kj_exception
|
||||
{% elif 'text' == field['type'] -%}
|
||||
void set{{field.c_name}}(StringPtr) except +reraise_kj_exception
|
||||
{% elif 'data' == field['type'] -%}
|
||||
void set{{field.c_name}}(ArrayPtr[byte]) except +reraise_kj_exception
|
||||
{% else -%}
|
||||
void set{{field.c_name}}(DynamicValue.Reader) except +reraise_kj_exception
|
||||
{%- endif %}
|
||||
{%- endmacro %}
|
||||
|
||||
{% macro setfield(field) -%}
|
||||
{% if 'int' in field['type'] -%}
|
||||
cpdef _set_{{field.name}}(self, {{field.type}}_t value):
|
||||
self.thisptr_child.set{{field.c_name}}(value)
|
||||
{% elif 'void' == field['type'] -%}
|
||||
cpdef _set_{{field.name}}(self, value=None):
|
||||
pass
|
||||
{% elif 'bool' == field['type'] -%}
|
||||
cpdef _set_{{field.name}}(self, cbool value):
|
||||
self.thisptr_child.set{{field.c_name}}(value)
|
||||
{% elif 'list' == field['type'] -%}
|
||||
cpdef _set_{{field.name}}(self, list value):
|
||||
cdef uint i = 0
|
||||
self.init("{{field.name}}", len(value))
|
||||
cdef _DynamicListBuilder temp = self._get_{{field.name}}()
|
||||
for elem in value:
|
||||
{% if 'struct' in field['sub_type'] -%}
|
||||
temp._get(i).from_dict(elem)
|
||||
{% else -%}
|
||||
temp[i] = elem
|
||||
{% endif -%}
|
||||
i += 1
|
||||
{% elif 'text' == field['type'] -%}
|
||||
cpdef _set_{{field.name}}(self, value):
|
||||
cdef StringPtr temp_string
|
||||
if type(value) is bytes:
|
||||
temp_string = StringPtr(<char*>value, len(value))
|
||||
else:
|
||||
encoded_value = value.encode('utf-8')
|
||||
temp_string = StringPtr(<char*>encoded_value, len(encoded_value))
|
||||
self.thisptr_child.set{{field.c_name}}(temp_string)
|
||||
{% elif 'data' == field['type'] -%}
|
||||
cpdef _set_{{field.name}}(self, value):
|
||||
cdef StringPtr temp_string
|
||||
if type(value) is bytes:
|
||||
temp_string = StringPtr(<char*>value, len(value))
|
||||
else:
|
||||
encoded_value = value.encode('utf-8')
|
||||
temp_string = StringPtr(<char*>encoded_value, len(encoded_value))
|
||||
self.thisptr_child.set{{field.c_name}}(ArrayPtr[byte](<byte *>temp_string.begin(), temp_string.size()))
|
||||
{% else -%}
|
||||
cpdef _set_{{field.name}}(self, value):
|
||||
_setDynamicFieldStatic(self.thisptr, "{{field.name}}", value, self._parent)
|
||||
{% endif -%}
|
||||
{%- endmacro %}
|
||||
|
||||
import capnp
|
||||
import {{file.filename | replace('.', '_')}}
|
||||
|
||||
from capnp.includes.types cimport *
|
||||
from capnp cimport helpers
|
||||
from capnp.includes.capnp_cpp cimport DynamicValue, Schema, VOID, StringPtr, ArrayPtr, Data
|
||||
from capnp.lib.capnp cimport _DynamicStructReader, _DynamicStructBuilder, _DynamicListBuilder, _DynamicEnum, _StructSchemaField, to_python_builder, to_python_reader, _to_dict, _setDynamicFieldStatic, _Schema, _InterfaceSchema
|
||||
|
||||
from capnp.helpers.non_circular cimport reraise_kj_exception
|
||||
|
||||
cdef DynamicValue.Reader _extract_dynamic_struct_builder(_DynamicStructBuilder value):
|
||||
return DynamicValue.Reader(value.thisptr.asReader())
|
||||
|
||||
cdef DynamicValue.Reader _extract_dynamic_struct_reader(_DynamicStructReader value):
|
||||
return DynamicValue.Reader(value.thisptr)
|
||||
|
||||
cdef DynamicValue.Reader _extract_dynamic_enum(_DynamicEnum value):
|
||||
return DynamicValue.Reader(value.thisptr)
|
||||
|
||||
cdef _from_list(_DynamicListBuilder msg, list d):
|
||||
cdef size_t count = 0
|
||||
for val in d:
|
||||
msg._set(count, val)
|
||||
count += 1
|
||||
|
||||
|
||||
cdef extern from "{{file.filename}}.h":
|
||||
{%- for node in code.nodes %}
|
||||
Schema get{{node.module_name}}Schema"capnp::Schema::from<{{node.c_module_path}}>"()
|
||||
|
||||
cdef cppclass {{node.module_name}}"{{node.c_module_path}}":
|
||||
cppclass Reader:
|
||||
{%- for field in node.struct.fields %}
|
||||
{{ getter(field, "Reader")|indent(12)}}
|
||||
{%- endfor %}
|
||||
cppclass Builder:
|
||||
{%- for field in node.struct.fields %}
|
||||
{{ getter(field, "Builder")|indent(12)}}
|
||||
{{ setter(field)|indent(12)}}
|
||||
{%- endfor %}
|
||||
{%- endfor %}
|
||||
|
||||
cdef cppclass C_DynamicStruct_Reader" ::capnp::DynamicStruct::Reader":
|
||||
{%- for node in code.nodes %}
|
||||
{{node.module_name}}.Reader as{{node.module_name}}"as<{{node.c_module_path}}>"()
|
||||
{%- endfor %}
|
||||
|
||||
cdef cppclass C_DynamicStruct_Builder" ::capnp::DynamicStruct::Builder":
|
||||
{%- for node in code.nodes %}
|
||||
{{node.module_name}}.Builder as{{node.module_name}}"as<{{node.c_module_path}}>"()
|
||||
{%- endfor %}
|
||||
|
||||
{%- for node in code.nodes %}
|
||||
|
||||
{{node.schema}} = _Schema()._init(get{{node.module_name}}Schema()).as_struct()
|
||||
{{node.module_path}}.schema = {{node.schema}}
|
||||
|
||||
cdef class {{node.module_name}}_Reader(_DynamicStructReader):
|
||||
cdef {{node.module_name}}.Reader thisptr_child
|
||||
def __init__(self, _DynamicStructReader struct):
|
||||
self._init(struct.thisptr, struct._parent, struct.is_root, False)
|
||||
self.thisptr_child = (<C_DynamicStruct_Reader>struct.thisptr).as{{node.module_name}}()
|
||||
{% for field in node.struct.fields %}
|
||||
|
||||
{{ getfield(field, "Reader")|indent(4) }}
|
||||
|
||||
property {{field.name}}:
|
||||
def __get__(self):
|
||||
return self._get_{{field.name}}()
|
||||
{%- endfor %}
|
||||
|
||||
def to_dict(self, verbose=False, ordered=False):
|
||||
ret = {
|
||||
{% for field in node.struct.fields %}
|
||||
{% if field.discriminantValue == 65535 %}
|
||||
'{{field.name}}': _to_dict(self.{{field.name}}, verbose, ordered),
|
||||
{% endif %}
|
||||
{%- endfor %}
|
||||
}
|
||||
|
||||
{% if node.is_union %}
|
||||
which = self._which_str()
|
||||
ret[which] = getattr(self, which)
|
||||
{% endif %}
|
||||
|
||||
return ret
|
||||
|
||||
cdef class {{node.module_name}}_Builder(_DynamicStructBuilder):
|
||||
cdef {{node.module_name}}.Builder thisptr_child
|
||||
def __init__(self, _DynamicStructBuilder struct):
|
||||
self._init(struct.thisptr, struct._parent, struct.is_root, False)
|
||||
self.thisptr_child = (<C_DynamicStruct_Builder>struct.thisptr).as{{node.module_name}}()
|
||||
{% for field in node.struct.fields %}
|
||||
{{ getfield(field, "Builder")|indent(4) }}
|
||||
{{ setfield(field)|indent(4) }}
|
||||
|
||||
property {{field.name}}:
|
||||
def __get__(self):
|
||||
return self._get_{{field.name}}()
|
||||
def __set__(self, value):
|
||||
self._set_{{field.name}}(value)
|
||||
{%- endfor %}
|
||||
|
||||
def to_dict(self, verbose=False, ordered=False):
|
||||
ret = {
|
||||
{% for field in node.struct.fields %}
|
||||
{% if field.discriminantValue == 65535 %}
|
||||
'{{field.name}}': _to_dict(self.{{field.name}}, verbose, ordered),
|
||||
{% endif %}
|
||||
{%- endfor %}
|
||||
}
|
||||
|
||||
{% if node.is_union %}
|
||||
which = self._which_str()
|
||||
ret[which] = getattr(self, which)
|
||||
{% endif %}
|
||||
|
||||
return ret
|
||||
|
||||
def from_dict(self, dict d):
|
||||
cdef str key
|
||||
for key, val in d.iteritems():
|
||||
if False: pass
|
||||
{% for field in node.struct.fields %}
|
||||
elif key == "{{field.name}}":
|
||||
try:
|
||||
self._set_{{field.name}}(val)
|
||||
except Exception as e:
|
||||
if 'expected isSetInUnion(field)' in str(e):
|
||||
self.init(key)
|
||||
self._set_{{field.name}}(val)
|
||||
else:
|
||||
raise
|
||||
{%- endfor %}
|
||||
else:
|
||||
raise ValueError('Key not found in struct: ' + key)
|
||||
|
||||
|
||||
capnp.register_type({{node.id}}, ({{node.module_name}}_Reader, {{node.module_name}}_Builder))
|
||||
{% endfor %}
|
||||
@@ -1,38 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
from distutils.core import setup
|
||||
from Cython.Build import cythonize
|
||||
from shutil import copyfile
|
||||
import os
|
||||
import re
|
||||
|
||||
|
||||
files = [{% for f in code.requestedFiles %}"{{f.filename}}", {% endfor %}]
|
||||
|
||||
for f in files:
|
||||
cpp_file = f + '.cpp'
|
||||
cplus_file = f + '.c++'
|
||||
cpp_mod = 0
|
||||
try:
|
||||
cpp_mod = os.path.getmtime(cpp_file)
|
||||
except:
|
||||
pass
|
||||
cplus_mod = 0
|
||||
try:
|
||||
cplus_mod = os.path.getmtime(cplus_file)
|
||||
except:
|
||||
pass
|
||||
if not os.path.exists(cpp_file) or cpp_mod < cplus_mod:
|
||||
if not os.path.exists(cplus_file):
|
||||
raise RuntimeError("You need to run `capnp compile -oc++` in addition to `-ocython` first.")
|
||||
copyfile(cplus_file, cpp_file)
|
||||
|
||||
with open(f + '.h', "r") as file:
|
||||
lines = file.readlines()
|
||||
with open(f + '.h', "w") as file:
|
||||
for line in lines:
|
||||
file.write(re.sub(r'Builder\(\)\s*=\s*delete;', 'Builder() = default;', line))
|
||||
|
||||
setup(
|
||||
name="{{code.requestedFiles[0] | replace('.', '_')}}",
|
||||
ext_modules=cythonize('*_capnp_cython.pyx', language="c++")
|
||||
)
|
||||
Reference in New Issue
Block a user