c2hs 0.16.4 → 0.16.5
raw patch · 7 files changed
+58/−88 lines, 7 filesdep ~basedep ~language-cnew-uploader
Dependency ranges changed: base, language-c
Files
- README +38/−53
- c2hs.cabal +9/−9
- src/C2HS/C.hs +1/−1
- src/C2HS/C/Trav.hs +1/−1
- src/C2HS/Gen/Bind.hs +6/−21
- src/C2HS/Gen/Header.hs +2/−2
- tests/system/Calls.chs +1/−1
README view
@@ -1,66 +1,51 @@- C->Haskell - Haskell Interface Generator -*-text-*-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+`c2hs` is a interfacing tool that eases Haskell access to C libraries.+The tool gets information about the C data type definitions and+function signatures by analysing the C header files of the library.+It uses this information to compute the missing details in the+template of a Haskell module — called the binding file —+that implements a Haskell binding to the C library. Hooks embedded in+the binding file signal where, which, and how C objects are accessed+from Haskell. The Haskell code in the binding file determines Haskell+types signatures and marshaling details. -C->Haskell is a interfacing tool that eases Haskell access to C libraries.-The tool gets information about the C data type definitions and function-signatures by analysing the C header files of the library. It uses this-information to compute the missing details in the template of a Haskell-module---called the binding file---that implements a Haskell binding to the C-library. Hooks embedded in the binding file signal where, which, and how C-objects are accessed from Haskell. The Haskell code in the binding file-determines Haskell types signatures and marshaling details. Further-information is at+Further information is on the+[wiki](https://github.com/haskell/c2hs/wiki/Home). Also see the+[user guide](https://github.com/haskell/c2hs/wiki/User-Guide) (also+available in the `doc` directory of the repository). - http://www.cse.unsw.edu.au/~chak/haskell/c2hs/ -Also see the tutorial in `doc/c2hs/'.+## Installing +See the file `INSTALL`. -Contents: - AUTHORS -- Author information- COPYING -- GNU General Public License (GPL)- INSTALL -- Help on installing this package- README -- This file- Setup.hs -- Cabal build script- TODO -- Open problems, bugs, and ideas for future extensions- c2hs.cabal -- Cabal package specification- doc -- Documentation- src -- Source code- src/C2HS -- Main program sources- src/Main.hs -- Compilation driver- tests -- Small test cases+## Copyleft +This system is free software; you can redistribute it and/or modify it+under the terms of the GNU General Public License as published by the+Free Software Foundation; either version 2 of the License, or (at your+option) any later version. --=-=-=-=-=-=-=-=-=-=-=-=-=-=-= INSTALLING =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=+This system is distributed in the hope that it will be useful, but+WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU+General Public License for more details. -See the file `INSTALL'.+You should have received a copy of the GNU General Public License+along with this system; if not, write to the Free Software Foundation,+Inc., 675 Mass Ave, Cambridge, MA 02139, USA. --=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- COPYLEFT -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=+> **NOTE HOWEVER**, all code included into generated bindings is under+> a BSD-style license that does not place any restrictions on the+> license of the inteface produced with `c2hs` (ie, closed proprietary+> licenses are possible, too). In other words, I do not care what you+> use `c2hs` for or to whom you are giving `c2hs` or any interfaces+> generated with `c2hs`, only if you modify or improve `c2hs` itself,+> you have to contribute your changes back to the community.+> Nevertheless, I will of course be particularly delighted if you+> choose to make your work freely available. -This system is free software; you can redistribute it and/or modify it under-the terms of the GNU General Public License as published by the Free Software-Foundation; either version 2 of the License, or (at your option) any later-version. -This system is distributed in the hope that it will be useful, but WITHOUT ANY-WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR-A PARTICULAR PURPOSE. See the GNU General Public License for more details.--You should have received a copy of the GNU General Public License along with-this system; if not, write to the Free Software Foundation, Inc., 675 Mass-Ave, Cambridge, MA 02139, USA.--NOTE: HOWEVER, all code included into generated bindings is under a BSD-style- license that does not place any restrictions on the license of the- inteface produced with C->Haskell (ie, closed proprietary licenses are- possible, too). In other words, I do not care what you use C->Haskell- for or to whom you are giving C->Haskell or any interfaces generated with- C->Haskell, only if you modify or improve C->Haskell itself, you have to- contribute your changes back to the community. Nevertheless, I will of- course be particularly delighted if you choose to make your work freely- available.---=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- CREDITS -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+## Credits -See the file `AUTHORS'.+See the file `AUTHORS`.
c2hs.cabal view
@@ -1,15 +1,15 @@ Name: c2hs-Version: 0.16.4+Version: 0.16.5 License: GPL-2 License-File: COPYING Copyright: Copyright (c) 1999-2007 Manuel M T Chakravarty- 2005-2008 Duncan Coutts+ 2005-2013 Duncan Coutts 2008 Benedikt Huber Author: Manuel M T Chakravarty-Maintainer: chak@cse.unsw.edu.au, duncan@haskell.org+Maintainer: chak@cse.unsw.edu.au, duncan@community.haskell.org, ian@skybluetrades.net Stability: Stable-Homepage: http://www.cse.unsw.edu.au/~chak/haskell/c2hs/-Bug-Reports: http://hackage.haskell.org/trac/c2hs/+Homepage: https://github.com/haskell/c2hs+Bug-Reports: https://github.com/haskell/c2hs/issues Synopsis: C->Haskell FFI tool that gives some cross-language type safety Description: C->Haskell assists in the development of Haskell bindings to C libraries. It extracts interface information from C header@@ -18,7 +18,7 @@ hsch2s), this ensures that C functions are imported with the correct Haskell types. Category: Development-Tested-With: GHC==6.12.3, GHC==7.0.4, GHC==7.6.1+Tested-With: GHC==6.12.3, GHC==7.0.4, GHC==7.6.1, GHC==7.6.3 Cabal-Version: >= 1.6 Build-Type: Simple @@ -34,14 +34,14 @@ tests/system/Makefile source-repository head- type: darcs- location: http://code.haskell.org/c2hs/+ type: git+ location: git://github.com/haskell/c2hs.git flag base3 Executable c2hs Build-Depends: base >= 2 && < 5,- language-c >= 0.3.1.1 && < 0.4.0,+ language-c >= 0.4.2 && < 0.5, filepath if flag(base3)
src/C2HS/C.hs view
@@ -93,7 +93,7 @@ ns <- getNameSupply case execParser translUnitP is pos builtinTypeNames ns of Left (ParseError (msgs,pos')) -> raiseError pos' msgs >>- return (CTranslUnit [] internalNode)+ return (CTranslUnit [] undefNode) Right (ct,ns') -> setNameSupply ns' >> return ct -- | given a file name (with suffix), parse that file as a C header and do the
src/C2HS/C/Trav.hs view
@@ -246,7 +246,7 @@ Just prevTag -> case isRefinedOrUse prevTag tag of Nothing -> return otag Just (fullTag, foreIde) -> do- transAttrCCT $ \ac -> addDefTagC ac ide fullTag+ _ <- transAttrCCT $ \ac -> addDefTagC ac ide fullTag foreIde `refersToDef` TagCD fullTag return Nothing -- transparent for env where
src/C2HS/Gen/Bind.hs view
@@ -125,22 +125,7 @@ import C2HS.Config (PlatformSpec(..)) import C2HS.State (CST, errorsPresent, showErrors, fatal, SwitchBoard(..), Traces(..), putTraceStr, getSwitch)-import C2HS.C (AttrC, CObj(..), CTag(..),- CDecl(..), CDeclSpec(..), CTypeSpec(..),- CStructUnion(..), CStructTag(..), CEnum(..), CDeclr(..), CAttr(..),- CDerivedDeclr(..),CArrSize(..),- CExpr(..), CBinaryOp(..), CUnaryOp(..), CConst (..),- CInteger(..),cInteger,getCInteger,getCCharAsInt,- runCT, ifCTExc,- raiseErrorCTExc, findValueObj, findFunObj, findTag,- applyPrefixToNameSpaces,- simplifyDecl, declrNamed, structMembers,- structName, tagName, declaredName , structFromDecl,- funResultAndArgs, chaseDecl, findAndChaseDecl,- checkForAlias, checkForOneAliasName, checkForOneCUName,- lookupEnum, lookupStructUnion, lookupDeclOrTag, isPtrDeclr,- dropPtrDeclr, isPtrDecl, getDeclOf, isFunDeclr,- refersToNewDef, partitionDeclSpecs, CDef(..))+import C2HS.C -- friends import C2HS.CHS (CHSModule(..), CHSFrag(..), CHSHook(..),@@ -884,7 +869,7 @@ interr "GenBind.funDef: marshRes: no default?" marshBody (Left ide) = identToString ide- marshBody (Right str) = str+ marshBody (Right str) = "(" ++ str ++ ")" retArgs' = case parm' of CHSParm _ _ _ (Just (_, CHSVoidArg)) _ -> retArgs@@ -894,8 +879,8 @@ funBody = joinLines marshIns ++ mkMarsh2 ++ call ++- joinLines marshOuts ++ marshRes +++ joinLines marshOuts ++ " " ++ (if isImpure || not isPure then "return " else "") ++ ret return $ sig ++ funHead ++ funBody@@ -913,8 +898,8 @@ ctxt = case octxt of Nothing -> "" Just ctxtStr -> ctxtStr ++ " => "- argTys = [ty | CHSParm im ty _ _ _ <- parms' , notVoid im]- resTys = [ty | CHSParm _ ty _ om _ <- parm':parms', notVoid om]+ argTys = ["(" ++ ty ++ ")" | CHSParm im ty _ _ _ <- parms' , notVoid im]+ resTys = ["(" ++ ty ++ ")" | CHSParm _ ty _ om _ <- parm':parms', notVoid om] resTup = let (lp, rp) = if isPure && length resTys == 1 then ("", "")@@ -962,7 +947,7 @@ retArg = if omArgKind == CHSVoidArg || omArgKind == CHSIOVoidArg then "" else outBndr marshBody (Left ide) = identToString ide- marshBody (Right str) = str+ marshBody (Right str) = "(" ++ str ++ ")" in (funArg, marshIn, callArgs, marshOut, retArg) marshArg _ _ = interr "GenBind.funDef: Missing default?"
src/C2HS/Gen/Header.hs view
@@ -182,8 +182,8 @@ do (enrs,transtbl') <- liftM unzip (mapM createEnumerator aliases) return (enrs,CHSTrans False CHSSameCase transtbl') createEnumerator (cid,hsid) = liftM (\enr -> ((enr,cid),(enr,hsid))) newEnrIdent- enumDef ide enrs = CEnum (Just ide) (Just$ map mkEnr enrs) [] internalNode- where mkEnr (name,value) = (name, Just $ CVar value internalNode)+ enumDef ide enrs = CEnum (Just ide) (Just$ map mkEnr enrs) [] undefNode+ where mkEnr (name,value) = (name, Just $ CVar value undefNode) enumFrag ide trans' = CHSHook (CHSEnum (internalIdent ide) (Just hsident) trans' Nothing instances pos) ghFrag (frag@(CHSHook _ ) : frags) =
tests/system/Calls.chs view
@@ -20,7 +20,7 @@ -- test typedef'ed args without argument variable in prototype {#call printString2#} {# call pure MyString as myString #} -{#fun foo as fooFun {} -> id `Int'#}+{#fun foo as fooFun {} -> `Int'#} {#fun pure bar as barFun {`Int'} -> `Float'#}