Fix build for Cython 0.21
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
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, EnumSchema as C_EnumSchema, DynamicStruct as C_DynamicStruct, 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, PyPromise, VoidPromise, CallContext, PyRestorer, RpcSystem, makeRpcServer, makeRpcClient, Capability as C_Capability, TwoPartyVatNetwork as C_TwoPartyVatNetwork, Side, AsyncIoStream, Own, makeTwoPartyVatNetwork, PromiseFulfillerPair as C_PromiseFulfillerPair, copyPromiseFulfillerPair, newPromiseAndFulfiller, PyArray, DynamicStruct_Builder
|
||||
from .capnp.includes.schema_cpp cimport Node as C_Node, EnumNode as C_EnumNode
|
||||
from .capnp.includes.types cimport *
|
||||
from .capnp.helpers.non_circular cimport reraise_kj_exception
|
||||
from .capnp.helpers cimport helpers
|
||||
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, EnumSchema as C_EnumSchema, DynamicStruct as C_DynamicStruct, 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, PyPromise, VoidPromise, CallContext, PyRestorer, RpcSystem, makeRpcServer, makeRpcClient, Capability as C_Capability, TwoPartyVatNetwork as C_TwoPartyVatNetwork, Side, AsyncIoStream, Own, makeTwoPartyVatNetwork, PromiseFulfillerPair as C_PromiseFulfillerPair, copyPromiseFulfillerPair, newPromiseAndFulfiller, PyArray, DynamicStruct_Builder
|
||||
from capnp.includes.schema_cpp cimport Node as C_Node, EnumNode as C_EnumNode
|
||||
from capnp.includes.types cimport *
|
||||
from capnp.helpers.non_circular cimport reraise_kj_exception
|
||||
from capnp.helpers cimport helpers
|
||||
|
||||
cdef class _DynamicStructReader:
|
||||
cdef C_DynamicStruct.Reader thisptr
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
cimport cython
|
||||
|
||||
from .capnp.helpers.helpers cimport makeRpcClientWithRestorer
|
||||
from capnp.helpers.helpers cimport makeRpcClientWithRestorer
|
||||
|
||||
from libc.stdlib cimport malloc, free
|
||||
from cython.operator cimport dereference as deref
|
||||
@@ -100,7 +100,7 @@ cdef public VoidPromise * call_server_method(PyObject * _server, char * _method_
|
||||
setattr(results, arg_name, arg_val)
|
||||
|
||||
return NULL
|
||||
|
||||
|
||||
cdef public C_Capability.Client * call_py_restorer(PyObject * _restorer, C_DynamicObject.Reader & _reader) except *:
|
||||
restorer = <object>_restorer
|
||||
reader = _DynamicObjectReader()._init(_reader, None)
|
||||
@@ -149,13 +149,13 @@ def _make_enum(enum_name, *sequential, **named):
|
||||
enums['reverse_mapping'] = reverse
|
||||
return type(enum_name, (), enums)
|
||||
|
||||
_Nature = _make_enum('_Nature',
|
||||
_Nature = _make_enum('_Nature',
|
||||
PRECONDITION = 0,
|
||||
LOCAL_BUG = 1,
|
||||
OS_ERROR = 2,
|
||||
NETWORK_FAILURE = 3,
|
||||
OTHER = 4)
|
||||
_Durability = _make_enum('_Durability',
|
||||
_Durability = _make_enum('_Durability',
|
||||
PERMANENT = 0,
|
||||
TEMPORARY = 1,
|
||||
OVERLOADED = 2)
|
||||
@@ -207,7 +207,7 @@ class KjException(Exception):
|
||||
self.message = message
|
||||
self.nature = nature
|
||||
self.durability = durability
|
||||
|
||||
|
||||
@property
|
||||
def file(self):
|
||||
return self.wrapper.file
|
||||
@@ -246,7 +246,7 @@ cdef public object wrap_kj_exception(capnp.Exception & exception):
|
||||
cdef public object wrap_kj_exception_for_reraise(capnp.Exception & exception):
|
||||
wrapper = _KjExceptionWrapper()._init(exception)
|
||||
wrapper_msg = str(wrapper)
|
||||
|
||||
|
||||
nature = wrapper.nature
|
||||
|
||||
if wrapper.nature == 'PRECONDITION':
|
||||
@@ -415,7 +415,7 @@ cdef class _DynamicResizableListBuilder:
|
||||
person = addressbook.Person.new_message()
|
||||
|
||||
phones = person.init_resizable_list('phones') # This returns a _DynamicResizableListBuilder
|
||||
|
||||
|
||||
phone = phones.add()
|
||||
phone.number = 'foo'
|
||||
phone = phones.add()
|
||||
@@ -447,7 +447,7 @@ cdef class _DynamicResizableListBuilder:
|
||||
orphan_val = orphan.get()
|
||||
self._list.append((orphan, orphan_val))
|
||||
return orphan_val
|
||||
|
||||
|
||||
def __getitem__(self, index):
|
||||
return self._list[index][1]
|
||||
|
||||
@@ -477,7 +477,7 @@ cdef class _DynamicListBuilder:
|
||||
person = addressbook.Person.new_message()
|
||||
|
||||
phones = person.init('phones', 2) # This returns a _DynamicListBuilder
|
||||
|
||||
|
||||
phone = phones[0]
|
||||
phone.number = 'foo'
|
||||
phone = phones[1]
|
||||
@@ -942,7 +942,7 @@ cdef class _DynamicStructBuilder:
|
||||
This class is almost a 1 for 1 wrapping of the Cap'n Proto C++ DynamicStruct::Builder. The only difference is that instead of a `get`/`set` method, __getattr__/__setattr__ is overloaded and the field name is passed onto the C++ equivalent function. This means you just use . syntax to access or set any field. For field names that don't follow valid python naming convention for fields, use the global functions :py:func:`getattr`/:py:func:`setattr`::
|
||||
|
||||
person = addressbook.Person.new_message() # This returns a _DynamicStructBuilder
|
||||
|
||||
|
||||
person.name = 'foo' # using . syntax
|
||||
print person.name # using . syntax
|
||||
|
||||
@@ -968,15 +968,15 @@ cdef class _DynamicStructBuilder:
|
||||
|
||||
def write(self, file):
|
||||
"""Writes the struct's containing message to the given file object in unpacked binary format.
|
||||
|
||||
|
||||
This is a shortcut for calling capnp._write_message_to_fd(). This can only be called on the
|
||||
message's root struct.
|
||||
|
||||
|
||||
:type file: file
|
||||
:param file: A file or socket object (or anything with a fileno() method), open for write.
|
||||
|
||||
|
||||
:rtype: void
|
||||
|
||||
|
||||
:Raises: :exc:`exceptions.ValueError` if this isn't the message's root struct.
|
||||
"""
|
||||
self._check_write()
|
||||
@@ -985,15 +985,15 @@ cdef class _DynamicStructBuilder:
|
||||
|
||||
def write_packed(self, file):
|
||||
"""Writes the struct's containing message to the given file object in packed binary format.
|
||||
|
||||
|
||||
This is a shortcut for calling capnp._write_packed_message_to_fd(). This can only be called on
|
||||
the message's root struct.
|
||||
|
||||
|
||||
:type file: file
|
||||
:param file: A file or socket object (or anything with a fileno() method), open for write.
|
||||
|
||||
|
||||
:rtype: void
|
||||
|
||||
|
||||
:Raises: :exc:`exceptions.ValueError` if this isn't the message's root struct.
|
||||
"""
|
||||
self._check_write()
|
||||
@@ -1044,7 +1044,7 @@ cdef class _DynamicStructBuilder:
|
||||
cdef C_DynamicValue.Builder value = self.thisptr.get(field)
|
||||
|
||||
return to_python_builder(value, self._parent)
|
||||
|
||||
|
||||
def __getattr__(self, field):
|
||||
return self._get(field)
|
||||
|
||||
@@ -1060,7 +1060,7 @@ cdef class _DynamicStructBuilder:
|
||||
cpdef init(self, field, size=None):
|
||||
"""Method for initializing fields that are of type union/struct/list
|
||||
|
||||
Typically, you don't have to worry about initializing structs/unions, so this method is mainly for lists.
|
||||
Typically, you don't have to worry about initializing structs/unions, so this method is mainly for lists.
|
||||
|
||||
:type field: str
|
||||
:param field: The field name to initialize
|
||||
@@ -1080,7 +1080,7 @@ cdef class _DynamicStructBuilder:
|
||||
cpdef init_resizable_list(self, field):
|
||||
"""Method for initializing fields that are of type list (of structs)
|
||||
|
||||
This version of init returns a :class:`_DynamicResizableListBuilder` that allows you to add members one at a time (ie. if you don't know the size for sure). This is only meant for lists of Cap'n Proto objects, since for primitive types you can just define a normal python list and fill it yourself.
|
||||
This version of init returns a :class:`_DynamicResizableListBuilder` that allows you to add members one at a time (ie. if you don't know the size for sure). This is only meant for lists of Cap'n Proto objects, since for primitive types you can just define a normal python list and fill it yourself.
|
||||
|
||||
.. warning:: You need to call :meth:`_DynamicResizableListBuilder.finish` on the list object before serializing the Cap'n Proto message. Failure to do so will cause your objects not to be written out as well as leaking orphan structs into your message.
|
||||
|
||||
@@ -1854,7 +1854,7 @@ cdef class TwoPartyClient:
|
||||
return sock
|
||||
|
||||
cpdef restore(self, objectId) except +reraise_kj_exception:
|
||||
cdef _MessageBuilder builder
|
||||
cdef _MessageBuilder builder
|
||||
cdef _MessageReader reader
|
||||
cdef _DynamicObjectBuilder object_builder
|
||||
cdef _DynamicObjectReader object_reader
|
||||
@@ -2191,7 +2191,7 @@ class _StructModule(object):
|
||||
if field.which() == 'group':
|
||||
name = field.name.capitalize()
|
||||
union_schema = schema.get_dependency(field.group.typeId).node.struct
|
||||
|
||||
|
||||
if union_schema.discriminantCount == 0:
|
||||
continue
|
||||
|
||||
@@ -2206,7 +2206,7 @@ class _StructModule(object):
|
||||
|
||||
:type file: file
|
||||
:param file: A python file-like object. It must be a "real" file, with a `fileno()` method.
|
||||
|
||||
|
||||
:type traversal_limit_in_words: int
|
||||
:param traversal_limit_in_words: Limits how many total words of data are allowed to be traversed. Is actually a uint64_t, and values can be up to 2^64-1. Default is 8*1024*1024.
|
||||
|
||||
@@ -2221,7 +2221,7 @@ class _StructModule(object):
|
||||
|
||||
:type file: file
|
||||
:param file: A python file-like object. It must be a "real" file, with a `fileno()` method.
|
||||
|
||||
|
||||
:type traversal_limit_in_words: int
|
||||
:param traversal_limit_in_words: Limits how many total words of data are allowed to be traversed. Is actually a uint64_t, and values can be up to 2^64-1. Default is 8*1024*1024.
|
||||
|
||||
@@ -2236,7 +2236,7 @@ class _StructModule(object):
|
||||
|
||||
:type file: file
|
||||
:param file: A python file-like object. It must be a "real" file, with a `fileno()` method.
|
||||
|
||||
|
||||
:type traversal_limit_in_words: int
|
||||
:param traversal_limit_in_words: Limits how many total words of data are allowed to be traversed. Is actually a uint64_t, and values can be up to 2^64-1. Default is 8*1024*1024.
|
||||
|
||||
@@ -2251,7 +2251,7 @@ class _StructModule(object):
|
||||
|
||||
:type file: file
|
||||
:param file: A python file-like object. It must be a "real" file, with a `fileno()` method.
|
||||
|
||||
|
||||
:type traversal_limit_in_words: int
|
||||
:param traversal_limit_in_words: Limits how many total words of data are allowed to be traversed. Is actually a uint64_t, and values can be up to 2^64-1. Default is 8*1024*1024.
|
||||
|
||||
@@ -2266,7 +2266,7 @@ class _StructModule(object):
|
||||
|
||||
:type buf: buffer
|
||||
:param buf: Any Python object that supports the buffer interface.
|
||||
|
||||
|
||||
:type traversal_limit_in_words: int
|
||||
:param traversal_limit_in_words: Limits how many total words of data are allowed to be traversed. Is actually a uint64_t, and values can be up to 2^64-1. Default is 8*1024*1024.
|
||||
|
||||
@@ -2290,7 +2290,7 @@ class _StructModule(object):
|
||||
|
||||
:type buf: buffer
|
||||
:param buf: Any Python object that supports the readable buffer interface.
|
||||
|
||||
|
||||
:type traversal_limit_in_words: int
|
||||
:param traversal_limit_in_words: Limits how many total words of data are allowed to be traversed. Is actually a uint64_t, and values can be up to 2^64-1. Default is 8*1024*1024.
|
||||
|
||||
@@ -2372,7 +2372,7 @@ cdef class SchemaParser:
|
||||
return ret
|
||||
|
||||
def load(self, file_name, display_name=None, imports=[]):
|
||||
"""Load a Cap'n Proto schema from a file
|
||||
"""Load a Cap'n Proto schema from a file
|
||||
|
||||
You will have to load a schema before you can begin doing anything
|
||||
meaningful with this library. Loading a schema is much like loading
|
||||
@@ -2538,7 +2538,7 @@ cdef class _MessageBuilder:
|
||||
:return: An AnyPointer that you can set fields in
|
||||
"""
|
||||
return _DynamicObjectBuilder()._init(self.thisptr.getRootAnyPointer(), self)
|
||||
|
||||
|
||||
cpdef set_root(self, value) except +reraise_kj_exception:
|
||||
"""A method for instantiating Cap'n Proto structs by copying from an existing struct
|
||||
|
||||
@@ -2694,7 +2694,7 @@ cdef class _PackedMessageReader(_MessageReader):
|
||||
opts.traversalLimitInWords = traversal_limit_in_words
|
||||
if nesting_limit is not None:
|
||||
opts.nestingLimit = nesting_limit
|
||||
|
||||
|
||||
self.thisptr = new schema_cpp.PackedMessageReader(stream, opts)
|
||||
return self
|
||||
|
||||
@@ -2711,13 +2711,13 @@ cdef class _PackedMessageReaderBytes(_MessageReader):
|
||||
opts.traversalLimitInWords = traversal_limit_in_words
|
||||
if nesting_limit is not None:
|
||||
opts.nestingLimit = nesting_limit
|
||||
|
||||
|
||||
cdef const void *ptr
|
||||
cdef Py_ssize_t sz
|
||||
PyObject_AsReadBuffer(buf, &ptr, &sz)
|
||||
|
||||
self.stream = new schema_cpp.ArrayInputStream(schema_cpp.ByteArrayPtr(<byte *>ptr, sz))
|
||||
|
||||
|
||||
self.thisptr = new schema_cpp.PackedMessageReader(deref(self.stream), opts)
|
||||
|
||||
def __dealloc__(self):
|
||||
@@ -2748,7 +2748,7 @@ cdef class _InputMessageReader(_MessageReader):
|
||||
opts.traversalLimitInWords = traversal_limit_in_words
|
||||
if nesting_limit is not None:
|
||||
opts.nestingLimit = nesting_limit
|
||||
|
||||
|
||||
self.thisptr = new schema_cpp.InputStreamMessageReader(stream, opts)
|
||||
return self
|
||||
|
||||
@@ -2771,7 +2771,7 @@ cdef class _PackedFdMessageReader(_MessageReader):
|
||||
opts.traversalLimitInWords = traversal_limit_in_words
|
||||
if nesting_limit is not None:
|
||||
opts.nestingLimit = nesting_limit
|
||||
|
||||
|
||||
self.thisptr = new schema_cpp.PackedFdMessageReader(fd, opts)
|
||||
|
||||
cdef class _MultipleMessageReader:
|
||||
@@ -2784,7 +2784,7 @@ cdef class _MultipleMessageReader:
|
||||
self.schema = schema
|
||||
self.traversal_limit_in_words = traversal_limit_in_words
|
||||
self.nesting_limit = nesting_limit
|
||||
|
||||
|
||||
self.stream = new schema_cpp.FdInputStream(fd)
|
||||
self.buffered_stream = new schema_cpp.BufferedInputStreamWrapper(deref(self.stream))
|
||||
|
||||
@@ -2815,7 +2815,7 @@ cdef class _MultiplePackedMessageReader:
|
||||
self.schema = schema
|
||||
self.traversal_limit_in_words = traversal_limit_in_words
|
||||
self.nesting_limit = nesting_limit
|
||||
|
||||
|
||||
self.stream = new schema_cpp.FdInputStream(fd)
|
||||
self.buffered_stream = new schema_cpp.BufferedInputStreamWrapper(deref(self.stream))
|
||||
|
||||
@@ -2846,7 +2846,7 @@ cdef class _FlatArrayMessageReader(_MessageReader):
|
||||
opts.traversalLimitInWords = traversal_limit_in_words
|
||||
if nesting_limit is not None:
|
||||
opts.nestingLimit = nesting_limit
|
||||
|
||||
|
||||
cdef const void *ptr
|
||||
cdef Py_ssize_t sz
|
||||
PyObject_AsReadBuffer(buf, &ptr, &sz)
|
||||
@@ -2937,7 +2937,7 @@ def _write_packed_message_to_fd(int fd, _MessageBuilder message):
|
||||
_global_schema_parser = None
|
||||
|
||||
def load(file_name, display_name=None, imports=[]):
|
||||
"""Load a Cap'n Proto schema from a file
|
||||
"""Load a Cap'n Proto schema from a file
|
||||
|
||||
You will have to load a schema before you can begin doing anything
|
||||
meaningful with this library. Loading a schema is much like loading
|
||||
|
||||
Reference in New Issue
Block a user