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

Conversion of ref/array/vector types to generic pointer for FFI #53

Open
MatthewFluet opened this issue Apr 14, 2014 · 1 comment
Open

Comments

@MatthewFluet
Copy link
Member

On Fri, 11 Apr 2014, John Reppy wrote:

I've been working on a new version of the SML3d library (based on the programmable
core profile) and there is a feature that would greatly reduce the size of the C/ML
interface. For a C function like

void glDrawElements (GLenum, GLsizei, GLenum, void *);

I generate multiple wrappers where the fourth parameter type is specialized to
various different array and vector types:

val glDrawElements = _import "glDrawElements" stdcall : (glenum * glsizei * glenum * MLton.Pointer.t) -> unit;
val glDrawElementsArrub = _import "glDrawElements" stdcall : (glenum * glsizei * glenum * Word8.word array) -> unit;
val glDrawElementsArrui = _import "glDrawElements" stdcall : (glenum * glsizei * glenum * Word32.word array) -> unit;
val glDrawElementsArrus = _import "glDrawElements" stdcall : (glenum * glsizei * glenum * Word16.word array) -> unit;
val glDrawElementsVecub = _import "glDrawElements" stdcall : (glenum * glsizei * glenum * Word8.word vector) -> unit;
val glDrawElementsVecui = _import "glDrawElements" stdcall : (glenum * glsizei * glenum * Word32.word vector) -> unit;
val glDrawElementsVecus = _import "glDrawElements" stdcall : (glenum * glsizei * glenum * Word16.word vector) -> unit;

What I would like are functions in Unsafe.Vector and Unsafe.Array to cast vector and array types to pointers.

val toPtr : 'a Vector.vector -> MLton.Pointer.t
val toPtr : 'a Array.array -> MLtonPointer.t

For completeness, it would be good to have these on the monomorphic vector and array types too.

@kni
Copy link
Contributor

kni commented Jan 18, 2019

And I very want it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants