Update imports and add func_new

This commit is contained in:
Brandon Fish
2019-02-15 09:40:28 -06:00
parent bfd5e21605
commit 3ebb80e50e
6 changed files with 196 additions and 31 deletions

View File

@ -75,22 +75,36 @@ typedef struct {
} wasmer_memory_t;
typedef struct {
} wasmer_table_t;
typedef union {
const wasmer_func_t *func;
const wasmer_table_t *table;
const wasmer_memory_t *memory;
const wasmer_global_t *global;
} wasmer_import_export_value;
typedef struct {
wasmer_byte_array module_name;
wasmer_byte_array import_name;
wasmer_import_export_kind tag;
wasmer_import_export_value value;
} wasmer_import_t;
typedef struct {
uint32_t min;
uint32_t max;
} wasmer_limits_t;
typedef struct {
} wasmer_table_t;
/**
* Gets wasmer_export kind
*/
wasmer_import_export_kind wasmer_export_kind(wasmer_export_t *export_);
/**
* Gets func from wasm_export
* Gets name from wasmer_export
*/
wasmer_byte_array wasmer_export_name(wasmer_export_t *export_);
@ -127,6 +141,21 @@ wasmer_result_t wasmer_func_call(wasmer_func_t *func,
wasmer_value_t *results,
int results_len);
/**
* Frees memory for the given Func
*/
void wasmer_func_destroy(wasmer_func_t *func);
/**
* Creates new func
* The caller owns the object and should call `wasmer_func_destroy` to free it.
*/
const wasmer_func_t *wasmer_func_new(void (*func)(void *data),
const wasmer_value_tag *params,
int params_len,
const wasmer_value_tag *returns,
int returns_len);
/**
* Frees memory for the given Global
*/
@ -220,7 +249,8 @@ void wasmer_instance_exports(wasmer_instance_t *instance, wasmer_exports_t **exp
wasmer_result_t wasmer_instantiate(wasmer_instance_t **instance,
uint8_t *wasm_bytes,
uint32_t wasm_bytes_len,
wasmer_import_object_t *import_object);
wasmer_import_t *imports,
int imports_len);
/**
* Gets the length in bytes of the last error.