Replies: 11 comments
-
Related to #103. |
Beta Was this translation helpful? Give feedback.
-
This is likely to be tricky for reasons that are not really specific to ctypes. What type would you like the function to have on the OCaml side? |
Beta Was this translation helpful? Give feedback.
-
The same as the printf functions, using formats :-) |
Beta Was this translation helpful? Give feedback.
-
It's possible in theory, at least if the API you're binding exposes something analogous to https://github.com/ocaml/ocaml/blob/trunk/stdlib/camlinternalFormatBasics.ml |
Beta Was this translation helpful? Give feedback.
-
Indeed, I thought about doing the same but this would be quite heavy. |
Beta Was this translation helpful? Give feedback.
-
I don't know if that may work for your but in tsdl what I did is to use OCaml's pretty printing machinery and simply use the variadic function with a "%s" formatter, see API and implementation. |
Beta Was this translation helpful? Give feedback.
-
Nice but in my case, I really need to pass arguments to the openmaple printf functions, because it handles maple objects in formats to turn them into strings :( |
Beta Was this translation helpful? Give feedback.
-
Some mechanism for invoking (simple) variadic functions would indeed be great. As per #103, I, too, need to call |
Beta Was this translation helpful? Give feedback.
-
Hi, @bendiken, I believe that if you only require static arities on the OCaml side, using Ctypes's cstubs support (0.4.0+ iirc) should generate code that works without ABI restriction. If you require the variadicity in OCaml, too, there is a type encoding problem which may need to be resolved. Out of curiosity, what is the purpose of your |
Beta Was this translation helpful? Give feedback.
-
@dsheets Thanks—fixed arity (e.g., defining |
Beta Was this translation helpful? Give feedback.
-
@dsheets FYI, I decided it would take me longer to figure out Cstubs usage than to just write the pesky stubs, so in this instance I ended up adding basic |
Beta Was this translation helpful? Give feedback.
-
I have to bind a printf-like function, i.e. a function taking a format string and a list of additional parameters depending on the format string.
Is there a way to do this in ctypes ?
Beta Was this translation helpful? Give feedback.
All reactions