Merge pull request #136 from ternaris/lists-from-tuples

support initializing DynamicListBuilder from tuple
This commit is contained in:
Jason Paryani
2017-04-09 17:36:35 -07:00
committed by GitHub
2 changed files with 9 additions and 0 deletions

View File

@@ -727,6 +727,9 @@ cdef _setDynamicField(_DynamicSetterClasses thisptr, field, value, parent):
elif value_type is list:
builder = to_python_builder(thisptr.init(field, len(value)), parent)
_from_list(builder, value)
elif value_type is tuple:
builder = to_python_builder(thisptr.init(field, len(value)), parent)
_from_tuple(builder, value)
elif value_type is dict:
if _DynamicSetterClasses is DynamicStruct_Builder:
builder = to_python_builder(thisptr.get(field), parent)
@@ -912,6 +915,11 @@ cdef _from_list(_DynamicListBuilder msg, list d):
msg._set(i, x)
cdef _from_tuple(_DynamicListBuilder msg, tuple d):
for i, x in enumerate(d):
msg._set(i, x)
cdef class _DynamicEnum:
cdef _init(self, capnp.DynamicEnum other, object parent):
self.thisptr = other