Refactor layout of pxd files
This commit is contained in:
0
capnp/__init__.pxd
Normal file
0
capnp/__init__.pxd
Normal file
@@ -7,11 +7,16 @@
|
|||||||
# cython: embedsignature = True
|
# cython: embedsignature = True
|
||||||
|
|
||||||
cimport cython
|
cimport cython
|
||||||
cimport capnp_cpp as capnp
|
|
||||||
cimport schema_cpp
|
|
||||||
from capnp_cpp cimport Schema as C_Schema, StructSchema as C_StructSchema, InterfaceSchema as C_InterfaceSchema, DynamicStruct as C_DynamicStruct, DynamicValue as C_DynamicValue, Type as C_Type, DynamicList as C_DynamicList, fixMaybe, getEnumString, 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, new_client, new_server, server_to_client, Request, Response, RemotePromise, convert_to_pypromise, PyPromise, VoidPromise, CallContext, PyRestorer, RpcSystem, makeRpcServer, makeRpcClient, makeRpcClientWithRestorer, restoreHelper, Capability as C_Capability, TwoPartyVatNetwork as C_TwoPartyVatNetwork, Side, AsyncIoStream, Own, makeTwoPartyVatNetwork, PromiseFulfillerPair as C_PromiseFulfillerPair, copyPromiseFulfillerPair, newPromiseAndFulfiller, reraise_kj_exception
|
|
||||||
|
|
||||||
from schema_cpp cimport Node as C_Node, EnumNode as C_EnumNode
|
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, DynamicStruct as C_DynamicStruct, DynamicValue as C_DynamicValue, Type as C_Type, DynamicList as C_DynamicList, fixMaybe, getEnumString, 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, new_client, new_server, server_to_client, Request, Response, RemotePromise, convert_to_pypromise, PyPromise, VoidPromise, CallContext, PyRestorer, RpcSystem, makeRpcServer, makeRpcClient, restoreHelper, Capability as C_Capability, TwoPartyVatNetwork as C_TwoPartyVatNetwork, Side, AsyncIoStream, Own, makeTwoPartyVatNetwork, PromiseFulfillerPair as C_PromiseFulfillerPair, copyPromiseFulfillerPair, newPromiseAndFulfiller, reraise_kj_exception
|
||||||
|
from .capnp.includes.schema_cpp cimport Node as C_Node, EnumNode as C_EnumNode
|
||||||
|
|
||||||
|
from .capnp.helpers.helpers cimport makeRpcClientWithRestorer
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
from cython.operator cimport dereference as deref
|
from cython.operator cimport dereference as deref
|
||||||
|
|
||||||
from cpython.ref cimport PyObject, Py_INCREF, Py_DECREF
|
from cpython.ref cimport PyObject, Py_INCREF, Py_DECREF
|
||||||
|
|||||||
0
capnp/helpers/__init__.pxd
Normal file
0
capnp/helpers/__init__.pxd
Normal file
11
capnp/helpers/checkCompiler.h
Normal file
11
capnp/helpers/checkCompiler.h
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#ifdef __GNUC__
|
||||||
|
#if __clang__
|
||||||
|
#if __cplusplus >= 201103L && !__has_include(<initializer_list>)
|
||||||
|
#warning "Your compiler supports C++11 but your C++ standard library does not. If your system has libc++ installed (as should be the case on e.g. Mac OSX), try adding -stdlib=libc++ to your CFLAGS (ignore the other warning that says to use CXXFLAGS)."
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "capnp/dynamic.h"
|
||||||
|
|
||||||
|
static_assert(CAPNP_VERSION >= 3000, "Version of Cap'n Proto C++ Library is too old. Please upgrade to a version >= 0.3 and then re-install this python library");
|
||||||
@@ -1,8 +1,6 @@
|
|||||||
#include "kj/common.h"
|
#include "kj/common.h"
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
static_assert(CAPNP_VERSION >= 3000, "Version of Cap'n Proto C++ Library is too old. Please upgrade to a version >= 0.3 and then re-install this python library");
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
T fixMaybe(::kj::Maybe<T> val) {
|
T fixMaybe(::kj::Maybe<T> val) {
|
||||||
KJ_IF_MAYBE(new_val, val) {
|
KJ_IF_MAYBE(new_val, val) {
|
||||||
29
capnp/helpers/helpers.pxd
Normal file
29
capnp/helpers/helpers.pxd
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
from .capnp.includes.capnp_cpp cimport Maybe, DynamicStruct, Request, PyPromise, VoidPromise, RemotePromise, DynamicCapability, InterfaceSchema, EnumSchema, StructSchema, DynamicValue, Capability, RpcSystem, MessageBuilder, MessageReader, TwoPartyVatNetwork
|
||||||
|
|
||||||
|
from non_circular cimport reraise_kj_exception
|
||||||
|
|
||||||
|
from cpython.ref cimport PyObject
|
||||||
|
|
||||||
|
cdef extern from "helpers/fixMaybe.h":
|
||||||
|
EnumSchema.Enumerant fixMaybe(Maybe[EnumSchema.Enumerant]) except +reraise_kj_exception
|
||||||
|
char * getEnumString(DynamicStruct.Reader val)
|
||||||
|
char * getEnumString(DynamicStruct.Builder val)
|
||||||
|
char * getEnumString(Request val)
|
||||||
|
|
||||||
|
cdef extern from "helpers/capabilityHelper.h":
|
||||||
|
# PyPromise evalLater(EventLoop &, PyObject * func)
|
||||||
|
# PyPromise there(EventLoop & loop, PyPromise & promise, PyObject * func, PyObject * error_func)
|
||||||
|
PyPromise then(PyPromise & promise, PyObject * func, PyObject * error_func)
|
||||||
|
VoidPromise then(RemotePromise & promise, PyObject * func, PyObject * error_func)
|
||||||
|
PyPromise then(VoidPromise & promise, PyObject * func, PyObject * error_func)
|
||||||
|
DynamicCapability.Client new_client(InterfaceSchema&, PyObject *)
|
||||||
|
DynamicValue.Reader new_server(InterfaceSchema&, PyObject *)
|
||||||
|
Capability.Client server_to_client(InterfaceSchema&, PyObject *)
|
||||||
|
PyPromise convert_to_pypromise(RemotePromise&)
|
||||||
|
|
||||||
|
cdef extern from "helpers/rpcHelper.h":
|
||||||
|
cdef cppclass PyRestorer:
|
||||||
|
PyRestorer(PyObject *, StructSchema&)
|
||||||
|
Capability.Client restoreHelper(RpcSystem&, MessageBuilder&)
|
||||||
|
Capability.Client restoreHelper(RpcSystem&, MessageReader&)
|
||||||
|
RpcSystem makeRpcClientWithRestorer(TwoPartyVatNetwork&, PyRestorer&)
|
||||||
8
capnp/helpers/non_circular.pxd
Normal file
8
capnp/helpers/non_circular.pxd
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
from cpython.ref cimport PyObject
|
||||||
|
|
||||||
|
cdef extern from "helpers/capabilityHelper.h":
|
||||||
|
cppclass PythonInterfaceDynamicImpl:
|
||||||
|
PythonInterfaceDynamicImpl(PyObject *)
|
||||||
|
|
||||||
|
cdef extern from "helpers/capabilityHelper.h":
|
||||||
|
void reraise_kj_exception()
|
||||||
0
capnp/includes/__init__.pxd
Normal file
0
capnp/includes/__init__.pxd
Normal file
@@ -1,7 +1,11 @@
|
|||||||
# schema.capnp.cpp.pyx
|
# schema.capnp.cpp.pyx
|
||||||
# distutils: language = c++
|
# distutils: language = c++
|
||||||
# distutils: extra_compile_args = --std=c++11
|
# distutils: extra_compile_args = --std=c++11
|
||||||
|
cdef extern from "helpers/checkCompiler.h":
|
||||||
|
pass
|
||||||
|
|
||||||
from schema_cpp cimport Node, Data, StructNode, EnumNode, InterfaceNode, MessageBuilder, MessageReader
|
from schema_cpp cimport Node, Data, StructNode, EnumNode, InterfaceNode, MessageBuilder, MessageReader
|
||||||
|
from .capnp.helpers.non_circular cimport PythonInterfaceDynamicImpl, reraise_kj_exception
|
||||||
|
|
||||||
from cpython.ref cimport PyObject
|
from cpython.ref cimport PyObject
|
||||||
from libc.stdint cimport *
|
from libc.stdint cimport *
|
||||||
@@ -17,9 +21,6 @@ cdef extern from "kj/async.h" namespace " ::kj":
|
|||||||
ctypedef Promise[PyObject *] PyPromise
|
ctypedef Promise[PyObject *] PyPromise
|
||||||
ctypedef Promise[void] VoidPromise
|
ctypedef Promise[void] VoidPromise
|
||||||
|
|
||||||
cdef extern from "capabilityHelper.h":
|
|
||||||
void reraise_kj_exception()
|
|
||||||
|
|
||||||
cdef extern from "capnp/common.h" namespace " ::capnp":
|
cdef extern from "capnp/common.h" namespace " ::capnp":
|
||||||
enum Void:
|
enum Void:
|
||||||
VOID " ::capnp::VOID"
|
VOID " ::capnp::VOID"
|
||||||
@@ -252,26 +253,24 @@ cdef extern from "capnp/any.h" namespace " ::capnp":
|
|||||||
Builder(Builder)
|
Builder(Builder)
|
||||||
DynamicStruct.Builder getAs"getAs< ::capnp::DynamicStruct>"(StructSchema)
|
DynamicStruct.Builder getAs"getAs< ::capnp::DynamicStruct>"(StructSchema)
|
||||||
|
|
||||||
cdef extern from "fixMaybe.h":
|
cdef extern from "helpers/fixMaybe.h":
|
||||||
EnumSchema.Enumerant fixMaybe(Maybe[EnumSchema.Enumerant]) except +reraise_kj_exception
|
EnumSchema.Enumerant fixMaybe(Maybe[EnumSchema.Enumerant]) except +reraise_kj_exception
|
||||||
char * getEnumString(DynamicStruct.Reader val)
|
char * getEnumString(DynamicStruct.Reader val)
|
||||||
char * getEnumString(DynamicStruct.Builder val)
|
char * getEnumString(DynamicStruct.Builder val)
|
||||||
char * getEnumString(Request val)
|
char * getEnumString(Request val)
|
||||||
|
|
||||||
cdef extern from "capabilityHelper.h":
|
cdef extern from "helpers/capabilityHelper.h":
|
||||||
# PyPromise evalLater(EventLoop &, PyObject * func)
|
# PyPromise evalLater(EventLoop &, PyObject * func)
|
||||||
# PyPromise there(EventLoop & loop, PyPromise & promise, PyObject * func, PyObject * error_func)
|
# PyPromise there(EventLoop & loop, PyPromise & promise, PyObject * func, PyObject * error_func)
|
||||||
PyPromise then(PyPromise & promise, PyObject * func, PyObject * error_func)
|
PyPromise then(PyPromise & promise, PyObject * func, PyObject * error_func)
|
||||||
VoidPromise then(RemotePromise & promise, PyObject * func, PyObject * error_func)
|
VoidPromise then(RemotePromise & promise, PyObject * func, PyObject * error_func)
|
||||||
PyPromise then(VoidPromise & promise, PyObject * func, PyObject * error_func)
|
PyPromise then(VoidPromise & promise, PyObject * func, PyObject * error_func)
|
||||||
cppclass PythonInterfaceDynamicImpl:
|
|
||||||
PythonInterfaceDynamicImpl(PyObject *)
|
|
||||||
DynamicCapability.Client new_client(InterfaceSchema&, PyObject *)
|
DynamicCapability.Client new_client(InterfaceSchema&, PyObject *)
|
||||||
DynamicValueForward.Reader new_server(InterfaceSchema&, PyObject *)
|
DynamicValueForward.Reader new_server(InterfaceSchema&, PyObject *)
|
||||||
Capability.Client server_to_client(InterfaceSchema&, PyObject *)
|
Capability.Client server_to_client(InterfaceSchema&, PyObject *)
|
||||||
PyPromise convert_to_pypromise(RemotePromise&)
|
PyPromise convert_to_pypromise(RemotePromise&)
|
||||||
|
|
||||||
cdef extern from "rpcHelper.h":
|
cdef extern from "helpers/rpcHelper.h":
|
||||||
cdef cppclass PyRestorer:
|
cdef cppclass PyRestorer:
|
||||||
PyRestorer(PyObject *, StructSchema&)
|
PyRestorer(PyObject *, StructSchema&)
|
||||||
Capability.Client restoreHelper(RpcSystem&, MessageBuilder&)
|
Capability.Client restoreHelper(RpcSystem&, MessageBuilder&)
|
||||||
@@ -718,7 +718,7 @@ cdef extern from "kj/array.h" namespace " ::kj":
|
|||||||
word* begin()
|
word* begin()
|
||||||
size_t size()
|
size_t size()
|
||||||
|
|
||||||
cdef extern from "capabilityHelper.h":
|
cdef extern from "helpers/capabilityHelper.h":
|
||||||
void reraise_kj_exception()
|
void reraise_kj_exception()
|
||||||
|
|
||||||
cdef extern from "kj/array.h" namespace " ::kj":
|
cdef extern from "kj/array.h" namespace " ::kj":
|
||||||
2
setup.py
2
setup.py
@@ -48,7 +48,7 @@ setup(
|
|||||||
name="pycapnp",
|
name="pycapnp",
|
||||||
packages=["capnp"],
|
packages=["capnp"],
|
||||||
version=VERSION,
|
version=VERSION,
|
||||||
package_data={'capnp': ['*.pxd', '*.pyx', '*.h']},
|
package_data={'capnp': ['*.pxd', '*.pyx', '*.h', 'helpers/*.pxd', 'helpers/*.h', 'includes/*.pxd']},
|
||||||
ext_modules=cythonize('capnp/*.pyx', language="c++"),
|
ext_modules=cythonize('capnp/*.pyx', language="c++"),
|
||||||
install_requires=[
|
install_requires=[
|
||||||
'cython > 0.19',
|
'cython > 0.19',
|
||||||
|
|||||||
Reference in New Issue
Block a user