コード例 #1
0
ファイル: test_ptr.py プロジェクト: gambitcostas/capnpy
def test_list_item_length():
    assert ptr.list_item_length(ptr.LIST_SIZE_VOID) == 0
    assert ptr.list_item_length(ptr.LIST_SIZE_BIT) == -1
    assert ptr.list_item_length(ptr.LIST_SIZE_8) == 1
    assert ptr.list_item_length(ptr.LIST_SIZE_16) == 2
    assert ptr.list_item_length(ptr.LIST_SIZE_32) == 4
    assert ptr.list_item_length(ptr.LIST_SIZE_64) == 8
    assert ptr.list_item_length(ptr.LIST_SIZE_PTR) == 8
    assert ptr.list_item_length(ptr.LIST_SIZE_COMPOSITE) == -1
コード例 #2
0
ファイル: _copy_pointer.py プロジェクト: nickmyatt/capnpy
def _copy_list_primitive(src, p, src_pos, dst, dst_pos):
    src_pos = ptr.deref(p, src_pos)
    count = ptr.list_item_count(p)
    size_tag = ptr.list_size_tag(p)
    body_length = 0
    if size_tag == ptr.LIST_SIZE_BIT:
        body_length = (count + 8 - 1) / 8  # divide by 8 and round up
    else:
        body_length = count * ptr.list_item_length(size_tag)
    #
    dst_pos = dst.alloc_list(dst_pos, size_tag, count, body_length)
    check_bounds(src, body_length, src_pos)
    dst.write_slice(dst_pos, src, src_pos, body_length)
コード例 #3
0
ファイル: list.py プロジェクト: afcarl/capnpy
 def _set_list_tag(self, size_tag, item_count):
     self._size_tag = size_tag
     if size_tag == ptr.LIST_SIZE_COMPOSITE:
         tag = self._seg.read_ptr(self._offset)
         self._tag = tag
         self._item_count = ptr.offset(tag)
         self._item_length = (ptr.struct_data_size(tag)+ptr.struct_ptrs_size(tag))*8
         self._item_offset = 8
     else:
         self._tag = -1
         self._item_count = item_count
         self._item_length = ptr.list_item_length(size_tag)
         self._item_offset = 0
コード例 #4
0
def _endof_list_primitive(seg, p, offset, item_size, count):
    item_size = ptr.list_item_length(item_size)
    return ptr.round_up_to_word(offset + item_size * count)
コード例 #5
0
 def visit_list_primitive(self, buf, p, offset, item_size, count):
     item_size = ptr.list_item_length(item_size)
     return ptr.round_up_to_word(offset + item_size*count)