diff --git a/capnp/includes/capnp_cpp.pxd b/capnp/includes/capnp_cpp.pxd index a1bb81c..bf5426b 100644 --- a/capnp/includes/capnp_cpp.pxd +++ b/capnp/includes/capnp_cpp.pxd @@ -6,11 +6,7 @@ cdef extern from "../helpers/checkCompiler.h": 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 libc.stdint cimport * -ctypedef unsigned int uint -from libcpp cimport bool as cbool +from .capnp.includes.types cimport * cdef extern from "kj/async.h" namespace " ::kj": cdef cppclass Promise[T]: diff --git a/capnp/includes/schema_cpp.pxd b/capnp/includes/schema_cpp.pxd index 122bdc6..2a6932a 100644 --- a/capnp/includes/schema_cpp.pxd +++ b/capnp/includes/schema_cpp.pxd @@ -6,21 +6,8 @@ from libc.stdint cimport * from capnp_cpp cimport DynamicOrphan from .capnp.helpers.non_circular cimport reraise_kj_exception -ctypedef unsigned int uint -ctypedef uint8_t byte -ctypedef uint8_t UInt8 -ctypedef uint16_t UInt16 -ctypedef uint32_t UInt32 -ctypedef uint64_t UInt64 -ctypedef int8_t Int8 -ctypedef int16_t Int16 -ctypedef int32_t Int32 -ctypedef int64_t Int64 -ctypedef char * Object -ctypedef bint Bool -ctypedef float Float32 -ctypedef double Float64 +from .capnp.includes.types cimport * cdef extern from "capnp/dynamic.h" namespace " ::capnp": cdef cppclass DynamicValue: diff --git a/capnp/includes/types.pxd b/capnp/includes/types.pxd new file mode 100644 index 0000000..10567ce --- /dev/null +++ b/capnp/includes/types.pxd @@ -0,0 +1,19 @@ +from cpython.ref cimport PyObject, Py_INCREF, Py_DECREF +from cpython.exc cimport PyErr_Clear +from libc.stdint cimport * +ctypedef unsigned int uint +ctypedef uint8_t byte +ctypedef uint8_t UInt8 +ctypedef uint16_t UInt16 +ctypedef uint32_t UInt32 +ctypedef uint64_t UInt64 +ctypedef int8_t Int8 +ctypedef int16_t Int16 +ctypedef int32_t Int32 +ctypedef int64_t Int64 + +ctypedef char * Object +ctypedef bint Bool +ctypedef float Float32 +ctypedef double Float64 +from libcpp cimport bool as cbool \ No newline at end of file diff --git a/capnp/lib/capnp.pxd b/capnp/lib/capnp.pxd new file mode 100644 index 0000000..1259ebc --- /dev/null +++ b/capnp/lib/capnp.pxd @@ -0,0 +1,17 @@ +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.includes.types cimport * + +cdef class _DynamicStructReader: + cdef C_DynamicStruct.Reader thisptr + cdef public object _parent + cdef public bint is_root + cdef object _obj_to_pin + + cdef _init(self, C_DynamicStruct.Reader other, object parent, bint isRoot=?) + + cpdef which(self) + + cpdef as_builder(self) \ No newline at end of file diff --git a/capnp/lib/capnp.pyx b/capnp/lib/capnp.pyx index db6ada4..52fb6e0 100644 --- a/capnp/lib/capnp.pyx +++ b/capnp/lib/capnp.pyx @@ -8,37 +8,10 @@ cimport cython -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 cpython.ref cimport PyObject, Py_INCREF, Py_DECREF -from cpython.exc cimport PyErr_Clear -from libc.stdint cimport * -ctypedef unsigned int uint -ctypedef uint8_t byte -ctypedef uint8_t UInt8 -ctypedef uint16_t UInt16 -ctypedef uint32_t UInt32 -ctypedef uint64_t UInt64 -ctypedef int8_t Int8 -ctypedef int16_t Int16 -ctypedef int32_t Int32 -ctypedef int64_t Int64 - -ctypedef char * Object -ctypedef bint Bool -ctypedef float Float32 -ctypedef double Float64 from libc.stdlib cimport malloc, free -from libcpp cimport bool as cbool +from cython.operator cimport dereference as deref from types import ModuleType as _ModuleType import os as _os @@ -761,11 +734,6 @@ cdef class _DynamicStructReader: print person.name # using . syntax print getattr(person, 'field-with-hyphens') # for names that are invalid for python, use getattr """ - cdef C_DynamicStruct.Reader thisptr - cdef public object _parent - cdef public bint is_root - cdef object _obj_to_pin - cdef _init(self, C_DynamicStruct.Reader other, object parent, bint isRoot=False): self.thisptr = other self._parent = parent diff --git a/tox.ini b/tox.ini index 052d760..54b3276 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py26,py27,py32,py33 +envlist = py27,py32,py33 [testenv] deps=