Readjust where things are exported in the new API

This commit is contained in:
Mark McCaskey 2020-04-10 12:12:36 -07:00
parent bf09dc5e67
commit 4f23ed7f20
4 changed files with 14 additions and 29 deletions

View File

@ -282,13 +282,16 @@ pub mod codegen {
// TODO: `import` or `imports`?
pub mod import {
//! Types and functions for Wasm imports.
pub use wasmer_runtime_core::import::{ImportObject, ImportObjectIterator, LikeNamespace, Namespace};
pub use wasmer_runtime_core::import::{
ImportObject, ImportObjectIterator, LikeNamespace, Namespace,
};
pub use wasmer_runtime_core::types::{ExternDescriptor, ImportDescriptor};
pub use wasmer_runtime_core::{func, imports};
}
pub mod export {
//! Types and functions for Wasm exports.
pub use wasmer_runtime_core::export::Export;
pub use wasmer_runtime_core::types::{ExportDescriptor, ExternDescriptor};
}
@ -394,23 +397,3 @@ impl CompiledModule for Module {
Ok(())
}
}
// Below this line is things copied from `wasmer-runtime` to make the C API work.
// All these additions should be reviewed carefully before shipping.
/// Compile WebAssembly binary code into a [`Module`].
/// This function is useful if it is necessary to
/// compile a module before it can be instantiated
/// (otherwise, the [`instantiate`] function should be used).
///
/// [`Module`]: struct.Module.html
/// [`instantiate`]: fn.instantiate.html
///
/// # Params:
/// * `wasm`: A `&[u8]` containing the
/// binary code of the wasm module you want to compile.
/// # Errors:
/// If the operation fails, the function returns `Err(error::CompileError::...)`.
pub fn compile(wasm: &[u8]) -> error::CompileResult<Module> {
wasmer_runtime_core::compile_with(&wasm[..], &default_compiler())
}

View File

@ -18,9 +18,10 @@ use std::{
sync::Arc,
};
use wasmer::import::{ImportObject, ImportObjectIterator};
use wasmer::wasm::{Ctx, FuncSig, Global, Memory, Module, Table, Type};
use wasmer::vm::Ctx;
use wasmer::wasm::{Export, FuncSig, Global, Memory, Module, Table, Type};
use wasmer_runtime_core::{
export::{Context, Export, FuncPointer},
export::{Context, FuncPointer},
module::ImportName,
};

View File

@ -11,8 +11,8 @@ use crate::{
use libc::{c_char, c_int, c_void};
use std::{collections::HashMap, ffi::CStr, ptr, slice};
use wasmer::import::{ImportObject, Namespace};
use wasmer::wasm::{Ctx, Global, Instance, Memory, Table, Value};
use wasmer_runtime_core::export::Export;
use wasmer::vm::Ctx;
use wasmer::wasm::{Export, Global, Instance, Memory, Table, Value};
/// Opaque pointer to a `wasmer_runtime::Instance` value in Rust.
///
@ -164,7 +164,7 @@ pub unsafe extern "C" fn wasmer_instantiate(
}
let bytes: &[u8] = slice::from_raw_parts_mut(wasm_bytes, wasm_bytes_len as usize);
let module_result = wasmer::compile(bytes);
let module_result = wasmer::compiler::compile(bytes);
let module = match module_result {
Ok(module) => module,
Err(error) => {

View File

@ -9,10 +9,11 @@ use crate::{
};
use libc::c_int;
use std::{collections::HashMap, slice};
use wasmer::compiler::{compile, default_compiler};
use wasmer::import::{ImportObject, Namespace};
use wasmer::wasm::{Global, Table};
use wasmer::{compile, default_compiler, Instance, Memory, Module};
use wasmer_runtime_core::{cache::Artifact, export::Export, load_cache_with};
use wasmer::wasm::{Export, Global, Table};
use wasmer::{Instance, Memory, Module};
use wasmer_runtime_core::{cache::Artifact, load_cache_with};
#[repr(C)]
pub struct wasmer_module_t;