Browse thread
[Caml-list] create a closure in external C function?
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Fabrice Le Fessant <fabrice.le_fessant@i...> |
| Subject: | Re: [Caml-list] create a closure in external C function? |
What you can do is create the closure in ML, and call a C stub inside
this closure that will call your C function. I tried to implement what
you were asking for (i.e. dlsym in Caml), but the main problem is
building an arbitrary frame for the C call from the argument types.
An example:
I finally had a C function receiving three arguments. This function is
called from a ML closure used as a stub for the function received by
dlsym. "ml_call_1" is called with the C function as first parameter,
a list of types as second parameter, and the argument as last parameter.
value ml_ccall_1(value f_v, value types_v, value arg1_v)
{
}
My problem is: how to call the function f_v, using the types in
types_v (either integer, char, string or double) to build the call,
and using arg1_v (translated using its type) as argument.
Of course, I can implement this easily on my PC, but I don't know any
way to implement such a function in an architecture-independant way...
- Fabrice
PS: I can give you the code I have already written for building the
closure, and so on if you are interested... but I'm stuck on this
function !
-------------------
To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr