Constructor of a host function's `VMContext` for synchronous functions. This creates a `VMArrayCallHostFuncContext` which under the hood will be viewed as `VMContext` in the eventually created `VMFuncRef`.
(
engine: &Engine,
ty: FuncType,
func: F,
)
| 2274 | /// This creates a `VMArrayCallHostFuncContext` which under the hood will |
| 2275 | /// be viewed as `VMContext` in the eventually created `VMFuncRef`. |
| 2276 | fn vmctx_sync<F, T>( |
| 2277 | engine: &Engine, |
| 2278 | ty: FuncType, |
| 2279 | func: F, |
| 2280 | ) -> Result<StoreBox<VMArrayCallHostFuncContext>, OutOfMemory> |
| 2281 | where |
| 2282 | F: Fn(Caller<'_, T>, &mut [MaybeUninit<ValRaw>]) -> Result<()> + Send + Sync + 'static, |
| 2283 | T: 'static, |
| 2284 | { |
| 2285 | assert!(ty.comes_from_same_engine(engine)); |
| 2286 | |
| 2287 | unsafe { |
| 2288 | VMArrayCallHostFuncContext::new( |
| 2289 | Self::array_call_trampoline::<T, F>, |
| 2290 | ty.type_index(), |
| 2291 | try_new::<Box<_>>(HostFuncState { |
| 2292 | func, |
| 2293 | _ty: ty.into_registered_type(), |
| 2294 | })?, |
| 2295 | ) |
| 2296 | } |
| 2297 | } |
| 2298 | |
| 2299 | /// Constructor of a host function's `VMContext` for asynchronous functions. |
| 2300 | /// |
nothing calls this directly
no test coverage detected