Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions | Variables
make_data_cpp Namespace Reference

Functions

 iterate_as_uint32 (path)
 
 convert (fmt, name, src_path, dst_path)
 

Variables

tuple cpp
 

Detailed Description

Generate a source file containing the given binary data.

Output type is C++.

Function Documentation

◆ convert()

make_data_cpp.convert (   fmt,
  name,
  src_path,
  dst_path 
)

Definition at line 31 of file make_data_cpp.py.

31def convert(fmt, name, src_path, dst_path):
32 header, line_begin, line_end, footer = fmt
33 assert os.path.exists(src_path)
34 src = iterate_as_uint32(src_path)
35 with open(dst_path, 'w') as o:
36 o.write(header.format(name))
37 while True:
38 line = ','.join('%d' % v for _, v in zip(range(8), src))
39 if not line:
40 break
41 o.write('%s%s%s\n' % (line_begin, line, line_end))
42 o.write(footer.format(name))
43
44
static Editor::Movement convert(skui::Key key)
Definition zip.py:1

◆ iterate_as_uint32()

make_data_cpp.iterate_as_uint32 (   path)

Definition at line 20 of file make_data_cpp.py.

20def iterate_as_uint32(path):
21 with open(path, 'rb') as f:
22 s = struct.Struct('@I')
23 assert s.size == 4
24 mm = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)
25 assert (len(mm) % s.size) == 0
26 for offset in range(0, len(mm), s.size):
27 yield s.unpack_from(mm, offset)[0]
28 mm.close()
29
30

Variable Documentation

◆ cpp

tuple make_data_cpp.cpp
Initial value:
1= ('#include <cstdint>\nextern "C" uint32_t {0}[] __attribute__((aligned(16))) = {{\n',
2 '', ',', '}};\n')

Definition at line 45 of file make_data_cpp.py.