Hs2lib 0.5.0 → 0.5.1
raw patch · 4 files changed
+23/−12 lines, 4 files
Files
- Hs2lib.cabal +1/−1
- LIMITS.txt +3/−0
- WinDll/Lib/NativeMapping_Base.cpphs +18/−10
- WinDll/Version/Hs2lib.hs +1/−1
Hs2lib.cabal view
@@ -1,5 +1,5 @@ Name: Hs2lib -Version: 0.5.0 +Version: 0.5.1 Cabal-Version: >= 1.10 Build-Type: Custom License: BSD3
LIMITS.txt view
@@ -1,3 +1,6 @@+Version 0.5.1 + - Library bug fix which cauzed an error in marshalling + Version 0.5.0 - Added support for memory leak tracing with the --debug flag % Added support for qualified importing. It is now possible to export
WinDll/Lib/NativeMapping_Base.cpphs view
@@ -232,6 +232,9 @@ -- | Tranform functions to and from the correct types -- TODO: Update this variant to use the impure variants, This will be an issue.. +-- TODO: Can this even be defined using the native functions? +-- This instance can't be generated. It'll stay here for now, buy it can only +-- be used by types which define toFFI/fromFFI instead of toNative/fromNative instance (FFIType a b, FFIType c d) => FFIType (a -> c) (b -> d) where toFFI _ST_ f x = toFFI _ST_ (f (fromFFI _ST_ x)) fromFFI _ST_ f x = fromFFI _ST_ (f (toFFI _ST_ x)) @@ -239,16 +242,20 @@ -- | I decided to use a CAString because on windows this gives me a constant 16 value instance FFIType String CWString where toNative = RECORDM(__FILE__, __LINE__, "newCWString" , newCWString) - fromNative _ST_ ptr = (RECORD( __FILE__, __LINE__, "peekCWString", id)) _ST_ ptr - >> peekCWString ptr - >>= \str -> freeFFI _ST_ "" ptr - >> return str + fromNative _ST_ ptr = do {(RECORD( __FILE__, __LINE__, "peekCWString", id)) _ST_ ptr; + str <- peekCWString ptr; + freeFFI _ST_ "" ptr; + return str;} + freeFFI = FREE( __FILE__, __LINE__, "freeCWString", F.free) -- | Intermediate conversion instance for storing values of arrays instance (Storable a, FFIType b a) => FFIType [b] (Ptr a) where - toNative _ST_ = (RECORDM(__FILE__, __LINE__, "newArray", newArray)) _ST_ . map (toFFI _ST_) - fromList _ST_ x = fmap (map (fromFFI _ST_)) . (RECORD(__FILE__, __LINE__, "peekArray", id) >>= peekArray (fromFFI _ST_ x)) _ST_ + toNative _ST_ = (RECORDM(__FILE__, __LINE__, "newArray", (\val -> newArray =<< mapM (toNative _ST_) val))) _ST_ + fromList _ST_ x ptr = do {(RECORD(__FILE__, __LINE__, "peekArray", id)) _ST_ ptr; + i <- fromNative _ST_ x; + v <- peekArray i ptr; + mapM (fromNative _ST_) v;} -- | Another simple identity instance, I really need to get that overlapping instances -- looked at. @@ -282,8 +289,8 @@ -- | Convert between FastString and CWString instance FFIType FastString CWString where - toFFI _ST_ = toFFI _ST_.unpackFS - fromFFI _ST_ = mkFastString.fromFFI _ST_ + toNative _ST_ = toNative _ST_ . unpackFS + fromNative _ST_ = (mkFastString `fmap`) . fromNative _ST_ -- | Fix integers from the machine dependend values to fixed 32bit values instance FFIType Int CInt where @@ -310,9 +317,9 @@ instance Storable a => FFIType [a] (Ptr a) where toNative = RECORDM(__FILE__, __LINE__, "newArray", newArray) --fmap castPtr . new -- newArray #ifdef DEBUG - fromList st ic ptr = (RECORD( __FILE__, __LINE__, "peek", id)) st ptr >> peekArray (fromFFI st ic) ptr --const (peek . castPtr) --peekArray + fromList st ic ptr = (RECORD( __FILE__, __LINE__, "peek", id)) st ptr >> fromNative st ic >>= \i -> peekArray i ptr --const (peek . castPtr) --peekArray #else - fromList = peekArray . fromFFI --const (peek . castPtr) --peekArray + fromList ic ptr = fromNative ic >>= \i -> peekArray i ptr --const (peek . castPtr) --peekArray #endif freeFFI = FREE( __FILE__, __LINE__, "freeArray", F.free) -- | Intermediate conversion instance for storing values of arrays @@ -372,6 +379,7 @@ fromFFI = _CONST_ toInteger -- | Instance for Functor classes +-- TODO: rewrite this. instance (Functor f, FFIType a b) => FFIType (f a) (f b) where toFFI _ST_ = fmap (toFFI _ST_) fromFFI _ST_ = fmap (fromFFI _ST_)
WinDll/Version/Hs2lib.hs view
@@ -19,7 +19,7 @@ -- | Version Number verNum :: [Int] -verNum = [0,5,0] +verNum = [0,5,1] -- | Version string verStr :: String