Merge branch 'master' of https://github.com/amluto/capnpc-python-cpp into develop
Conflicts: capnp/capnp.pyx capnp/capnp_cpp.pxd
This commit is contained in:
@@ -350,6 +350,7 @@ cdef class _DynamicStructReader:
|
|||||||
"""
|
"""
|
||||||
cdef C_DynamicStruct.Reader thisptr
|
cdef C_DynamicStruct.Reader thisptr
|
||||||
cdef public object _parent
|
cdef public object _parent
|
||||||
|
cdef object _obj_to_pin
|
||||||
cdef _init(self, C_DynamicStruct.Reader other, object parent):
|
cdef _init(self, C_DynamicStruct.Reader other, object parent):
|
||||||
self.thisptr = other
|
self.thisptr = other
|
||||||
self._parent = parent
|
self._parent = parent
|
||||||
@@ -382,6 +383,14 @@ cdef class _DynamicStructReader:
|
|||||||
"""
|
"""
|
||||||
return fixMaybe(self.thisptr.which()).getProto().getName().cStr()
|
return fixMaybe(self.thisptr.which()).getProto().getName().cStr()
|
||||||
|
|
||||||
|
property schema:
|
||||||
|
"""A _StructSchema object matching this reader"""
|
||||||
|
def __get__(self):
|
||||||
|
return _StructSchema()._init(self.thisptr.getSchema())
|
||||||
|
|
||||||
|
def __dir__(self):
|
||||||
|
return list(self.schema.fieldnames)
|
||||||
|
|
||||||
cdef class _DynamicStructBuilder:
|
cdef class _DynamicStructBuilder:
|
||||||
"""Builds Cap'n Proto structs
|
"""Builds Cap'n Proto structs
|
||||||
|
|
||||||
@@ -531,6 +540,21 @@ cdef class _DynamicStructBuilder:
|
|||||||
"""
|
"""
|
||||||
return _DynamicOrphan()._init(self.thisptr.disown(field), self._parent)
|
return _DynamicOrphan()._init(self.thisptr.disown(field), self._parent)
|
||||||
|
|
||||||
|
cpdef asReader(self):
|
||||||
|
cdef _DynamicStructReader reader
|
||||||
|
reader = _DynamicStructReader()._init(self.thisptr.asReader(),
|
||||||
|
self._parent)
|
||||||
|
reader._obj_to_pin = self
|
||||||
|
return reader
|
||||||
|
|
||||||
|
property schema:
|
||||||
|
"""A _StructSchema object matching this reader"""
|
||||||
|
def __get__(self):
|
||||||
|
return _StructSchema()._init(self.thisptr.getSchema())
|
||||||
|
|
||||||
|
def __dir__(self):
|
||||||
|
return list(self.schema.fieldnames)
|
||||||
|
|
||||||
cdef class _DynamicOrphan:
|
cdef class _DynamicOrphan:
|
||||||
cdef C_DynamicOrphan thisptr
|
cdef C_DynamicOrphan thisptr
|
||||||
cdef public object _parent
|
cdef public object _parent
|
||||||
@@ -569,10 +593,28 @@ cdef class _Schema:
|
|||||||
|
|
||||||
cdef class _StructSchema:
|
cdef class _StructSchema:
|
||||||
cdef C_StructSchema thisptr
|
cdef C_StructSchema thisptr
|
||||||
|
cdef object __fieldnames
|
||||||
cdef _init(self, C_StructSchema other):
|
cdef _init(self, C_StructSchema other):
|
||||||
self.thisptr = other
|
self.thisptr = other
|
||||||
|
self.__fieldnames = None
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
property fieldnames:
|
||||||
|
"""A tuple of the field names in the struct."""
|
||||||
|
def __get__(self):
|
||||||
|
if self.__fieldnames is not None:
|
||||||
|
return self.__fieldnames
|
||||||
|
fieldlist = self.thisptr.getFields()
|
||||||
|
nfields = fieldlist.size()
|
||||||
|
self.__fieldnames = tuple(fieldlist[i].getProto().getName().cStr()
|
||||||
|
for i in xrange(nfields))
|
||||||
|
return self.__fieldnames
|
||||||
|
|
||||||
|
property node:
|
||||||
|
"""The raw schema node"""
|
||||||
|
def __get__(self):
|
||||||
|
return _DynamicStructReader()._init(self.thisptr.getProto(), None)
|
||||||
|
|
||||||
cdef class _ParsedSchema:
|
cdef class _ParsedSchema:
|
||||||
cdef C_ParsedSchema thisptr
|
cdef C_ParsedSchema thisptr
|
||||||
cdef _init(self, C_ParsedSchema other):
|
cdef _init(self, C_ParsedSchema other):
|
||||||
|
|||||||
@@ -33,21 +33,16 @@ cdef extern from "capnp/schema.h" namespace " ::capnp":
|
|||||||
Schema getDependency(uint64_t id) except +
|
Schema getDependency(uint64_t id) except +
|
||||||
#InterfaceSchema asInterface() const;
|
#InterfaceSchema asInterface() const;
|
||||||
|
|
||||||
cdef cppclass MemberForward" ::capnp::StructSchema::Field":
|
|
||||||
pass
|
|
||||||
|
|
||||||
cdef cppclass StructSchema(Schema):
|
cdef cppclass StructSchema(Schema):
|
||||||
cppclass FieldList:
|
|
||||||
uint size()
|
|
||||||
MemberForward operator[](uint index)
|
|
||||||
|
|
||||||
cppclass Field:
|
cppclass Field:
|
||||||
StructNode.Member.Reader getProto()
|
StructNode.Member.Reader getProto()
|
||||||
StructSchema getContainingStruct()
|
StructSchema getContainingStruct()
|
||||||
uint getIndex()
|
uint getIndex()
|
||||||
FieldList getFields()
|
|
||||||
|
|
||||||
Node.Reader getProto()
|
cppclass FieldList:
|
||||||
|
uint size()
|
||||||
|
Field operator[](uint index)
|
||||||
|
|
||||||
FieldList getFields()
|
FieldList getFields()
|
||||||
Field getFieldByName(char * name)
|
Field getFieldByName(char * name)
|
||||||
|
|
||||||
@@ -106,6 +101,7 @@ cdef extern from "capnp/dynamic.h" namespace " ::capnp":
|
|||||||
Maybe[StructSchema.Field] which()
|
Maybe[StructSchema.Field] which()
|
||||||
void adopt(char *, DynamicOrphan)
|
void adopt(char *, DynamicOrphan)
|
||||||
DynamicOrphan disown(char *)
|
DynamicOrphan disown(char *)
|
||||||
|
DynamicStruct.Reader asReader()
|
||||||
|
|
||||||
cdef extern from "fixMaybe.h":
|
cdef extern from "fixMaybe.h":
|
||||||
StructSchema.Field fixMaybe(Maybe[StructSchema.Field]) except+
|
StructSchema.Field fixMaybe(Maybe[StructSchema.Field]) except+
|
||||||
|
|||||||
Reference in New Issue
Block a user