All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
0.10.0 - 2024-01-28
- Support for OCaml arrays (PR #61 by @mt-caret).
- Support for OCaml float arrays (PR #61 by @mt-caret).
- OCaml exceptions are now represented by
OCaml<OCamlException>
values instead of customOCamlException
values. This makes them first-class and safer to use because the fact that executing the garbage collector can invalidate references is now encoded in the type (PR #60 by @mt-caret)
0.9.2 - 2023-07-27
- Expansion of bytecode-callable functions (PR #53, reported and debugged by @mt-caret in #52).
0.9.1 - 2023-07-12
- Expansion of bytecode-callable functions.
0.9.0 - 2023-07-12
- Support for OCaml
Bigarray.Array1
values (PR #26 by @g2p) - Support for callable closure values with more automatic conversion between Rust and OCaml values (PR #44 and PR #45 by @sebastiencs)
- Conversions for
<Box<[u8]>
(PR #47 by @sebastiencs) - Support for defining bytecode-callable wrappers for functions with
ocaml_export!
macro (PR #50)
0.8.8 - 2022-03-23
- Fixed compilation issue in some environments (PR #43 by @c-cube)
0.8.7 - 2021-10-12
- Conversion for tuples of 10 elements.
- Internal changes to tuple conversion handling to use a slightly safer version of
store_field
to construct the tuples.
0.8.6 - 2021-10-12
- Bug in the conversion of
Result<T, E>
(Rust->OCaml) values that could result in memory corruption if the OCaml garbage collector happened to run during the conversion.
0.8.5 - 2021-08-16
no-caml-startup
feature flag that disables calls tocaml_startup
when initializing the runtime. This makesOCamlRuntime::init_persistent()
a noop. It is useful for being able to load code that usesocaml-rs
in an utop toplevel (for example, when runningdune utop
). Will be enabled if the environment variableOCAML_INTEROP_NO_CAML_STARTUP
is set. This is a temporary option that is likely to be removed in the future once a better solution is implemented.
0.8.4 - 2021-05-18
- Implementation of
ToOCaml<T>
forBoxRoot<T>
.
- Conversion from/to unit (
()
) values.
0.8.3 - 2021-04-30
- Conversion from/to unit (
()
) values.
0.8.2 - 2021-04-27
- Breakage when building 0.8.1 on arm64 (by @zshipko).
0.8.1 - 2021-04-25
custom_ptr_val
method toOCaml<T>
to obtain pointers to values embedded in OCaml custom blocks (by @g2p). Experimental API.DynBox<T>
, support for custom OCaml values that wrap Rust values (by @g2p). Experimental API.
- There is no longer a need to
ocaml_interop_setup
from OCaml programs.
0.8.0 - 2021-04-07
- Support for allocating OCaml polymorphic variants.
impl_to_ocaml_polymorphic_variant!
macro.ocaml_alloc_polymorphic_variant!
macro.caml_state
feature flag that gets forwarded toocaml-sys
.
0.7.2 - 2021-03-18
- Bumped
ocaml-sys
dependency to at least0.20.1
.
0.7.1 - 2021-03-18
- Bumped
ocaml-boxroot-sys
dependency to0.2
that includes awithout-ocamlopt
feature flag.
0.7.0 - 2021-03-16
BoxRoot::from_raw
method.BoxRoot::get_raw
method.
0.6.0 - 2021-03-15
- New BoxRoot type for rooted values, implemented by: https://gitlab.com/ocaml-rust/ocaml-boxroot
to_boxroot(cr)
method toToOCaml
trait.- Support for OCaml tuples of up to 10 elements (until now tuples containing up to 4 elements were supported)
ocaml_interop_setup
andocaml_interop_teardown
functions that must be called by OCaml programs before calling Rust code.
- Rooted values (both local and global roots) are now handled by BoxRoot.
ocaml_frame!
macro. BoxRoot replaces the need for opening new local root frames.to_ocaml!
macro. Without local roots this has no advantage forvalue.to_ocaml(cr)
.
0.5.3 - 2021-01-26
- Added nul terminator to string passed to
caml_startup
(by @mat13mn)
0.5.2 - 2021-01-25
Drop
implementation forOCamlRuntime
that shuts down the OCaml runtime.
OCamlRuntime::recover_handle()
now returns a&mut
reference instead of an owned value.
OCamlRuntime::shutdown(self)
, now handled byDrop
implementation.
0.5.1 - 2021-01-22
- Syntax in
impl_from_ocaml_variant!
for variant tags with named fields (records instead of tuples).
0.5.0 - 2021-01-20
OCamlRuntime::releasing_runtime(&mut self, f: FnOnce() -> T)
releases the OCaml runtime, callsf
, and then re-acquires the OCaml runtime. Maybe more complicated patterns should be supported, but for now I haven't given this much thought.- Support for unpacking OCaml polymorphic variants into Rust values.
to_rust(cr: &OCamlRuntime)
method toOCamlRef<T>
values.OCaml::unit()
method to obtain an OCaml unit value.OCaml::none()
method to obtain an OCamlNone
value.- Support for tuple-structs in struct/record mapping macros.
OCaml::as_ref(&self) -> OCamlRef<T>
method. Useful for immediate OCaml values (ints, unit, None, booleans) to convert them intoOCamlRef
s without the need for rooting.Deref
implementation to get anOCamlRef<T>
from anOCaml<T>
.
- The GC-handle has been replaced by an OCaml-Runtime-handle that must be passed around as a
&mut
reference.OCaml<'a, T>
values have their lifetime associated to this handle through an immutable borrow, just like it used to be with the now-gone GC-handle. - Exported functions don't implicitly open an
ocaml_frame!
anymore, but instead receive an OCaml-runtime-handle as their first argument. ocaml_frame!
doesn't create a GC-handle anymore, but instead takes as input an OCaml-Runtime-handle, and uses it to instantiate a new frame and list of Root-variables through an immutable borrow.ocaml_frame!
is now only required to instantiate Root-variables, any interaction with the OCaml runtime will make use of an OCaml-Runtime-handle, which should be around already. The syntax also changed slightly, requiring a comma after the OCaml-Runtime-handle parameter.OCamlRoot
has been renamed toOCamlRawRoot
.- Rust functions that are exported to OCaml must now declare at least one argument.
- Functions that are exported to OCaml now follow a caller-save convention. These functions now receive
OCamlRef<T>
arguments. - Functions that are imported from OCaml now follow a caller-save convention. These functions now receive
OCamlRef<T>
arguments. - Calls to OCaml functions don't return
Result
anymore, and instead panic on unexpected exceptions. to_rust()
method is now implemented directly intoOCaml<T>
, theToRust
trait is not required anymore.keep_raw()
method in root variables is nowunsafe
and returns anOCamlRef<T>
.OCaml<T>::as_i64()
->to_i64()
.OCaml<T>::as_bool()
->to_bool()
.
ToRust
trait.OCamlRawRooted
type.ocaml_call!
macro.ocaml_alloc!
macro.OCamlAllocToken
type.OCamlRef::set
method (useOCamlRawRoot::keep
instead).
0.4.4 - 2020-11-02
- Bug in macro when expanding root variables
0.4.3 - 2020-11-02
- Conversion to/from
Result
values.
0.4.2 - 2020-10-22
- Bug in
hd
andtl
functions ofOCaml<OCamlList<A>>
.
0.4.1 - 2020-10-21
- docs.rs documentation build.
0.4.0 - 2020-10-20
- This crate now depends on ocaml-sys.
- Switched from
std
tocore
on every place it was possible.
0.3.0 - 2020-10-06
- Support for
Box<T>
conversions (boxed values get converted the same as their contents). OCaml::of_i64_unchecked
as anunsafe
unchecked version ofOCaml::of_i64
.- More documentation.
- More tests.
ocaml_frame!
andocaml_export!
macros now expect a list of local root variables. This fixes the hardcoded limit of 8 local roots per frame, and makes each frame allocate only as many roots as are actually needed.to_ocaml!
now accepts an optional third argument. It must be a root variable. In this case anOCamlRef<T>
is returned instead of anOCaml<T>
.IntoRust
andinto_rust()
have been renamed toToRust
andto_rust()
.OCaml::of_i64
can fail and return an error now (because of the possibly lost bit).- Immutable borrows through
as_bytes
andas_str
forOCaml<String>
andOCaml<OCamlBytes>
are no longer marked asunsafe
. - Made possible conversions between Rust
str
/[u8]
/String
/Vec<u8>
values andOCaml<OCamlBytes>
andOCaml<String>
more explicit (used to beAsRef<[u8]>
andAsRef<str>
before). - Add new
OCamlFloat
type for OCaml boxed floats, to more explicitly differentiate from unboxed float arguments in functions and declarations.
nokeep
annotation when opening anocaml_frame!
/ocaml_export!
function was removed. Opening the frame without any root variable declaration behaves the same as the oldnokeep
annotation.OCaml<f64>
is no longer a valid representation for OCaml floats, useOCaml<OCamlFloat>
instead.keep
method in GC handles andOCaml<T>
values was removed. Thekeep
method in root variables should be used instead, or the third optional parameter of theto_ocaml!
macro.