Skip to content
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

Switch to caller-rooted arguments calling convention for imported OCaml functions #17

Merged
merged 43 commits into from
Jan 20, 2021

Conversation

tizoc
Copy link
Owner

@tizoc tizoc commented Dec 19, 2020

Changes

Changes to simplify Rust->OCaml calls through the use of a caller-save calling convention, and handling unexpected exceptions with a panic!.

  • Make ocaml! produce functions that expect rooted arguments.
  • Make ocaml! functions return results directly, instead of wrapped in Result. panic! on unexpected exceptions.
  • Implement a way to catch OCaml raised exceptions. (Nothing will be done here for now, users will have to resort to std::panic::catch_unwind).
  • Remove ocaml_call! and ocaml_alloc! macros.
  • Update docs and examples
  • Make FromOCaml::from_ocaml take a ref instead of a copy.

@tizoc tizoc force-pushed the rooted-arguments-more branch from c6473fd to 075d331 Compare December 20, 2020 20:13
@tizoc tizoc marked this pull request as ready for review December 20, 2020 20:13
@g2p
Copy link
Contributor

g2p commented Dec 23, 2020

FWIW, you don't have to pass self by reference or change as_* to to_* for OCaml types that are basically one usize, Clippy gave that advice due to a recently introduced bug: rust-lang/rust-clippy#6316 (comment)

@tizoc
Copy link
Owner Author

tizoc commented Dec 23, 2020

Thanks, that is good to know, I'm pretty sure I saw that warning at some point. The as_ -> to_ changes are made were for consistency (the as_ ones I have return borrowed values, while the ones that changed from as_ -> to_ return new ones).

@tizoc tizoc force-pushed the rooted-arguments-more branch 2 times, most recently from e795c4c to de5e6d6 Compare December 24, 2020 18:41
@tizoc tizoc force-pushed the rooted-arguments-more branch from 3e151bf to d3df4b8 Compare January 13, 2021 00:19
@tizoc tizoc merged commit ef8aa53 into master Jan 20, 2021
@tizoc tizoc deleted the rooted-arguments-more branch January 20, 2021 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants