-
Notifications
You must be signed in to change notification settings - Fork 1.5k
c-api: new wasmtime_trap_new_code function #10765
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
c-api: new wasmtime_trap_new_code function #10765
Conversation
e95f7fb
to
78ea5b9
Compare
@@ -129,7 +131,13 @@ public: | |||
explicit Trap(std::string_view msg) | |||
: Trap(wasmtime_trap_new(msg.data(), msg.size())) {} | |||
|
|||
/// Returns the descriptive message associated with this trap | |||
/// Creates a new trap with the given wasmtime trap code. | |||
Trap(wasmtime_trap_code_enum code) |
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.
i'm not sure if this constructor signature is a good idea or if it's desired, i can change it if not :)
78ea5b9
to
388b3ff
Compare
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.
Thanks! Would you be up for sync-ing the implementation in C and Rust? The trap code listing here already doesn't match the Rust definition, so using from_u8
I don't think will work for the out-of-fuel trap for example. The convert-to-u8
can probably use trap as u8
nowadays, I'm not sure it was possible to do that when it was originally written. That should make the from_u8
conversion work as well.
Additionally would you be up for adding a test for this? Somewhere within this file is probably a good place to go.
61b2d25
to
e527e25
Compare
1cb87ae
to
12b0870
Compare
12b0870
to
f6848b6
Compare
f8e4c19
to
5e2dc3e
Compare
right now, returning wasmtime-recognized traps from functions is only available to the Rust API. this PR adds a new function
wasmtime_trap_new_code
to the c api that returns a newwasm_trap_t
with theTrap
value associated with the given code.