Implement tagged enum for params/results

This commit is contained in:
Brandon Fish
2019-02-02 14:53:07 -06:00
parent 3633ab8ef4
commit 9120a9d1f8
3 changed files with 115 additions and 21 deletions

View File

@@ -13,19 +13,39 @@ typedef enum {
WASMER_COMPILE_ERROR = 2,
} wasmer_compile_result_t;
enum wasmer_value_tag {
WASM_I32,
WASM_I64,
WASM_F32,
WASM_F64,
};
typedef uint32_t wasmer_value_tag;
typedef struct wasmer_import_object_t wasmer_import_object_t;
typedef struct wasmer_instance_t wasmer_instance_t;
typedef union {
int32_t I32;
int64_t I64;
float F32;
double F64;
} wasmer_value;
typedef struct {
wasmer_value_tag tag;
wasmer_value value;
} wasmer_value_t;
void wasmer_import_object_destroy(wasmer_import_object_t *import_object);
wasmer_import_object_t *wasmer_import_object_new(void);
wasmer_call_result_t wasmer_instance_call(wasmer_instance_t *instance,
const char *name,
const uint32_t *params,
const wasmer_value_t *params,
int params_len,
uint32_t *results,
wasmer_value_t *results,
int results_len);
void wasmer_instance_destroy(wasmer_instance_t *instance);