fix(runtime-core) Rename ExternalFunction to HostFunction.

This commit is contained in:
Ivan Enderlin
2020-02-17 16:02:23 +01:00
parent 533609ff70
commit ad77803243

View File

@ -111,14 +111,14 @@ pub trait WasmTypeList {
Rets: WasmTypeList; Rets: WasmTypeList;
} }
/// Empty trait to specify the kind of `ExternalFunction`: With or /// Empty trait to specify the kind of `HostFunction`: With or
/// without a `vm::Ctx` argument. See the `ExplicitVmCtx` and the /// without a `vm::Ctx` argument. See the `ExplicitVmCtx` and the
/// `ImplicitVmCtx` structures. /// `ImplicitVmCtx` structures.
/// ///
/// This type is never aimed to be used by a user. It is used by the /// This trait is never aimed to be used by a user. It is used by the
/// trait system to automatically generate an appropriate `wrap` /// trait system to automatically generate an appropriate `wrap`
/// function. /// function.
pub trait ExternalFunctionKind {} pub trait HostFunctionKind {}
/// This empty structure indicates that an external function must /// This empty structure indicates that an external function must
/// contain an explicit `vm::Ctx` argument (at first position). /// contain an explicit `vm::Ctx` argument (at first position).
@ -140,14 +140,14 @@ pub struct ExplicitVmCtx {}
/// ``` /// ```
pub struct ImplicitVmCtx {} pub struct ImplicitVmCtx {}
impl ExternalFunctionKind for ExplicitVmCtx {} impl HostFunctionKind for ExplicitVmCtx {}
impl ExternalFunctionKind for ImplicitVmCtx {} impl HostFunctionKind for ImplicitVmCtx {}
/// Represents a function that can be converted to a `vm::Func` /// Represents a function that can be converted to a `vm::Func`
/// (function pointer) that can be called within WebAssembly. /// (function pointer) that can be called within WebAssembly.
pub trait ExternalFunction<Kind, Args, Rets> pub trait HostFunction<Kind, Args, Rets>
where where
Kind: ExternalFunctionKind, Kind: HostFunctionKind,
Args: WasmTypeList, Args: WasmTypeList,
Rets: WasmTypeList, Rets: WasmTypeList,
{ {
@ -228,8 +228,8 @@ where
/// Creates a new `Func`. /// Creates a new `Func`.
pub fn new<F, Kind>(func: F) -> Func<'a, Args, Rets, Host> pub fn new<F, Kind>(func: F) -> Func<'a, Args, Rets, Host>
where where
Kind: ExternalFunctionKind, Kind: HostFunctionKind,
F: ExternalFunction<Kind, Args, Rets>, F: HostFunction<Kind, Args, Rets>,
{ {
let (func, func_env) = func.to_raw(); let (func, func_env) = func.to_raw();
@ -381,7 +381,7 @@ macro_rules! impl_traits {
} }
} }
impl< $( $x, )* Rets, Trap, FN > ExternalFunction<ExplicitVmCtx, ( $( $x ),* ), Rets> for FN impl< $( $x, )* Rets, Trap, FN > HostFunction<ExplicitVmCtx, ( $( $x ),* ), Rets> for FN
where where
$( $x: WasmExternType, )* $( $x: WasmExternType, )*
Rets: WasmTypeList, Rets: WasmTypeList,
@ -496,7 +496,7 @@ macro_rules! impl_traits {
} }
} }
impl< $( $x, )* Rets, Trap, FN > ExternalFunction<ImplicitVmCtx, ( $( $x ),* ), Rets> for FN impl< $( $x, )* Rets, Trap, FN > HostFunction<ImplicitVmCtx, ( $( $x ),* ), Rets> for FN
where where
$( $x: WasmExternType, )* $( $x: WasmExternType, )*
Rets: WasmTypeList, Rets: WasmTypeList,