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 public object _parent
|
||||
cdef object _obj_to_pin
|
||||
cdef _init(self, C_DynamicStruct.Reader other, object parent):
|
||||
self.thisptr = other
|
||||
self._parent = parent
|
||||
@@ -382,6 +383,14 @@ cdef class _DynamicStructReader:
|
||||
"""
|
||||
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:
|
||||
"""Builds Cap'n Proto structs
|
||||
|
||||
@@ -531,6 +540,21 @@ cdef class _DynamicStructBuilder:
|
||||
"""
|
||||
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 C_DynamicOrphan thisptr
|
||||
cdef public object _parent
|
||||
@@ -569,10 +593,28 @@ cdef class _Schema:
|
||||
|
||||
cdef class _StructSchema:
|
||||
cdef C_StructSchema thisptr
|
||||
cdef object __fieldnames
|
||||
cdef _init(self, C_StructSchema other):
|
||||
self.thisptr = other
|
||||
self.__fieldnames = None
|
||||
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 C_ParsedSchema thisptr
|
||||
cdef _init(self, C_ParsedSchema other):
|
||||
|
||||
@@ -33,21 +33,16 @@ cdef extern from "capnp/schema.h" namespace " ::capnp":
|
||||
Schema getDependency(uint64_t id) except +
|
||||
#InterfaceSchema asInterface() const;
|
||||
|
||||
cdef cppclass MemberForward" ::capnp::StructSchema::Field":
|
||||
pass
|
||||
|
||||
cdef cppclass StructSchema(Schema):
|
||||
cppclass FieldList:
|
||||
uint size()
|
||||
MemberForward operator[](uint index)
|
||||
|
||||
cppclass Field:
|
||||
StructNode.Member.Reader getProto()
|
||||
StructSchema getContainingStruct()
|
||||
uint getIndex()
|
||||
FieldList getFields()
|
||||
|
||||
Node.Reader getProto()
|
||||
cppclass FieldList:
|
||||
uint size()
|
||||
Field operator[](uint index)
|
||||
|
||||
FieldList getFields()
|
||||
Field getFieldByName(char * name)
|
||||
|
||||
@@ -106,6 +101,7 @@ cdef extern from "capnp/dynamic.h" namespace " ::capnp":
|
||||
Maybe[StructSchema.Field] which()
|
||||
void adopt(char *, DynamicOrphan)
|
||||
DynamicOrphan disown(char *)
|
||||
DynamicStruct.Reader asReader()
|
||||
|
||||
cdef extern from "fixMaybe.h":
|
||||
StructSchema.Field fixMaybe(Maybe[StructSchema.Field]) except+
|
||||
|
||||
Reference in New Issue
Block a user