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

[WIP] Add Obj.t typ for OCaml values #703

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

bobot
Copy link
Contributor

@bobot bobot commented Jan 11, 2022

Allows to have C function with value argument and result. Should fix #643 in a more satisfactory way.

WIP because it remains ugly part in ffi

Duplicate of #569 opened 3 years ago. I hope there are now more interesting use cases for this feature.

CC @disteph @gasche

bobot added 2 commits January 11, 2022 23:43
    Allows to have C function with `value` argument and result
@bobot
Copy link
Contributor Author

bobot commented Jan 12, 2022

I think a version with ocaml_any: 'a typ is not needed because a version with:

  val ocaml_value :
     ?format: (Format.formatter -> 'a -> unit) -> string -> 'a typ
  (** Value representing directly the OCaml value. [ocaml_value ?format name]
     the [name] and [format] are only used for debugging *)

is simpler and more regular. First one defines the typ then use it.

If the function is polymorphic it is a little harder and needs Obj.t but it is also less needed:

https://github.com/ocamllabs/ocaml-ctypes/blob/a35e4bf1c89e502b91a41beec3979cacaac531ac/tests/test-passing-ocaml-values/stubs/functions.ml#L46-L48

and outside the functor:
https://github.com/ocamllabs/ocaml-ctypes/blob/a35e4bf1c89e502b91a41beec3979cacaac531ac/tests/test-passing-ocaml-values/test_passing_ocaml_values.ml#L80-L82

With the one of opam repository
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.

Support for gmp?
1 participant