1 /**
2  * \file wasmtime/wat.h
3  *
4  * APIs for converting the text format to binary
5  */
6 
7 #ifndef WASMTIME_WAT_H
8 #define WASMTIME_WAT_H
9 
10 #include <wasmtime/conf.h>
11 #include <wasmtime/error.h>
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
17 #ifdef WASMTIME_FEATURE_WAT
18 
19 /**
20  * \brief Converts from the text format of WebAssembly to the binary format.
21  *
22  * \param wat this it the input pointer with the WebAssembly Text Format inside
23  *        of it. This will be parsed and converted to the binary format.
24  * \param wat_len this it the length of `wat`, in bytes.
25  * \param ret if the conversion is successful, this byte vector is filled in
26  *        with the WebAssembly binary format.
27  *
28  * \return a non-null error if parsing fails, or returns `NULL`. If parsing
29  * fails then `ret` isn't touched.
30  *
31  * This function does not take ownership of `wat`, and the caller is expected to
32  * deallocate the returned #wasmtime_error_t and #wasm_byte_vec_t.
33  */
34 WASM_API_EXTERN wasmtime_error_t *
35 wasmtime_wat2wasm(const char *wat, size_t wat_len, wasm_byte_vec_t *ret);
36 
37 #endif // WASMTIME_FEATURE_WAT
38 
39 #ifdef __cplusplus
40 } // extern "C"
41 #endif
42 
43 #endif // WASMTIME_WAT_H
44