hcom 0.0.0.1 → 0.0.0.2
raw patch · 8 files changed
+55/−108 lines, 8 files
Files
- System/Win32/Com.hs +2/−2
- System/Win32/Com/Automation.hs +7/−7
- System/Win32/Com/Base.hs +0/−16
- System/Win32/Com/Exception.hs +0/−31
- System/Win32/Com/HDirect/HDirect.hs +0/−2
- System/Win32/Com/HDirect/Pointer.hs +1/−9
- System/Win32/Com/HDirect/WideString.hs +12/−12
- hcom.cabal +33/−29
System/Win32/Com.hs view
@@ -591,8 +591,8 @@ | len == 0 = return "" | otherwise = do stackStringLen (4 + fromIntegral len) "" $ \ pstr -> do - bstrToStringLen (castPtr bstr) len (castPtr pstr) - unmarshallString pstr + bstrToStringLen (castPtr bstr) len (castPtr pstr) + unmarshallString pstr where len = bstrLen (castPtr bstr)
System/Win32/Com/Automation.hs view
@@ -1634,13 +1634,13 @@ (len, ienum) <- newEnum ip -- enumNext (fromIntegral sizeofVARIANT) resVariant (fromIntegral len) ienum let getByOne ie = do - mb <- ie # enumNextOne (fromIntegral sizeofVARIANT) resVariant - case mb of - Nothing -> return [] - Just x -> do - -- note: here we have the option of making it on-demand.. - xs <- getByOne ie - return (x:xs) + mb <- ie # enumNextOne (fromIntegral sizeofVARIANT) resVariant + case mb of + Nothing -> return [] + Just x -> do + -- note: here we have the option of making it on-demand.. + xs <- getByOne ie + return (x:xs) ls <- getByOne ienum return (len, ls)
System/Win32/Com/Base.hs view
@@ -1,4 +1,3 @@-{-# OPTIONS_GHC -XCPP -fglasgow-exts #-} -- Automatically generated by HaskellDirect (ihc.exe), snapshot 171208 -- Created: 23:37 Pacific Standard Time, Wednesday 17 December, 2008 -- Command line: -fno-qualified-names -fno-imports -fno-export-lists -fout-pointers-are-not-refs -c System/Win32/Com/Base.idl -o System/Win32/Com/Base.hs @@ -21,9 +20,6 @@ import Control.Exception import Data.Typeable -#if BASE <=3 -import GHC.IOBase -#endif newtype IUnknown_ a = Unknown (ForeignPtr ()) type IUnknown a = IUnknown_ a @@ -68,7 +64,6 @@ comErrorTc = mkTyCon3 "com2" "System.Win32.Com.Base" "ComError" -#if !defined(BASE) || BASE > 3 data SomeCOMException = forall e . Exception e => SomeCOMException e deriving Typeable @@ -92,17 +87,6 @@ toException = comToException fromException = comFromException -#else -instance Typeable ComError where -#if __GLASGOW_HASKELL__ < 604 - typeOf _ = mkAppTy comErrorTc [] -#else - typeOf _ = mkTyConApp comErrorTc [] -#endif - -throwComException :: ComException -> IO a -throwComException c = throwDyn c -#endif coFailWithHR :: HRESULT -> String -> IO a coFailWithHR hr msg = throwComException ComException{comException=(ComError hr),comExceptionMsg=msg}
System/Win32/Com/Exception.hs view
@@ -1,4 +1,3 @@-{-# OPTIONS -XCPP #-} ----------------------------------------------------------------------------- -- | -- Module : System.Win32.Com.Exception @@ -26,8 +25,6 @@ import Numeric ( showHex ) import System.IO.Error ( ioeGetErrorString ) -#if BASE == 3 -import GHC.IOBase import Control.Exception -- | @act `catchComException` (ex -> hdlr ex)@ performs the @@ -35,33 +32,6 @@ -- passing them to the handler @hdlr@. catchComException :: IO a -> (Com_Exception -> IO a) -> IO a catchComException act hdlr = - Control.Exception.catch act - (\ ex -> - case ex of - DynException d -> - case fromDynamic d of - Just ce -> hdlr (Right ce) - _ -> throwIO ex - IOException ioe -> hdlr (Left ioe) - _ -> throwIO ex) - -catch_ce_ :: IO a -> (Maybe ComException -> IO a) -> IO a -catch_ce_ act hdlr = - catchComException - act - (\ e -> - case e of - Left ioe -> hdlr Nothing - Right ce -> hdlr (Just ce)) - -#else -import Control.Exception - --- | @act `catchComException` (ex -> hdlr ex)@ performs the --- IO action @act@, but catches any IO or COM exceptions @ex@, --- passing them to the handler @hdlr@. -catchComException :: IO a -> (Com_Exception -> IO a) -> IO a -catchComException act hdlr = Control.Exception.catch act (\ e -> case fromException e of @@ -78,7 +48,6 @@ case e of Left ioe -> hdlr Nothing Right ce -> hdlr (Just ce)) -#endif -- | @Com_Exception@ is either an 'IOException' or 'ComException'; -- no attempt is made to embed one inside the other.
System/Win32/Com/HDirect/HDirect.hs view
@@ -45,9 +45,7 @@ infixl 5 .+. -#if __GLASGOW_HASKELL__ >= 601 foreignPtrToPtr = unsafeForeignPtrToPtr -#endif {- At the moment the IDL compiler will emit calls to types with identity marshallers
System/Win32/Com/HDirect/Pointer.hs view
@@ -47,18 +47,10 @@ type Finalizer a = Ptr a -> IO () makeFO :: Ptr a -> FunPtr (Ptr a -> IO ()) -> IO (ForeignPtr b)-#if __GLASGOW_HASKELL__ > 601+ makeFO obj finaliser = newForeignPtr (mkFinal finaliser obj) obj >>= return.castForeignPtr-#else-makeFO obj finaliser = newForeignPtr obj (mkFinal finaliser obj) >>= return.castForeignPtr-#endif -#if __GLASGOW_HASKELL__ < 505-mkFinal final obj = ap0 final obj-foreign import ccall "dynamic" ap0 :: FunPtr (Ptr a -> IO()) -> (Ptr a -> IO ())-#else mkFinal final _ = final-#endif --Helpers.
System/Win32/Com/HDirect/WideString.hs view
@@ -24,10 +24,10 @@ stackWideString :: String -> (Ptr Wchar_t -> IO a) -> IO a stackWideString str wcont = do stackString str $ \ len pstr -> do - let wlen = wideStringLen pstr - stackFrame (sizeofWideString*(wlen+1)) $ \ pwide -> do - primStringToWide pstr (fromIntegral len) pwide wlen - wcont pwide + let wlen = wideStringLen pstr + stackFrame (sizeofWideString*(wlen+1)) $ \ pwide -> do + primStringToWide pstr (fromIntegral len) pwide wlen + wcont pwide mkWideString :: String -> WideString mkWideString ls = unsafePerformIO (stringToWide ls) @@ -35,11 +35,11 @@ stringToWide :: String -> IO WideString stringToWide str = stackString str $ \ len pstr -> do - let wlen = wideStringLen pstr - -- Note: we're using the task allocator here. - pwide <- primAllocMemory ((wlen + 1) * sizeofWideString) - primStringToWide pstr (fromIntegral len) (castPtr pwide) wlen - unmarshallWideString (castPtr pwide) + let wlen = wideStringLen pstr + -- Note: we're using the task allocator here. + pwide <- primAllocMemory ((wlen + 1) * sizeofWideString) + primStringToWide pstr (fromIntegral len) (castPtr pwide) wlen + unmarshallWideString (castPtr pwide) -- Sometimes a (wchar_t*) double up as holding a 16-bit (yep, no kidding) - -- higher 16 bits have to be zero, lower 16 the val. We *love* this stuff. @@ -56,8 +56,8 @@ stackString str pcont = do let len = 1 + fromIntegral (length str) stackFrame len $ \ ptr -> do - writeString False ptr str - pcont (fromIntegral len) (castPtr ptr) + writeString False ptr str + pcont (fromIntegral len) (castPtr ptr) marshallWideString :: WideString -> IO (Ptr WideString) marshallWideString (WideString ptr) = marshallPointer ptr >>= return.castPtr @@ -146,5 +146,5 @@ wstr wlen -foreign import ccall "primStringToWide" prim_System_Win32_Com_HDirect_WideString_primStringToWide :: Ptr Char -> Word32 -> Ptr Word16 -> Word32 -> IO Int32 +foreign import ccall "primStringToWide" prim_System_Win32_Com_HDirect_WideString_primStringToWide :: Ptr Char -> Word32 -> Ptr Word16 -> Word32 -> IO Int32
hcom.cabal view
@@ -1,5 +1,5 @@ Name: hcom -version: 0.0.0.1 +version: 0.0.0.2 Synopsis: Haskell COM support library Description: Supporting for writing COM\/Automation clients in Haskell, and for @@ -7,7 +7,7 @@ . This is an updated version of the original `com` library that works with newer GHCs. -Cabal-version: >= 1.2 +Cabal-version: >= 1.20 build-type: Simple Maintainer: Niklas Larsson <niklas@mm.st> License: BSD3 @@ -28,9 +28,10 @@ ComDllMain.hs CHANGES -library { -if os(windows) - Exposed-Modules: System.Win32.Com, +library + Default-language: Haskell2010 + if os(windows) + Exposed-Modules: System.Win32.Com, System.Win32.Com.Base, System.Win32.Com.Automation, System.Win32.Com.Automation.Base, @@ -52,31 +53,34 @@ System.Win32.Com.HDirect.PointerPrim, System.Win32.Com.HDirect.WideString - Include-dirs: . cbits include + Include-dirs: . cbits include - Includes: include/PointerSrc.h - include/WideStringSrc.h - include/comPrim.h - include/autoPrim.h - include/Registry.h - include/safeArrayPrim.h - include/SafeArray.h - include/StdTypes.h + Includes: include/PointerSrc.h + include/WideStringSrc.h + include/comPrim.h + include/autoPrim.h + include/Registry.h + include/safeArrayPrim.h + include/SafeArray.h + include/StdTypes.h - C-Sources: cbits/PointerSrc.c - cbits/WideStringSrc.c - cbits/ComPrimSrc.c - cbits/AutoPrimSrc.c - cbits/Registry.c - cbits/SafeArrayPrim.c + C-Sources: cbits/PointerSrc.c + cbits/WideStringSrc.c + cbits/ComPrimSrc.c + cbits/AutoPrimSrc.c + cbits/Registry.c + cbits/SafeArrayPrim.c - Extra-libraries: kernel32, user32, ole32, oleaut32, advapi32 - GHC-Options: -O2 -fglasgow-exts - Extensions: CPP + Extra-libraries: kernel32, user32, ole32, oleaut32, advapi32 + GHC-Options: -O2 -fglasgow-exts -fno-warn-unsupported-calling-conventions - Build-depends: old-time - Build-Depends: base >= 4 - CPP-Options: -DBASE=4 -else - Buildable: False -} + Build-depends: old-time + Build-Depends: base >= 4 + CPP-Options: -DBASE=4 + else + Buildable: False + + +source-repository head + type: git + location: https://github.com/melted/hcom