From cdcdda11bbdf2d39340ec9bdb51e6af8e2cb268c Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 14 Dec 2016 17:44:37 -0800 Subject: Make some binary reading/writing utilities public (#245) * Make some binary reading/writing utilities public This is mostly a refactor to make some of the internal binary reading/writing utilities public and available to the wasm linker prototype that I'm working on. --- src/binary-reader.h | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/binary-reader.h') diff --git a/src/binary-reader.h b/src/binary-reader.h index e51c0f01..93ffe1cc 100644 --- a/src/binary-reader.h +++ b/src/binary-reader.h @@ -49,6 +49,10 @@ typedef struct WasmBinaryReader { WasmResult (*begin_module)(uint32_t version, void* user_data); WasmResult (*end_module)(void* user_data); + WasmResult (*begin_section)(WasmBinaryReaderContext* ctx, + WasmBinarySection section_type, + uint32_t size); + /* custom section */ WasmResult (*begin_custom_section)(WasmBinaryReaderContext* ctx, uint32_t size, @@ -242,9 +246,10 @@ typedef struct WasmBinaryReader { void* user_data); WasmResult (*begin_elem_segment_init_expr)(uint32_t index, void* user_data); WasmResult (*end_elem_segment_init_expr)(uint32_t index, void* user_data); - WasmResult (*on_elem_segment_function_index_count)(uint32_t index, - uint32_t count, - void* user_data); + WasmResult (*on_elem_segment_function_index_count)( + WasmBinaryReaderContext* ctx, + uint32_t index, + uint32_t count); WasmResult (*on_elem_segment_function_index)(uint32_t index, uint32_t func_index, void* user_data); @@ -308,6 +313,14 @@ WasmResult wasm_read_binary(struct WasmAllocator* allocator, WasmBinaryReader* reader, uint32_t num_function_passes, const WasmReadBinaryOptions* options); + +size_t wasm_read_u32_leb128(const uint8_t* ptr, + const uint8_t* end, + uint32_t* out_value); + +size_t wasm_read_i32_leb128(const uint8_t* ptr, + const uint8_t* end, + uint32_t* out_value); WASM_EXTERN_C_END #endif /* WASM_BINARY_READER_H_ */ -- cgit v1.2.3