Hello Maxime,
Thursday, October 4, 2007, 2:55:41 AM, you wrote:
If I write a small C function for doing the finalizer myself, I still
wouldn't get passed the FILE * to close, only the struct foo * pointer
which is of no use.
you can use global assocs list
--
Best regards,
Bulat
Stefan O'Rear wrote:
Calling Haskell code from the garbage collector is essentially
impossible to do efficiently and correctly. Don't even try it, your
sanity is not worth saving 3 lines of C coding.
It is a sad thing indeed if that is correct advice.
Jules
Stefan O'Rear wrote:
On Thu, Oct 04, 2007 at 12:55:41AM +0200, Maxime Henrion wrote:
When writing the binding for foo_new(), I need to open a file with
fopen() to pass it the FILE *. Then I get a struct foo * that I can
easily associate the the foo_destroy() finalizer. However, when
Hello all,
I have recently developed a small set of bindings for a C library, and
encountered a problem that I think could be interesting to others.
My problem was that the C function I was writing bindings to expects to
be passed a FILE *. So, I had basically two possibles routes to
Hello Maxime,
Wednesday, October 3, 2007, 7:57:58 PM, you wrote:
And then I discovered Foreign.Concurrent, which allows one to associate
a plain Haskell IO action to a pointer. The 'Foreign.Concurrent' name
is a bit misleading to me; it seems this module is named so because it
needs
I think you want to use wrapper functions from the FFI:
type HsPlayerFinalizer = Ptr PlayerStruct - IO ()
foreign import ccall wrapper mkPlayerFinalizer :: HsPlayerFinalizer
- IO (FunPtr HsPlayerFinalizer)
You can then make an arbitrary Haskell function (including a partially
applied function
On Wed, Oct 03, 2007 at 05:57:58PM +0200, Maxime Henrion wrote:
I have recently developed a small set of bindings for a C library, and
encountered a problem that I think could be interesting to others.
My problem was that the C function I was writing bindings to expects to
be passed a FILE
Stefan O'Rear wrote:
On Wed, Oct 03, 2007 at 05:57:58PM +0200, Maxime Henrion wrote:
I have recently developed a small set of bindings for a C library, and
encountered a problem that I think could be interesting to others.
My problem was that the C function I was writing bindings to
On Thu, Oct 04, 2007 at 12:55:41AM +0200, Maxime Henrion wrote:
When writing the binding for foo_new(), I need to open a file with
fopen() to pass it the FILE *. Then I get a struct foo * that I can
easily associate the the foo_destroy() finalizer. However, when
finalizing the struct foo *