support initializing DynamicListBuilder from tuple

This commit is contained in:
Florian Friesdorf
2017-02-09 02:10:50 +01:00
parent 455ffdf4ab
commit 1bfc20fefb
2 changed files with 9 additions and 0 deletions

View File

@@ -719,6 +719,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)
@@ -904,6 +907,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