packages feed

c2hs 0.16.0 → 0.16.2

raw patch · 9 files changed

+60/−33 lines, 9 filesdep ~arraydep ~basedep ~containers

Dependency ranges changed: array, base, containers, directory, filepath, pretty, process

Files

c2hs.cabal view
@@ -1,6 +1,6 @@ Name:           c2hs-Version:        0.16.0-License:        GPL+Version:        0.16.2+License:        GPL-2 License-File:   COPYING Copyright:      Copyright (c) 1999-2007 Manuel M T Chakravarty                               2005-2008 Duncan Coutts@@ -18,8 +18,8 @@                 hsch2s), this ensures that C functions are imported with the                 correct Haskell types. Category:       Development-Tested-With:    GHC==6.8.2, GHC==6.10.1-Cabal-Version:  >= 1.2+Tested-With:    GHC==6.10.4, GHC==6.12.1+Cabal-Version:  >= 1.6 Build-Type:     Simple  --TODO: Cabal should allow 'Data-Files' in the executable stanza@@ -29,16 +29,13 @@                 AUTHORS INSTALL README                 doc/c2hs.xml doc/c2hs.css doc/man1/c2hs.1 doc/Makefile -                tests/system/Calls.chs tests/system/calls.h-                tests/system/Cpp.chs tests/system/cpp.h-                tests/system/Enums.chs tests/system/enums.h tests/system/enums.c-                tests/system/Marsh.chs tests/system/marsh.h-                tests/system/Pointer.chs tests/system/pointer.h tests/system/pointer.c-                tests/system/Simple.chs tests/system/simple.h tests/system/simple.c-                tests/system/Sizeof.chs tests/system/sizeof.h tests/system/sizeof.c-                tests/system/Structs.chs tests/system/structs.h tests/system/structs.c+                tests/system/*.chs tests/system/*.h tests/system/*.c                 tests/system/structs.expect                 tests/system/Makefile++source-repository head+  type:         darcs+  location:     http://code.haskell.org/c2hs/  flag base3 
src/C2HS/C/Info.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} --  C->Haskell Compiler: information about the C implementation -- --  Author : Manuel M T Chakravarty@@ -64,6 +65,7 @@ import C2HS.State  (getSwitch) import C2HS.Switches   (platformSB) import C2HS.Gen.Monad    (GB)+import Data.Errors   -- calibration of C's primitive types@@ -114,7 +116,11 @@ size CULLongPT       = Storable.sizeOf (undefined :: CLLong) size CFloatPT        = Storable.sizeOf (undefined :: CFloat) size CDoublePT       = Storable.sizeOf (undefined :: CDouble)+#if MIN_VERSION_base(4,2,0)+size CLDoublePT      = 0  --marks it as an unsupported type, see 'specType'+#else size CLDoublePT      = Storable.sizeOf (undefined :: CLDouble)+#endif size (CSFieldPT bs)  = -bs size (CUFieldPT bs)  = -bs @@ -139,7 +145,11 @@ alignment CULLongPT       = return $ Storable.alignment (undefined :: CULLong) alignment CFloatPT        = return $ Storable.alignment (undefined :: CFloat) alignment CDoublePT       = return $ Storable.alignment (undefined :: CDouble)+#if MIN_VERSION_base(4,2,0)+alignment CLDoublePT      = interr "Info.alignment: CLDouble not supported"+#else alignment CLDoublePT      = return $ Storable.alignment (undefined :: CLDouble)+#endif alignment (CSFieldPT bs)  = fieldAlignment bs alignment (CUFieldPT bs)  = fieldAlignment bs 
src/C2HS/C/Names.hs view
@@ -35,8 +35,6 @@ module C2HS.C.Names (nameAnalysis) where -import Control.Monad (mapM_)- import Language.C.Data.Ident import Language.C.Data.Position import Language.C.Syntax
src/C2HS/C/Trav.hs view
@@ -574,10 +574,10 @@ -- -- * returns an abstract declarator funResultAndArgs :: CDecl -> ([CDecl], CDecl, Bool)-funResultAndArgs (CDecl specs [(Just declr, _, _)] _) =+funResultAndArgs cdecl@(CDecl specs [(Just declr, _, _)] _) =   let (args, declr', variadic) = funArgs declr       result                   = CDecl specs [(Just declr', Nothing, Nothing)]-                                       (newAttrsOnlyPos nopos)+                                       (newAttrsOnlyPos (posOf cdecl))   in   (args, result, variadic)   where
src/C2HS/CHS/Lexer.hs view
@@ -806,7 +806,7 @@     state <- initialState nameSupply     let (ts, lstate, errs) = execLexer chslexer (cs, pos, state)         (_, pos', state')  = lstate-    mapM raise errs+    mapM_ raise errs     assertFinalState pos' state'     setNameSupply $ namesup state'     return ts
src/C2HS/Gen/Bind.hs view
@@ -793,10 +793,12 @@ -- foreignImport :: String -> String -> String -> Bool -> ExtType -> String foreignImport header ident hsIdent isUnsafe ty  =-  "foreign import ccall " ++ safety ++ " " ++ show (header ++ " " ++ ident) +++  "foreign import ccall " ++ safety ++ " " ++ show entity ++   "\n  " ++ hsIdent ++ " :: " ++ showExtType ty ++ "\n"   where     safety = if isUnsafe then "unsafe" else "safe"+    entity | null header = ident+           | otherwise   = header ++ " " ++ ident  -- | Haskell code for the foreign import dynamic declaration needed by a call hook --@@ -1452,9 +1454,6 @@ -- -- * the declaration may have at most one declarator ----- * C functions are represented as `Ptr (FunEt ...)' or `Addr' if in---   compatibility mode (ie, `--old-ffi=yes')--- extractSimpleType                    :: Bool -> Position -> CDecl -> GB ExtType extractSimpleType isResult pos cdecl  =   do@@ -1490,9 +1489,6 @@ -- -- * the declaration may have at most one declarator ----- * all C pointers (including functions) are represented as 'Addr' if in---   compatibility mode (--old-ffi)--- -- * typedef'ed types are chased -- -- * the first argument specifies whether the type specifies the result of a@@ -2132,8 +2128,8 @@ unsupportedTypeSpecErr cpos  =   raiseErrorCTExc cpos     ["Unsupported type!",-     "The type specifier of this declaration is not supported by your C \-     \compiler."+     "The type specifier of this declaration is not supported by your \+     \combination of C compiler and Haskell compiler."     ]  variadicErr          :: Position -> Position -> GB a
src/Control/State.hs view
@@ -65,9 +65,10 @@                     unpackCST, readCST, writeCST, transCST,                     liftIO) import qualified System.CIO as CIO-import Data.Errors      (ErrorLevel(..), Error, makeError, errorLevel)+import Data.Errors      (Error, makeError) import Language.C.Data.Name import Language.C.Data.Position+import Language.C.Data.Error hiding (Error)   -- state used in the whole compiler@@ -244,7 +245,9 @@ showErrors :: PreCST e s String showErrors  = CST $ do                 ErrorState _ _ errs <- transBase extractErrs-                return $ foldr (.) id (map shows errs) ""+                return $ concatMap (showErrorInfo "" . errorInfo) errs+                --FIXME: should be using show here ^^, but Show instance+                --       for CError from language-c is weird               where                 extractErrs    :: BaseState e -> (BaseState e, ErrorState)                 extractErrs bs  = (bs {errorsBS = initialErrorState},
src/Data/Errors.hs view
@@ -69,7 +69,12 @@   errorAtPos         :: Position -> [String] -> a-errorAtPos pos msg  = (error . show . makeError LevelError pos) msg+errorAtPos pos      = error+                      --FIXME: should be using show here, but Show instance+                      --       for CError from language-c is wierd+                    . showErrorInfo "" . errorInfo+                    . makeError LevelError pos+  -- | indent the given multiline text by the given number of spaces --
src/System/CIO.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} --  Compiler Toolkit: Compiler I/O -- --  Author : Manuel M T Chakravarty@@ -61,7 +62,7 @@             ) where -import Prelude (Bool, Char, String, FilePath, (.), Show)+import Prelude (Bool, Char, String, FilePath, (.), ($), Show, return) import qualified System.IO as IO import qualified System.Directory   as IO (doesFileExist, removeFile) import qualified System.Environment as IO (getArgs, getProgName)@@ -75,7 +76,16 @@ -- -------------  openFile     :: FilePath -> IO.IOMode -> PreCST e s IO.Handle-openFile p m  = liftIO (IO.openFile p m)+openFile p m  = liftIO $ do+  hnd <- IO.openFile p m+#if MIN_VERSION_base(4,2,0)+  --FIXME: really we should be using utf8 for .chs and .hs files+  --       however the current .chs lexer cannot cope with chars+  --       that are over 255, it goes into an infinte loop.+  --       As an workaround, use latin1 encoding for the moment:+  IO.hSetEncoding hnd IO.latin1+#endif+  return hnd  hClose   :: IO.Handle -> PreCST e s () hClose h  = liftIO (IO.hClose h)@@ -99,10 +109,18 @@ hPutStrLn h s  = liftIO (IO.hPutStrLn h s)  writeFile                   :: FilePath -> String -> PreCST e s ()-writeFile fname contents  = liftIO (IO.writeFile fname contents)+writeFile fname contents  = do+  --FIXME: see encoding comment with openFile above+  --       this isn't exception-safe+  hnd <- openFile fname IO.WriteMode+  hPutStr hnd contents+  hClose hnd  readFile       :: FilePath -> PreCST e s String-readFile fname  = liftIO (IO.readFile fname)+readFile fname  = do+  --FIXME: see encoding comment with openFile above+  hnd <- openFile fname IO.ReadMode+  liftIO (IO.hGetContents hnd)  print   :: Show a => a -> PreCST e s () print a  = liftIO (IO.print a)