Added bitwriter framework

This commit is contained in:
Dan Hirsch 2012-07-27 15:22:09 -07:00
parent ec7e9f2016
commit 1b9314e73e
3 changed files with 123 additions and 1 deletions

View file

@ -79,6 +79,12 @@ typedef struct HParseResult_ {
HArena * arena;
} HParseResult;
/**
* TODO: document me.
* Relevant functions: h_bit_writer_new, h_bit_writer_put, h_bit_writer_get_buffer, h_bit_writer_free
*/
typedef struct HBitWriter_ HBitWriter;
/**
* Type of an action to apply to an AST, used in the action() parser.
* It can be any (user-defined) function that takes a HParseResult*
@ -449,4 +455,26 @@ char* h_write_result_unamb(const HParsedToken* tok);
*/
void h_pprint(FILE* stream, const HParsedToken* tok, int indent, int delta);
/**
* TODO: Document me
*/
HBitWriter *h_bit_writer_new(void);
/**
* TODO: Document me
*/
void h_bit_writer_put(HBitWriter* w, unsigned long long data, size_t nbits);
/**
* TODO: Document me
* Must not free [w] until you're done with the result.
* [len] is in bytes.
*/
uint8_t *h_bit_writer_get_buffer(HBitWriter* w, size_t *len);
/**
* TODO: Document me
*/
void h_bit_writer_free(HBitWriter* w);
#endif // #ifndef HAMMER_HAMMER__H