mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-13 22:08:45 +00:00
Finish merge with C API refactor
This commit is contained in:
@@ -8,7 +8,6 @@ use wasmer_engine_native::Native;
|
||||
#[cfg(feature = "object-file")]
|
||||
use wasmer_engine_object_file::ObjectFile;
|
||||
|
||||
// cbindegn should see this
|
||||
/// this can be a wasmer-specific type with wasmer-specific functions for manipulating it
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
#[repr(C)]
|
||||
@@ -34,7 +33,6 @@ impl Default for wasmer_compiler_t {
|
||||
}
|
||||
}
|
||||
|
||||
// cbindegn should see this
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
#[repr(C)]
|
||||
#[allow(non_camel_case_types)]
|
||||
@@ -60,6 +58,7 @@ impl Default for wasmer_engine_t {
|
||||
}
|
||||
}
|
||||
|
||||
/// cbindgen:ignore
|
||||
/// this can be a wasmer-specific type with wasmer-specific functions for manipulating it
|
||||
#[derive(Debug, Default)]
|
||||
#[repr(C)]
|
||||
@@ -68,12 +67,12 @@ pub struct wasm_config_t {
|
||||
engine: wasmer_engine_t,
|
||||
}
|
||||
|
||||
/// cbindgen:ignore
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wasm_config_new() -> Box<wasm_config_t> {
|
||||
Box::new(wasm_config_t::default())
|
||||
}
|
||||
|
||||
// cbindegn should see this
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wasm_config_set_compiler(
|
||||
config: &mut wasm_config_t,
|
||||
@@ -82,12 +81,12 @@ pub extern "C" fn wasm_config_set_compiler(
|
||||
config.compiler = compiler;
|
||||
}
|
||||
|
||||
// cbindegn should see this
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wasm_config_set_engine(config: &mut wasm_config_t, engine: wasmer_engine_t) {
|
||||
config.engine = engine;
|
||||
}
|
||||
|
||||
/// cbindgen:ignore
|
||||
#[repr(C)]
|
||||
pub struct wasm_engine_t {
|
||||
pub(crate) inner: Arc<dyn Engine + Send + Sync>,
|
||||
@@ -166,9 +165,11 @@ cfg_if! {
|
||||
}
|
||||
}
|
||||
|
||||
/// cbindgen:ignore
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn wasm_engine_delete(_wasm_engine_address: Option<Box<wasm_engine_t>>) {}
|
||||
|
||||
/// cbindgen:ignore
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wasm_engine_new_with_config(
|
||||
config: Box<wasm_config_t>,
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#[macro_use]
|
||||
pub mod macros;
|
||||
|
||||
/// cbindgen:ignore
|
||||
pub mod engine;
|
||||
|
||||
/// cbindgen:ignore
|
||||
@@ -30,8 +29,4 @@ pub mod value;
|
||||
#[cfg(feature = "wasi")]
|
||||
pub mod wasi;
|
||||
|
||||
// TODO: find a home for this function
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn wasm_instance_get_vmctx_ptr(instance: &wasm_instance_t) -> *mut c_void {
|
||||
instance.inner.vmctx_ptr() as _
|
||||
}
|
||||
pub mod wasmer;
|
||||
|
||||
9
lib/c-api/src/wasm_c_api/wasmer.rs
Normal file
9
lib/c-api/src/wasm_c_api/wasmer.rs
Normal file
@@ -0,0 +1,9 @@
|
||||
//! Wasmer-specific extensions to the Wasm C API.
|
||||
|
||||
use crate::wasm_c_api::instance::wasm_instance_t;
|
||||
use std::ffi::c_void;
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn wasm_instance_get_vmctx_ptr(instance: &wasm_instance_t) -> *mut c_void {
|
||||
instance.inner.vmctx_ptr() as _
|
||||
}
|
||||
Reference in New Issue
Block a user