support initializing DynamicListBuilder from tuple
This commit is contained in:
@@ -122,5 +122,6 @@ cdef to_python_reader(C_DynamicValue.Reader self, object parent)
|
|||||||
cdef to_python_builder(C_DynamicValue.Builder self, object parent)
|
cdef to_python_builder(C_DynamicValue.Builder self, object parent)
|
||||||
cdef _to_dict(msg, bint verbose, bint ordered)
|
cdef _to_dict(msg, bint verbose, bint ordered)
|
||||||
cdef _from_list(_DynamicListBuilder msg, list d)
|
cdef _from_list(_DynamicListBuilder msg, list d)
|
||||||
|
cdef _from_tuple(_DynamicListBuilder msg, tuple d)
|
||||||
cdef _setDynamicFieldWithField(DynamicStruct_Builder thisptr, _StructSchemaField field, value, parent)
|
cdef _setDynamicFieldWithField(DynamicStruct_Builder thisptr, _StructSchemaField field, value, parent)
|
||||||
cdef _setDynamicFieldStatic(DynamicStruct_Builder thisptr, field, value, parent)
|
cdef _setDynamicFieldStatic(DynamicStruct_Builder thisptr, field, value, parent)
|
||||||
|
|||||||
@@ -719,6 +719,9 @@ cdef _setDynamicField(_DynamicSetterClasses thisptr, field, value, parent):
|
|||||||
elif value_type is list:
|
elif value_type is list:
|
||||||
builder = to_python_builder(thisptr.init(field, len(value)), parent)
|
builder = to_python_builder(thisptr.init(field, len(value)), parent)
|
||||||
_from_list(builder, value)
|
_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:
|
elif value_type is dict:
|
||||||
if _DynamicSetterClasses is DynamicStruct_Builder:
|
if _DynamicSetterClasses is DynamicStruct_Builder:
|
||||||
builder = to_python_builder(thisptr.get(field), parent)
|
builder = to_python_builder(thisptr.get(field), parent)
|
||||||
@@ -904,6 +907,11 @@ cdef _from_list(_DynamicListBuilder msg, list d):
|
|||||||
msg._set(i, x)
|
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 class _DynamicEnum:
|
||||||
cdef _init(self, capnp.DynamicEnum other, object parent):
|
cdef _init(self, capnp.DynamicEnum other, object parent):
|
||||||
self.thisptr = other
|
self.thisptr = other
|
||||||
|
|||||||
Reference in New Issue
Block a user