support initializing DynamicListBuilder from tuple
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user