mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-12 05:18:43 +00:00
chore(c-api) Simplify code.
This commit is contained in:
@@ -42,12 +42,9 @@ impl From<ExportType> for wasm_exporttype_t {
|
||||
|
||||
impl From<&ExportType> for wasm_exporttype_t {
|
||||
fn from(other: &ExportType) -> Self {
|
||||
let name = other.name().to_string().into();
|
||||
let name = Box::new(other.name().to_string().into());
|
||||
let extern_type = Box::new(other.ty().into());
|
||||
|
||||
wasm_exporttype_t {
|
||||
name: Box::new(name),
|
||||
extern_type,
|
||||
}
|
||||
wasm_exporttype_t { name, extern_type }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,13 +50,13 @@ impl From<ImportType> for wasm_importtype_t {
|
||||
|
||||
impl From<&ImportType> for wasm_importtype_t {
|
||||
fn from(other: &ImportType) -> Self {
|
||||
let module = other.module().to_string().into();
|
||||
let name = other.name().to_string().into();
|
||||
let module = Box::new(other.module().to_string().into());
|
||||
let name = Box::new(other.name().to_string().into());
|
||||
let extern_type = Box::new(other.ty().into());
|
||||
|
||||
wasm_importtype_t {
|
||||
module: Box::new(module),
|
||||
name: Box::new(name),
|
||||
module,
|
||||
name,
|
||||
extern_type,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,11 +33,11 @@ impl From<String> for wasm_name_t {
|
||||
let mut boxed_str: Box<str> = string.into_boxed_str();
|
||||
let data = boxed_str.as_mut_ptr();
|
||||
let size = boxed_str.bytes().len();
|
||||
let wasm_byte = Self { data, size };
|
||||
let wasm_name = Self { data, size };
|
||||
|
||||
Box::leak(boxed_str);
|
||||
|
||||
wasm_byte
|
||||
wasm_name
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -411,13 +411,13 @@ unsafe fn wasi_get_unordered_imports_inner(
|
||||
*imports = import_object
|
||||
.into_iter()
|
||||
.map(|((module, name), export)| {
|
||||
let module = module.into();
|
||||
let name = name.into();
|
||||
let module = Box::new(module.into());
|
||||
let name = Box::new(name.into());
|
||||
let extern_inner = Extern::from_vm_export(store, export);
|
||||
|
||||
Box::new(wasm_named_extern_t {
|
||||
module: Box::new(module),
|
||||
name: Box::new(name),
|
||||
module,
|
||||
name,
|
||||
r#extern: Box::new(wasm_extern_t {
|
||||
instance: None,
|
||||
inner: extern_inner,
|
||||
|
||||
Reference in New Issue
Block a user