Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #[repr(C)]
- pub struct FunctionKernel<T: Value>(fn(Call) -> JsResult<T>);
- impl<T: Value> Kernel<()> for FunctionKernel<T> {
- extern "C" fn callback(info: &CallbackInfo) {
- info.scope().exec(info, |call| {
- let data = info.data();
- let FunctionKernel(kernel) = unsafe { Self::from_wrapper(data.to_raw()) };
- // error: the parameter type `T` might not live long enough
- // note: the parameter type `T` must be valid for the anonymous lifetime #1 defined on the block at 6:39...
- if let Ok(value) = kernel(call) {
- // ~~~~~~~~~~~~
- info.set_return(value);
- }
- })
- }
- // ...
- }
- impl<'a> RootScopeInternal<'a> for RootScope<'a> {
- fn exec<T: 'a, U: This, F: FnOnce(FunctionCall<U>) -> T>(&'a mut self, info: &'a CallbackInfo, f: F) -> T {
- let mut v8_scope = raw::HandleScope::new();
- unsafe {
- neon_sys::scope::enter(&mut v8_scope, self.isolate().to_raw());
- }
- let call = info.as_call(self);
- let result = f(call);
- unsafe {
- neon_sys::scope::exit(&mut v8_scope);
- }
- result
- }
- // ...
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement