mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-12 13:28:49 +00:00
Address feedback: misc clean ups
This commit is contained in:
@@ -130,6 +130,14 @@ impl Instance {
|
|||||||
exports,
|
exports,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// # Safety
|
||||||
|
// `initialize_host_envs` should be called after instantiation but before
|
||||||
|
// returning an `Instance` to the user. We set up the host environments
|
||||||
|
// via `WasmerEnv::init_with_instance`.
|
||||||
|
//
|
||||||
|
// This usage is correct because we pass a valid pointer to `instance` and the
|
||||||
|
// correct error type returned by `WasmerEnv::init_with_instance` as a generic
|
||||||
|
// parameter.
|
||||||
unsafe {
|
unsafe {
|
||||||
instance
|
instance
|
||||||
.handle
|
.handle
|
||||||
|
|||||||
@@ -174,12 +174,12 @@ pub extern "C" fn wasi_env_new(mut config: Box<wasi_config_t>) -> Option<Box<was
|
|||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn wasi_env_delete(_state: Option<Box<wasi_env_t>>) {}
|
pub extern "C" fn wasi_env_delete(_state: Option<Box<wasi_env_t>>) {}
|
||||||
|
|
||||||
|
/// This function is deprecated. You may safely remove all calls to it and everything
|
||||||
|
/// will continue to work.
|
||||||
// Dead code: deprecate or remove
|
// Dead code: deprecate or remove
|
||||||
|
#[allow(unused_variables)]
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn wasi_env_set_instance(
|
pub extern "C" fn wasi_env_set_instance(env: &mut wasi_env_t, instance: &wasm_instance_t) -> bool {
|
||||||
_env: &mut wasi_env_t,
|
|
||||||
_instance: &wasm_instance_t,
|
|
||||||
) -> bool {
|
|
||||||
/*
|
/*
|
||||||
let memory = if let Ok(memory) = instance.inner.exports.get_memory("memory") {
|
let memory = if let Ok(memory) = instance.inner.exports.get_memory("memory") {
|
||||||
memory
|
memory
|
||||||
@@ -192,9 +192,12 @@ pub extern "C" fn wasi_env_set_instance(
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// This function is deprecated. You may safely remove all calls to it and everything
|
||||||
|
/// will continue to work.
|
||||||
// Dead code: deprecate or remove
|
// Dead code: deprecate or remove
|
||||||
|
#[allow(unused_variables)]
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn wasi_env_set_memory(_env: &mut wasi_env_t, _memory: &wasm_memory_t) {
|
pub extern "C" fn wasi_env_set_memory(env: &mut wasi_env_t, memory: &wasm_memory_t) {
|
||||||
//env.inner.set_memory(memory.inner.clone());
|
//env.inner.set_memory(memory.inner.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -145,11 +145,19 @@ intptr_t wasi_env_read_stdout(wasi_env_t *env, char *buffer, uintptr_t buffer_le
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(WASMER_WASI_ENABLED)
|
#if defined(WASMER_WASI_ENABLED)
|
||||||
bool wasi_env_set_instance(wasi_env_t *_env, const wasm_instance_t *_instance);
|
/**
|
||||||
|
* This function is deprecated. You may safely remove all calls to it and everything
|
||||||
|
* will continue to work.
|
||||||
|
*/
|
||||||
|
bool wasi_env_set_instance(wasi_env_t *env, const wasm_instance_t *instance);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(WASMER_WASI_ENABLED)
|
#if defined(WASMER_WASI_ENABLED)
|
||||||
void wasi_env_set_memory(wasi_env_t *_env, const wasm_memory_t *_memory);
|
/**
|
||||||
|
* This function is deprecated. You may safely remove all calls to it and everything
|
||||||
|
* will continue to work.
|
||||||
|
*/
|
||||||
|
void wasi_env_set_memory(wasi_env_t *env, const wasm_memory_t *memory);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(WASMER_WASI_ENABLED)
|
#if defined(WASMER_WASI_ENABLED)
|
||||||
|
|||||||
@@ -1163,6 +1163,7 @@ impl InstanceHandle {
|
|||||||
/// - This function must be called with the correct `Err` type parameter: the error type is not
|
/// - This function must be called with the correct `Err` type parameter: the error type is not
|
||||||
/// visible to code in `wasmer_vm`, so it's the caller's responsibility to ensure these
|
/// visible to code in `wasmer_vm`, so it's the caller's responsibility to ensure these
|
||||||
/// functions are called with the correct type.
|
/// functions are called with the correct type.
|
||||||
|
/// - `instance_ptr` must point to a valid `wasmer::Instance`.
|
||||||
pub unsafe fn initialize_host_envs<Err: Sized>(
|
pub unsafe fn initialize_host_envs<Err: Sized>(
|
||||||
&mut self,
|
&mut self,
|
||||||
instance_ptr: *const std::ffi::c_void,
|
instance_ptr: *const std::ffi::c_void,
|
||||||
|
|||||||
@@ -82,7 +82,8 @@ impl WasiEnv {
|
|||||||
|
|
||||||
/// Get a reference to the memory
|
/// Get a reference to the memory
|
||||||
pub fn memory(&self) -> &Memory {
|
pub fn memory(&self) -> &Memory {
|
||||||
self.memory_ref().unwrap()
|
self.memory_ref()
|
||||||
|
.expect("Memory should be set on `WasiEnv` first")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_memory_and_wasi_state(
|
pub(crate) fn get_memory_and_wasi_state(
|
||||||
|
|||||||
Reference in New Issue
Block a user