From 3ece246f23bde6307d71ec420319eb870a527a7c Mon Sep 17 00:00:00 2001 From: Jason Paryani Date: Sat, 10 Aug 2013 13:54:25 -0700 Subject: [PATCH] Simplify code base Remove bootstrap directory as well as cython wrapping of the schema protocol. --- bootstrap/README.md | 1 - bootstrap/c++.capnp | 27 - bootstrap/capnp.tmpl.pxd | 128 --- bootstrap/capnp.tmpl.pyx | 223 ----- bootstrap/schema.capnp | 314 ------- bootstrap/setup.py | 261 ------ bootstrap/translate.py | 29 - capnp/capnp.pyx | 49 +- capnp/schema.pxd | 9 - capnp/schema.pyx | 1810 -------------------------------------- examples/example.py | 10 +- 11 files changed, 26 insertions(+), 2835 deletions(-) delete mode 100644 bootstrap/README.md delete mode 100644 bootstrap/c++.capnp delete mode 100644 bootstrap/capnp.tmpl.pxd delete mode 100644 bootstrap/capnp.tmpl.pyx delete mode 100644 bootstrap/schema.capnp delete mode 100644 bootstrap/setup.py delete mode 100644 bootstrap/translate.py delete mode 100644 capnp/schema.pxd delete mode 100644 capnp/schema.pyx diff --git a/bootstrap/README.md b/bootstrap/README.md deleted file mode 100644 index 5236270..0000000 --- a/bootstrap/README.md +++ /dev/null @@ -1 +0,0 @@ -Ignore this directory. It is for bootstrapping the compiler from capnpc -v. \ No newline at end of file diff --git a/bootstrap/c++.capnp b/bootstrap/c++.capnp deleted file mode 100644 index 90b3542..0000000 --- a/bootstrap/c++.capnp +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright (c) 2013, Kenton Varda -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright notice, this -# list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -@0xbdf87d7bb8304e81; -$namespace("capnproto::annotations"); - -annotation namespace(file): Text; diff --git a/bootstrap/capnp.tmpl.pxd b/bootstrap/capnp.tmpl.pxd deleted file mode 100644 index 79514c6..0000000 --- a/bootstrap/capnp.tmpl.pxd +++ /dev/null @@ -1,128 +0,0 @@ -# schema.capnp.cpp.pyx -# distutils: language = c++ -# distutils: extra_compile_args = --std=c++11 -# distutils: libraries = capnp - -from libc.stdint cimport * -ctypedef unsigned int uint -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 - -cdef extern from "capnp/blob.h" namespace "::capnp": - cdef cppclass Data: - cppclass Reader: - char * begin() - size_t size() - cppclass Builder: - char * begin() - size_t size() - cdef cppclass Text: - cppclass Reader: - char * cStr() - cppclass Builder: - char * cStr() -cdef extern from "capnp/message.h" namespace "::capnp": - cdef cppclass List[T]: - cppclass Reader: - T operator[](uint) - uint size() - cppclass Builder: - T operator[](uint) - uint size() - -cdef extern from "capnp/schema.capnp.h" namespace "::capnp::schema": -{%- for node_dict in enum_types %} - enum {{node_name|capitalize}}: - {%- for member_name, member_dict in node_dict['members'].items() %} - {{node_dict['full_name_cython']}}_{{member_name}} "::capnp::schema::{{node_dict['full_name']}}::{{member_name|upper_and_under}}" - {%- endfor %} -{%- endfor %} -{%- for node_dict in union_types %} - enum {{node_dict['full_name_cython']}}_Which: - {%- for member_name, member_dict in node_dict['members'].items() %} - {{node_dict['full_name_cython']}}_{{member_name}} "::capnp::schema::{{node_dict['full_name']|replace('.', '::')}}::Which::{{member_name|upper_and_under}}" - {%- endfor %} -{%- endfor %} -{%- for node_name, node_dict in nodes.items() %} - {% if node_dict['body'] != 'enum' %}cdef cppclass {{node_name|capitalize}}{%- endif %} -{%- endfor %} - -{%- for node_name, node_dict in nodes.items() recursive %} - - {%- if node_dict['body'] != 'enum' %} - {{ 'cdef ' if loop.depth == 1 }}cppclass {{node_name|capitalize}}: - - {%- for node_name, node_dict in node_dict['nestedNodes'].items() %} - cppclass {{node_name|capitalize}} - {%- endfor %} - - {{ loop(node_dict['nestedNodes'].items()) | indent }} - cppclass Reader: - {{'int which()' if node_dict['body'] == 'union'}} - {%- for member_name, member_dict in node_dict['members'].items() %} - {{member_dict['type']}}{{'.Reader' if member_dict.get('type', '').startswith('List') or member_dict.get('type', '') in ['Text', 'Data'] }} get{{member_name|capitalize}}() - {%- endfor %} - cppclass Builder: - {{'int which()' if node_dict['body'] == 'union'}} - {%- for member_name, member_dict in node_dict['members'].items() %} - {{member_dict['type']}}{{'.Builder' if member_dict.get('type', '').startswith('List') or member_dict.get('type', '') in ['Text', 'Data'] }} get{{member_name|capitalize}}() - {%- if member_dict.get('type', '').startswith('List') %} - {{member_dict['type']}}.Builder init{{member_name|capitalize}}(int) - {%- else %} - {{' ' if not member_dict['type']}}void set{{member_name|capitalize}}({{member_dict['type']}}) - {%- endif %} - {%- endfor %} - {%- endif %} -{%- endfor %} - -cdef extern from "capnp/message.h" namespace "::capnp": - cdef cppclass ReaderOptions: - uint64_t traversalLimitInWords - uint nestingLimit - - cdef cppclass MessageBuilder: -{%- for name, values in nodes.items() %} - {%- if values['body'] != 'enum' %} - {{name}}.Builder getRoot{{name}}'getRoot<{{namespace}}::{{name}}>'() - {{name}}.Builder initRoot{{name}}'initRoot<{{namespace}}::{{name}}>'() - {%- endif %} -{%- endfor %} - - cdef cppclass MessageReader: -{%- for name, values in nodes.items() %} - {%- if values['body'] != 'enum' %} - {{name}}.Reader getRoot{{name}}'getRoot<{{namespace}}::{{name}}>'() - {%- endif %} -{%- endfor %} - - cdef cppclass MallocMessageBuilder(MessageBuilder): - MallocMessageBuilder() - MallocMessageBuilder(int) - - enum Void: - VOID - -cdef extern from "capnp/serialize.h" namespace "::capnp": - cdef cppclass StreamFdMessageReader(MessageReader): - StreamFdMessageReader(int) - StreamFdMessageReader(int, ReaderOptions) - - void writeMessageToFd(int, MessageBuilder&) - -cdef extern from "capnp/serialize-packed.h" namespace "::capnp": - cdef cppclass PackedFdMessageReader(MessageReader): - PackedFdMessageReader(int) - StreamFdMessageReader(int, ReaderOptions) - - void writePackedMessageToFd(int, MessageBuilder&) diff --git a/bootstrap/capnp.tmpl.pyx b/bootstrap/capnp.tmpl.pyx deleted file mode 100644 index a4b4a10..0000000 --- a/bootstrap/capnp.tmpl.pyx +++ /dev/null @@ -1,223 +0,0 @@ -# schema.capnp.cpp.pyx -# distutils: language = c++ -# distutils: extra_compile_args = --std=c++11 -# distutils: libraries = capnp - -cimport schema_cpp as capnp -from schema_cpp cimport {% for node_name, node_dict in nodes.items() %}{% if node_dict['body'] != 'enum' %}{{node_name|capitalize}} as C_{{node_name|capitalize}}{{',' if not loop.last}}{%- endif %}{% endfor %} -from schema_cpp cimport {% for node_dict in enum_types %}{%- for member_name, member_dict in node_dict['members'].items() %}{{node_dict['full_name_cython']}}_{{member_name}}{{',' if not loop.last}}{%- endfor %}{{',' if not loop.last}}{%- endfor %} -from schema_cpp cimport {% for node_dict in union_types %}{%- for member_name, member_dict in node_dict['members'].items() %}{{node_dict['full_name_cython']}}_{{member_name}}{{',' if not loop.last}}{%- endfor %}{{',' if not loop.last}}{% endfor %} - -# from schema_cpp cimport * -# Not doing this since we want to namespace away the class names - -from cython.operator cimport dereference as deref - -from libc.stdint cimport * -ctypedef unsigned int uint -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 -cdef extern from "capnp/blob.h" namespace "::capnp": - cdef cppclass Data: - char * begin() - size_t size() - cdef cppclass Text: - char * cStr() -cdef extern from "capnp/message.h" namespace "::capnp": - cdef cppclass List[T]: - cppclass Reader: - T operator[](uint) - uint size() - cppclass Builder: - T operator[](uint) - uint size() -def make_enum(enum_name, *sequential, **named): - enums = dict(zip(sequential, range(len(sequential))), **named) - reverse = dict((value, key) for key, value in enums.iteritems()) - enums['reverse_mapping'] = reverse - return type(enum_name, (), enums) - -{%- for list_name, list_dict in list_types.items() %} -cdef class _{{ list_name |replace('[', '_')|replace(']','_')|replace('.','_')}}Reader: - cdef List[{{ list_dict['elem_type_cython'] }}].Reader thisptr - cdef init(self, List[{{ list_dict['elem_type_cython'] }}].Reader other): - self.thisptr = other - return self - def __getitem__(self, index): - size = self.thisptr.size() - if index >= size: - raise IndexError('Out of bounds') - index = index % size - {%- if list_dict['elem_type'] in built_in_types %} - return self.thisptr[index] - {%- else %} - return _{{ list_dict['elem_type']|replace('.','_') }}Reader().init(<{{ list_dict['elem_type_cython'] }}.Reader>self.thisptr[index]) - {%- endif %} - - def __len__(self): - return self.thisptr.size() -cdef class _{{ list_name |replace('[', '_')|replace(']','_')|replace('.','_')}}Builder: - cdef List[{{ list_dict['elem_type_cython'] }}].Builder thisptr - cdef init(self, List[{{ list_dict['elem_type_cython'] }}].Builder other): - self.thisptr = other - return self - def __getitem__(self, index): - size = self.thisptr.size() - if index >= size: - raise IndexError('Out of bounds') - index = index % size - {%- if list_dict['elem_type'] in built_in_types %} - return self.thisptr[index] - {%- else %} - return _{{ list_dict['elem_type']|replace('.','_') }}Builder().init(<{{ list_dict['elem_type_cython'] }}.Builder>self.thisptr[index]) - {%- endif %} - def __len__(self): - return self.thisptr.size() -{%- endfor %} -{%- for node_name, node_dict in nodes.items() recursive %} -{{ loop(node_dict['nestedNodes'].items()) }} - - {%- if node_dict['body'] != 'enum' %} - {%- if node_dict['body'] == 'union' %} -{{ node_dict['full_name_cython'] }}_Which = make_enum('{{ node_dict['full_name_cython'] }}_Which', {%- for member_name, member_dict in node_dict['members'].items() %}{{member_name}} = {{node_dict['full_name_cython']}}_{{member_name}},{%- endfor %}) - {%- endif %} -cdef class {{ node_dict['full_name_cython'] }}Reader: - cdef C_{{ node_dict['full_name'] }}.Reader thisptr - cdef init(self, C_{{ node_dict['full_name'] }}.Reader other): - self.thisptr = other - return self - {% if node_dict['body'] == 'union' %} - cpdef int which(self): - return self.thisptr.which() - {%- endif %} - {%- for member_name, member_dict in node_dict['members'].items() %} - property {{member_name}}: - def __get__(self): - {%- if member_dict['type'] in primitive_types %} - return self.thisptr.get{{member_name|capitalize}}() - {%- elif member_dict['type'].startswith('List[') %} - return _{{ member_dict['type'] |replace('[', '_')|replace(']','_')|replace('.','_')}}Reader().init(self.thisptr.get{{member_name|capitalize}}()) - {%- elif member_dict['type'] == 'Text' %} - return self.thisptr.get{{member_name|capitalize}}().cStr() - {%- elif member_dict['type'] == 'Data' %} - temp = self.thisptr.get{{member_name|capitalize}}() - return (temp.begin())[:temp.size()] - {%- elif member_dict['type'] in built_in_types %} - return None - {%- else %} - return _{{ member_dict['full_type']|replace('.','_') }}Reader().init(self.thisptr.get{{member_name|capitalize}}()) - {%- endif %} - {%- endfor %} - -cdef class {{ node_dict['full_name_cython'] }}Builder: - cdef C_{{ node_dict['full_name'] }}.Builder thisptr - cdef init(self, C_{{ node_dict['full_name'] }}.Builder other): - self.thisptr = other - return self - {% if node_dict['body'] == 'union' %} - cpdef int which(self): - return self.thisptr.which() - {%- endif %} - {%- for member_name, member_dict in node_dict['members'].items() %} - property {{member_name}}: - def __get__(self): - {%- if member_dict['type'] in primitive_types %} - return self.thisptr.get{{member_name|capitalize}}() - {%- elif member_dict['type'].startswith('List[') %} - return _{{ member_dict['type'] |replace('[', '_')|replace(']','_')|replace('.','_')}}Builder().init(self.thisptr.get{{member_name|capitalize}}()) - {%- elif member_dict['type'] == 'Text' %} - return self.thisptr.get{{member_name|capitalize}}().cStr() - {%- elif member_dict['type'] == 'Data' %} - temp = self.thisptr.get{{member_name|capitalize}}() - return (temp.begin())[:temp.size()] - {%- elif member_dict['type'] in built_in_types %} - return None - {%- else %} - return _{{ member_dict['full_type']|replace('.','_') }}Builder().init(self.thisptr.get{{member_name|capitalize}}()) - {%- endif %} - {%- if member_dict['type'] in primitive_types %} - def __set__(self, val): - self.thisptr.set{{member_name|capitalize}}(val) - {%- elif member_dict['type'].startswith('List[') %} - cpdef init{{member_name|capitalize}}(self, uint num): - return _{{ member_dict['type'] |replace('[', '_')|replace(']','_')|replace('.','_')}}Builder().init(self.thisptr.init{{member_name|capitalize}}(num)) - {%- else %} - def __set__(self, val): - pass - {%- endif %} - {%- endfor %} - {%- else %} -{{ node_dict['full_name_cython'] }} = make_enum('{{ node_dict['full_name_cython'] }}', {%- for member_name, member_dict in node_dict['members'].items() %}{{member_name}} = {{node_dict['full_name_cython']}}_{{member_name}},{%- endfor %}) - {%- endif %} -{%- endfor %} - -cdef class MessageBuilder: - cdef capnp.MessageBuilder * thisptr - def __dealloc__(self): - del self.thisptr -{%- for name, node_dict in nodes.items() %} - {%- if node_dict['body'] != 'enum' %} - cpdef getRoot{{name}}(self): - return {{ node_dict['full_name_cython'] }}Builder().init(self.thisptr.getRoot{{name}}()) - cpdef initRoot{{name}}(self): - return {{ node_dict['full_name_cython'] }}Builder().init(self.thisptr.initRoot{{name}}()) - {%- endif %} -{%- endfor %} -cdef class MallocMessageBuilder(MessageBuilder): - def __cinit__(self): - self.thisptr = new capnp.MallocMessageBuilder() - - -cdef class MessageReader: - cdef capnp.MessageReader * thisptr - def __dealloc__(self): - del self.thisptr -{%- for name, node_dict in nodes.items() %} - {%- if node_dict['body'] != 'enum' %} - cpdef getRoot{{name}}(self): - return {{ node_dict['full_name_cython'] }}Reader().init(self.thisptr.getRoot{{name}}()) - {%- endif %} -{%- endfor %} - -cdef class StreamFdMessageReader(MessageReader): - def __cinit__(self, int fd): - self.thisptr = new capnp.StreamFdMessageReader(fd) - -cdef class PackedFdMessageReader(MessageReader): - def __cinit__(self, int fd): - self.thisptr = new capnp.PackedFdMessageReader(fd) - -def writeMessageToFd(int fd, MessageBuilder m): - capnp.writeMessageToFd(fd, deref(m.thisptr)) -def writePackedMessageToFd(int fd, MessageBuilder m): - capnp.writePackedMessageToFd(fd, deref(m.thisptr)) - -# Make the namespace human usable -from types import ModuleType - -{%- for node_name, node_dict in nodes.items() recursive %} -temp = {{ node_dict['full_name'] }} = ModuleType('{{ node_dict['full_name'] }}') -{%- if node_dict['body'] == 'struct' %} -temp.Reader = {{ node_dict['full_name_cython'] }}Reader -temp.Builder = {{ node_dict['full_name_cython'] }}Builder -{%- elif node_dict['body'] == 'union' %} -temp.Reader = {{ node_dict['full_name_cython'] }}Reader -temp.Builder = {{ node_dict['full_name_cython'] }}Builder -temp.Which = {{ node_dict['full_name_cython'] }}_Which -{%- else %} -{{ node_dict['full_name'] }} = {{ node_dict['full_name_cython'] }} -{%- endif %} -{{ loop(node_dict['nestedNodes'].items()) }} -{%- endfor %} - diff --git a/bootstrap/schema.capnp b/bootstrap/schema.capnp deleted file mode 100644 index eddc8f2..0000000 --- a/bootstrap/schema.capnp +++ /dev/null @@ -1,314 +0,0 @@ -# Copyright (c) 2013, Kenton Varda -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright notice, this -# list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -using Cxx = import "c++.capnp"; - -@0xb471df2f45ca32c7; -$Cxx.namespace("capnp::schema"); - -# WARNING: This protocol is still subject to backwards-incompatible change. - -using Id = UInt64; -# The globally-unique ID of a file, type, or annotation. - -struct Node { - id @0 :Id; - - displayName @1 :Text; - # Name to present to humans to identify this Node. You should not attempt to parse this. Its - # format could change. It is not guaranteed to be unique. - # - # (On Zooko's triangle, this is the node's nickname.) - - scopeId @2 :Id = 0; - # ID of the lexical parent node. Typically, the scope node will have a NestedNode pointing back - # at this node, but robust code should avoid relying on this. `scopeId` is zero if the node has - # no parent, which is normally only the case with files, but should be allowed for any kind of - # node (in order to make runtime type generation easier). - - nestedNodes @3 :List(NestedNode); - # List of nodes nested within this node, along with the names under which they were declared. - - struct NestedNode { - name @0 :Text; - # Unqualified symbol name. Unlike Node.name, this *can* be used programmatically. - # - # (On Zooko's triangle, this is the node's petname according to its parent scope.) - - id @1 :Id; - # ID of the nested node. Typically, the target node's scopeId points back to this node, but - # robust code should avoid relying on this. - } - - annotations @4 :List(Annotation); - # Annotations applied to this node. - - body @5 union { - # Info specific to each kind of node. - - fileNode @6 :FileNode; - structNode @7 :StructNode; - enumNode @8 :EnumNode; - interfaceNode @9 :InterfaceNode; - constNode @10 :ConstNode; - annotationNode @11 :AnnotationNode; - } -} - -struct Type { - # Represents a type expression. - - body @0 union { - voidType @1 :Void; - boolType @2 :Void; - int8Type @3 :Void; - int16Type @4 :Void; - int32Type @5 :Void; - int64Type @6 :Void; - uint8Type @7 :Void; - uint16Type @8 :Void; - uint32Type @9 :Void; - uint64Type @10 :Void; - float32Type @11 :Void; - float64Type @12 :Void; - textType @13 :Void; - dataType @14 :Void; - - listType @15 :Type; # Value = the element type. - - enumType @16 :Id; - structType @17 :Id; - interfaceType @18 :Id; - - objectType @19 :Void; - } -} - -struct Value { - # Represents a value, e.g. a field default value, constant value, or annotation value. - - body @0 union { - # Note ordinals 1 and 10 are intentionally swapped to improve union layout. - voidValue @10 :Void; - boolValue @2 :Bool; - int8Value @3 :Int8; - int16Value @4 :Int16; - int32Value @5 :Int32; - int64Value @6 :Int64; - uint8Value @7 :UInt8; - uint16Value @8 :UInt16; - uint32Value @9 :UInt32; - uint64Value @1 :UInt64; - float32Value @11 :Float32; - float64Value @12 :Float64; - textValue @13 :Text; - dataValue @14 :Data; - - listValue @15 :Object; - - enumValue @16 :UInt16; - structValue @17 :Object; - - interfaceValue @18 :Void; - # The only interface value that can be represented statically is "null", whose methods always - # throw exceptions. - - objectValue @19 :Object; - } -} - -struct Annotation { - # Describes an annotation applied to a declaration. Note AnnotationNode describes the - # annotation's declaration, while this describes a use of the annotation. - - id @0 :Id; - # ID of the annotation node. - - value @1 :Value; -} - -struct FileNode { - imports @0 :List(Import); - struct Import { - id @0 :Id; - # ID of the imported file. - - name @1 :Text; - # Name which *this* file used to refer to the foreign file. This may be a relative name. - # This information is provided because it might be useful for code generation, e.g. to generate - # #include directives in C++. - # - # (On Zooko's triangle, this is the import's petname according to the importing file.) - } -} - -enum ElementSize { - # Possible element sizes for encoded lists. These correspond exactly to the possible values of - # the 3-bit element size component of a list pointer. - - empty @0; # aka "void", but that's a keyword. - bit @1; - byte @2; - twoBytes @3; - fourBytes @4; - eightBytes @5; - pointer @6; - inlineComposite @7; -} - -struct StructNode { - dataSectionWordSize @0 :UInt16; - pointerSectionSize @1 :UInt16; - - preferredListEncoding @2 :ElementSize; - # The preferred element size to use when encoding a list of this struct. If this is anything - # other than `inlineComposite` then the struct is one word or less in size and is a candidate for - # list packing optimization. - - members @3 :List(Member); - # Top-level fields and unions of the struct, ordered by ordinal number, except that members of - # unions are not included in this list (because they are nested inside the union declaration). - # Note that this ordering is stable as the protocol evolves -- new members can only be added to - # the end. So, when encoding a struct as tag/value pairs with numeric tags, it actually may make - # sense to use the field's position in this list rather than the original ordinal number to - # identify fields. - - struct Member { - name @0 :Text; - - ordinal @1 :UInt16; - - codeOrder @2 :UInt16; - # Indicates where this member appeared in the code, relative to other members. - # Code ordering may have semantic relevance -- programmers tend to place related fields - # together. So, using code ordering makes sense in human-readable formats where ordering is - # otherwise irrelevant, like JSON. The values of codeOrder are tightly-packed, so the maximum - # value is count(members) - 1. Fields that are members of a union are only ordered relative to - # the other members of that union, so the maximum value there is count(union.members). - - annotations @3 :List(Annotation); - - body @4 union { - # More member types could be added over time. Consumers should skip those that they - # don't understand. - - fieldMember @5 :Field; - unionMember @6 :Union; - } - } - - struct Field { - offset @0 :UInt32; - # Offset, in units of the field's size, from the beginning of the section in which the field - # resides. E.g. for a UInt32 field, multiply this by 4 to get the byte offset from the - # beginning of the data section. - - type @1 :Type; - defaultValue @2 :Value; - } - - struct Union { - discriminantOffset @0 :UInt32; - # Offset of the union's 16-bit discriminant within the struct's data section, in 16-bit units. - - members @1 :List(Member); - # Fields of this union, ordered by ordinal. Currently all members are fields, but - # consumers should skip member types that they don't understand. The first member in this list - # gets discriminant value zero, the next gets one, and so on. - } -} - -struct EnumNode { - enumerants @0 :List(Enumerant); - # Enumerants, in order by ordinal. - - struct Enumerant { - name @0 :Text; - - codeOrder @1 :UInt16; - # Specifies order in which the enumerants were declared in the code. - # Like Struct.Field.codeOrder. - - annotations @2 :List(Annotation); - } -} - -struct InterfaceNode { - methods @0 :List(Method); - # Methods, in order by ordinal. - - struct Method { - name @0 :Text; - - codeOrder @1 :UInt16; - # Specifies order in which the methods were declared in the code. - # Like Struct.Field.codeOrder. - - params @2 :List(Param); - struct Param { - name @0 :Text; - type @1 :Type; - defaultValue @2 :Value; - annotations @3 :List(Annotation); - } - - requiredParamCount @3 :UInt16; - # One plus the index of the last parameter that has no default value. In languages where - # method calls look like function calls, this is the minimum number of parameters that must - # always be specified, while subsequent parameters are optional. - - returnType @4 :Type; - - annotations @5 :List(Annotation); - } -} - -struct ConstNode { - type @0 :Type; - value @1 :Value; -} - -struct AnnotationNode { - type @0 :Type; - - targetsFile @1 :Bool; - targetsConst @2 :Bool; - targetsEnum @3 :Bool; - targetsEnumerant @4 :Bool; - targetsStruct @5 :Bool; - targetsField @6 :Bool; - targetsUnion @7 :Bool; - targetsInterface @8 :Bool; - targetsMethod @9 :Bool; - targetsParam @10 :Bool; - targetsAnnotation @11 :Bool; -} - -struct CodeGeneratorRequest { - nodes @0 :List(Node); - # All nodes parsed by the compiler, including for the files on the command line and their - # imports. - - requestedFiles @1 :List(Id); - # IDs of files which were listed on the command line. -} diff --git a/bootstrap/setup.py b/bootstrap/setup.py deleted file mode 100644 index c15e36a..0000000 --- a/bootstrap/setup.py +++ /dev/null @@ -1,261 +0,0 @@ -#!/usr/bin/env python -from distutils.core import setup -from Cython.Build import cythonize -from jinja2 import Environment, FileSystemLoader -import os - -curr_dir = os.path.abspath(os.path.dirname(__file__)) -env = Environment(loader=FileSystemLoader(curr_dir)) - -nodes = { - -'Node' : {'body' : 'struct', -'members' : { - 'id' : {'type' : 'UInt64'}, - 'displayName' : {'type' : 'Text'}, - 'scopeId' : {'type' : 'UInt64'}, - 'nestedNodes' : {'type' : 'List[Node.NestedNode]'}, -'NestedNode' : {'body' : 'struct', 'is_not_field' : True, -'members' : { - 'name' : {'type' : 'Text'}, - 'id' : {'type' : 'UInt64'}, -}}, - 'annotations' : {'type' : 'List[Annotation]'}, -'body' : {'body' : 'union', -'members' : { - 'fileNode' : {'type' : 'FileNode'}, - 'structNode' : {'type' : 'StructNode'}, - 'enumNode' : {'type' : 'EnumNode'}, - 'interfaceNode' : {'type' : 'InterfaceNode'}, - 'constNode' : {'type' : 'ConstNode'}, - 'annotationNode' : {'type' : 'AnnotationNode'}, -}}, -}}, -'Type' : {'body' : 'struct', -'members' : { -'body' : {'body' : 'union', -'members' : { - 'voidType' : {'type' : 'Void'}, - 'boolType' : {'type' : 'Void'}, - 'int8Type' : {'type' : 'Void'}, - 'int16Type' : {'type' : 'Void'}, - 'int32Type' : {'type' : 'Void'}, - 'int64Type' : {'type' : 'Void'}, - 'uint8Type' : {'type' : 'Void'}, - 'uint16Type' : {'type' : 'Void'}, - 'uint32Type' : {'type' : 'Void'}, - 'uint64Type' : {'type' : 'Void'}, - 'float32Type' : {'type' : 'Void'}, - 'float64Type' : {'type' : 'Void'}, - 'textType' : {'type' : 'Void'}, - 'dataType' : {'type' : 'Void'}, - 'listType' : {'type' : 'Type'}, - 'enumType' : {'type' : 'UInt64'}, - 'structType' : {'type' : 'UInt64'}, - 'interfaceType' : {'type' : 'UInt64'}, - 'objectType' : {'type' : 'Void'}, -}}, -}}, -'Value' : {'body' : 'struct', -'members' : { -'body' : {'body' : 'union', -'members' : { - 'voidValue' : {'type' : 'Void'}, - 'boolValue' : {'type' : 'Bool'}, - 'int8Value' : {'type' : 'Int8'}, - 'int16Value' : {'type' : 'Int16'}, - 'int32Value' : {'type' : 'Int32'}, - 'int64Value' : {'type' : 'Int64'}, - 'uint8Value' : {'type' : 'UInt8'}, - 'uint16Value' : {'type' : 'UInt16'}, - 'uint32Value' : {'type' : 'UInt32'}, - 'uint64Value' : {'type' : 'UInt64'}, - 'float32Value' : {'type' : 'Float32'}, - 'float64Value' : {'type' : 'Float64'}, - 'textValue' : {'type' : 'Text'}, - 'dataValue' : {'type' : 'Data'}, - 'listValue' : {'type' : 'Object'}, - 'enumValue' : {'type' : 'UInt16'}, - 'structValue' : {'type' : 'Object'}, - 'interfaceValue' : {'type' : 'Void'}, - 'objectValue' : {'type' : 'Object'}, -}}, -}}, -'Annotation' : {'body' : 'struct', -'members' : { - 'id' : {'type' : 'UInt64'}, - 'value' : {'type' : 'Value'}, -}}, -'FileNode' : {'body' : 'struct', -'members' : { - 'imports' : {'type' : 'List[FileNode.Import]'}, -'Import' : {'body' : 'struct', 'is_not_field' : True, -'members' : { - 'id' : {'type' : 'UInt64'}, - 'name' : {'type' : 'Text'}, -}}, -}}, -'ElementSize' : {'body' : 'enum', -'members' : { - 'empty' : {}, - 'bit' : {}, - 'byte' : {}, - 'twoBytes' : {}, - 'fourBytes' : {}, - 'eightBytes' : {}, - 'pointer' : {}, - 'inlineComposite' : {}, -}}, -'StructNode' : {'body' : 'struct', -'members' : { - 'dataSectionWordSize' : {'type' : 'UInt16'}, - 'pointerSectionSize' : {'type' : 'UInt16'}, - # 'preferredListEncoding' : {'type' : 'ElementSize'}, - 'members' : {'type' : 'List[StructNode.Member]'}, -'Member' : {'body' : 'struct', 'is_not_field' : True, -'members' : { - 'name' : {'type' : 'Text'}, - 'ordinal' : {'type' : 'UInt16'}, - 'codeOrder' : {'type' : 'UInt16'}, - 'annotations' : {'type' : 'List[Annotation]'}, -'body' : {'body' : 'union', -'members' : { - 'fieldMember' : {'type' : 'StructNode.Field'}, - 'unionMember' : {'type' : 'StructNode.Union'}, -}}, -}}, -'Field' : {'body' : 'struct', 'is_not_field' : True, -'members' : { - 'offset' : {'type' : 'UInt32'}, - 'type' : {'type' : 'Type'}, - 'defaultValue' : {'type' : 'Value'}, -}}, -'Union' : {'body' : 'struct', 'is_not_field' : True, -'members' : { - 'discriminantOffset' : {'type' : 'UInt32'}, - 'members' : {'type' : 'List[StructNode.Member]'}, -}}, -}}, -'EnumNode' : {'body' : 'struct', -'members' : { - 'enumerants' : {'type' : 'List[EnumNode.Enumerant]'}, -'Enumerant' : {'body' : 'struct', 'is_not_field' : True, -'members' : { - 'name' : {'type' : 'Text'}, - 'codeOrder' : {'type' : 'UInt16'}, - 'annotations' : {'type' : 'List[Annotation]'}, -}}, -}}, -'InterfaceNode' : {'body' : 'struct', -'members' : { - 'methods' : {'type' : 'List[InterfaceNode.Method]'}, -'Method' : {'body' : 'struct', 'is_not_field' : True, -'members' : { - 'name' : {'type' : 'Text'}, - 'codeOrder' : {'type' : 'UInt16'}, - 'params' : {'type' : 'List[InterfaceNode.Method.Param]'}, -'Param' : {'body' : 'struct', 'is_not_field' : True, -'members' : { - 'name' : {'type' : 'Text'}, - 'type' : {'type' : 'Type'}, - 'defaultValue' : {'type' : 'Value'}, - 'annotations' : {'type' : 'List[Annotation]'}, -}}, - 'requiredParamCount' : {'type' : 'UInt16'}, - 'returnType' : {'type' : 'Type'}, - 'annotations' : {'type' : 'List[Annotation]'}, -}}, -}}, -'ConstNode' : {'body' : 'struct', -'members' : { - 'type' : {'type' : 'Type'}, - 'value' : {'type' : 'Value'}, -}}, -'AnnotationNode' : {'body' : 'struct', -'members' : { - 'type' : {'type' : 'Type'}, - 'targetsFile' : {'type' : 'Bool'}, - 'targetsConst' : {'type' : 'Bool'}, - 'targetsEnum' : {'type' : 'Bool'}, - 'targetsEnumerant' : {'type' : 'Bool'}, - 'targetsStruct' : {'type' : 'Bool'}, - 'targetsField' : {'type' : 'Bool'}, - 'targetsUnion' : {'type' : 'Bool'}, - 'targetsInterface' : {'type' : 'Bool'}, - 'targetsMethod' : {'type' : 'Bool'}, - 'targetsParam' : {'type' : 'Bool'}, - 'targetsAnnotation' : {'type' : 'Bool'}, -}}, -'CodeGeneratorRequest' : {'body' : 'struct', -'members' : { - 'nodes' : {'type' : 'List[Node]'}, - 'requestedFiles' : {'type' : 'List[UInt64]'}, -}}, -} -primitive_types = set(('Bool','Int8','Int16','Int32','Int64','UInt8','UInt16','UInt32','UInt64','Float32','Float64')) -built_in_types = set(('Bool','Int8','Int16','Int32','Int64','UInt8','UInt16','UInt32','UInt64','Float32','Float64', 'Text', 'Data', 'Void', 'Object')) -list_types = {} -enum_types = [] -union_types = [] -def capitalize(s): - if len(s) < 2: - return s - return s[0].upper() + s[1:] -def upper_and_under(s): - if len(s) < 2: - return s - ret = [s[0]] - for letter in s[1:]: - if letter.isupper(): - ret.append('_') - ret.append(letter) - return ''.join(ret).upper() -def fixNodes(n): - def fixNode(node_dict, full_name): - nested = {} - node_dict['full_name'] = full_name - node_dict['full_name_cython'] = '_' + full_name.replace('.', '_') - for member, member_dict in node_dict['members'].items(): - member_dict['full_type'] = member_dict.get('type') - if 'body' in member_dict: - nested[member] = fixNode(member_dict, full_name+'.'+capitalize(member)) - if member_dict['body'] == 'enum': - enum_types.append(nested[member]) - elif member_dict['body'] == 'union': - union_types.append(nested[member]) - if 'is_not_field' in member_dict: - del node_dict['members'][member] - else: - node_dict['members'][member] = {'type' : full_name+'.'+capitalize(member)} - node_dict['members'][member]['full_type'] = node_dict['members'][member].get('type') - elif member_dict.get('type', '').startswith('List'): - elem_type = member_dict['type'][member_dict['type'].find('[')+1:member_dict['type'].find(']')] - elem_type_name = elem_type if elem_type in built_in_types else capitalize((full_name+'.'+elem_type)) - elem_type_cython = elem_type if elem_type in built_in_types else 'C_' + capitalize((full_name+'.'+elem_type)) - list_types['List[%s]' % elem_type_name] = {'elem_type' : elem_type, 'elem_type_cython' : elem_type_cython} - member_dict['type'] = 'List[%s]' % elem_type_name - - elif '.' in member_dict.get('type', ''): - member_dict['type'] = '.'.join(member_dict['type'].split('.')[1:]) - node_dict['nestedNodes'] = nested - return node_dict - for node, node_dict in n.items(): - res=fixNode(node_dict, capitalize(node)) - if node_dict['body'] == 'enum': - enum_types.append(res) - elif node_dict['body'] == 'union': - union_types.append(res) - return n - -env.filters['capitalize'] = capitalize -env.filters['upper_and_under'] = upper_and_under -nodes = fixNodes(nodes) -tmpl = env.get_template('capnp.tmpl.pxd') -open(os.path.join(curr_dir, 'schema_cpp.pxd'), 'w').write(tmpl.render(nodes=nodes, namespace='::capnp::schema', built_in_types=built_in_types, enum_types=enum_types, union_types=union_types)) -tmpl = env.get_template('capnp.tmpl.pyx') -open(os.path.join(curr_dir, 'schema.capnp.cpp.pyx'), 'w').write(tmpl.render(nodes=nodes, namespace='::capnp::schema', primitive_types=primitive_types, built_in_types=built_in_types, list_types=list_types, enum_types=enum_types, union_types=union_types)) - -setup( - name = "capnp", - ext_modules = cythonize('schema.capnp.cpp.pyx'), -) \ No newline at end of file diff --git a/bootstrap/translate.py b/bootstrap/translate.py deleted file mode 100644 index bb3618e..0000000 --- a/bootstrap/translate.py +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env python -from jinja2 import Template - - -nodes = { -'Node' : {'body' : 'struct', - 'members' : { - 'id' : {'type' : 'UInt64'} - } - }} -f=open('schema.verbose') -for line in f.readlines()[10:]: - sline = line.strip() - if sline == '': - continue - elif sline.startswith('struct ') or sline.startswith('union ') or sline.startswith('enum '): - print "'%s' : {'body' : '%s',\n'members' : {" % (line.split()[1], line.split()[0]) - elif sline.startswith('}'): - print '}},' - else: - if len(sline.split()) > 1: - name, type = sline.split()[:2] - if type.startswith('List('): - type = type.replace('List(', 'List[').replace(')', ']').replace('[.', '[') - if type.startswith('.'): - type = type[1:] - print ' ', "'%s' : {'type' : '%s'}," % (name, type) - else: - print ' ', "'%s' : {}," % sline.split()[0] \ No newline at end of file diff --git a/capnp/capnp.pyx b/capnp/capnp.pyx index 0885691..1eb41af 100644 --- a/capnp/capnp.pyx +++ b/capnp/capnp.pyx @@ -13,7 +13,6 @@ from capnp_cpp cimport SchemaLoader as C_SchemaLoader, Schema as C_Schema, Struc from schema_cpp cimport CodeGeneratorRequest as C_CodeGeneratorRequest, Node as C_Node, EnumNode as C_EnumNode from cython.operator cimport dereference as deref -from schema cimport _NodeReader from libc.stdint cimport * ctypedef unsigned int uint ctypedef uint8_t UInt8 @@ -69,6 +68,22 @@ cdef extern from "capnp/list.h" namespace " ::capnp": T operator[](uint) except +ValueError uint size() +cdef class _NodeReader: + cdef C_Node.Reader thisptr + cdef init(self, C_Node.Reader other): + self.thisptr = other + return self + + property displayName: + def __get__(self): + return self.thisptr.getDisplayName().cStr() + property scopeId: + def __get__(self): + return self.thisptr.getScopeId() + property id: + def __get__(self): + return self.thisptr.getId() + cdef class _DynamicListReader: cdef C_DynamicList.Reader thisptr cdef public object _parent @@ -530,11 +545,10 @@ def upper_and_under(s): from types import ModuleType import re -import schema import subprocess -def _load(module, node, loader, name, isUnion = False): - if name is None or len(name) == 0: +def _load(module, node, loader, name): + if name is None or len(name) == 0: # This only is true for the root fileNode return if name[0] == ':': name = name[1:] @@ -546,27 +560,6 @@ def _load(module, node, loader, name, isUnion = False): local_module.__dict__[sub_name] = new_m local_module = new_m local_module._root_module = module - for nestedNode in node.nestedNodes: - s = loader.get(nestedNode.id) - _load(module, s.getProto(), loader, name + ':' + nestedNode.name) - - body = node.body - which = body.which() - - if which == schema.Node.Body.Which.enumNode: - enum = body.enumNode - - local_module._parent_module.__dict__[sub_name] = _make_enum(name, **{upper_and_under(e.name) : e.name for e in enum.enumerants}) - elif which == schema.Node.Body.Which.structNode: - struct = body.structNode - - for member in struct.members: - if member.body.which() == schema.StructNode.Member.Body.Which.unionMember: - sub_name = capitalize(member.name) - new_m = local_module.__dict__.get(sub_name, ModuleType(sub_name)) - local_module.__dict__[sub_name] = new_m - - new_m.Which = _make_enum(sub_name+':Which', **{upper_and_under(e.name) : e.name for e in member.body.unionMember.members}) return local_module @@ -574,9 +567,9 @@ def load(file_name, cat_path='/bin/cat'): p = subprocess.Popen(['capnpc', '-o'+cat_path, file_name], stdout=subprocess.PIPE) retcode = p.wait() if retcode != 0: - raise RuntimeError("capnpc failed for some reason") + raise RuntimeError("capnpc failed for some reason. Make sure `capnpc` is in your path, and that the path to cat (%s) is correct" % cat_path) - reader = schema.StreamFdMessageReader(p.stdout.fileno()) + reader = StreamFdMessageReader(p.stdout.fileno()) request = reader.getRootCodeGeneratorRequest() module = ModuleType(file_name) loader = SchemaLoader() @@ -592,7 +585,7 @@ def load(file_name, cat_path='/bin/cat'): try: s = s.asStruct() local_module.Schema = s - except: pass + except: pass # We only need to store away StructSchemas return module diff --git a/capnp/schema.pxd b/capnp/schema.pxd deleted file mode 100644 index 47e7323..0000000 --- a/capnp/schema.pxd +++ /dev/null @@ -1,9 +0,0 @@ -# schema.capnp.cpp.pyx -# distutils: language = c++ -# distutils: extra_compile_args = --std=c++11 -# distutils: libraries = capnp -from schema_cpp cimport Node as C_Node -cdef class _NodeReader: - cdef C_Node.Reader thisptr - cdef init(self, C_Node.Reader other) - \ No newline at end of file diff --git a/capnp/schema.pyx b/capnp/schema.pyx deleted file mode 100644 index 412a706..0000000 --- a/capnp/schema.pyx +++ /dev/null @@ -1,1810 +0,0 @@ -# schema.capnp.cpp.pyx -# distutils: language = c++ -# distutils: extra_compile_args = --std=c++11 -fpermissive -# distutils: libraries = capnp -# cython: c_string_type = str -# cython: c_string_encoding = default - -cimport schema_cpp as capnp -from schema_cpp cimport CodeGeneratorRequest as C_CodeGeneratorRequest,InterfaceNode as C_InterfaceNode,Value as C_Value,ConstNode as C_ConstNode,Type as C_Type,FileNode as C_FileNode,Node as C_Node,AnnotationNode as C_AnnotationNode,EnumNode as C_EnumNode,StructNode as C_StructNode,Annotation as C_Annotation -from schema_cpp cimport _ElementSize_inlineComposite,_ElementSize_eightBytes,_ElementSize_pointer,_ElementSize_bit,_ElementSize_twoBytes,_ElementSize_fourBytes,_ElementSize_byte,_ElementSize_empty -from schema_cpp cimport _Value_Body_uint32Value,_Value_Body_float64Value,_Value_Body_voidValue,_Value_Body_dataValue,_Value_Body_listValue,_Value_Body_int32Value,_Value_Body_enumValue,_Value_Body_int8Value,_Value_Body_boolValue,_Value_Body_int16Value,_Value_Body_float32Value,_Value_Body_interfaceValue,_Value_Body_uint16Value,_Value_Body_uint8Value,_Value_Body_int64Value,_Value_Body_structValue,_Value_Body_textValue,_Value_Body_uint64Value,_Value_Body_objectValue,_Type_Body_boolType,_Type_Body_structType,_Type_Body_int32Type,_Type_Body_voidType,_Type_Body_uint16Type,_Type_Body_dataType,_Type_Body_objectType,_Type_Body_int64Type,_Type_Body_float64Type,_Type_Body_interfaceType,_Type_Body_uint32Type,_Type_Body_uint8Type,_Type_Body_listType,_Type_Body_int8Type,_Type_Body_float32Type,_Type_Body_enumType,_Type_Body_uint64Type,_Type_Body_textType,_Type_Body_int16Type,_Node_Body_annotationNode,_Node_Body_interfaceNode,_Node_Body_enumNode,_Node_Body_structNode,_Node_Body_constNode,_Node_Body_fileNode,_StructNode_Member_Body_fieldMember,_StructNode_Member_Body_unionMember - -# from schema_cpp cimport * -# Not doing this since we want to namespace away the class names - -from cython.operator cimport dereference as deref - -from libc.stdint cimport * -ctypedef unsigned int uint -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 -cdef extern from "capnp/blob.h" namespace " ::capnp": - cdef cppclass Data: - char * begin() - size_t size() - cdef cppclass Text: - char * cStr() -cdef extern from "capnp/message.h" namespace " ::capnp": - cdef cppclass List[T]: - cppclass Reader: - T operator[](uint) - uint size() - cppclass Builder: - T operator[](uint) - uint size() -def make_enum(enum_name, *sequential, **named): - enums = dict(zip(sequential, range(len(sequential))), **named) - reverse = dict((value, key) for key, value in enums.iteritems()) - enums['reverse_mapping'] = reverse - return type(enum_name, (), enums) -cdef class _List_InterfaceNode_InterfaceNode_Method_Reader: - cdef List[C_InterfaceNode.InterfaceNode.Method].Reader thisptr - cdef init(self, List[C_InterfaceNode.InterfaceNode.Method].Reader other): - self.thisptr = other - return self - def __getitem__(self, index): - size = self.thisptr.size() - if index >= size: - raise IndexError('Out of bounds') - index = index % size - return _InterfaceNode_MethodReader().init(self.thisptr[index]) - - def __len__(self): - return self.thisptr.size() -cdef class _List_InterfaceNode_InterfaceNode_Method_Builder: - cdef List[C_InterfaceNode.InterfaceNode.Method].Builder thisptr - cdef init(self, List[C_InterfaceNode.InterfaceNode.Method].Builder other): - self.thisptr = other - return self - def __getitem__(self, index): - size = self.thisptr.size() - if index >= size: - raise IndexError('Out of bounds') - index = index % size - return _InterfaceNode_MethodBuilder().init(self.thisptr[index]) - def __len__(self): - return self.thisptr.size() -cdef class _List_EnumNode_EnumNode_Enumerant_Reader: - cdef List[C_EnumNode.EnumNode.Enumerant].Reader thisptr - cdef init(self, List[C_EnumNode.EnumNode.Enumerant].Reader other): - self.thisptr = other - return self - def __getitem__(self, index): - size = self.thisptr.size() - if index >= size: - raise IndexError('Out of bounds') - index = index % size - return _EnumNode_EnumerantReader().init(self.thisptr[index]) - - def __len__(self): - return self.thisptr.size() -cdef class _List_EnumNode_EnumNode_Enumerant_Builder: - cdef List[C_EnumNode.EnumNode.Enumerant].Builder thisptr - cdef init(self, List[C_EnumNode.EnumNode.Enumerant].Builder other): - self.thisptr = other - return self - def __getitem__(self, index): - size = self.thisptr.size() - if index >= size: - raise IndexError('Out of bounds') - index = index % size - return _EnumNode_EnumerantBuilder().init(self.thisptr[index]) - def __len__(self): - return self.thisptr.size() -cdef class _List_StructNode_Union_StructNode_Member_Reader: - cdef List[C_StructNode.Union.StructNode.Member].Reader thisptr - cdef init(self, List[C_StructNode.Union.StructNode.Member].Reader other): - self.thisptr = other - return self - def __getitem__(self, index): - size = self.thisptr.size() - if index >= size: - raise IndexError('Out of bounds') - index = index % size - return _StructNode_MemberReader().init(self.thisptr[index]) - - def __len__(self): - return self.thisptr.size() -cdef class _List_StructNode_Union_StructNode_Member_Builder: - cdef List[C_StructNode.Union.StructNode.Member].Builder thisptr - cdef init(self, List[C_StructNode.Union.StructNode.Member].Builder other): - self.thisptr = other - return self - def __getitem__(self, index): - size = self.thisptr.size() - if index >= size: - raise IndexError('Out of bounds') - index = index % size - return _StructNode_MemberBuilder().init(self.thisptr[index]) - def __len__(self): - return self.thisptr.size() -cdef class _List_InterfaceNode_Method_InterfaceNode_Method_Param_Reader: - cdef List[C_InterfaceNode.Method.InterfaceNode.Method.Param].Reader thisptr - cdef init(self, List[C_InterfaceNode.Method.InterfaceNode.Method.Param].Reader other): - self.thisptr = other - return self - def __getitem__(self, index): - size = self.thisptr.size() - if index >= size: - raise IndexError('Out of bounds') - index = index % size - return _InterfaceNode_Method_ParamReader().init(self.thisptr[index]) - - def __len__(self): - return self.thisptr.size() -cdef class _List_InterfaceNode_Method_InterfaceNode_Method_Param_Builder: - cdef List[C_InterfaceNode.Method.InterfaceNode.Method.Param].Builder thisptr - cdef init(self, List[C_InterfaceNode.Method.InterfaceNode.Method.Param].Builder other): - self.thisptr = other - return self - def __getitem__(self, index): - size = self.thisptr.size() - if index >= size: - raise IndexError('Out of bounds') - index = index % size - return _InterfaceNode_Method_ParamBuilder().init(self.thisptr[index]) - def __len__(self): - return self.thisptr.size() -cdef class _List_InterfaceNode_Method_Param_Annotation_Reader: - cdef List[C_InterfaceNode.Method.Param.Annotation].Reader thisptr - cdef init(self, List[C_InterfaceNode.Method.Param.Annotation].Reader other): - self.thisptr = other - return self - def __getitem__(self, index): - size = self.thisptr.size() - if index >= size: - raise IndexError('Out of bounds') - index = index % size - return _AnnotationReader().init(self.thisptr[index]) - - def __len__(self): - return self.thisptr.size() -cdef class _List_InterfaceNode_Method_Param_Annotation_Builder: - cdef List[C_InterfaceNode.Method.Param.Annotation].Builder thisptr - cdef init(self, List[C_InterfaceNode.Method.Param.Annotation].Builder other): - self.thisptr = other - return self - def __getitem__(self, index): - size = self.thisptr.size() - if index >= size: - raise IndexError('Out of bounds') - index = index % size - return _AnnotationBuilder().init(self.thisptr[index]) - def __len__(self): - return self.thisptr.size() -cdef class _List_UInt64_Reader: - cdef List[UInt64].Reader thisptr - cdef init(self, List[UInt64].Reader other): - self.thisptr = other - return self - def __getitem__(self, index): - size = self.thisptr.size() - if index >= size: - raise IndexError('Out of bounds') - index = index % size - return self.thisptr[index] - - def __len__(self): - return self.thisptr.size() -cdef class _List_UInt64_Builder: - cdef List[UInt64].Builder thisptr - cdef init(self, List[UInt64].Builder other): - self.thisptr = other - return self - def __getitem__(self, index): - size = self.thisptr.size() - if index >= size: - raise IndexError('Out of bounds') - index = index % size - return self.thisptr[index] - def __len__(self): - return self.thisptr.size() -cdef class _List_Node_Node_NestedNode_Reader: - cdef List[C_Node.Node.NestedNode].Reader thisptr - cdef init(self, List[C_Node.Node.NestedNode].Reader other): - self.thisptr = other - return self - def __getitem__(self, index): - size = self.thisptr.size() - if index >= size: - raise IndexError('Out of bounds') - index = index % size - return _Node_NestedNodeReader().init(self.thisptr[index]) - - def __len__(self): - return self.thisptr.size() -cdef class _List_Node_Node_NestedNode_Builder: - cdef List[C_Node.Node.NestedNode].Builder thisptr - cdef init(self, List[C_Node.Node.NestedNode].Builder other): - self.thisptr = other - return self - def __getitem__(self, index): - size = self.thisptr.size() - if index >= size: - raise IndexError('Out of bounds') - index = index % size - return _Node_NestedNodeBuilder().init(self.thisptr[index]) - def __len__(self): - return self.thisptr.size() -cdef class _List_StructNode_Member_Annotation_Reader: - cdef List[C_StructNode.Member.Annotation].Reader thisptr - cdef init(self, List[C_StructNode.Member.Annotation].Reader other): - self.thisptr = other - return self - def __getitem__(self, index): - size = self.thisptr.size() - if index >= size: - raise IndexError('Out of bounds') - index = index % size - return _AnnotationReader().init(self.thisptr[index]) - - def __len__(self): - return self.thisptr.size() -cdef class _List_StructNode_Member_Annotation_Builder: - cdef List[C_StructNode.Member.Annotation].Builder thisptr - cdef init(self, List[C_StructNode.Member.Annotation].Builder other): - self.thisptr = other - return self - def __getitem__(self, index): - size = self.thisptr.size() - if index >= size: - raise IndexError('Out of bounds') - index = index % size - return _AnnotationBuilder().init(self.thisptr[index]) - def __len__(self): - return self.thisptr.size() -cdef class _List_InterfaceNode_Method_Annotation_Reader: - cdef List[C_InterfaceNode.Method.Annotation].Reader thisptr - cdef init(self, List[C_InterfaceNode.Method.Annotation].Reader other): - self.thisptr = other - return self - def __getitem__(self, index): - size = self.thisptr.size() - if index >= size: - raise IndexError('Out of bounds') - index = index % size - return _AnnotationReader().init(self.thisptr[index]) - - def __len__(self): - return self.thisptr.size() -cdef class _List_InterfaceNode_Method_Annotation_Builder: - cdef List[C_InterfaceNode.Method.Annotation].Builder thisptr - cdef init(self, List[C_InterfaceNode.Method.Annotation].Builder other): - self.thisptr = other - return self - def __getitem__(self, index): - size = self.thisptr.size() - if index >= size: - raise IndexError('Out of bounds') - index = index % size - return _AnnotationBuilder().init(self.thisptr[index]) - def __len__(self): - return self.thisptr.size() -cdef class _List_StructNode_StructNode_Member_Reader: - cdef List[C_StructNode.StructNode.Member].Reader thisptr - cdef init(self, List[C_StructNode.StructNode.Member].Reader other): - self.thisptr = other - return self - def __getitem__(self, index): - size = self.thisptr.size() - if index >= size: - raise IndexError('Out of bounds') - index = index % size - return _StructNode_MemberReader().init(self.thisptr[index]) - - def __len__(self): - return self.thisptr.size() -cdef class _List_StructNode_StructNode_Member_Builder: - cdef List[C_StructNode.StructNode.Member].Builder thisptr - cdef init(self, List[C_StructNode.StructNode.Member].Builder other): - self.thisptr = other - return self - def __getitem__(self, index): - size = self.thisptr.size() - if index >= size: - raise IndexError('Out of bounds') - index = index % size - return _StructNode_MemberBuilder().init(self.thisptr[index]) - def __len__(self): - return self.thisptr.size() -cdef class _List_Node_Annotation_Reader: - cdef List[C_Node.Annotation].Reader thisptr - cdef init(self, List[C_Node.Annotation].Reader other): - self.thisptr = other - return self - def __getitem__(self, index): - size = self.thisptr.size() - if index >= size: - raise IndexError('Out of bounds') - index = index % size - return _AnnotationReader().init(self.thisptr[index]) - - def __len__(self): - return self.thisptr.size() -cdef class _List_Node_Annotation_Builder: - cdef List[C_Node.Annotation].Builder thisptr - cdef init(self, List[C_Node.Annotation].Builder other): - self.thisptr = other - return self - def __getitem__(self, index): - size = self.thisptr.size() - if index >= size: - raise IndexError('Out of bounds') - index = index % size - return _AnnotationBuilder().init(self.thisptr[index]) - def __len__(self): - return self.thisptr.size() -cdef class _List_CodeGeneratorRequest_Node_Reader: - cdef List[C_CodeGeneratorRequest.Node].Reader thisptr - cdef init(self, List[C_CodeGeneratorRequest.Node].Reader other): - self.thisptr = other - return self - def __getitem__(self, index): - size = self.thisptr.size() - if index >= size: - raise IndexError('Out of bounds') - index = index % size - return _NodeReader().init(self.thisptr[index]) - - def __len__(self): - return self.thisptr.size() -cdef class _List_CodeGeneratorRequest_Node_Builder: - cdef List[C_CodeGeneratorRequest.Node].Builder thisptr - cdef init(self, List[C_CodeGeneratorRequest.Node].Builder other): - self.thisptr = other - return self - def __getitem__(self, index): - size = self.thisptr.size() - if index >= size: - raise IndexError('Out of bounds') - index = index % size - return _NodeBuilder().init(self.thisptr[index]) - def __len__(self): - return self.thisptr.size() -cdef class _List_FileNode_FileNode_Import_Reader: - cdef List[C_FileNode.FileNode.Import].Reader thisptr - cdef init(self, List[C_FileNode.FileNode.Import].Reader other): - self.thisptr = other - return self - def __getitem__(self, index): - size = self.thisptr.size() - if index >= size: - raise IndexError('Out of bounds') - index = index % size - return _FileNode_ImportReader().init(self.thisptr[index]) - - def __len__(self): - return self.thisptr.size() -cdef class _List_FileNode_FileNode_Import_Builder: - cdef List[C_FileNode.FileNode.Import].Builder thisptr - cdef init(self, List[C_FileNode.FileNode.Import].Builder other): - self.thisptr = other - return self - def __getitem__(self, index): - size = self.thisptr.size() - if index >= size: - raise IndexError('Out of bounds') - index = index % size - return _FileNode_ImportBuilder().init(self.thisptr[index]) - def __len__(self): - return self.thisptr.size() -cdef class _List_EnumNode_Enumerant_Annotation_Reader: - cdef List[C_EnumNode.Enumerant.Annotation].Reader thisptr - cdef init(self, List[C_EnumNode.Enumerant.Annotation].Reader other): - self.thisptr = other - return self - def __getitem__(self, index): - size = self.thisptr.size() - if index >= size: - raise IndexError('Out of bounds') - index = index % size - return _AnnotationReader().init(self.thisptr[index]) - - def __len__(self): - return self.thisptr.size() -cdef class _List_EnumNode_Enumerant_Annotation_Builder: - cdef List[C_EnumNode.Enumerant.Annotation].Builder thisptr - cdef init(self, List[C_EnumNode.Enumerant.Annotation].Builder other): - self.thisptr = other - return self - def __getitem__(self, index): - size = self.thisptr.size() - if index >= size: - raise IndexError('Out of bounds') - index = index % size - return _AnnotationBuilder().init(self.thisptr[index]) - def __len__(self): - return self.thisptr.size() - -cdef class _CodeGeneratorRequestReader: - cdef C_CodeGeneratorRequest.Reader thisptr - cdef init(self, C_CodeGeneratorRequest.Reader other): - self.thisptr = other - return self - - property nodes: - def __get__(self): - return _List_CodeGeneratorRequest_Node_Reader().init(self.thisptr.getNodes()) - property requestedFiles: - def __get__(self): - return _List_UInt64_Reader().init(self.thisptr.getRequestedFiles()) - -cdef class _CodeGeneratorRequestBuilder: - cdef C_CodeGeneratorRequest.Builder thisptr - cdef init(self, C_CodeGeneratorRequest.Builder other): - self.thisptr = other - return self - - property nodes: - def __get__(self): - return _List_CodeGeneratorRequest_Node_Builder().init(self.thisptr.getNodes()) - cpdef initNodes(self, uint num): - return _List_CodeGeneratorRequest_Node_Builder().init(self.thisptr.initNodes(num)) - property requestedFiles: - def __get__(self): - return _List_UInt64_Builder().init(self.thisptr.getRequestedFiles()) - cpdef initRequestedFiles(self, uint num): - return _List_UInt64_Builder().init(self.thisptr.initRequestedFiles(num)) - -_ElementSize = make_enum('_ElementSize',inlineComposite = _ElementSize_inlineComposite,eightBytes = _ElementSize_eightBytes,pointer = _ElementSize_pointer,bit = _ElementSize_bit,twoBytes = _ElementSize_twoBytes,fourBytes = _ElementSize_fourBytes,byte = _ElementSize_byte,empty = _ElementSize_empty,) - - - -cdef class _InterfaceNode_Method_ParamReader: - cdef C_InterfaceNode.Method.Param.Reader thisptr - cdef init(self, C_InterfaceNode.Method.Param.Reader other): - self.thisptr = other - return self - - property defaultValue: - def __get__(self): - return _ValueReader().init(self.thisptr.getDefaultValue()) - property type: - def __get__(self): - return _TypeReader().init(self.thisptr.getType()) - property name: - def __get__(self): - return self.thisptr.getName().cStr() - property annotations: - def __get__(self): - return _List_InterfaceNode_Method_Param_Annotation_Reader().init(self.thisptr.getAnnotations()) - -cdef class _InterfaceNode_Method_ParamBuilder: - cdef C_InterfaceNode.Method.Param.Builder thisptr - cdef init(self, C_InterfaceNode.Method.Param.Builder other): - self.thisptr = other - return self - - property defaultValue: - def __get__(self): - return _ValueBuilder().init(self.thisptr.getDefaultValue()) - def __set__(self, val): - pass - property type: - def __get__(self): - return _TypeBuilder().init(self.thisptr.getType()) - def __set__(self, val): - pass - property name: - def __get__(self): - return self.thisptr.getName().cStr() - def __set__(self, val): - pass - property annotations: - def __get__(self): - return _List_InterfaceNode_Method_Param_Annotation_Builder().init(self.thisptr.getAnnotations()) - cpdef initAnnotations(self, uint num): - return _List_InterfaceNode_Method_Param_Annotation_Builder().init(self.thisptr.initAnnotations(num)) -cdef class _InterfaceNode_MethodReader: - cdef C_InterfaceNode.Method.Reader thisptr - cdef init(self, C_InterfaceNode.Method.Reader other): - self.thisptr = other - return self - - property codeOrder: - def __get__(self): - return self.thisptr.getCodeOrder() - property name: - def __get__(self): - return self.thisptr.getName().cStr() - property params: - def __get__(self): - return _List_InterfaceNode_Method_InterfaceNode_Method_Param_Reader().init(self.thisptr.getParams()) - property requiredParamCount: - def __get__(self): - return self.thisptr.getRequiredParamCount() - property returnType: - def __get__(self): - return _TypeReader().init(self.thisptr.getReturnType()) - property annotations: - def __get__(self): - return _List_InterfaceNode_Method_Annotation_Reader().init(self.thisptr.getAnnotations()) - -cdef class _InterfaceNode_MethodBuilder: - cdef C_InterfaceNode.Method.Builder thisptr - cdef init(self, C_InterfaceNode.Method.Builder other): - self.thisptr = other - return self - - property codeOrder: - def __get__(self): - return self.thisptr.getCodeOrder() - def __set__(self, val): - self.thisptr.setCodeOrder(val) - property name: - def __get__(self): - return self.thisptr.getName().cStr() - def __set__(self, val): - pass - property params: - def __get__(self): - return _List_InterfaceNode_Method_InterfaceNode_Method_Param_Builder().init(self.thisptr.getParams()) - cpdef initParams(self, uint num): - return _List_InterfaceNode_Method_InterfaceNode_Method_Param_Builder().init(self.thisptr.initParams(num)) - property requiredParamCount: - def __get__(self): - return self.thisptr.getRequiredParamCount() - def __set__(self, val): - self.thisptr.setRequiredParamCount(val) - property returnType: - def __get__(self): - return _TypeBuilder().init(self.thisptr.getReturnType()) - def __set__(self, val): - pass - property annotations: - def __get__(self): - return _List_InterfaceNode_Method_Annotation_Builder().init(self.thisptr.getAnnotations()) - cpdef initAnnotations(self, uint num): - return _List_InterfaceNode_Method_Annotation_Builder().init(self.thisptr.initAnnotations(num)) -cdef class _InterfaceNodeReader: - cdef C_InterfaceNode.Reader thisptr - cdef init(self, C_InterfaceNode.Reader other): - self.thisptr = other - return self - - property methods: - def __get__(self): - return _List_InterfaceNode_InterfaceNode_Method_Reader().init(self.thisptr.getMethods()) - -cdef class _InterfaceNodeBuilder: - cdef C_InterfaceNode.Builder thisptr - cdef init(self, C_InterfaceNode.Builder other): - self.thisptr = other - return self - - property methods: - def __get__(self): - return _List_InterfaceNode_InterfaceNode_Method_Builder().init(self.thisptr.getMethods()) - cpdef initMethods(self, uint num): - return _List_InterfaceNode_InterfaceNode_Method_Builder().init(self.thisptr.initMethods(num)) - - -_Value_Body_Which = make_enum('_Value_Body_Which',uint32Value = _Value_Body_uint32Value,float64Value = _Value_Body_float64Value,voidValue = _Value_Body_voidValue,dataValue = _Value_Body_dataValue,listValue = _Value_Body_listValue,int32Value = _Value_Body_int32Value,enumValue = _Value_Body_enumValue,int8Value = _Value_Body_int8Value,boolValue = _Value_Body_boolValue,int16Value = _Value_Body_int16Value,float32Value = _Value_Body_float32Value,interfaceValue = _Value_Body_interfaceValue,uint16Value = _Value_Body_uint16Value,uint8Value = _Value_Body_uint8Value,int64Value = _Value_Body_int64Value,structValue = _Value_Body_structValue,textValue = _Value_Body_textValue,uint64Value = _Value_Body_uint64Value,objectValue = _Value_Body_objectValue,) -cdef class _Value_BodyReader: - cdef C_Value.Body.Reader thisptr - cdef init(self, C_Value.Body.Reader other): - self.thisptr = other - return self - - cpdef int which(self): - return self.thisptr.which() - property uint32Value: - def __get__(self): - return self.thisptr.getUint32Value() - property float64Value: - def __get__(self): - return self.thisptr.getFloat64Value() - property voidValue: - def __get__(self): - return None - property dataValue: - def __get__(self): - temp = self.thisptr.getDataValue() - return (temp.begin())[:temp.size()] - property listValue: - def __get__(self): - return None - property int32Value: - def __get__(self): - return self.thisptr.getInt32Value() - property enumValue: - def __get__(self): - return self.thisptr.getEnumValue() - property int8Value: - def __get__(self): - return self.thisptr.getInt8Value() - property boolValue: - def __get__(self): - return self.thisptr.getBoolValue() - property int16Value: - def __get__(self): - return self.thisptr.getInt16Value() - property float32Value: - def __get__(self): - return self.thisptr.getFloat32Value() - property interfaceValue: - def __get__(self): - return None - property uint16Value: - def __get__(self): - return self.thisptr.getUint16Value() - property uint8Value: - def __get__(self): - return self.thisptr.getUint8Value() - property int64Value: - def __get__(self): - return self.thisptr.getInt64Value() - property structValue: - def __get__(self): - return None - property textValue: - def __get__(self): - return self.thisptr.getTextValue().cStr() - property uint64Value: - def __get__(self): - return self.thisptr.getUint64Value() - property objectValue: - def __get__(self): - return None - -cdef class _Value_BodyBuilder: - cdef C_Value.Body.Builder thisptr - cdef init(self, C_Value.Body.Builder other): - self.thisptr = other - return self - - cpdef int which(self): - return self.thisptr.which() - property uint32Value: - def __get__(self): - return self.thisptr.getUint32Value() - def __set__(self, val): - self.thisptr.setUint32Value(val) - property float64Value: - def __get__(self): - return self.thisptr.getFloat64Value() - def __set__(self, val): - self.thisptr.setFloat64Value(val) - property voidValue: - def __get__(self): - return None - def __set__(self, val): - pass - property dataValue: - def __get__(self): - temp = self.thisptr.getDataValue() - return (temp.begin())[:temp.size()] - def __set__(self, val): - pass - property listValue: - def __get__(self): - return None - def __set__(self, val): - pass - property int32Value: - def __get__(self): - return self.thisptr.getInt32Value() - def __set__(self, val): - self.thisptr.setInt32Value(val) - property enumValue: - def __get__(self): - return self.thisptr.getEnumValue() - def __set__(self, val): - self.thisptr.setEnumValue(val) - property int8Value: - def __get__(self): - return self.thisptr.getInt8Value() - def __set__(self, val): - self.thisptr.setInt8Value(val) - property boolValue: - def __get__(self): - return self.thisptr.getBoolValue() - def __set__(self, val): - self.thisptr.setBoolValue(val) - property int16Value: - def __get__(self): - return self.thisptr.getInt16Value() - def __set__(self, val): - self.thisptr.setInt16Value(val) - property float32Value: - def __get__(self): - return self.thisptr.getFloat32Value() - def __set__(self, val): - self.thisptr.setFloat32Value(val) - property interfaceValue: - def __get__(self): - return None - def __set__(self, val): - pass - property uint16Value: - def __get__(self): - return self.thisptr.getUint16Value() - def __set__(self, val): - self.thisptr.setUint16Value(val) - property uint8Value: - def __get__(self): - return self.thisptr.getUint8Value() - def __set__(self, val): - self.thisptr.setUint8Value(val) - property int64Value: - def __get__(self): - return self.thisptr.getInt64Value() - def __set__(self, val): - self.thisptr.setInt64Value(val) - property structValue: - def __get__(self): - return None - def __set__(self, val): - pass - property textValue: - def __get__(self): - return self.thisptr.getTextValue().cStr() - def __set__(self, val): - pass - property uint64Value: - def __get__(self): - return self.thisptr.getUint64Value() - def __set__(self, val): - self.thisptr.setUint64Value(val) - property objectValue: - def __get__(self): - return None - def __set__(self, val): - pass -cdef class _ValueReader: - cdef C_Value.Reader thisptr - cdef init(self, C_Value.Reader other): - self.thisptr = other - return self - - property body: - def __get__(self): - return _Value_BodyReader().init(self.thisptr.getBody()) - -cdef class _ValueBuilder: - cdef C_Value.Builder thisptr - cdef init(self, C_Value.Builder other): - self.thisptr = other - return self - - property body: - def __get__(self): - return _Value_BodyBuilder().init(self.thisptr.getBody()) - def __set__(self, val): - pass - -cdef class _ConstNodeReader: - cdef C_ConstNode.Reader thisptr - cdef init(self, C_ConstNode.Reader other): - self.thisptr = other - return self - - property type: - def __get__(self): - return _TypeReader().init(self.thisptr.getType()) - property value: - def __get__(self): - return _ValueReader().init(self.thisptr.getValue()) - -cdef class _ConstNodeBuilder: - cdef C_ConstNode.Builder thisptr - cdef init(self, C_ConstNode.Builder other): - self.thisptr = other - return self - - property type: - def __get__(self): - return _TypeBuilder().init(self.thisptr.getType()) - def __set__(self, val): - pass - property value: - def __get__(self): - return _ValueBuilder().init(self.thisptr.getValue()) - def __set__(self, val): - pass - - -_Type_Body_Which = make_enum('_Type_Body_Which',boolType = _Type_Body_boolType,structType = _Type_Body_structType,int32Type = _Type_Body_int32Type,voidType = _Type_Body_voidType,uint16Type = _Type_Body_uint16Type,dataType = _Type_Body_dataType,objectType = _Type_Body_objectType,int64Type = _Type_Body_int64Type,float64Type = _Type_Body_float64Type,interfaceType = _Type_Body_interfaceType,uint32Type = _Type_Body_uint32Type,uint8Type = _Type_Body_uint8Type,listType = _Type_Body_listType,int8Type = _Type_Body_int8Type,float32Type = _Type_Body_float32Type,enumType = _Type_Body_enumType,uint64Type = _Type_Body_uint64Type,textType = _Type_Body_textType,int16Type = _Type_Body_int16Type,) -cdef class _Type_BodyReader: - cdef C_Type.Body.Reader thisptr - cdef init(self, C_Type.Body.Reader other): - self.thisptr = other - return self - - cpdef int which(self): - return self.thisptr.which() - property boolType: - def __get__(self): - return None - property structType: - def __get__(self): - return self.thisptr.getStructType() - property int32Type: - def __get__(self): - return None - property voidType: - def __get__(self): - return None - property uint16Type: - def __get__(self): - return None - property dataType: - def __get__(self): - return None - property objectType: - def __get__(self): - return None - property int64Type: - def __get__(self): - return None - property float64Type: - def __get__(self): - return None - property interfaceType: - def __get__(self): - return self.thisptr.getInterfaceType() - property uint32Type: - def __get__(self): - return None - property uint8Type: - def __get__(self): - return None - property listType: - def __get__(self): - return _TypeReader().init(self.thisptr.getListType()) - property int8Type: - def __get__(self): - return None - property float32Type: - def __get__(self): - return None - property enumType: - def __get__(self): - return self.thisptr.getEnumType() - property uint64Type: - def __get__(self): - return None - property textType: - def __get__(self): - return None - property int16Type: - def __get__(self): - return None - -cdef class _Type_BodyBuilder: - cdef C_Type.Body.Builder thisptr - cdef init(self, C_Type.Body.Builder other): - self.thisptr = other - return self - - cpdef int which(self): - return self.thisptr.which() - property boolType: - def __get__(self): - return None - def __set__(self, val): - pass - property structType: - def __get__(self): - return self.thisptr.getStructType() - def __set__(self, val): - self.thisptr.setStructType(val) - property int32Type: - def __get__(self): - return None - def __set__(self, val): - pass - property voidType: - def __get__(self): - return None - def __set__(self, val): - pass - property uint16Type: - def __get__(self): - return None - def __set__(self, val): - pass - property dataType: - def __get__(self): - return None - def __set__(self, val): - pass - property objectType: - def __get__(self): - return None - def __set__(self, val): - pass - property int64Type: - def __get__(self): - return None - def __set__(self, val): - pass - property float64Type: - def __get__(self): - return None - def __set__(self, val): - pass - property interfaceType: - def __get__(self): - return self.thisptr.getInterfaceType() - def __set__(self, val): - self.thisptr.setInterfaceType(val) - property uint32Type: - def __get__(self): - return None - def __set__(self, val): - pass - property uint8Type: - def __get__(self): - return None - def __set__(self, val): - pass - property listType: - def __get__(self): - return _TypeBuilder().init(self.thisptr.getListType()) - def __set__(self, val): - pass - property int8Type: - def __get__(self): - return None - def __set__(self, val): - pass - property float32Type: - def __get__(self): - return None - def __set__(self, val): - pass - property enumType: - def __get__(self): - return self.thisptr.getEnumType() - def __set__(self, val): - self.thisptr.setEnumType(val) - property uint64Type: - def __get__(self): - return None - def __set__(self, val): - pass - property textType: - def __get__(self): - return None - def __set__(self, val): - pass - property int16Type: - def __get__(self): - return None - def __set__(self, val): - pass -cdef class _TypeReader: - cdef C_Type.Reader thisptr - cdef init(self, C_Type.Reader other): - self.thisptr = other - return self - - property body: - def __get__(self): - return _Type_BodyReader().init(self.thisptr.getBody()) - -cdef class _TypeBuilder: - cdef C_Type.Builder thisptr - cdef init(self, C_Type.Builder other): - self.thisptr = other - return self - - property body: - def __get__(self): - return _Type_BodyBuilder().init(self.thisptr.getBody()) - def __set__(self, val): - pass - - -cdef class _FileNode_ImportReader: - cdef C_FileNode.Import.Reader thisptr - cdef init(self, C_FileNode.Import.Reader other): - self.thisptr = other - return self - - property id: - def __get__(self): - return self.thisptr.getId() - property name: - def __get__(self): - return self.thisptr.getName().cStr() - -cdef class _FileNode_ImportBuilder: - cdef C_FileNode.Import.Builder thisptr - cdef init(self, C_FileNode.Import.Builder other): - self.thisptr = other - return self - - property id: - def __get__(self): - return self.thisptr.getId() - def __set__(self, val): - self.thisptr.setId(val) - property name: - def __get__(self): - return self.thisptr.getName().cStr() - def __set__(self, val): - pass -cdef class _FileNodeReader: - cdef C_FileNode.Reader thisptr - cdef init(self, C_FileNode.Reader other): - self.thisptr = other - return self - - property imports: - def __get__(self): - return _List_FileNode_FileNode_Import_Reader().init(self.thisptr.getImports()) - -cdef class _FileNodeBuilder: - cdef C_FileNode.Builder thisptr - cdef init(self, C_FileNode.Builder other): - self.thisptr = other - return self - - property imports: - def __get__(self): - return _List_FileNode_FileNode_Import_Builder().init(self.thisptr.getImports()) - cpdef initImports(self, uint num): - return _List_FileNode_FileNode_Import_Builder().init(self.thisptr.initImports(num)) - - -_Node_Body_Which = make_enum('_Node_Body_Which',annotationNode = _Node_Body_annotationNode,interfaceNode = _Node_Body_interfaceNode,enumNode = _Node_Body_enumNode,structNode = _Node_Body_structNode,constNode = _Node_Body_constNode,fileNode = _Node_Body_fileNode,) -cdef class _Node_BodyReader: - cdef C_Node.Body.Reader thisptr - cdef init(self, C_Node.Body.Reader other): - self.thisptr = other - return self - - cpdef int which(self): - return self.thisptr.which() - property annotationNode: - def __get__(self): - return _AnnotationNodeReader().init(self.thisptr.getAnnotationNode()) - property interfaceNode: - def __get__(self): - return _InterfaceNodeReader().init(self.thisptr.getInterfaceNode()) - property enumNode: - def __get__(self): - return _EnumNodeReader().init(self.thisptr.getEnumNode()) - property structNode: - def __get__(self): - return _StructNodeReader().init(self.thisptr.getStructNode()) - property constNode: - def __get__(self): - return _ConstNodeReader().init(self.thisptr.getConstNode()) - property fileNode: - def __get__(self): - return _FileNodeReader().init(self.thisptr.getFileNode()) - -cdef class _Node_BodyBuilder: - cdef C_Node.Body.Builder thisptr - cdef init(self, C_Node.Body.Builder other): - self.thisptr = other - return self - - cpdef int which(self): - return self.thisptr.which() - property annotationNode: - def __get__(self): - return _AnnotationNodeBuilder().init(self.thisptr.getAnnotationNode()) - def __set__(self, val): - pass - property interfaceNode: - def __get__(self): - return _InterfaceNodeBuilder().init(self.thisptr.getInterfaceNode()) - def __set__(self, val): - pass - property enumNode: - def __get__(self): - return _EnumNodeBuilder().init(self.thisptr.getEnumNode()) - def __set__(self, val): - pass - property structNode: - def __get__(self): - return _StructNodeBuilder().init(self.thisptr.getStructNode()) - def __set__(self, val): - pass - property constNode: - def __get__(self): - return _ConstNodeBuilder().init(self.thisptr.getConstNode()) - def __set__(self, val): - pass - property fileNode: - def __get__(self): - return _FileNodeBuilder().init(self.thisptr.getFileNode()) - def __set__(self, val): - pass - -cdef class _Node_NestedNodeReader: - cdef C_Node.NestedNode.Reader thisptr - cdef init(self, C_Node.NestedNode.Reader other): - self.thisptr = other - return self - - property name: - def __get__(self): - return self.thisptr.getName().cStr() - property id: - def __get__(self): - return self.thisptr.getId() - -cdef class _Node_NestedNodeBuilder: - cdef C_Node.NestedNode.Builder thisptr - cdef init(self, C_Node.NestedNode.Builder other): - self.thisptr = other - return self - - property name: - def __get__(self): - return self.thisptr.getName().cStr() - def __set__(self, val): - pass - property id: - def __get__(self): - return self.thisptr.getId() - def __set__(self, val): - self.thisptr.setId(val) -cdef class _NodeReader: - cdef init(self, C_Node.Reader other): - self.thisptr = other - return self - - property body: - def __get__(self): - return _Node_BodyReader().init(self.thisptr.getBody()) - property displayName: - def __get__(self): - return self.thisptr.getDisplayName().cStr() - property annotations: - def __get__(self): - return _List_Node_Annotation_Reader().init(self.thisptr.getAnnotations()) - property scopeId: - def __get__(self): - return self.thisptr.getScopeId() - property nestedNodes: - def __get__(self): - return _List_Node_Node_NestedNode_Reader().init(self.thisptr.getNestedNodes()) - property id: - def __get__(self): - return self.thisptr.getId() - -cdef class _NodeBuilder: - cdef C_Node.Builder thisptr - cdef init(self, C_Node.Builder other): - self.thisptr = other - return self - - property body: - def __get__(self): - return _Node_BodyBuilder().init(self.thisptr.getBody()) - def __set__(self, val): - pass - property displayName: - def __get__(self): - return self.thisptr.getDisplayName().cStr() - def __set__(self, val): - pass - property annotations: - def __get__(self): - return _List_Node_Annotation_Builder().init(self.thisptr.getAnnotations()) - cpdef initAnnotations(self, uint num): - return _List_Node_Annotation_Builder().init(self.thisptr.initAnnotations(num)) - property scopeId: - def __get__(self): - return self.thisptr.getScopeId() - def __set__(self, val): - self.thisptr.setScopeId(val) - property nestedNodes: - def __get__(self): - return _List_Node_Node_NestedNode_Builder().init(self.thisptr.getNestedNodes()) - cpdef initNestedNodes(self, uint num): - return _List_Node_Node_NestedNode_Builder().init(self.thisptr.initNestedNodes(num)) - property id: - def __get__(self): - return self.thisptr.getId() - def __set__(self, val): - self.thisptr.setId(val) - -cdef class _AnnotationNodeReader: - cdef C_AnnotationNode.Reader thisptr - cdef init(self, C_AnnotationNode.Reader other): - self.thisptr = other - return self - - property targetsField: - def __get__(self): - return self.thisptr.getTargetsField() - property targetsConst: - def __get__(self): - return self.thisptr.getTargetsConst() - property targetsFile: - def __get__(self): - return self.thisptr.getTargetsFile() - property targetsStruct: - def __get__(self): - return self.thisptr.getTargetsStruct() - property targetsParam: - def __get__(self): - return self.thisptr.getTargetsParam() - property targetsUnion: - def __get__(self): - return self.thisptr.getTargetsUnion() - property targetsAnnotation: - def __get__(self): - return self.thisptr.getTargetsAnnotation() - property targetsEnumerant: - def __get__(self): - return self.thisptr.getTargetsEnumerant() - property type: - def __get__(self): - return _TypeReader().init(self.thisptr.getType()) - property targetsEnum: - def __get__(self): - return self.thisptr.getTargetsEnum() - property targetsInterface: - def __get__(self): - return self.thisptr.getTargetsInterface() - property targetsMethod: - def __get__(self): - return self.thisptr.getTargetsMethod() - -cdef class _AnnotationNodeBuilder: - cdef C_AnnotationNode.Builder thisptr - cdef init(self, C_AnnotationNode.Builder other): - self.thisptr = other - return self - - property targetsField: - def __get__(self): - return self.thisptr.getTargetsField() - def __set__(self, val): - self.thisptr.setTargetsField(val) - property targetsConst: - def __get__(self): - return self.thisptr.getTargetsConst() - def __set__(self, val): - self.thisptr.setTargetsConst(val) - property targetsFile: - def __get__(self): - return self.thisptr.getTargetsFile() - def __set__(self, val): - self.thisptr.setTargetsFile(val) - property targetsStruct: - def __get__(self): - return self.thisptr.getTargetsStruct() - def __set__(self, val): - self.thisptr.setTargetsStruct(val) - property targetsParam: - def __get__(self): - return self.thisptr.getTargetsParam() - def __set__(self, val): - self.thisptr.setTargetsParam(val) - property targetsUnion: - def __get__(self): - return self.thisptr.getTargetsUnion() - def __set__(self, val): - self.thisptr.setTargetsUnion(val) - property targetsAnnotation: - def __get__(self): - return self.thisptr.getTargetsAnnotation() - def __set__(self, val): - self.thisptr.setTargetsAnnotation(val) - property targetsEnumerant: - def __get__(self): - return self.thisptr.getTargetsEnumerant() - def __set__(self, val): - self.thisptr.setTargetsEnumerant(val) - property type: - def __get__(self): - return _TypeBuilder().init(self.thisptr.getType()) - def __set__(self, val): - pass - property targetsEnum: - def __get__(self): - return self.thisptr.getTargetsEnum() - def __set__(self, val): - self.thisptr.setTargetsEnum(val) - property targetsInterface: - def __get__(self): - return self.thisptr.getTargetsInterface() - def __set__(self, val): - self.thisptr.setTargetsInterface(val) - property targetsMethod: - def __get__(self): - return self.thisptr.getTargetsMethod() - def __set__(self, val): - self.thisptr.setTargetsMethod(val) - - -cdef class _EnumNode_EnumerantReader: - cdef C_EnumNode.Enumerant.Reader thisptr - cdef init(self, C_EnumNode.Enumerant.Reader other): - self.thisptr = other - return self - - property codeOrder: - def __get__(self): - return self.thisptr.getCodeOrder() - property name: - def __get__(self): - return self.thisptr.getName().cStr() - property annotations: - def __get__(self): - return _List_EnumNode_Enumerant_Annotation_Reader().init(self.thisptr.getAnnotations()) - -cdef class _EnumNode_EnumerantBuilder: - cdef C_EnumNode.Enumerant.Builder thisptr - cdef init(self, C_EnumNode.Enumerant.Builder other): - self.thisptr = other - return self - - property codeOrder: - def __get__(self): - return self.thisptr.getCodeOrder() - def __set__(self, val): - self.thisptr.setCodeOrder(val) - property name: - def __get__(self): - return self.thisptr.getName().cStr() - def __set__(self, val): - pass - property annotations: - def __get__(self): - return _List_EnumNode_Enumerant_Annotation_Builder().init(self.thisptr.getAnnotations()) - cpdef initAnnotations(self, uint num): - return _List_EnumNode_Enumerant_Annotation_Builder().init(self.thisptr.initAnnotations(num)) -cdef class _EnumNodeReader: - cdef C_EnumNode.Reader thisptr - cdef init(self, C_EnumNode.Reader other): - self.thisptr = other - return self - - property enumerants: - def __get__(self): - return _List_EnumNode_EnumNode_Enumerant_Reader().init(self.thisptr.getEnumerants()) - -cdef class _EnumNodeBuilder: - cdef C_EnumNode.Builder thisptr - cdef init(self, C_EnumNode.Builder other): - self.thisptr = other - return self - - property enumerants: - def __get__(self): - return _List_EnumNode_EnumNode_Enumerant_Builder().init(self.thisptr.getEnumerants()) - cpdef initEnumerants(self, uint num): - return _List_EnumNode_EnumNode_Enumerant_Builder().init(self.thisptr.initEnumerants(num)) - - -cdef class _StructNode_UnionReader: - cdef C_StructNode.Union.Reader thisptr - cdef init(self, C_StructNode.Union.Reader other): - self.thisptr = other - return self - - property discriminantOffset: - def __get__(self): - return self.thisptr.getDiscriminantOffset() - property members: - def __get__(self): - return _List_StructNode_Union_StructNode_Member_Reader().init(self.thisptr.getMembers()) - -cdef class _StructNode_UnionBuilder: - cdef C_StructNode.Union.Builder thisptr - cdef init(self, C_StructNode.Union.Builder other): - self.thisptr = other - return self - - property discriminantOffset: - def __get__(self): - return self.thisptr.getDiscriminantOffset() - def __set__(self, val): - self.thisptr.setDiscriminantOffset(val) - property members: - def __get__(self): - return _List_StructNode_Union_StructNode_Member_Builder().init(self.thisptr.getMembers()) - cpdef initMembers(self, uint num): - return _List_StructNode_Union_StructNode_Member_Builder().init(self.thisptr.initMembers(num)) - - -_StructNode_Member_Body_Which = make_enum('_StructNode_Member_Body_Which',fieldMember = _StructNode_Member_Body_fieldMember,unionMember = _StructNode_Member_Body_unionMember,) -cdef class _StructNode_Member_BodyReader: - cdef C_StructNode.Member.Body.Reader thisptr - cdef init(self, C_StructNode.Member.Body.Reader other): - self.thisptr = other - return self - - cpdef int which(self): - return self.thisptr.which() - property fieldMember: - def __get__(self): - return _StructNode_FieldReader().init(self.thisptr.getFieldMember()) - property unionMember: - def __get__(self): - return _StructNode_UnionReader().init(self.thisptr.getUnionMember()) - -cdef class _StructNode_Member_BodyBuilder: - cdef C_StructNode.Member.Body.Builder thisptr - cdef init(self, C_StructNode.Member.Body.Builder other): - self.thisptr = other - return self - - cpdef int which(self): - return self.thisptr.which() - property fieldMember: - def __get__(self): - return _StructNode_FieldBuilder().init(self.thisptr.getFieldMember()) - def __set__(self, val): - pass - property unionMember: - def __get__(self): - return _StructNode_UnionBuilder().init(self.thisptr.getUnionMember()) - def __set__(self, val): - pass -cdef class _StructNode_MemberReader: - cdef C_StructNode.Member.Reader thisptr - cdef init(self, C_StructNode.Member.Reader other): - self.thisptr = other - return self - - property ordinal: - def __get__(self): - return self.thisptr.getOrdinal() - property body: - def __get__(self): - return _StructNode_Member_BodyReader().init(self.thisptr.getBody()) - property codeOrder: - def __get__(self): - return self.thisptr.getCodeOrder() - property name: - def __get__(self): - return self.thisptr.getName().cStr() - property annotations: - def __get__(self): - return _List_StructNode_Member_Annotation_Reader().init(self.thisptr.getAnnotations()) - -cdef class _StructNode_MemberBuilder: - cdef C_StructNode.Member.Builder thisptr - cdef init(self, C_StructNode.Member.Builder other): - self.thisptr = other - return self - - property ordinal: - def __get__(self): - return self.thisptr.getOrdinal() - def __set__(self, val): - self.thisptr.setOrdinal(val) - property body: - def __get__(self): - return _StructNode_Member_BodyBuilder().init(self.thisptr.getBody()) - def __set__(self, val): - pass - property codeOrder: - def __get__(self): - return self.thisptr.getCodeOrder() - def __set__(self, val): - self.thisptr.setCodeOrder(val) - property name: - def __get__(self): - return self.thisptr.getName().cStr() - def __set__(self, val): - pass - property annotations: - def __get__(self): - return _List_StructNode_Member_Annotation_Builder().init(self.thisptr.getAnnotations()) - cpdef initAnnotations(self, uint num): - return _List_StructNode_Member_Annotation_Builder().init(self.thisptr.initAnnotations(num)) - -cdef class _StructNode_FieldReader: - cdef C_StructNode.Field.Reader thisptr - cdef init(self, C_StructNode.Field.Reader other): - self.thisptr = other - return self - - property defaultValue: - def __get__(self): - return _ValueReader().init(self.thisptr.getDefaultValue()) - property type: - def __get__(self): - return _TypeReader().init(self.thisptr.getType()) - property offset: - def __get__(self): - return self.thisptr.getOffset() - -cdef class _StructNode_FieldBuilder: - cdef C_StructNode.Field.Builder thisptr - cdef init(self, C_StructNode.Field.Builder other): - self.thisptr = other - return self - - property defaultValue: - def __get__(self): - return _ValueBuilder().init(self.thisptr.getDefaultValue()) - def __set__(self, val): - pass - property type: - def __get__(self): - return _TypeBuilder().init(self.thisptr.getType()) - def __set__(self, val): - pass - property offset: - def __get__(self): - return self.thisptr.getOffset() - def __set__(self, val): - self.thisptr.setOffset(val) -cdef class _StructNodeReader: - cdef C_StructNode.Reader thisptr - cdef init(self, C_StructNode.Reader other): - self.thisptr = other - return self - - property dataSectionWordSize: - def __get__(self): - return self.thisptr.getDataSectionWordSize() - property members: - def __get__(self): - return _List_StructNode_StructNode_Member_Reader().init(self.thisptr.getMembers()) - property pointerSectionSize: - def __get__(self): - return self.thisptr.getPointerSectionSize() - -cdef class _StructNodeBuilder: - cdef C_StructNode.Builder thisptr - cdef init(self, C_StructNode.Builder other): - self.thisptr = other - return self - - property dataSectionWordSize: - def __get__(self): - return self.thisptr.getDataSectionWordSize() - def __set__(self, val): - self.thisptr.setDataSectionWordSize(val) - property members: - def __get__(self): - return _List_StructNode_StructNode_Member_Builder().init(self.thisptr.getMembers()) - cpdef initMembers(self, uint num): - return _List_StructNode_StructNode_Member_Builder().init(self.thisptr.initMembers(num)) - property pointerSectionSize: - def __get__(self): - return self.thisptr.getPointerSectionSize() - def __set__(self, val): - self.thisptr.setPointerSectionSize(val) - -cdef class _AnnotationReader: - cdef C_Annotation.Reader thisptr - cdef init(self, C_Annotation.Reader other): - self.thisptr = other - return self - - property id: - def __get__(self): - return self.thisptr.getId() - property value: - def __get__(self): - return _ValueReader().init(self.thisptr.getValue()) - -cdef class _AnnotationBuilder: - cdef C_Annotation.Builder thisptr - cdef init(self, C_Annotation.Builder other): - self.thisptr = other - return self - - property id: - def __get__(self): - return self.thisptr.getId() - def __set__(self, val): - self.thisptr.setId(val) - property value: - def __get__(self): - return _ValueBuilder().init(self.thisptr.getValue()) - def __set__(self, val): - pass - -cdef class MessageBuilder: - cdef capnp.MessageBuilder * thisptr - def __dealloc__(self): - del self.thisptr - cpdef getRootCodeGeneratorRequest(self): - return _CodeGeneratorRequestBuilder().init(self.thisptr.getRootCodeGeneratorRequest()) - cpdef initRootCodeGeneratorRequest(self): - return _CodeGeneratorRequestBuilder().init(self.thisptr.initRootCodeGeneratorRequest()) - cpdef getRootInterfaceNode(self): - return _InterfaceNodeBuilder().init(self.thisptr.getRootInterfaceNode()) - cpdef initRootInterfaceNode(self): - return _InterfaceNodeBuilder().init(self.thisptr.initRootInterfaceNode()) - cpdef getRootValue(self): - return _ValueBuilder().init(self.thisptr.getRootValue()) - cpdef initRootValue(self): - return _ValueBuilder().init(self.thisptr.initRootValue()) - cpdef getRootConstNode(self): - return _ConstNodeBuilder().init(self.thisptr.getRootConstNode()) - cpdef initRootConstNode(self): - return _ConstNodeBuilder().init(self.thisptr.initRootConstNode()) - cpdef getRootType(self): - return _TypeBuilder().init(self.thisptr.getRootType()) - cpdef initRootType(self): - return _TypeBuilder().init(self.thisptr.initRootType()) - cpdef getRootFileNode(self): - return _FileNodeBuilder().init(self.thisptr.getRootFileNode()) - cpdef initRootFileNode(self): - return _FileNodeBuilder().init(self.thisptr.initRootFileNode()) - cpdef getRootNode(self): - return _NodeBuilder().init(self.thisptr.getRootNode()) - cpdef initRootNode(self): - return _NodeBuilder().init(self.thisptr.initRootNode()) - cpdef getRootAnnotationNode(self): - return _AnnotationNodeBuilder().init(self.thisptr.getRootAnnotationNode()) - cpdef initRootAnnotationNode(self): - return _AnnotationNodeBuilder().init(self.thisptr.initRootAnnotationNode()) - cpdef getRootEnumNode(self): - return _EnumNodeBuilder().init(self.thisptr.getRootEnumNode()) - cpdef initRootEnumNode(self): - return _EnumNodeBuilder().init(self.thisptr.initRootEnumNode()) - cpdef getRootStructNode(self): - return _StructNodeBuilder().init(self.thisptr.getRootStructNode()) - cpdef initRootStructNode(self): - return _StructNodeBuilder().init(self.thisptr.initRootStructNode()) - cpdef getRootAnnotation(self): - return _AnnotationBuilder().init(self.thisptr.getRootAnnotation()) - cpdef initRootAnnotation(self): - return _AnnotationBuilder().init(self.thisptr.initRootAnnotation()) -cdef class MallocMessageBuilder(MessageBuilder): - def __cinit__(self): - self.thisptr = new capnp.MallocMessageBuilder() - - -cdef class MessageReader: - cdef capnp.MessageReader * thisptr - def __dealloc__(self): - del self.thisptr - cpdef getRootCodeGeneratorRequest(self): - return _CodeGeneratorRequestReader().init(self.thisptr.getRootCodeGeneratorRequest()) - cpdef getRootInterfaceNode(self): - return _InterfaceNodeReader().init(self.thisptr.getRootInterfaceNode()) - cpdef getRootValue(self): - return _ValueReader().init(self.thisptr.getRootValue()) - cpdef getRootConstNode(self): - return _ConstNodeReader().init(self.thisptr.getRootConstNode()) - cpdef getRootType(self): - return _TypeReader().init(self.thisptr.getRootType()) - cpdef getRootFileNode(self): - return _FileNodeReader().init(self.thisptr.getRootFileNode()) - cpdef getRootNode(self): - return _NodeReader().init(self.thisptr.getRootNode()) - cpdef getRootAnnotationNode(self): - return _AnnotationNodeReader().init(self.thisptr.getRootAnnotationNode()) - cpdef getRootEnumNode(self): - return _EnumNodeReader().init(self.thisptr.getRootEnumNode()) - cpdef getRootStructNode(self): - return _StructNodeReader().init(self.thisptr.getRootStructNode()) - cpdef getRootAnnotation(self): - return _AnnotationReader().init(self.thisptr.getRootAnnotation()) - -cdef class StreamFdMessageReader(MessageReader): - def __cinit__(self, int fd): - self.thisptr = new capnp.StreamFdMessageReader(fd) - -cdef class PackedFdMessageReader(MessageReader): - def __cinit__(self, int fd): - self.thisptr = new capnp.PackedFdMessageReader(fd) - -def writeMessageToFd(int fd, MessageBuilder m): - capnp.writeMessageToFd(fd, deref(m.thisptr)) -def writePackedMessageToFd(int fd, MessageBuilder m): - capnp.writePackedMessageToFd(fd, deref(m.thisptr)) - -# Make the namespace human usable -from types import ModuleType -temp = CodeGeneratorRequest = ModuleType('CodeGeneratorRequest') -temp.Reader = _CodeGeneratorRequestReader -temp.Builder = _CodeGeneratorRequestBuilder - -temp = ElementSize = ModuleType('ElementSize') -ElementSize = _ElementSize - -temp = InterfaceNode = ModuleType('InterfaceNode') -temp.Reader = _InterfaceNodeReader -temp.Builder = _InterfaceNodeBuilder - -temp = InterfaceNode.Method = ModuleType('InterfaceNode.Method') -temp.Reader = _InterfaceNode_MethodReader -temp.Builder = _InterfaceNode_MethodBuilder - -temp = InterfaceNode.Method.Param = ModuleType('InterfaceNode.Method.Param') -temp.Reader = _InterfaceNode_Method_ParamReader -temp.Builder = _InterfaceNode_Method_ParamBuilder - -temp = Value = ModuleType('Value') -temp.Reader = _ValueReader -temp.Builder = _ValueBuilder - -temp = Value.Body = ModuleType('Value.Body') -temp.Reader = _Value_BodyReader -temp.Builder = _Value_BodyBuilder -temp.Which = _Value_Body_Which - -temp = ConstNode = ModuleType('ConstNode') -temp.Reader = _ConstNodeReader -temp.Builder = _ConstNodeBuilder - -temp = Type = ModuleType('Type') -temp.Reader = _TypeReader -temp.Builder = _TypeBuilder - -temp = Type.Body = ModuleType('Type.Body') -temp.Reader = _Type_BodyReader -temp.Builder = _Type_BodyBuilder -temp.Which = _Type_Body_Which - -temp = FileNode = ModuleType('FileNode') -temp.Reader = _FileNodeReader -temp.Builder = _FileNodeBuilder - -temp = FileNode.Import = ModuleType('FileNode.Import') -temp.Reader = _FileNode_ImportReader -temp.Builder = _FileNode_ImportBuilder - -temp = Node = ModuleType('Node') -temp.Reader = _NodeReader -temp.Builder = _NodeBuilder - -temp = Node.Body = ModuleType('Node.Body') -temp.Reader = _Node_BodyReader -temp.Builder = _Node_BodyBuilder -temp.Which = _Node_Body_Which - -temp = Node.NestedNode = ModuleType('Node.NestedNode') -temp.Reader = _Node_NestedNodeReader -temp.Builder = _Node_NestedNodeBuilder - -temp = AnnotationNode = ModuleType('AnnotationNode') -temp.Reader = _AnnotationNodeReader -temp.Builder = _AnnotationNodeBuilder - -temp = EnumNode = ModuleType('EnumNode') -temp.Reader = _EnumNodeReader -temp.Builder = _EnumNodeBuilder - -temp = EnumNode.Enumerant = ModuleType('EnumNode.Enumerant') -temp.Reader = _EnumNode_EnumerantReader -temp.Builder = _EnumNode_EnumerantBuilder - -temp = StructNode = ModuleType('StructNode') -temp.Reader = _StructNodeReader -temp.Builder = _StructNodeBuilder - -temp = StructNode.Union = ModuleType('StructNode.Union') -temp.Reader = _StructNode_UnionReader -temp.Builder = _StructNode_UnionBuilder - -temp = StructNode.Member = ModuleType('StructNode.Member') -temp.Reader = _StructNode_MemberReader -temp.Builder = _StructNode_MemberBuilder - -temp = StructNode.Member.Body = ModuleType('StructNode.Member.Body') -temp.Reader = _StructNode_Member_BodyReader -temp.Builder = _StructNode_Member_BodyBuilder -temp.Which = _StructNode_Member_Body_Which - -temp = StructNode.Field = ModuleType('StructNode.Field') -temp.Reader = _StructNode_FieldReader -temp.Builder = _StructNode_FieldBuilder - -temp = Annotation = ModuleType('Annotation') -temp.Reader = _AnnotationReader -temp.Builder = _AnnotationBuilder - - diff --git a/examples/example.py b/examples/example.py index 4ebd5e6..d864e5b 100644 --- a/examples/example.py +++ b/examples/example.py @@ -27,7 +27,7 @@ def writeAddressBook(fd): bobPhones[0].number = "555-4567" bobPhones[0].type = 'home' bobPhones[1].number = "555-7654" - bobPhones[1].type = addressbook.Person.PhoneNumber.Type.WORK + bobPhones[1].type = 'work' bob.employment.unemployed = None # This is definitely bad, syntax will change at some point capnp.writePackedMessageToFd(fd, message) @@ -45,13 +45,13 @@ def printAddressBook(fd): which = person.employment.which() print(which) - if which == addressbook.Person.Employment.Which.UNEMPLOYED: + if which == 'unemployed': print('unemployed') - elif which == addressbook.Person.Employment.Which.EMPLOYER: + elif which == 'employer': print('employer:', person.employment.employer) - elif which == addressbook.Person.Employment.Which.SCHOOL: + elif which == 'school': print('student at:', person.employment.school) - elif which == addressbook.Person.Employment.Which.SELF_EMPLOYED: + elif which == 'selfEmployed': print('self employed') print()