MCPcopy Create free account
hub / github.com/XiaoMi/mace / array_to_bytes

Method array_to_bytes

tools/python/micro/proto_to_bytes.py:127–147  ·  view source on GitHub ↗
(self, in_bytes, array,
                       object_queue, parent_addr, descriptor)

Source from the content-addressed store, hash-verified

125 parent_addr, FieldDescriptor.TYPE_BYTES)
126
127 def array_to_bytes(self, in_bytes, array,
128 object_queue, parent_addr, descriptor):
129 length = len(array)
130 in_bytes += self.pack(length, self.get_pack_type())
131 offset = len(in_bytes)
132 in_bytes += self.pack(offset, self.get_pack_type())
133 if length > 0:
134 array_length = len(array)
135 for i in range(array_length):
136 # other units needn't write offset to their parent
137 array_parent_addr = parent_addr
138 if i > 0:
139 array_parent_addr = -1
140 des_type = descriptor.type
141 if des_type is FieldDescriptor.TYPE_STRING:
142 des_type = TYPE_STRING_EX
143 elif des_type is FieldDescriptor.TYPE_BYTES:
144 des_type = TYPE_BYTES_EX
145 object_queue.put(
146 ObjInfo(array[i], array_parent_addr, offset, des_type))
147 return in_bytes
148
149 def container_obj_to_bytes(self, obj_info, object_queue, parent_addr):
150 bytes = b''

Callers 1

Calls 3

packMethod · 0.95
get_pack_typeMethod · 0.95
ObjInfoClass · 0.85

Tested by

no test coverage detected