mirror of
https://github.com/fluencelabs/wasmer
synced 2024-12-13 22:25:40 +00:00
Also generate C++ bindings
This commit is contained in:
parent
6ed72a50ce
commit
2defd27fac
@ -17,11 +17,18 @@ fn build() {
|
||||
|
||||
use cbindgen::Language;
|
||||
cbindgen::Builder::new()
|
||||
.with_crate(crate_dir)
|
||||
.with_crate(crate_dir.clone())
|
||||
.with_language(Language::C)
|
||||
.generate()
|
||||
.expect("Unable to generate bindings")
|
||||
.expect("Unable to generate C bindings")
|
||||
.write_to_file("wasmer.h");
|
||||
|
||||
cbindgen::Builder::new()
|
||||
.with_crate(crate_dir)
|
||||
.with_language(Language::Cxx)
|
||||
.generate()
|
||||
.expect("Unable to generate C++ bindings")
|
||||
.write_to_file("wasmer.hh");
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "generate-c-api-headers"))]
|
||||
|
71
lib/runtime-c-api/wasmer.hh
Normal file
71
lib/runtime-c-api/wasmer.hh
Normal file
@ -0,0 +1,71 @@
|
||||
#include <cstdarg>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
|
||||
enum class wasmer_call_result_t {
|
||||
WASMER_CALL_OK = 1,
|
||||
WASMER_CALL_ERROR = 2,
|
||||
};
|
||||
|
||||
enum class wasmer_compile_result_t {
|
||||
WASMER_COMPILE_OK = 1,
|
||||
WASMER_COMPILE_ERROR = 2,
|
||||
};
|
||||
|
||||
enum class wasmer_value_tag : uint32_t {
|
||||
WASM_I32,
|
||||
WASM_I64,
|
||||
WASM_F32,
|
||||
WASM_F64,
|
||||
};
|
||||
|
||||
struct wasmer_import_object_t;
|
||||
|
||||
struct wasmer_instance_context_t;
|
||||
|
||||
struct wasmer_instance_t;
|
||||
|
||||
union wasmer_value {
|
||||
int32_t I32;
|
||||
int64_t I64;
|
||||
float F32;
|
||||
double F64;
|
||||
};
|
||||
|
||||
struct wasmer_value_t {
|
||||
wasmer_value_tag tag;
|
||||
wasmer_value value;
|
||||
};
|
||||
|
||||
extern "C" {
|
||||
|
||||
void wasmer_import_object_destroy(wasmer_import_object_t *import_object);
|
||||
|
||||
wasmer_import_object_t *wasmer_import_object_new();
|
||||
|
||||
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);
|
||||
|
||||
wasmer_call_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);
|
||||
|
||||
void wasmer_instance_context_memory(wasmer_instance_context_t *instance);
|
||||
|
||||
void wasmer_instance_destroy(wasmer_instance_t *instance);
|
||||
|
||||
wasmer_compile_result_t wasmer_instantiate(wasmer_instance_t **instance,
|
||||
uint8_t *wasm_bytes,
|
||||
uint32_t wasm_bytes_len,
|
||||
wasmer_import_object_t *import_object);
|
||||
|
||||
} // extern "C"
|
Loading…
Reference in New Issue
Block a user