-
Notifications
You must be signed in to change notification settings - Fork 286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(neon): Update try-catch
to match the RFC; return a T: Sized
instead of T: Value
#631
Conversation
src/context/internal.rs
Outdated
@@ -205,7 +204,7 @@ extern "C" fn try_catch_glue<'a, 'b: 'a, C, T, F>(rust_thunk: *mut c_void, | |||
match catch_unwind(AssertUnwindSafe(|| f(cx))) { | |||
// No Rust panic, no JS exception. | |||
Ok(Ok(result)) => unsafe { | |||
*returned = result.to_raw(); | |||
*(returned as *mut T) = result; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
let mut unwind_value: MaybeUninit<*mut c_void> = MaybeUninit::zeroed(); | ||
|
||
let ctrl = unsafe { | ||
neon_runtime::try_catch::with(try_catch_glue::<Self, T, F>, | ||
rust_thunk as *mut c_void, | ||
(self as *mut Self) as *mut c_void, | ||
local.as_mut_ptr(), | ||
ok.as_mut_ptr() as *mut c_void, |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
3c989e5
to
a45812c
Compare
a45812c
to
8beb98e
Compare
try_catch
return NeonResult<T>
instead of JsResult
try-catch
to match the RFC; return a T: Sized
instead of T: Value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM overall
@@ -152,13 +152,13 @@ extern "C" { | |||
// returns `CONTROL_RETURNED`. | |||
// The `unwind_value` out-parameter can be assumed to be initialized if and only if this | |||
// function returns `CONTROL_PANICKED`. | |||
typedef try_catch_control_t (*Neon_TryCatchGlue)(void *rust_thunk, void *cx, v8::Local<v8::Value> *result, void **unwind_value); | |||
typedef try_catch_control_t (*Neon_TryCatchGlue)(void *rust_thunk, void *cx, void *ok, void **unwind_value); |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
|
||
// The `result` out-parameter can be assumed to be initialized if and only if this function | ||
// returns `CONTROL_RETURNED` or `CONTROL_THREW`. | ||
// The `unwind_value` out-parameter can be assumed to be initialized if and only if this | ||
// function returns `CONTROL_PANICKED`. | ||
try_catch_control_t Neon_TryCatch_With(Neon_TryCatchGlue glue, void *rust_thunk, void *cx, v8::Local<v8::Value> *result, void **unwind_value); | ||
try_catch_control_t Neon_TryCatch_With(Neon_TryCatchGlue glue, void *rust_thunk, void *cx, void *ok, v8::Local<v8::Value> *err, void **unwind_value); |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this changes behavior we should have a test for the new behavior, i.e. a result that produces a non-Value
value.
Otherwise looks great!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ca59545
to
eb43562
Compare
As requested by #630
UnwindSafe
boundT: Value
toT: Sized
T
(()
)