More Finaliser Trouble

Ashley Yakeley <[email protected]>
Newsgroups gmane.comp.lang.haskell.ffi
Organization Myself
Message-ID <[email protected]>
How do I pass a parameter to a finaliser? The pointer itself does not 
have enough information to run the finaliser, I need an extra parameter 
available at the time the pointer is created.

This was easy to do when I could write finalisers in Haskell, of course, 
since I could just apply the parameter to my finaliser function to get a 
finaliser that had the correct type. This is what it looked like:

  foreign import ccall "JVMBridge.h JVMBridge_DeleteGlobalRefGC"
    rawDeleteGlobalRefGC :: JavaVM -> RawGlobalRef -> IO ();


  vm <- rawGetJavaVM ?jvmenv;
  gref <- newForeignPtr rgref (rawDeleteGlobalRefGC vm
   (MkRawGlobalRef rgref));
  return (MkVMRef gref);

But with the new FFI I can't do this so easily. How would I pass the 
'vm' parameter to a finaliser which is only allowed to look at the 
'rgref' pointer?

-- 
Ashley Yakeley, Seattle WA
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.