NEWS:
* Switching endianness mid-byte no longer potentially re-reads bytes.
* bit_offset now consistently refers to the number of bits already
  read.
* HParsedTokens now have a bit_length field; this is a size_t.  This
  may be removed for memory reasons.

The bit writer has not yet been updated to match; the result of
switching bit writer endianness in the middle of a byte remains
undefined.
This commit is contained in:
TQ Hirsch 2015-01-04 04:00:09 +01:00
parent 58af99ae40
commit af73181cf4
12 changed files with 86 additions and 48 deletions

View file

@ -70,6 +70,8 @@ typedef struct HInputStream_ {
size_t index;
size_t length;
char bit_offset;
char margin; // The number of bits on the end that is being read
// towards that should be ignored.
char endianness;
char overrun;
} HInputStream;
@ -295,6 +297,9 @@ extern HParserBackendVTable h__glr_backend_vtable;
// TODO(thequux): Set symbol visibility for these functions so that they aren't exported.
int64_t h_read_bits(HInputStream* state, int count, char signed_p);
static inline size_t h_input_stream_pos(HInputStream* state) {
return state->index * 8 + state->bit_offset + state->margin;
}
// need to decide if we want to make this public.
HParseResult* h_do_parse(const HParser* parser, HParseState *state);
void put_cached(HParseState *ps, const HParser *p, HParseResult *cached);