wasmer/lib/runtime-c-api/wasmer.h

92 lines
2.6 KiB
C
Raw Normal View History

2019-02-02 04:10:36 +00:00
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
2019-02-01 05:51:34 +00:00
2019-02-02 06:26:10 +00:00
typedef enum {
WASMER_CALL_OK = 1,
WASMER_CALL_ERROR = 2,
} wasmer_call_result_t;
2019-02-02 04:10:36 +00:00
typedef enum {
2019-02-01 05:51:34 +00:00
WASMER_COMPILE_OK = 1,
WASMER_COMPILE_ERROR = 2,
2019-02-02 04:10:36 +00:00
} wasmer_compile_result_t;
2019-02-01 05:51:34 +00:00
2019-02-05 03:46:47 +00:00
typedef enum {
WASMER_MEMORY_OK = 1,
WASMER_MEMORY_ERROR = 2,
} wasmer_memory_result_t;
enum wasmer_value_tag {
WASM_I32,
WASM_I64,
WASM_F32,
WASM_F64,
};
typedef uint32_t wasmer_value_tag;
2019-02-02 04:10:36 +00:00
typedef struct wasmer_import_object_t wasmer_import_object_t;
2019-02-01 05:51:34 +00:00
typedef struct wasmer_instance_context_t wasmer_instance_context_t;
2019-02-02 04:10:36 +00:00
typedef struct wasmer_instance_t wasmer_instance_t;
2019-02-01 05:51:34 +00:00
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;
2019-02-05 03:46:47 +00:00
typedef struct {
} wasmer_memory_t;
typedef struct {
uint32_t min;
uint32_t max;
} wasmer_limits_t;
2019-02-01 05:51:34 +00:00
void wasmer_import_object_destroy(wasmer_import_object_t *import_object);
2019-02-02 04:10:36 +00:00
wasmer_import_object_t *wasmer_import_object_new(void);
2019-02-01 05:51:34 +00:00
void wasmer_imports_set_import_func(wasmer_import_object_t *import_object,
const char *namespace_,
const char *name,
void (*func)(void *data),
const wasmer_value_tag *params,
int params_len,
const wasmer_value_tag *returns,
int returns_len);
2019-02-02 16:44:08 +00:00
wasmer_call_result_t wasmer_instance_call(wasmer_instance_t *instance,
const char *name,
const wasmer_value_t *params,
2019-02-02 16:44:08 +00:00
int params_len,
wasmer_value_t *results,
2019-02-02 16:44:08 +00:00
int results_len);
2019-02-02 06:26:10 +00:00
void wasmer_instance_context_memory(wasmer_instance_context_t *instance);
2019-02-02 06:26:10 +00:00
void wasmer_instance_destroy(wasmer_instance_t *instance);
2019-02-02 16:44:08 +00:00
wasmer_compile_result_t wasmer_instantiate(wasmer_instance_t **instance,
2019-02-02 06:26:10 +00:00
uint8_t *wasm_bytes,
uint32_t wasm_bytes_len,
2019-02-01 05:51:34 +00:00
wasmer_import_object_t *import_object);
2019-02-05 03:46:47 +00:00
void wasmer_memory_destroy(wasmer_memory_t *memory);
uint32_t wasmer_memory_length(wasmer_memory_t *memory);
wasmer_memory_result_t wasmer_memory_new(wasmer_memory_t **memory, wasmer_limits_t limits);
2019-02-05 06:01:01 +00:00
bool wasmer_validate(uint8_t *wasm_bytes, uint32_t wasm_bytes_len);