Remove HostRef as a reexport from wasmtime (#794)

This continues #788 and literally removes the type from the public API
of the `wasmtime` crate, making it inaccessible to the outside world.
Now it's purely an implementation detail, yay!
This commit is contained in:
Alex Crichton
2020-01-10 14:36:31 -06:00
committed by GitHub
parent 90db89d327
commit 2b7d627007
3 changed files with 24 additions and 33 deletions

View File

@@ -26,7 +26,7 @@ pub use crate::callable::Callable;
pub use crate::externals::*; pub use crate::externals::*;
pub use crate::instance::Instance; pub use crate::instance::Instance;
pub use crate::module::Module; pub use crate::module::Module;
pub use crate::r#ref::{AnyRef, HostInfo, HostRef}; pub use crate::r#ref::AnyRef;
pub use crate::runtime::{Config, Engine, OptLevel, Store, Strategy}; pub use crate::runtime::{Config, Engine, OptLevel, Store, Strategy};
pub use crate::trap::{FrameInfo, Trap}; pub use crate::trap::{FrameInfo, Trap};
pub use crate::types::*; pub use crate::types::*;

View File

@@ -7,9 +7,10 @@
use super::{ use super::{
AnyRef, Callable, Engine, ExportType, Extern, ExternType, Func, FuncType, Global, GlobalType, AnyRef, Callable, Engine, ExportType, Extern, ExternType, Func, FuncType, Global, GlobalType,
HostInfo, HostRef, ImportType, Instance, Limits, Memory, MemoryType, Module, Store, Table, ImportType, Instance, Limits, Memory, MemoryType, Module, Store, Table, TableType, Trap, Val,
TableType, Trap, Val, ValType, ValType,
}; };
use crate::r#ref::{HostInfo, HostRef};
use std::cell::RefCell; use std::cell::RefCell;
use std::rc::Rc; use std::rc::Rc;
use std::{mem, ptr, slice}; use std::{mem, ptr, slice};

View File

@@ -1,48 +1,38 @@
use wasmtime::*; use wasmtime::*;
use wat::parse_str;
#[test] #[test]
fn test_module_no_name() -> Result<(), String> { fn test_module_no_name() -> anyhow::Result<()> {
let store = Store::default(); let store = Store::default();
let binary = parse_str( let binary = wat::parse_str(
r#" r#"
(module (module
(func (export "run") (nop)) (func (export "run") (nop))
) )
"#, "#,
) )?;
.map_err(|e| format!("failed to parse WebAssembly text source: {}", e))?;
let module = HostRef::new( let module = Module::new(&store, &binary)?;
Module::new(&store, &binary).map_err(|e| format!("failed to compile module: {}", e))?, assert_eq!(module.name(), None);
);
assert_eq!(module.borrow().name(), None);
Ok(()) Ok(())
} }
#[test] #[test]
fn test_module_name() -> Result<(), String> { fn test_module_name() -> anyhow::Result<()> {
let store = Store::default(); let store = Store::default();
let binary = parse_str( let binary = wat::parse_str(
r#" r#"
(module $from_name_section (module $from_name_section
(func (export "run") (nop)) (func (export "run") (nop))
) )
"#, "#,
) )?;
.map_err(|e| format!("failed to parse WebAssembly text source: {}", e))?;
let module = HostRef::new( let module = Module::new(&store, &binary)?;
Module::new(&store, &binary).map_err(|e| format!("failed to compile module: {}", e))?, assert_eq!(module.name(), Some("from_name_section"));
);
assert_eq!(module.borrow().name(), Some("from_name_section"));
let module = HostRef::new( let module = Module::new_with_name(&store, &binary, "override")?;
Module::new_with_name(&store, &binary, "override") assert_eq!(module.name(), Some("override"));
.map_err(|e| format!("failed to compile module: {}", e))?,
);
assert_eq!(module.borrow().name(), Some("override"));
Ok(()) Ok(())
} }