Add signed int extract and construction functions, and test.
[ocaml-bitstring.git] / TODO
1 $Id$
2 Major to-do items.
3
4 (1) DONE - In bitmatch operator, use patterns not expressions.
5
6 (2) DONE - Allow matching against strings.
7
8 (3) DONE - Change the syntax so { ... } surrounds match patterns.
9
10 (4) Provide UInt32 and UInt64 types.
11
12 (5) DONE - Allow for specific offsets and alignment.  Something like this:
13
14     { start : 16;
15       another : 16 : offset(256);   (* location would be 256 bits from start *)
16     }
17
18 (6) and:
19
20     { start : 16;
21       another : 16 : align(32);     (* implicit 16 bit gap before this *)
22     }
23
24 (7) Assertions:
25
26     { start : 16 : assert (offset = 0); }
27
28    (Q: Are these evaluated at compile time or at run time or selectable?)
29
30 (8) Named but unbound patterns to avoid "Warning Y: unused variable".
31
32 (9) DONE -
33     Make the error locations fine-grained, particularly so they point to
34     individual fields, not the whole match.
35
36 (10) DONE - Cross-module, persistent, named patterns, see:
37   http://caml.inria.fr/pub/ml-archives/caml-list/2008/04/25992c9c9fa999fe1d35d961dd9917a2.en.html
38
39 (11) DONE -
40      Runtime endiannness expressions.  The suggested syntax is:
41
42     { field : len : endian (expr) }
43
44     where expr would evaluate to something like BigEndian or
45     LittleEndian.
46
47     There are several protocols around where endianness is only
48     determined at runtime, examples are libpcap and TIFF.
49
50 (12) DONE - More constant field lengths.
51
52 (13) PARTLY DONE - Implement native endian functions.
53
54 (14) PARTLY DONE - A proper test suite.
55
56 (15) DONE - More examples:
57
58     ELF binaries
59     GIF images
60
61 (16) We now know the offset of the current field relative to the
62      whole match.  This may allow more efficient aligned versions
63      of functions to be called (at compile time).  However do note
64      that the offset in the bitstring is usually not known.
65
66 (17) PARTLY DONE - Fix the META file.  Current one is very broken.
67
68 (18) DONE - check() qualifier:
69
70      { field : 16 : check (field > 100) }
71
72      The check(expr) qualifier will abort the rest of the match if the
73      expression is false.
74
75 (19) DONE - bind() qualifier:
76
77      { field : 16 : bind (field * 3) }
78        ^pattern           ^new value
79
80      The bind(expr) qualifier binds the pattern to a new value,
81      equivalent to doing:
82
83      let field = field * 3 in
84      (* remainder of match *)
85
86      There is a question of whether bind() should run before or
87      after when() [best is probably when() first, then bind()].
88
89 (20) DONE - save_offset_to() qualifier:
90
91      { field : 16 : save_offset_to (offset), bind (field - offset) }
92
93      or:
94
95      { field : 16 : save_offset_to (field_offset) } ->
96        printf "the offset of field (%d) is %d\n" field field_offset
97
98      save_offset_to(patt) binds the current match offset to
99      the variable, for later use within bind(), when() or
100      any later parts of the match.
101
102 (21) derive() so you can add your own variable decls:
103
104      { field : 32 : derive (field_as_int, Int32.to_int field) }
105
106      This would add a let derivation, equivalent to:
107
108      let field_as_int = Int32.to_int field
109
110      allowing you to use both the original field and field_as_int
111      as variables.
112
113      Note you can do this clumsily using bind():
114
115      { field : 32 : bind (field, Int32.to_int field) }
116
117      which redefines 'field' as a pair of (old value, derived value).
118
119 (22) Allow constant 0 to be used in constructors to mean a zero-length
120      bitstring of the right length, eg:
121
122      BITSTRING { 0 : 32*8 : bitstring }
123
124      which would be equivalent to:
125
126      BITSTRING { zeroes_bitstring (32*8) : 32*8 : bitstring }
127
128 (23) Add predicate Bitstring.is_zero_bitstring : bitstring -> bool
129
130 (24) Add a function to turn bitstrings into printable strings.
131
132 (25) Folding over bitstrings.  A narrow usage for this is to generate
133      checksums and hashes, where usually you want to fold over every
134      8/16/32-bit word.  So a set of functions which just enabled this
135      would be useful.  (However you still need le/be/ne variations so
136      it involves at least 7 functions).