Comments (9)
Ah thanks, not sure how I managed to miss this one but that looks like exactly what I would want :)
from ocaml-rs.
Just opened a PR: #89
from ocaml-rs.
I'm not opposed to adding a C file to ocaml-sys, I was trying to avoid it for a while but it's probably a better idea than rewriting the macros as Rust macros. This instance is a also little more complicated than the others since it depends on FLAT_FLOAT_ARRAY
.
I made a branch with your proposed additions: https://github.com/zshipko/ocaml-rs/tree/float-array
This branch defines ocaml_sys::FLAT_FLOAT_ARRAY and adds sys/src/ocaml-sys.c which contains wrappers for Double_val
, Store_double_val
, Double_field
and Store_double_field
(see https://github.com/zshipko/ocaml-rs/blob/float-array/sys/src/mlvalues.rs#L143)
Does that work for you? Or did you have something else in mind?
from ocaml-rs.
That looks great and I think would fit my use case.
One thing I find a bit surprising is that there doesn't seem to be any function in mlvalues.h
that would allocate a float array from the C side using the appropriate representation (i.e. with a Double_array_tag
if FLAT_FLOAT_ARRAY
is set and a 0 tag otherwise) but it feels that it's easy to do this on the Rust side using the newly added ocaml_sys::FLAT_FLOAT_ARRAY
constant. Maybe it would be worth having some helper function for this?
from ocaml-rs.
It looks like there is CAMLextern value caml_alloc_float_array (mlsize_t len);
in alloc.h
, I will add that as well.
from ocaml-rs.
Thanks, I only plan on using the ocaml-sys
bit that your PR is introducing, but maybe at some point you also want to use this in the ocaml-rs
part when converting a Vec<f64>
to an OCaml float array
. It seems that currently this would result in an array of boxed floats and somehow the OCaml runtime manages to use it but I ran into some issues while doing the same thing with the new flambda backend.
from ocaml-rs.
Thanks, I will take a look at that before I merge this!
from ocaml-rs.
FYI, I just released ocaml
sys` 0.23 with these changes
from ocaml-rs.
Great, thanks!
from ocaml-rs.
Related Issues (20)
- the trait `IntoValue` is not implemented for `Result<(), String>` HOT 3
- errors using the latest beta HOT 4
- FromValue not implemented for arrays
- Better backtrace when Rust panics HOT 5
- Command got signal SEGV. HOT 6
- Please support type parameters in `ocaml::import!`
- Command got signal ILL. HOT 2
- Error in M1. Builds for x86_64 but attempts to link for arm64
- How to think about custom types
- helper to define functions and custom types
- Fails to compile with OCaml 5 HOT 3
- Call overhead compared to C bindings HOT 8
- v1.0.0 release? HOT 2
- Support [@@noalloc] in ocaml::sig
- Validation in ocaml::sig?
- u32/u64 <--> int32/int64: dangerous to allow? HOT 1
- Remote derive like in serde
- Hardcoded "src" path to library source dir in ocaml-build
- Comments on thread safety and Sync and Send? HOT 26
- Document that ocaml values need to be rooted HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ocaml-rs.