haskell / c2hs

c2hs is a pre-processor for Haskell FFI bindings to C libraries
http://hackage.haskell.org/package/c2hs
Other
199 stars 50 forks source link

Use type parameter (if specified) for default out-marshall ForeignPtr #214

Open CthulhuDen opened 5 years ago

CthulhuDen commented 5 years ago

Related to #73.

I believe fix for that previous issue did not address the case when pointer type parater was specified in pointer declaration. For example, if we have

{# pointer *cpSpace as CPSpacePtr foreign finalizer cpSpaceFree -> CPSpace #}

The produced finalizer import block will read as follows:

foreign import ccall "Chiphunk.chs.h &cpSpaceFree"
  cpSpaceFree :: C2HSImp.FinalizerPtr ()

Note that the type paramter to FinalizePtr is still (), which will not compile together with type CPSpacePtr = C2HSImp.ForeignPtr (CPSpace).