2019-02-10 00:07:05 +00:00
|
|
|
#ifndef WASMER_H
|
|
|
|
#define WASMER_H
|
|
|
|
|
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 {
|
2019-02-12 01:07:28 +00:00
|
|
|
WASMER_OK = 1,
|
|
|
|
WASMER_ERROR = 2,
|
|
|
|
} wasmer_result_t;
|
2019-02-09 19:37:07 +00:00
|
|
|
|
2019-02-02 20:53:07 +00:00
|
|
|
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
|
|
|
|
2019-02-02 23:43:59 +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
|
|
|
|
2019-02-09 23:39:15 +00:00
|
|
|
typedef struct {
|
|
|
|
|
|
|
|
} wasmer_global_t;
|
|
|
|
|
2019-02-02 20:53:07 +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-09 23:39:15 +00:00
|
|
|
typedef struct {
|
|
|
|
bool mutable_;
|
|
|
|
wasmer_value_tag kind;
|
|
|
|
} wasmer_global_descriptor_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-09 19:37:07 +00:00
|
|
|
typedef struct {
|
|
|
|
|
|
|
|
} wasmer_table_t;
|
|
|
|
|
2019-02-09 23:39:15 +00:00
|
|
|
void wasmer_global_destroy(wasmer_global_t *global);
|
|
|
|
|
|
|
|
wasmer_value_t wasmer_global_get(wasmer_global_t *global);
|
|
|
|
|
|
|
|
wasmer_global_descriptor_t wasmer_global_get_descriptor(wasmer_global_t *global);
|
|
|
|
|
|
|
|
wasmer_global_t *wasmer_global_new(wasmer_value_t value, bool mutable_);
|
|
|
|
|
|
|
|
void wasmer_global_set(wasmer_global_t *global, wasmer_value_t value);
|
|
|
|
|
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
|
|
|
|
2019-02-02 23:43:59 +00:00
|
|
|
void wasmer_imports_set_import_func(wasmer_import_object_t *import_object,
|
|
|
|
const char *namespace_,
|
|
|
|
const char *name,
|
2019-02-03 01:10:08 +00:00
|
|
|
void (*func)(void *data),
|
|
|
|
const wasmer_value_tag *params,
|
|
|
|
int params_len,
|
|
|
|
const wasmer_value_tag *returns,
|
|
|
|
int returns_len);
|
2019-02-02 23:43:59 +00:00
|
|
|
|
2019-02-12 01:07:28 +00:00
|
|
|
wasmer_result_t wasmer_instance_call(wasmer_instance_t *instance,
|
|
|
|
const char *name,
|
|
|
|
const wasmer_value_t *params,
|
|
|
|
int params_len,
|
|
|
|
wasmer_value_t *results,
|
|
|
|
int results_len);
|
2019-02-02 06:26:10 +00:00
|
|
|
|
2019-02-10 20:24:36 +00:00
|
|
|
const wasmer_memory_t *wasmer_instance_context_memory(wasmer_instance_context_t *ctx,
|
|
|
|
uint32_t memory_idx);
|
2019-02-02 23:43:59 +00:00
|
|
|
|
2019-02-02 06:26:10 +00:00
|
|
|
void wasmer_instance_destroy(wasmer_instance_t *instance);
|
|
|
|
|
2019-02-12 01:07:28 +00:00
|
|
|
wasmer_result_t wasmer_instantiate(wasmer_instance_t **instance,
|
|
|
|
uint8_t *wasm_bytes,
|
|
|
|
uint32_t wasm_bytes_len,
|
|
|
|
wasmer_import_object_t *import_object);
|
2019-02-05 03:46:47 +00:00
|
|
|
|
2019-02-10 23:57:23 +00:00
|
|
|
int wasmer_last_error_length(void);
|
|
|
|
|
|
|
|
int wasmer_last_error_message(char *buffer, int length);
|
|
|
|
|
2019-02-10 21:20:35 +00:00
|
|
|
uint8_t *wasmer_memory_data(wasmer_memory_t *mem);
|
|
|
|
|
2019-02-10 20:14:42 +00:00
|
|
|
uint32_t wasmer_memory_data_length(wasmer_memory_t *mem);
|
|
|
|
|
2019-02-05 03:46:47 +00:00
|
|
|
void wasmer_memory_destroy(wasmer_memory_t *memory);
|
|
|
|
|
2019-02-12 01:07:28 +00:00
|
|
|
wasmer_result_t wasmer_memory_grow(wasmer_memory_t *memory, uint32_t delta);
|
2019-02-09 23:53:03 +00:00
|
|
|
|
2019-02-05 03:46:47 +00:00
|
|
|
uint32_t wasmer_memory_length(wasmer_memory_t *memory);
|
|
|
|
|
2019-02-12 01:07:28 +00:00
|
|
|
wasmer_result_t wasmer_memory_new(wasmer_memory_t **memory, wasmer_limits_t limits);
|
2019-02-05 06:01:01 +00:00
|
|
|
|
2019-02-09 19:37:07 +00:00
|
|
|
void wasmer_table_destroy(wasmer_table_t *table);
|
|
|
|
|
2019-02-12 01:07:28 +00:00
|
|
|
wasmer_result_t wasmer_table_grow(wasmer_table_t *table, uint32_t delta);
|
2019-02-09 19:58:50 +00:00
|
|
|
|
2019-02-09 19:37:07 +00:00
|
|
|
uint32_t wasmer_table_length(wasmer_table_t *table);
|
|
|
|
|
2019-02-12 01:07:28 +00:00
|
|
|
wasmer_result_t wasmer_table_new(wasmer_table_t **table, wasmer_limits_t limits);
|
2019-02-09 19:37:07 +00:00
|
|
|
|
2019-02-05 06:01:01 +00:00
|
|
|
bool wasmer_validate(uint8_t *wasm_bytes, uint32_t wasm_bytes_len);
|
2019-02-10 00:07:05 +00:00
|
|
|
|
|
|
|
#endif /* WASMER_H */
|