Repository: haskell/c2hs Branch: master Commit: 6f699f611b81 Files: 298 Total size: 885.7 KB Directory structure: gitextract_ckd6s0y2/ ├── .boring ├── .github/ │ └── workflows/ │ └── haskell-ci.yml ├── .gitignore ├── .travis.yml ├── AUTHORS ├── C2HS.hs ├── COPYING ├── ChangeLog ├── ChangeLog.CTKlight ├── ChangeLog.old ├── INSTALL ├── README ├── README.CTKlight ├── README.md ├── REGRESSION-SUITE ├── Setup.hs ├── TODO ├── TODO.CTKlight ├── appveyor.yml ├── c2hs.cabal ├── cabal.haskell-ci ├── custom-setup.hs ├── doc/ │ ├── Makefile │ ├── c2hs.css │ ├── c2hs.xml │ └── man1/ │ └── c2hs.1 ├── examples/ │ └── libghttpHS/ │ ├── Ghttp.chs │ ├── Makefile │ ├── ghttpHS.c │ └── ghttpHS.h ├── import-handling.md ├── regression-suite-vm/ │ ├── Vagrantfile │ ├── Vagrantfile-full │ └── run-regression ├── src/ │ ├── C2HS/ │ │ ├── C/ │ │ │ ├── Attrs.hs │ │ │ ├── Builtin.hs │ │ │ ├── Info.hs │ │ │ ├── Names.hs │ │ │ └── Trav.hs │ │ ├── C.hs │ │ ├── CHS/ │ │ │ └── Lexer.hs │ │ ├── CHS.hs │ │ ├── Config.hs │ │ ├── Gen/ │ │ │ ├── Bind.hs │ │ │ ├── Header.hs │ │ │ ├── Monad.hs │ │ │ └── Wrapper.hs │ │ ├── State.hs │ │ ├── Switches.hs │ │ ├── Version.hs │ │ ├── config.c │ │ └── config.h │ ├── Control/ │ │ ├── State.hs │ │ ├── StateBase.hs │ │ └── StateTrans.hs │ ├── Data/ │ │ ├── Attributes.hs │ │ ├── Errors.hs │ │ └── NameSpaces.hs │ ├── Main.hs │ ├── System/ │ │ └── CIO.hs │ └── Text/ │ └── Lexers.hs └── tests/ ├── bugs/ │ ├── call_capital/ │ │ ├── Capital.c │ │ ├── Capital.chs │ │ └── Capital.h │ ├── issue-10/ │ │ ├── Issue10.chs │ │ ├── issue10.c │ │ └── issue10.h │ ├── issue-102/ │ │ └── Issue102.chs │ ├── issue-103/ │ │ ├── Issue103.chs │ │ ├── Issue103A.chs │ │ ├── issue103.c │ │ └── issue103.h │ ├── issue-107/ │ │ └── Issue107.chs │ ├── issue-113/ │ │ ├── Issue113.chs │ │ ├── issue113.c │ │ └── issue113.h │ ├── issue-115/ │ │ ├── Issue115.chs │ │ ├── issue115.c │ │ └── issue115.h │ ├── issue-116/ │ │ ├── Issue116.chs │ │ ├── issue116.c │ │ └── issue116.h │ ├── issue-117/ │ │ ├── Issue117.chs │ │ ├── issue117.c │ │ └── issue117.h │ ├── issue-123/ │ │ ├── Issue123.chs │ │ ├── issue123.c │ │ └── issue123.h │ ├── issue-127/ │ │ ├── Issue127.chs │ │ ├── issue127.c │ │ └── issue127.h │ ├── issue-128/ │ │ ├── Issue128.chs │ │ ├── issue128.c │ │ └── issue128.h │ ├── issue-130/ │ │ ├── Issue130.chs │ │ ├── issue130.c │ │ └── issue130.h │ ├── issue-131/ │ │ ├── Issue131.chs │ │ ├── issue131.c │ │ └── issue131.h │ ├── issue-133/ │ │ ├── Issue133.chs │ │ └── issue133.h │ ├── issue-134/ │ │ ├── Issue134.chs │ │ └── issue134.h │ ├── issue-136/ │ │ ├── Issue136.chs │ │ ├── issue136.c │ │ └── issue136.h │ ├── issue-140/ │ │ ├── Issue140.chs │ │ ├── issue140.c │ │ └── issue140.h │ ├── issue-141/ │ │ ├── Issue141A.chs │ │ ├── Issue141B.chs │ │ ├── Issue141C.chs │ │ └── issue141.h │ ├── issue-149/ │ │ ├── Issue149.chs │ │ ├── issue149.c │ │ └── issue149.h │ ├── issue-15/ │ │ ├── Issue15.chs │ │ ├── issue15.c │ │ └── issue15.h │ ├── issue-151/ │ │ ├── Issue151.chs │ │ └── issue151.h │ ├── issue-152/ │ │ ├── Issue152.chs │ │ └── issue152.h │ ├── issue-155/ │ │ ├── Issue155.chs │ │ ├── Types.chs │ │ └── types.h │ ├── issue-16/ │ │ ├── Issue16.chs │ │ ├── issue16.c │ │ └── issue16.h │ ├── issue-180/ │ │ ├── Issue180.chs │ │ └── issue180.h │ ├── issue-19/ │ │ ├── Issue19.chs │ │ ├── issue19.c │ │ └── issue19.h │ ├── issue-192/ │ │ ├── Issue192.chs │ │ └── issue-192.h │ ├── issue-20/ │ │ ├── Issue20.chs │ │ ├── issue20.c │ │ └── issue20.h │ ├── issue-22/ │ │ ├── Issue22.chs │ │ ├── issue22.c │ │ └── issue22.h │ ├── issue-23/ │ │ ├── Issue23.chs │ │ ├── issue23.c │ │ ├── issue23.h │ │ └── issue23x.h │ ├── issue-230/ │ │ ├── Issue230.chs │ │ ├── issue230.c │ │ └── issue230.h │ ├── issue-242/ │ │ ├── Issue242.chs │ │ ├── issue242.c │ │ └── issue242.h │ ├── issue-25/ │ │ └── Issue25.chs │ ├── issue-257/ │ │ ├── Issue257.chs │ │ ├── issue257.c │ │ └── issue257.h │ ├── issue-29/ │ │ ├── Issue29.chs │ │ └── issue29.h │ ├── issue-30/ │ │ ├── Issue30.chs │ │ ├── Issue30Aux1.chs │ │ ├── Issue30Aux2.chs │ │ ├── issue30.c │ │ ├── issue30.h │ │ ├── issue30aux1.c │ │ ├── issue30aux1.h │ │ ├── issue30aux2.c │ │ └── issue30aux2.h │ ├── issue-31/ │ │ ├── Issue31.chs │ │ ├── issue31.c │ │ └── issue31.h │ ├── issue-32/ │ │ ├── Issue32.chs │ │ ├── issue32.c │ │ └── issue32.h │ ├── issue-36/ │ │ ├── Issue36.chs │ │ └── issue36.h │ ├── issue-37/ │ │ ├── Issue37.chs │ │ ├── issue37.c │ │ └── issue37.h │ ├── issue-38/ │ │ ├── Issue38.chs │ │ ├── issue38.c │ │ └── issue38.h │ ├── issue-43/ │ │ ├── Issue43.chs │ │ ├── issue43.c │ │ └── issue43.h │ ├── issue-44/ │ │ ├── Issue44.chs │ │ ├── issue44.c │ │ └── issue44.h │ ├── issue-45/ │ │ ├── Issue45.chs │ │ ├── issue45.c │ │ └── issue45.h │ ├── issue-46/ │ │ ├── Issue46.chs │ │ ├── issue46.c │ │ └── issue46.h │ ├── issue-47/ │ │ ├── Issue47.chs │ │ ├── issue47.c │ │ └── issue47.h │ ├── issue-48/ │ │ ├── Issue48.chs │ │ ├── issue48.c │ │ └── issue48.h │ ├── issue-51/ │ │ ├── Issue51_GNU.chs │ │ ├── Issue51_nonGNU.chs │ │ ├── issue51.c │ │ └── issue51.h │ ├── issue-54/ │ │ ├── Issue54.chs │ │ ├── issue54.c │ │ └── issue54.h │ ├── issue-60/ │ │ ├── Issue60.chs │ │ ├── _mingw.h │ │ ├── issue60.c │ │ └── stdlib.h │ ├── issue-62/ │ │ ├── Issue62.chs │ │ ├── issue62.c │ │ └── issue62.h │ ├── issue-65/ │ │ ├── Issue65.chs │ │ ├── issue65.c │ │ └── issue65.h │ ├── issue-69/ │ │ ├── Issue69.chs │ │ ├── issue69.c │ │ └── issue69.h │ ├── issue-7/ │ │ ├── Issue7.chs │ │ └── issue7.h │ ├── issue-70/ │ │ ├── Issue70.chs │ │ ├── issue70.c │ │ └── issue70.h │ ├── issue-73/ │ │ ├── Issue73.chs │ │ ├── issue73.c │ │ └── issue73.h │ ├── issue-75/ │ │ ├── Issue75.chs │ │ ├── issue75.c │ │ ├── issue75.h │ │ └── sndfile.h │ ├── issue-79/ │ │ ├── Issue79.chs │ │ ├── issue79.c │ │ └── issue79.h │ ├── issue-80/ │ │ ├── Issue80.chs │ │ ├── issue80.c │ │ └── issue80.h │ ├── issue-82/ │ │ ├── Issue82.chs │ │ └── include/ │ │ ├── Availability.h │ │ ├── AvailabilityInternal.h │ │ ├── TargetConditionals.h │ │ ├── _types.h │ │ ├── secure/ │ │ │ ├── _common.h │ │ │ └── _string.h │ │ ├── string.h │ │ ├── strings.h │ │ ├── sys/ │ │ │ └── cdefs.h │ │ └── xlocale/ │ │ └── _string.h │ ├── issue-83/ │ │ └── Issue83.chs │ ├── issue-9/ │ │ ├── Issue9.chs │ │ ├── issue9.c │ │ └── issue9.h │ ├── issue-93/ │ │ ├── Issue93.chs │ │ ├── issue93.c │ │ └── issue93.h │ ├── issue-95/ │ │ ├── Issue95.chs │ │ ├── issue95.c │ │ └── issue95.h │ ├── issue-96/ │ │ ├── Issue96.chs │ │ ├── issue96.c │ │ └── issue96.h │ ├── issue-97/ │ │ ├── Issue97.chs │ │ ├── Issue97A.chs │ │ ├── issue97.c │ │ └── issue97.h │ └── issue-98/ │ ├── Issue98.chs │ ├── issue98.c │ └── issue98.h ├── regression-suite.hs ├── regression-suite.yaml ├── system/ │ ├── Makefile │ ├── calls/ │ │ ├── Calls.chs │ │ └── calls.h │ ├── clean │ ├── cpp/ │ │ └── Cpp.chs │ ├── enums/ │ │ ├── Enums.chs │ │ ├── enums.c │ │ └── enums.h │ ├── interruptible/ │ │ ├── Interruptible.chs │ │ ├── interruptible.c │ │ └── interruptible.h │ ├── marsh/ │ │ ├── Marsh.chs │ │ └── marsh.h │ ├── pointer/ │ │ ├── Pointer.chs │ │ ├── pointer.c │ │ └── pointer.h │ ├── simple/ │ │ ├── Simple.chs │ │ ├── simple.c │ │ └── simple.h │ ├── sizeof/ │ │ ├── Sizeof.chs │ │ ├── sizeof.c │ │ └── sizeof.h │ └── structs/ │ ├── Structs.chs │ ├── structs.c │ └── structs.h ├── test-bugs.hs └── test-system.hs ================================================ FILE CONTENTS ================================================ ================================================ FILE: .boring ================================================ # Project specific \.setup-config$ autom4te\.cache c2hs\.spec$ c2hs/c/CLexer\.hs$ c2hs/c/CParser\.hs$ c2hs/c2hs$ c2hs/c2hs-inplace$ c2hs/tests/.*\.hs$ c2hs/tests/.*\.h$ \.chi$ c2hs/tests/enums$ c2hs/tests/marsh$ c2hs/tests/pointer$ c2hs/tests/structs$ c2hs/toplevel/C2HSConfig\.hs$ c2hs/toplevel/Version\.hs$ config\.log$ config\.status$ configure$ ^dist doc/c2hs/Makefile$ doc/c2hs/.*\.html$ doc/c2hs/.*\.txt$ doc/c2hs/man1/c2hs.1 postInst\.sh # # Boring file regexps: \.hi$ \.o$ \.o\.cmd$ \.ko$ \.ko\.cmd$ \.mod\.c$ (^|/)\.tmp_versions($|/) (^|/)CVS($|/) (^|/)RCS($|/) ~$ #(^|/)\.[^/] (^|/)_darcs($|/) \.bak$ \.BAK$ \.orig$ (^|/)vssver\.scc$ \.swp$ (^|/)MT($|/) (^|/)\{arch\}($|/) (^|/).arch-ids($|/) (^|/), \.class$ \.prof$ (^|/)\.DS_Store$ (^|/)BitKeeper($|/) (^|/)ChangeSet($|/) (^|/)\.svn($|/) \.py[co]$ \# \.cvsignore$ (^|/)Thumbs\.db$ ================================================ FILE: .github/workflows/haskell-ci.yml ================================================ # This GitHub workflow config has been generated by a script via # # haskell-ci 'github' 'c2hs.cabal' # # To regenerate the script (for example after adjusting tested-with) run # # haskell-ci regenerate # # For more information, see https://github.com/haskell-CI/haskell-ci # # version: 0.16.4 # # REGENDATA ("0.16.4",["github","c2hs.cabal"]) # name: Haskell-CI on: - push - pull_request jobs: linux: name: Haskell-CI - Linux - ${{ matrix.compiler }} runs-on: ubuntu-20.04 timeout-minutes: 60 container: image: buildpack-deps:bionic continue-on-error: ${{ matrix.allow-failure }} strategy: matrix: include: - compiler: ghc-9.6.2 compilerKind: ghc compilerVersion: 9.6.2 setup-method: ghcup allow-failure: false - compiler: ghc-9.4.5 compilerKind: ghc compilerVersion: 9.4.5 setup-method: ghcup allow-failure: false - compiler: ghc-9.2.8 compilerKind: ghc compilerVersion: 9.2.8 setup-method: ghcup allow-failure: false - compiler: ghc-9.0.2 compilerKind: ghc compilerVersion: 9.0.2 setup-method: ghcup allow-failure: false - compiler: ghc-8.10.7 compilerKind: ghc compilerVersion: 8.10.7 setup-method: ghcup allow-failure: false - compiler: ghc-8.8.4 compilerKind: ghc compilerVersion: 8.8.4 setup-method: hvr-ppa allow-failure: false - compiler: ghc-8.6.5 compilerKind: ghc compilerVersion: 8.6.5 setup-method: hvr-ppa allow-failure: false - compiler: ghc-8.4.4 compilerKind: ghc compilerVersion: 8.4.4 setup-method: hvr-ppa allow-failure: false - compiler: ghc-8.2.2 compilerKind: ghc compilerVersion: 8.2.2 setup-method: hvr-ppa allow-failure: false - compiler: ghc-8.0.2 compilerKind: ghc compilerVersion: 8.0.2 setup-method: hvr-ppa allow-failure: false - compiler: ghc-7.10.3 compilerKind: ghc compilerVersion: 7.10.3 setup-method: hvr-ppa allow-failure: false fail-fast: false steps: - name: apt run: | apt-get update apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5 if [ "${{ matrix.setup-method }}" = ghcup ]; then mkdir -p "$HOME/.ghcup/bin" curl -sL https://downloads.haskell.org/ghcup/0.1.19.2/x86_64-linux-ghcup-0.1.19.2 > "$HOME/.ghcup/bin/ghcup" chmod a+x "$HOME/.ghcup/bin/ghcup" "$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false) "$HOME/.ghcup/bin/ghcup" install cabal 3.10.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false) else apt-add-repository -y 'ppa:hvr/ghc' apt-get update apt-get install -y "$HCNAME" mkdir -p "$HOME/.ghcup/bin" curl -sL https://downloads.haskell.org/ghcup/0.1.19.2/x86_64-linux-ghcup-0.1.19.2 > "$HOME/.ghcup/bin/ghcup" chmod a+x "$HOME/.ghcup/bin/ghcup" "$HOME/.ghcup/bin/ghcup" install cabal 3.10.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false) fi env: HCKIND: ${{ matrix.compilerKind }} HCNAME: ${{ matrix.compiler }} HCVER: ${{ matrix.compilerVersion }} - name: Set PATH and environment variables run: | echo "$HOME/.cabal/bin" >> $GITHUB_PATH echo "LANG=C.UTF-8" >> "$GITHUB_ENV" echo "CABAL_DIR=$HOME/.cabal" >> "$GITHUB_ENV" echo "CABAL_CONFIG=$HOME/.cabal/config" >> "$GITHUB_ENV" HCDIR=/opt/$HCKIND/$HCVER if [ "${{ matrix.setup-method }}" = ghcup ]; then HC=$HOME/.ghcup/bin/$HCKIND-$HCVER echo "HC=$HC" >> "$GITHUB_ENV" echo "HCPKG=$HOME/.ghcup/bin/$HCKIND-pkg-$HCVER" >> "$GITHUB_ENV" echo "HADDOCK=$HOME/.ghcup/bin/haddock-$HCVER" >> "$GITHUB_ENV" echo "CABAL=$HOME/.ghcup/bin/cabal-3.10.1.0 -vnormal+nowrap" >> "$GITHUB_ENV" else HC=$HCDIR/bin/$HCKIND echo "HC=$HC" >> "$GITHUB_ENV" echo "HCPKG=$HCDIR/bin/$HCKIND-pkg" >> "$GITHUB_ENV" echo "HADDOCK=$HCDIR/bin/haddock" >> "$GITHUB_ENV" echo "CABAL=$HOME/.ghcup/bin/cabal-3.10.1.0 -vnormal+nowrap" >> "$GITHUB_ENV" fi HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\d+)\.(\d+)\.(\d+)(\.(\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))') echo "HCNUMVER=$HCNUMVER" >> "$GITHUB_ENV" if [ $((HCNUMVER >= 80000)) -ne 0 ] ; then echo "ARG_TESTS=--enable-tests" >> "$GITHUB_ENV" ; else echo "ARG_TESTS=--disable-tests" >> "$GITHUB_ENV" ; fi echo "ARG_BENCH=--enable-benchmarks" >> "$GITHUB_ENV" echo "HEADHACKAGE=false" >> "$GITHUB_ENV" echo "ARG_COMPILER=--$HCKIND --with-compiler=$HC" >> "$GITHUB_ENV" echo "GHCJSARITH=0" >> "$GITHUB_ENV" env: HCKIND: ${{ matrix.compilerKind }} HCNAME: ${{ matrix.compiler }} HCVER: ${{ matrix.compilerVersion }} - name: env run: | env - name: write cabal config run: | mkdir -p $CABAL_DIR cat >> $CABAL_CONFIG <> $CABAL_CONFIG < cabal-plan.xz echo 'f62ccb2971567a5f638f2005ad3173dba14693a45154c1508645c52289714cb2 cabal-plan.xz' | sha256sum -c - xz -d < cabal-plan.xz > $HOME/.cabal/bin/cabal-plan rm -f cabal-plan.xz chmod a+x $HOME/.cabal/bin/cabal-plan cabal-plan --version - name: checkout uses: actions/checkout@v3 with: path: source - name: initial cabal.project for sdist run: | touch cabal.project echo "packages: $GITHUB_WORKSPACE/source/." >> cabal.project cat cabal.project - name: sdist run: | mkdir -p sdist $CABAL sdist all --output-dir $GITHUB_WORKSPACE/sdist - name: unpack run: | mkdir -p unpacked find sdist -maxdepth 1 -type f -name '*.tar.gz' -exec tar -C $GITHUB_WORKSPACE/unpacked -xzvf {} \; - name: generate cabal.project run: | PKGDIR_c2hs="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/c2hs-[0-9.]*')" echo "PKGDIR_c2hs=${PKGDIR_c2hs}" >> "$GITHUB_ENV" rm -f cabal.project cabal.project.local touch cabal.project touch cabal.project.local echo "packages: ${PKGDIR_c2hs}" >> cabal.project if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo "package c2hs" >> cabal.project ; fi if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo " ghc-options: -Werror=missing-methods" >> cabal.project ; fi cat >> cabal.project <> cabal.project.local cat cabal.project cat cabal.project.local - name: dump install plan run: | $CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dry-run all cabal-plan - name: restore cache uses: actions/cache/restore@v3 with: key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }} path: ~/.cabal/store restore-keys: ${{ runner.os }}-${{ matrix.compiler }}- - name: install dependencies run: | $CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks --dependencies-only -j2 all $CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dependencies-only -j2 all - name: build w/o tests run: | $CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all - name: build run: | $CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --write-ghc-environment-files=always - name: tests run: | if [ $((HCNUMVER >= 80000)) -ne 0 ] ; then $CABAL v2-test $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --test-show-details=direct ; fi - name: cabal check run: | cd ${PKGDIR_c2hs} || false ${CABAL} -vnormal check - name: haddock run: | $CABAL v2-haddock --disable-documentation --haddock-all $ARG_COMPILER --with-haddock $HADDOCK $ARG_TESTS $ARG_BENCH all - name: unconstrained build run: | rm -f cabal.project.local $CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all - name: save cache uses: actions/cache/save@v3 if: always() with: key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }} path: ~/.cabal/store ================================================ FILE: .gitignore ================================================ /.cabal-sandbox/* /cabal.sandbox.config *.chi *.chs.h /dist/ /dist-newstyle/ *.hi /issues/ *.o /.shelly/*.txt /tests/bugs/call_capital/Capital /tests/bugs/call_capital/Capital.chi /tests/bugs/call_capital/Capital.chs.h /tests/bugs/call_capital/Capital.hs /tests/bugs/issue-09/Issue09.hs /tests/bugs/issue-10/Issue10 /tests/bugs/issue-10/Issue10.hs /tests/bugs/issue-10/Issue10.i /tests/bugs/issue-102/Issue102 /tests/bugs/issue-102/Issue102.hs /tests/bugs/issue-102/issue-102.txt /tests/bugs/issue-103/Issue103 /tests/bugs/issue-103/Issue103.hs /tests/bugs/issue-103/Issue103A.hs /tests/bugs/issue-107/Issue107 /tests/bugs/issue-107/Issue107.hs /tests/bugs/issue-113/Issue113 /tests/bugs/issue-113/Issue113.hs /tests/bugs/issue-115/Issue115 /tests/bugs/issue-115/Issue115.hs /tests/bugs/issue-116/Issue116 /tests/bugs/issue-116/Issue116.hs /tests/bugs/issue-117/Issue117 /tests/bugs/issue-117/Issue117.chs.c /tests/bugs/issue-117/Issue117.hs /tests/bugs/issue-123/Issue123 /tests/bugs/issue-123/Issue123.hs /tests/bugs/issue-127/Issue127 /tests/bugs/issue-127/Issue127.hs /tests/bugs/issue-128/Issue128 /tests/bugs/issue-128/Issue128.chs.c /tests/bugs/issue-128/Issue128.hs /tests/bugs/issue-130/Issue130 /tests/bugs/issue-130/Issue130.hs /tests/bugs/issue-131/Issue131 /tests/bugs/issue-131/Issue131.chs.c /tests/bugs/issue-131/Issue131.hs /tests/bugs/issue-133/Issue133 /tests/bugs/issue-133/Issue133.hs /tests/bugs/issue-134/Issue134 /tests/bugs/issue-134/Issue134.hs /tests/bugs/issue-136/Issue136 /tests/bugs/issue-136/Issue136.hs /tests/bugs/issue-140/Issue140 /tests/bugs/issue-140/Issue140.hs /tests/bugs/issue-141/Issue141A.hs /tests/bugs/issue-141/Issue141B.hs /tests/bugs/issue-149/Issue149 /tests/bugs/issue-149/Issue149.hs /tests/bugs/issue-15/Issue15 /tests/bugs/issue-15/Issue15.hs /tests/bugs/issue-151/Issue151.hs /tests/bugs/issue-152/Issue152 /tests/bugs/issue-152/Issue152.hs /tests/bugs/issue-152/Issue152.hs /tests/bugs/issue-155/Issue155 /tests/bugs/issue-155/Issue155.hs /tests/bugs/issue-155/Types.hs /tests/bugs/issue-16/Issue16 /tests/bugs/issue-16/Issue16.hs /tests/bugs/issue-19/Issue19 /tests/bugs/issue-19/Issue19.hs /tests/bugs/issue-192/Issue192.hs /tests/bugs/issue-20/Issue20 /tests/bugs/issue-20/Issue20.hs /tests/bugs/issue-20/Issue20.i /tests/bugs/issue-22/Issue22 /tests/bugs/issue-22/Issue22.hs /tests/bugs/issue-23/Issue23 /tests/bugs/issue-23/Issue23.hs /tests/bugs/issue-230/Issue230 /tests/bugs/issue-230/Issue230.hs /tests/bugs/issue-242/Issue242 /tests/bugs/issue-242/Issue242.hs /tests/bugs/issue-25/Issue25 /tests/bugs/issue-25/Issue25.hs /tests/bugs/issue-257/Issue257 /tests/bugs/issue-257/Issue257.chs.c /tests/bugs/issue-257/Issue257.hs /tests/bugs/issue-29/Issue29.hs /tests/bugs/issue-29/Issue29.i /tests/bugs/issue-30/Issue30 /tests/bugs/issue-30/Issue30.hs /tests/bugs/issue-30/Issue30Aux1.hs /tests/bugs/issue-30/Issue30Aux2.hs /tests/bugs/issue-31/Issue31 /tests/bugs/issue-31/Issue31.hs /tests/bugs/issue-32/Issue32 /tests/bugs/issue-32/Issue32.hs /tests/bugs/issue-36/Issue36 /tests/bugs/issue-36/Issue36.hs /tests/bugs/issue-37/Issue37 /tests/bugs/issue-37/Issue37.hs /tests/bugs/issue-38/Issue38 /tests/bugs/issue-38/Issue38.hs /tests/bugs/issue-43/Issue43 /tests/bugs/issue-43/Issue43.hs /tests/bugs/issue-44/Issue44 /tests/bugs/issue-44/Issue44.hs /tests/bugs/issue-45/Issue45 /tests/bugs/issue-45/Issue45.hs /tests/bugs/issue-46/Issue46 /tests/bugs/issue-46/Issue46.hs /tests/bugs/issue-47/Issue47 /tests/bugs/issue-47/Issue47.hs /tests/bugs/issue-48/Issue48 /tests/bugs/issue-48/Issue48.hs /tests/bugs/issue-51/Issue51 /tests/bugs/issue-51/Issue51.hs /tests/bugs/issue-51/Issue51_GNU /tests/bugs/issue-51/Issue51_GNU.hs /tests/bugs/issue-51/Issue51_nonGNU /tests/bugs/issue-51/Issue51_nonGNU.hs /tests/bugs/issue-54/Issue54 /tests/bugs/issue-54/Issue54.hs /tests/bugs/issue-60/Issue60 /tests/bugs/issue-60/Issue60.hs /tests/bugs/issue-60/Issue60.i /tests/bugs/issue-62/Issue62 /tests/bugs/issue-62/Issue62.hs /tests/bugs/issue-65/Issue65 /tests/bugs/issue-65/Issue65.hs /tests/bugs/issue-69/Issue69 /tests/bugs/issue-69/Issue69.hs /tests/bugs/issue-7/Issue7.hs /tests/bugs/issue-7/Issue7.i /tests/bugs/issue-70/Issue70.hs /tests/bugs/issue-73/Issue73 /tests/bugs/issue-73/Issue73.hs /tests/bugs/issue-75/Issue75 /tests/bugs/issue-75/Issue75.hs /tests/bugs/issue-79/Issue79 /tests/bugs/issue-79/Issue79.hs /tests/bugs/issue-80/Issue80 /tests/bugs/issue-80/Issue80.hs /tests/bugs/issue-82/Issue82 /tests/bugs/issue-82/Issue82.hs /tests/bugs/issue-83/Issue83 /tests/bugs/issue-83/Issue83.hs /tests/bugs/issue-9/Issue9 /tests/bugs/issue-9/Issue9.hs /tests/bugs/issue-93/Issue93 /tests/bugs/issue-93/Issue93.hs /tests/bugs/issue-95/Issue95 /tests/bugs/issue-95/Issue95.hs /tests/bugs/issue-96/Issue103 /tests/bugs/issue-96/Issue96 /tests/bugs/issue-96/Issue96.hs /tests/bugs/issue-97/Issue97 /tests/bugs/issue-97/Issue97.hs /tests/bugs/issue-97/Issue97A.hs /tests/bugs/issue-98/Issue98 /tests/bugs/issue-98/Issue98.hs /tests/system/calls/Calls.hs /tests/system/cpp/Cpp.hs /tests/system/enums/Enums.hs /tests/system/enums/enums /tests/system/interruptible/Interruptible.hs /tests/system/interruptible/interruptible /tests/system/marsh/Marsh.hs /tests/system/marsh/marsh /tests/system/pointer/Pointer.hs /tests/system/pointer/pointer /tests/system/simple/Simple.hs /tests/system/simple/simple /tests/system/sizeof/Sizeof.hs /tests/system/sizeof/sizeof /tests/system/structs/Structs.hs /tests/system/structs/structs ================================================ FILE: .travis.yml ================================================ env: global: - AWS_ACCESS_KEY_ID=AKIAIKUEH2ETWTBS2CKQ - secure: "Jzawnhgk3dX2INzbZIlnHCH+aKWqy96B9T1hzBh/Fqp4whglaZDO0mTLHQnhypqAt1rXO2o3yBNcKgGOcgfUuE71uBCzzaXieB0p8BhYn7cwYeANbuKNOGrsP6oDutS5F57FNWwgRp+2oanpgJNOs/6wvfElA7W6ibN8tZiLQrw=" matrix: - GHCVER=8.0.1 before_install: - travis_retry sudo add-apt-repository -y ppa:hvr/ghc - travis_retry sudo apt-get update - travis_retry sudo apt-get install libnetcdf-dev libgsl0-dev liblapack-dev - travis_retry sudo apt-get install cabal-install-2.4 ghc-$GHCVER-prof ghc-$GHCVER-dyn happy - export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/2.4/bin:$PATH install: - sudo apt-get update -qq - sudo pip install awscli - cabal update - | if [ $GHCVER = "head" ] || [ ${GHCVER%.*} = "7.8" ] || [ ${GHCVER%.*} = "7.10" ] || [ ${GHCVER%.*} = "8.0.1" ]; then travis_retry sudo apt-get install happy-1.19.5 alex-3.1.7 export PATH=/opt/alex/3.1.7/bin:/opt/happy/1.19.5/bin:$PATH else travis_retry sudo apt-get install happy alex fi - cabal install --only-dependencies --enable-tests -fregression script: - cabal install && cabal configure --enable-tests -fregression && cabal build && cabal test - ./dist/build/regression-suite/regression-suite ================================================ FILE: AUTHORS ================================================ Manuel M T Chakravarty Duncan Coutts with contributions from (alphabetical order) Bertram Felgenhauer Benedikt Huber John Lato Ian Lynagh André Pang Jens-Ulrik Petersen Armin Sander Sean Seefried Udo Stenzel Axel Simon Michael Weber Thanks for comments and suggestions to Roman Leshchinskiy Jan Kort Seth Kurtzberg Simon Marlow Matthias Neubauer Sven Panne Simon L. Peyton Jones Volker Wysk ================================================ FILE: C2HS.hs ================================================ -- C->Haskell Compiler: Marshalling library -- -- Copyright (c) [1999...2005] Manuel M T Chakravarty -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- -- 1. Redistributions of source code must retain the above copyright notice, -- this list of conditions and the following disclaimer. -- 2. Redistributions in binary form must reproduce the above copyright -- notice, this list of conditions and the following disclaimer in the -- documentation and/or other materials provided with the distribution. -- 3. The name of the author may not be used to endorse or promote products -- derived from this software without specific prior written permission. -- -- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN -- NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- --- Description --------------------------------------------------------------- -- -- Language: Haskell 98 -- -- This module provides the marshaling routines for Haskell files produced by -- C->Haskell for binding to C library interfaces. It exports all of the -- low-level FFI (language-independent plus the C-specific parts) together -- with the C->HS-specific higher-level marshalling routines. -- module C2HS {-# DEPRECATED "The C2HS module should no longer be used." #-} ( -- * Re-export the language-independent component of the FFI module Foreign, -- * Re-export the C language component of the FFI module Foreign.C, -- * Composite marshalling functions withCStringLenIntConv, peekCStringLenIntConv, withIntConv, withFloatConv, peekIntConv, peekFloatConv, withBool, peekBool, withEnum, peekEnum, -- * Conditional results using 'Maybe' nothingIf, nothingIfNull, -- * Bit masks combineBitMasks, containsBitMask, extractBitMasks, -- * Conversion between C and Haskell types cIntConv, cFloatConv, cToBool, cFromBool, cToEnum, cFromEnum ) where import Foreign import Foreign.C import Monad (liftM) -- Composite marshalling functions -- ------------------------------- -- Strings with explicit length -- withCStringLenIntConv :: Num n => String -> ((CString, n) -> IO a) -> IO a withCStringLenIntConv s f = withCStringLen s $ \(p, n) -> f (p, fromIntegral n) peekCStringLenIntConv :: Integral n => (CString, n) -> IO String peekCStringLenIntConv (s, n) = peekCStringLen (s, fromIntegral n) -- Marshalling of numerals -- withIntConv :: (Storable b, Integral a, Integral b) => a -> (Ptr b -> IO c) -> IO c withIntConv = with . fromIntegral withFloatConv :: (Storable b, RealFloat a, RealFloat b) => a -> (Ptr b -> IO c) -> IO c withFloatConv = with . realToFrac peekIntConv :: (Storable a, Integral a, Integral b) => Ptr a -> IO b peekIntConv = liftM fromIntegral . peek peekFloatConv :: (Storable a, RealFloat a, RealFloat b) => Ptr a -> IO b peekFloatConv = liftM realToFrac . peek -- Everything else below is deprecated. -- These functions are not used by code generated by c2hs. {-# DEPRECATED withBool "The C2HS module will soon stop providing unnecessary\nutility functions. Please use standard FFI library functions instead." #-} {-# DEPRECATED peekBool "The C2HS module will soon stop providing unnecessary\nutility functions. Please use standard FFI library functions instead." #-} {-# DEPRECATED withEnum "The C2HS module will soon stop providing unnecessary\nutility functions. Please use standard FFI library functions instead." #-} {-# DEPRECATED peekEnum "The C2HS module will soon stop providing unnecessary\nutility functions. Please use standard FFI library functions instead." #-} {-# DEPRECATED nothingIf "The C2HS module will soon stop providing unnecessary\nutility functions. Please use standard FFI library functions instead." #-} {-# DEPRECATED nothingIfNull "The C2HS module will soon stop providing unnecessary\nutility functions. Please use standard FFI library functions instead." #-} {-# DEPRECATED combineBitMasks "The C2HS module will soon stop providing unnecessary\nutility functions. Please use standard FFI library functions instead." #-} {-# DEPRECATED containsBitMask "The C2HS module will soon stop providing unnecessary\nutility functions. Please use standard FFI library functions instead." #-} {-# DEPRECATED extractBitMasks "The C2HS module will soon stop providing unnecessary\nutility functions. Please use standard FFI library functions instead." #-} {-# DEPRECATED cIntConv "The C2HS module will soon stop providing unnecessary\nutility functions. Please use standard FFI library functions instead." #-} {-# DEPRECATED cFloatConv "The C2HS module will soon stop providing unnecessary\nutility functions. Please use standard FFI library functions instead." #-} {-# DEPRECATED cFromBool "The C2HS module will soon stop providing unnecessary\nutility functions. Please use standard FFI library functions instead." #-} {-# DEPRECATED cToBool "The C2HS module will soon stop providing unnecessary\nutility functions. Please use standard FFI library functions instead." #-} {-# DEPRECATED cToEnum "The C2HS module will soon stop providing unnecessary\nutility functions. Please use standard FFI library functions instead." #-} {-# DEPRECATED cFromEnum "The C2HS module will soon stop providing unnecessary\nutility functions. Please use standard FFI library functions instead." #-} -- Passing Booleans by reference -- withBool :: (Integral a, Storable a) => Bool -> (Ptr a -> IO b) -> IO b withBool = with . fromBool peekBool :: (Integral a, Storable a) => Ptr a -> IO Bool peekBool = liftM toBool . peek -- Passing enums by reference -- withEnum :: (Enum a, Integral b, Storable b) => a -> (Ptr b -> IO c) -> IO c withEnum = with . cFromEnum peekEnum :: (Enum a, Integral b, Storable b) => Ptr b -> IO a peekEnum = liftM cToEnum . peek -- Storing of 'Maybe' values -- ------------------------- --TODO: kill off this orphan instance! instance Storable a => Storable (Maybe a) where sizeOf _ = sizeOf (undefined :: Ptr ()) alignment _ = alignment (undefined :: Ptr ()) peek p = do ptr <- peek (castPtr p) if ptr == nullPtr then return Nothing else liftM Just $ peek ptr poke p v = do ptr <- case v of Nothing -> return nullPtr Just v' -> new v' poke (castPtr p) ptr -- Conditional results using 'Maybe' -- --------------------------------- -- Wrap the result into a 'Maybe' type. -- -- * the predicate determines when the result is considered to be non-existing, -- i.e. it is represented by `Nothing' -- -- * the second argument allows to map a result wrapped into `Just' to some -- other domain -- nothingIf :: (a -> Bool) -> (a -> b) -> a -> Maybe b nothingIf p f x = if p x then Nothing else Just $ f x -- |Instance for special casing null pointers. -- nothingIfNull :: (Ptr a -> b) -> Ptr a -> Maybe b nothingIfNull = nothingIf (== nullPtr) -- Support for bit masks -- --------------------- -- Given a list of enumeration values that represent bit masks, combine these -- masks using bitwise disjunction. -- combineBitMasks :: (Enum a, Bits b) => [a] -> b combineBitMasks = foldl (.|.) 0 . map (fromIntegral . fromEnum) -- Tests whether the given bit mask is contained in the given bit pattern -- (i.e. all bits set in the mask are also set in the pattern). -- containsBitMask :: (Bits a, Enum b) => a -> b -> Bool bits `containsBitMask` bm = let bm' = fromIntegral . fromEnum $ bm in bm' .&. bits == bm' -- |Given a bit pattern, yield all bit masks that it contains. -- -- * This does *not* attempt to compute a minimal set of bit masks that when -- combined yield the bit pattern, instead all contained bit masks are -- produced. -- extractBitMasks :: (Bits a, Enum b, Bounded b) => a -> [b] extractBitMasks bits = [bm | bm <- [minBound..maxBound], bits `containsBitMask` bm] -- Conversion routines -- ------------------- -- |Integral conversion -- cIntConv :: (Integral a, Integral b) => a -> b cIntConv = fromIntegral -- |Floating conversion -- cFloatConv :: (RealFloat a, RealFloat b) => a -> b cFloatConv = realToFrac -- |Obtain C value from Haskell 'Bool'. -- cFromBool :: Num a => Bool -> a cFromBool = fromBool -- |Obtain Haskell 'Bool' from C value. -- cToBool :: Num a => a -> Bool cToBool = toBool -- |Convert a C enumeration to Haskell. -- cToEnum :: (Integral i, Enum e) => i -> e cToEnum = toEnum . fromIntegral -- |Convert a Haskell enumeration to C. -- cFromEnum :: (Enum e, Integral i) => e -> i cFromEnum = fromIntegral . fromEnum ================================================ FILE: COPYING ================================================ This program 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. GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program 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 program 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 program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. ================================================ FILE: ChangeLog ================================================ 0.28.8.* - Bump upper bounds of language-c to 0.10 [#261] 0.28.7 - Support for InterruptibleFFI (Alex Wied) - Support for equality in C macros (Vanessa McHale) - Make c2hs source comments more Haddock friendly (George Thomas) - (Un)Marshal a C bool into a CUChar instead of CInt - The lowest GHC version supported is now 8.0.1, this is due to upgrading Shelly to 1.9.0 for tests but generally the medium-to-long term plan is to update app code to use 8.0.1 features as well. 0.28.6 - Support for binding to anonymous nested structs and unions. 0.28.6 - Update for GHC 8.6.* 0.28.3 - Switch to language-c 0.7.1 [#192] 0.28.2 - Switch to language-c 0.6 [#176] 0.28.1 - Switch to language-c 0.5 [#157] - Fix class hook problem with imports [#155] 0.27.1 - Alternate specification for sizes in "+" parameters [#140] - Fix regression to do with incomplete structure types [#152] - Fix pattern match error [PR #153] (deech) 0.26.2 - Missing import bug [#151] - Parameter count checking for {#fun ...#} [#149] - Error message for "incomplete types" [#141] 0.26.1 - Better error messages [PR #139] (Noam Lewis) - Fix for OS X block syntax [#138] (Anthony Cowley) - Minimal support for va_list [PR #137] (Andy Adams-Moran) - Reorganise treatment of standard library imports used by C2HS [#136] (https://github.com/haskell/c2hs/blob/master/import-handling.md) - C structure tag/typedef confusion bug (caused problems for flock on OS X) [#134] - C typedefs to void pointers [#133] - Bool wrappers for unnamed parameters in C function definitions [#131] - Incorrect wrapping of some pure C functions [#130] 0.25.2 - Test fixes to work with GHC 7.10.1 0.25.1 - Marshalling for C bool values [#128] 0.24.1 - Revert bad fix for bool handling [#127] - Wrapper generation for bare structure arguments [#117] plus custom setup script to support Cabal builds on versions of Cabal without explicit support for extra C sources generated by preprocessors (@RyanGIScott) - Arrays in structuress bug [#123] - Test fixes for Windows 0.23.1 - Typedef and default marshalling hooks [#20, #25, #48] - Test fixes for 32-bit platforms (Jürgen Keck: @j-keck) - Multi-character constants for OS X [#15] - Better support for binding to variadic functions [#102] 0.22.1 - First (not very good) implementation of support for variadic functions [#102] - Default marshallers for Char types [#98] - Improve sizeof computations [#9, #10] 0.21.1 - Parametrized pointer types in pointer hooks [#36] - Special "+" parameters for efficient foreign pointer marshalling [#46] - Add default marshallers for C types [#83] - Fix treatment of arrays within structs [#115] - Add ability to omit given enum values [#116] - Regression suite tidy-ups 0.20.1 - Get CUDA Travis tests working again (hopefully...) - Modify approach for defining C2HS_MIN_VERSION macro to work with NVIDIA's nvcc CUDA compiler [#111] - Fix problem with parser for {#enum ...#} renamings [#113] 0.19.1 - Add {#const ...#} hook for accessing #defined constants [#65] - Persist enumeration definitions across modules [#103] - Add nocode keyword for enumeration definitions [#70] - Bump version for language-c to fix OS X problems [#82, #85] (thanks to Anthony Cowley and Benedikt Huber for help with this) - Add finalizer support to foreign pointer definitions [#73] - Comment parsing cleanups (Sivert Berg: @sivertb) 0.18.2 - Add C2HS_MIN_VERSION(major,minor,revision) preprocessor macro - Suppress regression suite build (and associated dependency installation) for non-Travis cases - Fix Cabal file to include previously missing tests 0.18.1 - Numerous improvements to Enum handling [#78] (Philipp Balzarek: @Philonous) - Handle Haddock comments within C2HS hook definitions [#62] (@tangboyun) - Better error messages for missing files (Zejun Wu: @watashi) - Write CHS dump files to output directory (Zejun Wu: @watashi) - Handle C calling conventions within function pointer declarations [#88] (Michael Steele: @mikesteele81) - Fix FreeBSD libssh2 problem [#87] (Cindy Wang: @CindyLinz) - Better error messages for hook syntax errors (Ryan Scott: @RyanGIScott) - Fixes for GHC 7.9 [#100] (@int-index) - Fix test suite to use C2HS from dist directory [#81] - Allow free intermixing of command line options and input files [#86] - Treat CLang "block" syntax and other "non-GNU" issues differently: always undefine __BLOCKS__ CPP symbol to avoid problems with blocks; add nonGNU directive to trigger undefine of GNU-specific pre-processor symbols [#77] - Handle indented CPP directives correctly [#80] - Handle #sizeof and #alignof on non-typedef's structures [#95] - Fix #get and #set hooks to access newtyped pointers [#96] - Fix round-trip problem for interface files caused by changes in language-c [#87] - Treat "with" specially so that it can appear both as a marshaller identifier in an input parameter definition and as a keyword in enum definitions [#93] - Temporarily disable CUDA regression suite examples (CUDA install problems on Travis) 0.17.2 - Fix more regressions from 0.16.6 (affected packages included gnome-keyring, hsndfile and cuda) - Add regression suite tests to reduce chances of future regressions 0.17.1 - Fix regressions from 0.16.6 (caused by fix for issue #45) - Version number bump (should have been done in the last release) 0.16.6 - Trivial integer casts in enum defines supporting typedefs [Anton Dessiatov] - Allow forward definition of enums (issue #23) - Binding of C enums with aliases (issue #38) - Default marshallers for enum and pointer hooks (issue #31) - Remove dependencies on C2HS module from marshalling code (issue #37) - Problem with MacOS blocks notation (issue #29) - Include directive on first line produces invalid Haskell (issue #16) - Add command-line switch to suppress GNU preprocessor symbols (issue #60) - Fix size and alignment computation of bitfields [Facundo Dominguez] - Allow prefixes to be replaced, not just removed (issue #19) - Allow reference to structure tags from accessors (issue #54) For access paths for {#get#}, {#set#}, etc., one can now specify that structure tags are to be searched preferentially by saying, for example, {#get struct _point->y#} instead of {#get _point->y#}. The latter case will search for typedef names first and only then structure tags. - Support for anonymous enums (issue #43) - with... unwrapper type declarations for pointer hooks (issue #44) - {#fun...#} indentation for use in where clauses (issue #45) - incorrect method names from terminal class in superclass instances (issue #21) - "offsetof" directive (issue #22) - --include flag cannot handle windows paths (issue #30) Now uses System.FilePath splitSearchPath function, which should be platform-agnostic. - Void functions produce "defined but not used" warning (issue #47) Handle fun hooks with a void result using ">>" instead of ">>=". - Add CPP undefine flags for Gnu compiler defines (issue #51) - Cabal test suite 0.16.5 - Migration to GitHub; documentation changes. CHANGES ABOVE THIS POINT ARE FOR VERSIONS AFTER THE MOVE OF THE REPOSITORY TO GITHUB. FOR EARLIER CHANGES SEE ChangeLog.old. ================================================ FILE: ChangeLog.CTKlight ================================================ 2005-05-18 Manuel M. T. Chakravarty * Makefile: Evil Hack to be able create base.build.conf before building `libctk.a' 2005-05-18 Andr Pang * Adaptation to GHC 6.4 and the Cabal package system 2005-05-18 Manuel M. T. Chakravarty * admin/BaseVersion.hs (versnum): 0.27.0 2004-05-15 Manuel M. T. Chakravarty * configure.in: Using `egrep' is available (as grep on SunOS doesn't handle regular expressions) noticed by Matthias Neubauer * syntax/Parsers.hs (execParser): Added a token mapping as an extra argument 2003-10-19 Manuel M T Chakravarty * configure.in: Support for Mac OS X by Sean Seefried 2003-10-19 Manuel M T Chakravarty * sysdep/Makefile: Posix (and hence, `runPiped') support disabled, as `runPiped' (1) isn't really used at the moment, (2) should be rewritten anyway, and (3) breaks with GHC 6.3 as the signature of `forkProcess' changed. * admin/BaseVersion.hs (versnum): 0.26.0 2003-06-10 Manuel M T Chakravarty * ../mk/common.mk (MKDEPENDFILES): defined ghc6 * syntax/Makefile (RANK2): defined ghc6 * sysdep/Makefile (SRCS): defined SysDepGHC6.hs as an alias for SysDepGHC4.hs * admin/BaseVersion.hs (versnum): 0.25.1 2003-03-13 Manuel M T Chakravarty * general/Sets.hs (domSetFM): added * general/FiniteMaps.hs (domFM): added (imageFM): added * admin/BaseVersion.hs (versnum): 0.25.0 2003-02-12 Manuel M T Chakravarty * general/UNames.hs: we derive `Show Name' explicitly to print the number only 2003-02-05 Manuel M T Chakravarty * general/FileOps.hs (mktemp): added 2003-02-01 Manuel M T Chakravarty * ../common.mk: I wasn't careful when removing the ability (for the user) to invoke make in the part directories and hence the ability to check dependencies in these directories. As a result, recursive invocations of make tried to check dependencies in part directories and erroneously decided that the target is alreasy up to date. Now the object file are removed before descending into the recursive make. * ../common.mk (gendepend): remove $(DEPEND) first * admin/BaseVersion.hs (versnum): 0.24.3 2002-09-16 Manuel M T Chakravarty * Makefile (libctk.o): generating library for GHCi 2002-09-06 Manuel M T Chakravarty * Makefile (OBJS): excluded state/DynArrays.o from the target objects for nhc98 (as it chokes on that module) 2002-05-16 Manuel M T Chakravarty * changed name if base package to `ctk' to not clash with GHC's new package naming scheme * admin/BaseVersion.hs (versnum): 0.24.2 2002-03-22 Manuel M T Chakravarty * ../configure.in: test for availability of the `posix' package made more reliable * admin/BaseVersion.hs (versnum): 0.24.1 2002-03-12 Manuel M T Chakravarty * Makefile: revised to new build system * admin/BaseVersion.hs (versnum): 0.24.0 2002-03-06 Manuel M T Chakravarty * general/Sets.hs (isSuperSet): cut'n'pasto 2002-03-05 Manuel M T Chakravarty * Makefile: fixed libctk.a target * ../configure.in: make sure to include the posix package only for GHC (and not for nhc98) * admin/BaseVersion.hs (versnum): 0.23.1 2002-02-11 Manuel M T Chakravarty * Makefile: we are now creating a library archive to use packages 2002-02-10 Manuel M T Chakravarty * ../mk/common.mk: added package support * ../configure.in: added package support; replaced -syslib by -package * admin/BaseVersion.hs (versnum): 0.23.0 2002-01-06 Manuel M T Chakravarty * common.mk: removed TMP as it causes problems on cygwin as reported by Karl M. Syring * admin/BaseVersion.hs (versnum): 0.22.5 2001-09-26 Manuel M. T. Chakravarty * general/UNames.hs: nhc98 1.08 doesn't grok deriving Ix * ../configure.in: better support for nhc98 * admin/BaseVersion.hs (versnum): 0.22.4 2001-05-20 Manuel M. T. Chakravarty * state/CIO.hs (doesFileExistCIO): added by Axel Simon 2001-05-13 Manuel M. T. Chakravarty * Makefile (spotless): remove config.cache 2001-04-21 Manuel M. T. Chakravarty * ../configure.in: Adapted to support ghc 5.x and removed support for ghc 3.x * admin/BaseVersion.hs (versnum): 0.22.3 2000-10-05 Manuel M. T. Chakravarty * ../configure.in: uses the fptools macro for determining ghc's version number 2000-10-02 Manuel M. T. Chakravarty * errors/Errors.hs (showError): special handling of internal positions * admin/Common.hs: added internal positions * admin/BaseVersion.hs (versnum): 0.22.2 2000-09-15 Manuel M. T. Chakravarty * ../configure.in: corrected ghc version number extraction to correctly handle patch levels; added happy - most have gone lost earlier... 2000-09-12 Manuel M. T. Chakravarty * syntax/Pretty.hs (<>): debugged 2000-09-11 Manuel M. T. Chakravarty * syntax/Pretty.hs (Pretty): type class for pretty printing (infixOp): added (usedWhen): added (punctuate): added (dot): added * admin/BaseVersion.hs (versnum): 0.22.1 2000-09-07 Manuel M. T. Chakravarty * syntax/Pretty.hs: Revision of the interface; the interface is now 90% compatible to SimonPJ's `Pretty' module; debugging (fullRender): dropping leading '\n's some more combinators * admin/BaseVersion.hs (versnum): 0.22.0 2000-09-03 Manuel M. T. Chakravarty * admin/Common.hs (tabPos): Roman pointed out that tab stops should be at 1, 9, ... rather than 0, 8, ... 2000-09-02 Manuel M. T. Chakravarty * admin/BaseVersion.hs (versnum): 0.21.1 2000-08-18 Manuel M. T. Chakravarty * sysdep/Makefile: Moved the posix stuff into an extra module, which can be enabled individually * ../configure.in: CygWin support; based on suggestions by Anibal Maffioletti Rodrigues de DEUS * ../configure.in: uses -silent on lndir only if supported (isn't supported before X11R6, says Jan Kort ) * admin/BaseVersion.hs (versnum): 0.21.0 2000-08-08 Manuel M. T. Chakravarty * syntax/Lexers.hs: Changed the associativity of `quest`, `star`, and `plus`. This change was suggested by Martin Norbck . ** WARNING ** This change may break some existing code!!! 2000-06-19 Manuel M. T. Chakravarty * admin/BaseVersion.hs (versnum): 0.20.2 2000-04-06 Manuel M. T. Chakravarty * ../configure.in: -fasm-x86 is used only if --with-ghc-native is given * general/Sets.hs (powerSet): impl 2000-04-05 Manuel M. T. Chakravarty * general/Sets.hs: derived Eq and Ord for FMs, which allows sets of sets and added `isSubSet' and `isSuperSet' * general/FiniteMaps.hs: derived Eq and Ord for FMs * admin/BaseVersion.hs (date): 0.20.1 2000-03-04 Manuel M. T. Chakravarty * ../configure.in: fixes re compiler & option selection 2000-03-01 Manuel M. T. Chakravarty * ../mk/common.mk: fixed dependency computations * ../configure.in: polished; on Linux, uses native code generator when compiling with GHC 4.0x, x >= 7 2000-02-27 Manuel M. T. Chakravarty * syntax/Parsers.hs: table handling substantially rewritten to improve the space behaviour * general/Utils.hs: `Tag' class * admin/BaseVersion.hs (versnum): 0.20.0 2000-02-23 Manuel M. T. Chakravarty * ../mk/config.mk.in: set correct access modes in INSTALL_DATA 1999-12-06 Manuel M. T. Chakravarty * graphs/Marks.hs: newly implemented * admin/BaseVersion.hs (versnum): 0.19.1 1999-12-03 Manuel M. T. Chakravarty * syms/Attributes.hs: instance Ord Attrs 1999-12-02 Manuel M. T. Chakravarty * sysdep/SysDepNHC1.hs: debugging 1999-12-01 Manuel M. T. Chakravarty * ../configure.in,../mk/common.mk: better dependency tool computation * syms/Idents.hs: uses `Attributed' * syms/Attributes.hs: `Attributed' type class, as suggested by Roman Lechtchinsky * admin/BaseVersion.hs (versnum): 0.19.0 * sysdep/SysDepNHC1.hs: Started the system dependent module for nhc98 with assistance from Malcolm Wallace 1999-11-30 Manuel M. T. Chakravarty * state/StateTrans.hs: Adapted to new names in mutable variables API * general/UNames.hs: Adapted to new names in mutable variables API * sysdep/SysDepGHC3.hs: adapted to new names of exported entities * sysdep/SysDepGHC4.hs: Cleaned up; no GHC internal stuff is used anymore (some of the names of exported entities changed!) * sysdep/Makefile: Added support for nhc98 * ../configure.in & friends: Added support for nhc98 * admin/BaseVersion.hs (versnum): 0.18.2 1999-11-17 Manuel M. T. Chakravarty * ../mk/config.mk.in: introduced `docdir' and `pkgdocdir' * Make system debianised, according to the suggestions and the patches of Michael Weber * admin/BaseVersion.hs (versnum): 0.18.1 1999-11-07 Manuel M. T. Chakravarty * general/FileOps.hs (fileFindIn): debugged 1999-11-06 Manuel M. T. Chakravarty * general/FileOps.hs: new module; implemented `fileFindIn' * general/FNameOps.hs (addPath): added * admin/BaseVersion.hs (versnum): 0.18.0 1999-10-29 Manuel M. T. Chakravarty * admin/BaseVersion.hs (versnum): 0.17.17; fully modularised the make system 1999-10-25 Manuel M. T. Chakravarty * state/CIO.hs (removeFileCIO): added * admin/BaseVersion.hs (versnum): 0.17.16 1999-10-24 Manuel M. T. Chakravarty * syms/NameSpaces.hs (nameSpaceToList): added * admin/BaseVersion.hs (versnum): 0.17.15 1999-10-21 Manuel M. T. Chakravarty * syms/Idents.hs (isLegalIdent): corrected `checkTail' - thanx Sven 1999-10-16 Manuel M. T. Chakravarty * syms/NameSpaces.hs (defLocal): uses `defGloal' if there is no local range Pre GNU-style change log ------------------------ 0.17.13 ~~~~~~~ 09Oct99 Debugging 0.17.12 ~~~~~~~ 27Sep99 `CIO.systemCIO' 26Sep99 Debugging and some more clean up of `Lexers' 25Sep99 Some convenience function on `Position's in `Common' 23Sep99 Added `\v' to the control lexer 0.17.11 ~~~~~~~ 22Sep99 Optimised and extended `Lexers' (meta actions can now return tokens or error messages); prepared the first separate distribution of CTKlight 21Sep99 Debugged `Lexers' 0.17.10 ~~~~~~~ 29Aug99 Added `Utils.lookupBy' 0.17.9 ~~~~~~ 22Aug99 Throughly revised `Lexers' (according to SPJ's suggestions) 12Aug99 Revised `Lexers.execLexer' (returns final state, changed semantics of meta actions slightly, and structure simplified) 0.17.8 ~~~~~~ 30Jul99 Clarified `NameSpaces' 19Jul99 Using Roman's `Parsers.seplist1' 0.17.7 ~~~~~~ 05Jul99 `Lexers' exports `ctrlLexer' 0.17.6 ~~~~~~ 07Jun99 Small additions to `Idents' 03Jun99 Small additions to `Attributes' 0.17.5 ~~~~~~ 05Apr99 Configurable makefile variables from common.mk into new config.mk 02Apr99 Small bug fixes 31Mar99 `Parsers': Support for parsing prefixes 30Mar99 Bug fixes (incl. `Parsers.sep') 0.17.4 ~~~~~~ 13Mar99 Added meta actions to `Parsers' 12Mar99 Revised for GHC 4.02 and Haskell 98 11Mar99 Extension of parser library with threaded state 04Mar99 Self-optimizing lexer library for regular expressions 27Feb99 Self-optimizing LL(1) parser library a la Swierstra/Duponcheel 0.16.0 ~~~~~~ 11Feb99 `Idents.cloneIdent' & standard attributes in `Attributes' 0.15.0 ~~~~~~ 02Feb99 `Set' module 0.14.2 ~~~~~~ 23Jan99 `Ident' got an instance for `Show' 0.14.1 ~~~~~~ 01Dec98 Extracted mk/dhc.mk and mk/nepal.mk from mk/common.mk 0.14.0 ~~~~~~ 13Nov98 Rewrote `CST' into `PreCST' that provides an extra state (part of the base state) that can be instantiated by an client compiler using the Toolkit. As a consequence, `state/Switches' can be moved into DHC. 0.13.0 ~~~~~~ 10Nov98 admin/Version.hs 0.12.0 ~~~~~~ 19Oct98 Added Sven Panne's `GetOpt' to general/ 0.11.1 ~~~~~~ 23Sep98 Completely overhauled Makefile system. 29Jul98 Finished extraction from what was originally called the HiPar toolkit. ================================================ FILE: ChangeLog.old ================================================ CHANGES ABOVE THIS POINT ARE FOR VERSIONS AFTER THE MOVE OF THE REPOSITORY TO GITHUB AND ARE DESCRIBED IN THE MAIN ChangeLog FILE. 2005-12-12 Manuel M T Chakravarty * c2hs/gen/GenBind.hs: When translating the target type of a pointer hook into a Haskell type, don't take the pointer hook alias map into account. * c2hs.cabal: version 0.14.5 * c2hs/gen/GenBind.hs: Suppress code generation if requested * c2hs/chs/CHS.hs: Added `nocode' to pointer hooks * c2hs/chs/CHSLexer.hs: Added `nocode' 2005-12-05 Jelmer Vernooij * c2hs/c/CTrav.hs: only match in `checkForOneCUName' if there are no indirections 2005-12-05 Jelmer Vernooij * c2hs/gen/GenBind.hs: support mapping struct and union names to haskell types * c2hs/c/CTrav.hs: added `checkForOneCUName' Fri Nov 25 10:54:56 EST 2005 Jelmer Vernooij * add prettify functions for structs, enums and unions 2005-08-10 Manuel M T Chakravarty * c2hs/gen/GBMonad.hs: apply `upcaseFirstLetter' and `downcaseFirstLetter' if specified * c2hs/chs/CHS.hs: added `upcaseFirstLetter' and `downcaseFirstLetter' 2005-08-09 Manuel M T Chakravarty * c2hs/gen/CInfo.hs: exports `getPlatform' 2005-08-08 Manuel M T Chakravarty * c2hs/toplevel/Main.hs: Added --platform switch for cross compilation * c2hs.cabal: 0.14.3 2005-08-08 Manuel M T Chakravarty * c2hs.cabal: 0.14.2 * Support asm construct (Duncon Coutts) * Hierachical modules (Duncon Coutts) 2005-07-13 Duncan Coutts * Remove old C lexer & parser and replace them with new ones using alex and happy 2005-07-14 Manuel M. T. Chakravarty * C2HS library as a single file added to the generated binding code 2005-07-13 Manuel M. T. Chakravarty * Cabal-ised the build system * c2hs.cabal (Version): 0.14.0 2005-05-18 Manuel M. T. Chakravarty * toplevel/Version.hs (versnum): 0.13.6 2005-03-14 Manuel M. T. Chakravarty * c/CParser.hs: Allow lists of GNU C attributes (patch contributed by Duncan Coutts ) * chs/CHSLexer.hs (instr): Allow 8-bit characters (Volker Wysk requested support for umlauts in strings) * toplevel/Version.hs (versnum): 0.13.5 2004-10-18 Manuel M. T. Chakravarty * chs/CHS.hs (showCHSModule): Don't add extra '\n' after directive during pretty printing * chs/CHSLexer.hs (cpp): forgot to adapt lexing of #c to the new situation where directives don't consume the following '\n' 2004-10-17 Manuel M. T. Chakravarty * c2hs.conf.in: Modernised package deps and options * gen/GenBind.hs (expandHook): We use the shadow identifier for generating the Haskell name. * chs/CHSLexer.hs (identOrKW): Identifier may be put in single quotes * toplevel/Version.hs (versnum): 0.13.4 2004-10-13 Manuel M. T. Chakravarty * chs/CHSLexer.hs (cpp): fixed lexing of directives such that they don't consume the '\n' that ends them * toplevel/Version.hs (versnum): 0.13.3 * toplevel/Main.hs (Flag): Added `--output-dir' option and removed `--old-ffi'. * gen/GenBind.hs (noDftMarshErr): better error message when default marshallers are not available (isIntegralCPrimType): handle C chars as integral types for marshalling * toplevel/Main.hs (process): if there is no explicit output file specified, the header file is put in the same directory as the binding file; otherwise, it goes in the directory where the output file is put 2004-10-09 Manuel M. T. Chakravarty * toplevel/Main.hs (process): store header file name in switch board * state/Switches.hs: Store the name of the generated header file (needed to generate complete foreign import declarations) * gen/GenBind.hs (foreignImport): Add name of header file to extent strings of generated foreign import declarations * c/CAttrs.hs (applyPrefix): never create empty shadow identifiers 2004-10-08 Manuel M. T. Chakravarty * chs/CHS.hs (dumpCHS): Header doesn't contain the "-- **" sequence anymore that Haddock dislikes. * c/CParser.hs (parseCStructUnion): We allow structs and unions with no declarations, as GNU C does * toplevel/Version.hs (versnum): 0.13.2 2004-08-21 Manuel M. T. Chakravarty * tests/Makefile: use configured $HC (courtesy Don Stewart ) 2004-06-11 Manuel M. T. Chakravarty * gen/GenBind.hs (pointerDef): Adapted to the standard interface for foreign pointers 2004-06-10 Manuel M. T. Chakravarty * c/CParser.hs: Added parsing of function bodies * c/CLexer.hs: Added tokens occuring in the statement syntax 2004-06-09 Manuel M. T. Chakravarty * c/CAST.hs: Added function bodies * c/CPretty.hs: Added `auto' and `register' storage specifiers * c/CLexer.hs: Added tokens for `auto' and `register' keywords * toplevel/Version.hs (versnum): 0.13.1 2004-05-15 Manuel M. T. Chakravarty * c/CParser.hs (parseCHeader): Duncan Coutts identified a space (and time) leak in the old typedef-name morphing setup; this has been rewritten now 2004-05-14 Manuel M. T. Chakravarty * toplevel/Version.hs (versnum): 0.13.0 "Pressing Forward" 2003-10-20 Manuel M T Chakravarty * gen/GenBind.hs (foreignImport): brought generated foreign import declarations in line with FFI Addendum * toplevel/C2HSConfig.hs.in: removed legacy FFI support * configure.in: removed legacy FFI support * mk/config.mk.in: removed legacy FFI support * lib/Makefile: Removed all deprecated code and support code for old versions of the FFI * toplevel/Version.hs (versnum): 0.12.1 2003-10-19 Manuel M T Chakravarty * c2hs.spec.in: Contributions by Jens Petersen : specify ghc version to build with; don't redundantly provide c2hs; separate library out into separate ghc version specific subpackage; put docs into separate subpackage; disable empty debuginfo subpackage generation - remove buildroot before installing; remove installed doc files, since they're explicitly listed * c/CLexer.hs (linedir): allow an arbitrary number of ints after the filename in a #line directive; problem was first reported by Sean Seefried * gen/GBMonad.hs (delayCode): Generate appropriate line numbers for delayed code; problem reported by Sean Seefried * chs/CHS.hs (showCHSModule): Never generate negative line numbers * toplevel/Version.hs (versnum): 0.12.0 "Springtime" 2003-06-10 Manuel M T Chakravarty * toplevel/Version.hs (versnum): 0.11.5 2003-05-30 Jens Petersen * configure.in: Search for compiler named HC too. 2003-05-30 Jens Petersen * c2hs.spec.in (Version): Set directly. (Release): Ditto. (%prep): Quieten setup. (%build): Use configure macro. (%install): Use makeinstall macro. (%post): Use _bindir. (%files): Make root own files. Use _bindir, _libdir and _mandir. 2003-05-22 Manuel M T Chakravarty * gen/GenBind.hs (Ord): Need instance for `<=' for indirectly defined `compare'; bug reported by Ian Lynagh * toplevel/Version.hs (versnum): 0.11.4 2003-04-16 Manuel M T Chakravarty * gen/GenHeader.hs (ghFrag): sentries for conditionals must not be turned into internal identifiers, as this spoils later equality tests with identifiers read from the pre-processed header file; bug reported by Axel Simon * toplevel/Version.hs (versnum): 0.11.3 2003-03-04 Manuel M T Chakravarty * gen/GenBind.hs (evalConstCExpr): supporting enumerators in constant expressions * toplevel/Version.hs (versnum): 0.11.2 2003-02-13 Manuel M T Chakravarty * chs/CHS.hs: removed the "header" tag (we now support the CPP #include directive) * Configuration-related patch by Ian Lynagh that removes issues with GHC 5.05 2003-02-12 Manuel M T Chakravarty * gen/GenBind.hs (expandFrag): Expanding conditionals * chs/CHSLexer.hs (haskell): the lexeme for one-line comments shouldn't include the terminating newline, as this removes the newline for following lexemes (eg CPP directives) and is not really necessary due to the Principle of the Longest Match * gen/GenHeader.hs: debugging 2003-02-05 Manuel M T Chakravarty * gen/GenHeader.hs: New module extracting CPP directives and inline-C from a .chs file * toplevel/Main.hs (process): Integrated generation of custom C header * c/CParser.hs (parseCHeader): Header file may be empty 2003-02-01 Manuel M T Chakravarty * chs/CHS.hs (showCHSModule): emitting GHC line pragmas (CHSFrag): added representations for cpp directives and inline-C code, and adapted the functions processind the representations * chs/CHSLexer.hs: Added support for pre-processor directives and inline-C code 2003-01-31 Manuel M T Chakravarty * toplevel/Main.hs (process): Now reading the binding module before the C header 2003-01-30 Manuel M T Chakravarty * c/CParser.hs: Allow more GNU attributes contributed by Axel Simon 2002-09-17 Manuel M T Chakravarty * gen/GBMonad.hs (HsObject): working around a problem with deriving Read in GHC 5.04.1 2002-09-16 Manuel M T Chakravarty * Makefile (ghci): target to load all of c2hs into GHCi 2002-09-13 Manuel M T Chakravarty * toplevel/c2hs_config.c: removed the `signed' modifier on suggestion of Seth Kurtzberg as it apparently confuses the Solaris 8 C compiler 2002-09-07 Manuel M T Chakravarty * c2hs.spec.in: add post install and uninstall scripts to register and deregister the package with GHC * configure.in: fixed REQUIRES_HASKELL for ghc * toplevel/Version.hs (versnum): 0.10.17 2002-09-06 Manuel M T Chakravarty * toplevel/C2HSConfig.hs.in (cppopts): Added "-x c" on suggestion by Axel Simon * Makefile (install): using --update-package instead of --add-package * configure.in: Fixed some nhc98 related issues * toplevel/Version.hs (versnum): 0.10.16 2002-07-12 Manuel M T Chakravarty * c2hs-config.in: added the system for which the package was compiled to the output of the --version option * c/CParser.hs (parseCStructUnion): Allow __extension__ in structure declarations and added `inline'. * c/CAST.hs: Added `inline' * c/CLexer.hs: Added support for `inline' keyword 2002-07-06 Manuel M T Chakravarty * toplevel/Version.hs (versnum): 0.10.15 2002-05-16 Manuel M T Chakravarty * lib/C2HSMarsh.hs: added support for bit masks * toplevel/Version.hs (versnum): 0.10.14 2002-05-10 Manuel M T Chakravarty * gen/GenBind.hs (setGet): corrected bug in bit fiddling 2002-05-02 Manuel M T Chakravarty * toplevel/Version.hs (versnum): 0.10.13 2002-04-16 Manuel M T Chakravarty * toplevel/Version.hs (versnum): 0.10.12 2002-03-20 Manuel M T Chakravarty * chs/CHSLexer.hs (haskell): Debug the handling of character literals * toplevel/Version.hs (versnum): 0.10.11 2002-03-12 Manuel M T Chakravarty * c2hs.spec.in: we now require the Haskell compiler to be the one for which the package was build * Makefile: adapted to revised build system * toplevel/Version.hs (versnum): 0.10.10 2002-03-06 Manuel M T Chakravarty * chs/CHSLexer.hs (haskell): Escape characters in Haskell strings haven't been handled correctly in all cases as reported by Volker Wysk ; we also have to handle character constants specially, because '"' is a legal Haskell character constant 2002-03-03 Manuel M T Chakravarty * configure.in: Package handling fix by Jens Petersen * toplevel/Version.hs (versnum): 0.10.9 2002-02-25 Manuel M T Chakravarty * gen/GenBind.hs: debugging 2002-02-24 Manuel M T Chakravarty * chs/CHS.hs (parseOptAs): `^' as synonym for previous identifier, but with underscores rewritten to caps * chs/CHSLexer.hs: added `CHSTokHat' 2002-02-23 Manuel M T Chakravarty * lib/C2HSMarsh.hs: added some more convenience functions 2002-02-21 Manuel M T Chakravarty * gen/GenBind.hs: Completed processing of function hooks 2002-02-18 Manuel M T Chakravarty * chs/CHSLexer.hs: Added `CHSTokMinus' * chs/CHS.hs: Revised the syntax of fun hooks * chs/CHSLexer.hs: Added `CHSTokAmp' (representing `&') * gen/GenBind.hs (foreignImport): factorised the code for call hook generation to make those portions that are also useful for fun hooks reusable (expandHook): implemented fun hooks * gen/GBMonad.hs: extracted monad-related code from `GenBind.hs' * gen/GenBind.hs: split off the monad definition and operations into `GBMonad.hs' 2002-02-17 Manuel M T Chakravarty * chs/CHSLexer.hs: introduced `hsverb' tokens * chs/CHS.hs: `pure' instead of `fun' to indicate calls to pure C functions (`fun' retained for backwards compatibility) * chs/CHSLexer.hs: introduced the keyword `pure' 2002-02-13 Manuel M T Chakravarty * Makefile: adapted to using GHC package management 2002-02-11 Manuel M T Chakravarty * lib/Makefile (depend): increase portability 2002-02-06 Manuel M T Chakravarty * configure.in: probe for `grep' 2002-02-05 Manuel M T Chakravarty * aclocal.m4 (CTK_GHC_VERSION): no \+ in sed on Solaris * toplevel/Version.hs (versnum): 0.10.7 2002-01-15 Manuel M T Chakravarty * gen/GenBind.hs (mergeMaps): now, the read map overrides any entires for shared keys in the map that is already in the monad; this is so that, if multiple import hooks add entries for shared keys, the textually latest prevails; any local entries are entered after all import hooks anyway * toplevel/Version.hs (versnum): 0.10.6 2002-01-10 Jens Petersen * c/CParser.hs (parseC): corrected "contained contained" in proceeding comments. * ../doc/c2hs/c2hs.sgml (Set Hooks): correct #get to #set * ../doc/c2hs/Makefile (TOP): "../../.." to "../.." 2002-01-10 Manuel M T Chakravarty * toplevel/Version.hs (versnum): 0.10.5 2001-12-20 Manuel M T Chakravarty * gen/GenBind.hs (expandHook): fixed a sizeof bug pointed out by Jens Petersen * toplevel/Version.hs (versnum): 0.10.4 2001-12-11 Manuel M. T. Chakravarty * toplevel/c2hs_config.c: now conforms to ISO C * toplevel/Version.hs (versnum): 0.10.3 2001-11-14 Manuel M. T. Chakravarty * gen/GenBind.hs (setGet): debugged 2001-11-13 Manuel M. T. Chakravarty * gen/GenBind.hs (setGet): reading and writing of bitfields (alignOffset): now handles alignment of bit fields (extractCompType): debugging 2001-11-12 Manuel M. T. Chakravarty * gen/GenBind.hs (specType): added bitfield handling (BitSize): introduced size specs for partially filled storage units * toplevel/C2HSConfig.hs.in (bitfieldDirection): added (bitfieldPadding): added (bitfieldIntSigned): added * toplevel/c2hs_config.c: runtime configuration query functions * gen/CInfo.hs (CPrimType): extended by variants for bitfields (size): now a function instead of an array (alignment): now a function instead of an array * gen/GenBind.hs (showExtType): simplified `showExtType' again; the brace level idea doen't work for `DefinedET' anyway; so, let's simplify the code 2001-11-08 Manuel M. T. Chakravarty * toplevel/Version.hs (versnum): 0.10.2 2001-10-17 Manuel M. T. Chakravarty * c/CParser.hs (parseCDecl): corrected the precise locatio where an __attribute__ annotation may occur. 2001-10-16 Manuel M. T. Chakravarty * gen/GenBind.hs (evalConstCExpr): added `alignof' * c/CNames.hs (naCExpr): added `alignof' * c/CAST.hs: added `alignof' * c/CParser.hs (parseCUnaryExpr): added `alignof' expressions * c/CLexer.hs: added keyword `alignof' * toplevel/Version.hs (versnum): 0.10.1 2001-10-08 Manuel M. T. Chakravarty * chs/CHS.hs: debugged 2001-10-07 Manuel M. T. Chakravarty * gen/GenBind.hs: handling class hooks * Makefile: improved cleaning targets * chs/CHS.hs (parseClass): added class hooks * chs/CHSLexer.hs: added tokens `class' and `=>' * gen/GenBind.hs (isFunExtType): IO types are function types * toplevel/Version.hs (versnum): 0.10.0 "Altocumulus Stratiformis Perlucidus Undulatus" 2001-08-26 Manuel M. T. Chakravarty * gen/GenBind.hs (foreignImport): `libName' removed until the new FFI conventions for libs are implemented in GHC * c/CTrav.hs (dropPtrDeclr): fixed pointer to pointer case * c/CPretty.hs: implemented pretty-printing for part of the C AST 2001-08-25 Manuel M. T. Chakravarty * gen/GenBind.hs (setGet): missed ";" in code generation * c/CParser.hs (cidOrTN): after struct or union tag we may have a normal idenifier or a type name; spotted by Simon Bowden and Michael Zinn 2001-08-23 Manuel M. T. Chakravarty * gen/GenBind.hs (expandHook): adding parenthesis around the generated type; problem pointed out by Matthew Tarnawsky * toplevel/Version.hs (versnum): 0.9.9 2001-06-20 Manuel M. T. Chakravarty * gen/GenBind.hs (expandHook): added sizeof hook (sizeAlignOf): corrected size computation for structures to conform to [K&R A7.4.8] (sizeAlignOf): improved handling of `DefinedET', which led to an endless loop * chs/CHS.hs: added sizeof hook * chs/CHSLexer.hs: added keyword `sizeof' * gen/GenBind.hs (evalConstCExpr): sizeof now supported * lib/C2HSDeprecated.hs: includes Storable methods of the new Storable in addition to those of the old * toplevel/Version.hs (versnum): 0.9.8 2001-06-18 Manuel M. T. Chakravarty * c/CParser.hs (parseCExpr): `CComma' requires at least two expressions; patch by Armin Sander * toplevel/Version.hs (versnum): 0.9.7 2001-06-16 Manuel M. T. Chakravarty * chs/CHS.hs: local prefix for enum hooks; courtesy of Armin Sander * gen/GenBind.hs (expandHook): correctly uses a `FunPtr' for pointers to functional types (setGet): no deep check required as set/get do not perform a deep copy; bug reported by Armin Sander (expandHook): local prefix for enum hooks; courtesy of Armin Sander * toplevel/Version.hs (versnum): 0.9.6 2001-05-20 Manuel M. T. Chakravarty * gen/GenBind.hs (enumInst): Fix for avoiding warnings when generated bindings are compiled with -Wall contributed by Armin Sander 2001-05-14 Axel Simon * toplevel/Main.hs, state/Switchboard.hs, chs/CHS.hs: add -i flag which takes a colon separated list of search paths for .chi files. * fixed some bugs in parsing import hooks 2001-05-13 Manuel M. T. Chakravarty * toplevel/Version.hs (versnum): 0.9.5 * gen/GenBind.hs (expandHook): revised to properly handle struct, union, and enum tags as C identifiers in pointer hooks; also handles non-abstract pointers with explicit "*" now better; the problems were pointed out by Marcin Kowalczyk * c/CTrav.hs (findTypeObjMaybe): added (lookupDeclOrTag): added (enumName): added (tagName): added * c/CLexer.hs (charconst): Patch from Armin Sander regarding character constants 2001-05-11 Manuel M. T. Chakravarty * c2hs-config.in: Patch from Jens-Ulrik Petersen fixes $sys variable setting * toplevel/Version.hs (versnum): 0.9.4 2001-05-06 Manuel M. T. Chakravarty * gen/GenBind.hs (extractCompType): rewrote that thing again * c/CTrav.hs (checkForOneAliasName): added 2001-05-05 Manuel M. T. Chakravarty * c/CTrav.hs (chaseDecl): simplified * gen/GenBind.hs (expandHook): debugged the pointer hook * c/CTrav.hs (findAndChaseDecl): correction * toplevel/Version.hs (versnum): 0.9.3 2001-05-03 Manuel M. T. Chakravarty * gen/GenBind.hs (expandHook): added import hook (mergePtrMap): added (dumpPtrMap): added * chs/CHS.hs (loadCHI): added (dumpCHI): added (CHSHook): added `import' hook * chs/CHSLexer.hs: Added the keywords `import' and `qualified' * toplevel/Version.hs (versnum): 0.9.2 2001-05-02 Manuel M. T. Chakravarty * gen/GenBind.hs (extractCompType): as pointed out by Axel Simon, we can't return `ForeignPtr's from imported foreign functions (setGet): the `accessType' story is largely redundant with the new formulation of `extractCompType', but we still need to check the marshaled type (setGet): `DefinedET' now takes a declaration rather than an identifier as its first argument; this is necessary for anonymous declerators (extractCompType): functions are now extracted correctly * c/CTrav.hs (isPtrDecl): works on identifiers now and chases declarations (dropPtrDeclr): added * gen/GenBind.hs (extractCompType): completely rewrote this function to properly handle pointer and function types and honour aliases introduced by pointer hooks 2001-05-01 Manuel M. T. Chakravarty * c/CTrav.hs (isPtrDeclr): functions types without an explizit pointer constructor are no longer regarded as pointers * gen/CInfo.hs: renamed `CAddrPT' and `CFunAddrPT' to `CPtrPT' and `CFunPtrPT', respectively * gen/GenBind.hs (extractCompType): revised for pointer hooks 2001-04-30 Manuel M. T. Chakravarty * gen/GenBind.hs (setGet): uses FunPtr for functions (extractPtrType): added 2001-04-28 Manuel M. T. Chakravarty * gen/GenBind.hs (expandHook): rewrote `alias'hook into `pointer' hook * chs/CHS.hs: rewrote the `alias' hook into the `pointer' hook * chs/CHSLexer.hs: removed `alias' token and added `pointer' and `newtype' * toplevel/Version.hs (versnum): 0.9.1 * gen/GenBind.hs: clean up 2001-04-21 Manuel M. T. Chakravarty * chs/CHSLexer.hs: Added `(' and `)' * chs/CHS.hs: Added code implementing the `alias' hook and the `deriving' option for the `enum' hook. This code was contributed by Axel Simon (also related code in CHSLexer.hs); but added parenthesis to `deriving' * c/CTrav.hs: Added code implementing the `alias' hook, which was contributed by Axel Simon * gen/GenBind.hs: The following patch was contributed by Axel Simon : `extractCompType' generates addresses of type `Ptr ' instead of `Addr' (if `--old-ffi=no', which is the default) * configure.in: Adapted for ghc 5.00 * toplevel/Version.hs (versnum): 0.9.0 "Blue Ginger" 2001-02-22 Manuel M. T. Chakravarty * lib/C2HSDeprecated.hs: Corrected String marshalling for 4.11; suggested by Marcin 'Qrczak' Kowalczyk 2001-02-19 Manuel M. T. Chakravarty * c2hs-config.in: generated code needs -package lang for compilation and linking * toplevel/Version.hs (versnum): 0.8.3 "Gentle Moon" 2001-02-13 Manuel M. T. Chakravarty * lib/NewStablePtr.hs.in: Adaptation layer for StablePtr for the legacy FFI interface 2001-02-12 Manuel M. T. Chakravarty * lib/C2HS.hs: Forgot to export `FunPtr' and associated functions * lib/C2HSDeprecated.hs: Some exports had been missing * c/CTrav.hs: Handle `CAttrs.BuiltinCO' * c/CNames.hs (nameAnalysis): add builtin type definitions * c/CBuiltin.hs: predefine `__builtin_va_list' as a typedef'd name * c/CParser.hs (parseCHeader): use `CBuiltin' * toplevel/Version.hs (versnum): 0.8.2 2001-02-11 Manuel M. T. Chakravarty * releasing version 0.8.1 "Gentle Moon" * ../doc/c2hs/: Documentation updated & added the Haskell FFI Marshalling Library specification 2001-02-09 Manuel M. T. Chakravarty * lib/Makefile: Debugging for 4.11 2001-02-05 Manuel M. T. Chakravarty * toplevel/C2HSConfig.hs.in: Moved the primitive characteristics table to `CInfo' (it is based now on getting the information from the FFI of the Haskell compiler compiling c2hs) * gen/CInfo.hs: Added 2001-02-04 Manuel M. T. Chakravarty * lib/C2HSMarsh.hs: Moved almost everything to `C2HSDeprecated' * lib/C2HSBase.hs: Much simplified conversion routines and the old `Storable' definition died 2001-02-03 Manuel M. T. Chakravarty * configure.in: Removed all the stuff that had to be there for the late `lib/C2HSConfig.hs.in' * lib/C2HSConfig.hs.in: RIP - All the relevant information is now available from the Standard FFI * C2HSDeprecated.hs: Added old C type names * lib/C2HS.hs: Added support for the New FFI Libraries (so that they are also useable with Haskell systems only supporting the old libraries) 2000-08-22 Manuel M. T. Chakravarty * lib/C2HSDeprecated.hs: contains a compatibility interface to the "Afterthought" series 2000-08-18 Manuel M. T. Chakravarty * toplevel/Version.hs (versnum): 0.8.0 "Gentle Moon" ** WARNING: Only the FFI of GHC 4.08 upwards is supported ** ** WARNING: Code breaking changes to the marshalling library ** ** Compatibility library provided ** 2000-08-12 Manuel M. T. Chakravarty * lib/C2HSBase.hs (IntConv): instances for Int8, Word8, and Char * toplevel/Version.hs (versnum): 0.7.10 2000-08-06 Manuel M. T. Chakravarty * chs/CHS.hs (showCHSTrans): corrected syntax (parseTrans): comma now correctly required after underscoreToCase * gen/GenBind.hs (transTabToTransFun): properly handles prefixes in the translation function (enumDef): prefixes are now generally removed from enumerators without the constraint that the prefix has to be removed from all enumerators or none 2000-08-04 Manuel M. T. Chakravarty * gen/GenBind.hs (usualArithConv): forgot a case; patch contributed by Axel Simon * toplevel/Version.hs (versnum): 0.7.9 2000-07-06 Manuel M. T. Chakravarty * gen/GenBind.hs (specType.matches): forgot a case; bug spotted by Axel Simon * lib/C2HSBase.hs (plusAddr): ugly kludge for GHC 4.08 (doesn't work with any older version for the moment) * toplevel/Version.hs (versnum): 0.7.8 2000-04-15 Manuel M. T. Chakravarty * c/CLexer.hs (pragma): ignores `#pragma's * toplevel/Version.hs (versnum): 0.7.7 2000-04-09 Manuel M. T. Chakravarty * mk/config.mk.in: added * gen/GenBind.hs: added `long long's (specType): added error message for unsupported types * lib/C2HSConfig.hs.in: added `long long's * toplevel/C2HSConfig.hs.in: added `long long's * toplevel/Version.hs (versnum): 0.7.6 2000-04-08 Manuel M. T. Chakravarty * configure.in: corrected sed expression for Solaris 2000-03-02 Manuel M. T. Chakravarty * tests/Makefile: added & revised all the tests * configure.in: debugging 2000-03-01 Manuel M. T. Chakravarty * lib/C2HSMarsh.hs (addrWithMarkerToList): debugged 2000-02-28 Manuel M. T. Chakravarty * gen/GenBind.hs (expandHook): adapted to new `CHSContext' def * c/CParser.hs: Using `Utils.Tag' class to make `CToken' an instance of `Token' * c/CLexer.hs: Making `CToken' an instance of `Utils.Tag' instead of `Eq' 2000-02-25 Manuel M. T. Chakravarty * chs/CHS.hs: added `header' tag in context hook * chs/CHSLexer.hs: added keyword `header' * c/CLexer.hs, c/CParser.hs, c/CAST.hs: added C99 type qualifier `restrict'; thanks to "Marcin 'Qrczak' Kowalczyk" for pointing this out 2000-02-24 Manuel M. T. Chakravarty * gen/GenBind.hs (foreignImport): system-dependent library suffix * configure.in,toplevel/C2HSConfig.hs.in: DLSUFFIX 2000-02-23 Manuel M. T. Chakravarty * toplevel/Version.hs (versnum): 0.7.5 1999-12-04 Manuel M. T. Chakravarty * lib/C2HSBase.hs (BoolConv): added 1999-11-24 Manuel M. T. Chakravarty * ../doc/c2hs/Makefile: corrections by Michael Weber 1999-11-17 Manuel M. T. Chakravarty * Man pages and debianisation, courtesy of Michael Weber * c/CNames.hs: no new range for tag definitions is started when entering a struct declaration list or a parameter list; thanks to Volker Wysk for the bug report * c/CAttrs.hs (enterNewObjRangeC): added (leaveObjRangeC): added 1999-11-16 Manuel M. T. Chakravarty * c/CTrav.hs (extractAlias): now correctly handles anonymous declarations; introduced new function `declaredDeclr'; thanks to Michael Weber for the bug report * toplevel/Version.hs (versnum): 0.7.4 1999-11-07 Manuel M. T. Chakravarty * lib/C2HSBase.hs: adapted to new `assign' and `deref' routines * gen/GenBind.hs: debugged * c/CTrav.hs (extractStruct): takes care that forward declerations of structs are followed to the full definition * lib/C2HSMarsh.hs: added `nothingIf', `nothingIfNull'; generalised string handling to `listToAddrWithLen' and `addrWithLenToList' 1999-11-06 Manuel M. T. Chakravarty * toplevel/Main.hs: Header file search in standard directories and directories passed in `-IDIR' options to cpp. * c2hs-config.in: Added `--c2hs' option to `c2hs-config' * lib/C2HSMarsh.hs: Michael's `Int'/`Word' patch 1999-11-03 Manuel M. T. Chakravarty * lib/C2HSMarsh.hs: more instances for `ToAddr' & `FromAddr' * toplevel/Version.hs (versnum): 0.7.3 1999-10-30 Manuel M. T. Chakravarty * Makefile: adapted to modularised CTK and added installation support * c2hs-config.in: added * toplevel/Version.hs (versnum): 0.7.2 1999-10-28 Manuel M. T. Chakravarty * c/CNames.hs: multiple declarations for the same object are now allowed (thanx Michael) * lib/C2HSMarsh.hs: added some suggestions from Michael Weber * c/CLexer.hs: #line directives 1999-10-26 Manuel M. T. Chakravarty * configure.in: no sizeof or align tests for char 1999-10-25 Manuel M. T. Chakravarty * gen/GenBind.hs: some clean up and improved error message with more position information * chs/CHS.hs: Positions are maintained for improved error messages. * toplevel/Main.hs: removes intermediate file (but it can be retained on explicit request) * toplevel/Version.hs (versnum): 0.7.1 1999-10-24 Manuel M. T. Chakravarty * examples/libghttpHS/Ghttp.chs: adapted to new syntax & features * configure.in: Solaris patch from Michael Weber * gen/GenBind.hs: new hook syntax * chs/CHS.hs (and friends): grok new hook syntax 1999-10-23 Manuel M. T. Chakravarty * toplevel/Version.hs (versnum): 0.7.0 (align hook syntax with paper) * c/CTrav.hs: routines from `CNames' and `GenBind' generalised and exported from `CTrav' (defTag): handles enum tags now correctly 1999-10-22 Manuel M. T. Chakravarty * c/CNames.hs: sets up the object associations for usage positions 1999-10-21 Manuel M. T. Chakravarty * c/CTrav.hs (defTag): handles refined struct definitions * toplevel/Main.hs: Command line option patch from Michael Weber * c/CNames.hs: computes the object reference attributes now * c/CTrav.hs (isTypedef): added * toplevel/Version.hs (versnum): 0.6.2 1999-10-20 Manuel M. T. Chakravarty * examples/libghttpHS/Ghttp.chs: uses `C2HS's exception handling * lib/C2HSMarsh.hs: debugging * toplevel/Version.hs (versnum): 0.6.1 1999-10-18 Manuel M. T. Chakravarty * c/CLexer.hs: computes attributes for identifiers 1999-10-17 Manuel M. T. Chakravarty * c/CNames.hs: moved gathering of definitions from `C', starting a more standard name analysis pass * c/CTrav.hs: basic traversal support for name space and definition attribute operations * c/CAttrs.hs: C definition attribute data type and operations * toplevel/Version.hs: 0.6.0 1999-10-16 Manuel M. T. Chakravarty * lib/C2HSMarsh.hs: Marshaling idioms & exception handling 1999-10-13 Manuel M. T. Chakravarty * examples/libghttpHS/Ghttp.chs: compiles * toplevel/Main.hs (execute): debugged * lib/C2HS.hs: Advanced marshaling support Pre-GNU style change log ------------------------ 0.5.1 ~~~~~ 12Oct99 lib/C2HSMarsh -> lib/C2HSBase; lib/C2HSMarsh new 0.5.0 ~~~~~ 08Oct99 Debugging 06Oct99 (# ... #) to {# ... #}; extended `C2HSMarsh'; `Ghttp' example 0.4.1 ~~~~~ 01Oct99 Improved autoconf support for computing the information necessary for determining struct offsets & corresponding changes in `GenBind' plus full struct and union support 0.4.0 ~~~~~ 29Sep99 Debugging 28Sep99 Improving marshaling lib 27Sep99 Autoconf support 26Sep99 More lexer debugging, typedef chasing & field hooks with indirections; preprocessing of the C header implemented 21Sep99 Debugged CHS lexer (Haskell comments etc) 0.3.0 ~~~~~ 06Sep99 Enums correctly lead to `CInt's in foreign import declarations 01Sep99 Added dot syntax for field hooks 0.2.2 ~~~~~ 01Sep99 Added support for explicit tag values in enumerations 31Aug99 added tag objects to `CAttrs.hs' and `C.hs'; enumeration hooks are partial functional 0.2.1 ~~~~~ 30Aug99 context and call hooks are functional 0.2.0 ~~~~~ 29Aug99 full path completed 19Aug99 started `lib' part 17Aug99 started `gen' part 17Aug99 finished the CHS parser and printing routines in `CHS.hs' 16Aug99 finished first version of CHS lexer; added `CHS.hs' 15Aug99 started `chs' part 0.1.1 ~~~~~ 12Aug99 Various fixes to the C lexer and parser; added toplevel/Main.hs and c/C.hs 0.1.0 ~~~~~ 03Apr99 Finished first complete version of C lexer and parser 27Feb99 starting project ================================================ FILE: INSTALL ================================================ C->Haskell Installation Instructions -*-text-*- ------------------------------------ Prerequisites ~~~~~~~~~~~~~ You need GHC, the Haskell compiler. Currently, this has to be GHC 6.8 upwards, which you can get from http://haskell.org/ghc Simple install procedure ~~~~~~~~~~~~~~~~~~~~~~~~ % tar -xzf .tar.gz # unpack the sources % cd # change to the toplevel directory % runghc Setup.hs configure # configure the build system % runghc Setup.hs build # build everything [ Become root if necessary ] % runghc Setup.hs install # install c2hs The Nitty-Gritty ~~~~~~~~~~~~~~~~ The './Setup.hs configure' command understands the following options: * --prefix=PREFIX install architecture-independent files in PREFIX [ Defaults to /usr/local ] * --with-compiler=HC use Haskell compiler HC This needs to be the full path to the compiler executable. * --with-happy=HAPPY ditto for parser generator Happy * --with-alex=ALEX ditto for lexer generator Alex * --user allow the use of packages from user database * --global only allow packages from the global database Documentation ~~~~~~~~~~~~~ Documentation can be formatted with $ make -C doc Currently there is no support for installing the documentation. That step has to be done manually. The generated html pages for the user guide live in: docs/user_guide/* The man page is: docs/man1/c2hs.1 Supported Systems and Porting ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Tested with GHC version 6.8.2 and 6.10.1. In principle it should work with any 6.x version since 6.4.2 however the current releases of the language-c package only work with ghc-6.8 and later. The actual c2hs sources might also compile with nhc98, but Cabal doesn't fully support nhc98 yet. ================================================ FILE: README ================================================ `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. 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). ## Installing See the file `INSTALL`. ## 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. 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 `c2hs` (i.e. 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. ## Credits See the file `AUTHORS`. ================================================ FILE: README.CTKlight ================================================ Compiler Toolkit - Light -*-text-*- ======================== Contents: README.CTKlight -- This file LICENSE.LIB -- GNU Library General Public License (LGPL) BaseVersion.hs -- Version, copyright, and disclaimer Config.hs -- Configuration module Common.hs -- Basic definitions, such as representation of positions DLists.hs -- Difference lists - provide O(1) append Errors.hs -- Types and functions for error handling FNameOps.hs -- Common operations on file names FiniteMaps.hs -- Finite maps based on 2-3 trees GetOpt.hs -- Sven Panne's Haskell version of the GNU getopt library Lexers.hs -- Self-optimising lexer combinators Parsers.hs -- Self-optimising parser combinators Pretty.hs -- Pretty printing combinators (the interface is essentially a superset of SimonPJ's pretty printing library) Sets.hs -- Sets as an instance of the above mentioned finite maps Utils.hs -- Utility routines The Compiler Toolkit Light (CTKlight) is a subset of the Compiler Toolkit (CTK) - an infrastructure for writing compilers in Haskell. CTKlight essentially provides support for implementing syntactical analysis without the more heavy-weight state management (like compiler switches, global error pool, and exceptions), identifier and attribute management, and various other utilities included in the full CTK. Both packages can be obtained from http://www.cse.unsw.edu.au/~chak/ctk/ -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- BUILDING -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= In contrast to full CTK, CTKlight is simply a set of Haskell modules without any complicated makefile structure. The code is Haskell 98 compliant with the exception that `Parser.hs' makes use of existentially quantified type variables - unfortunately, I do not believe that the same method of self-optimisation would work without existential types. The modules are tested with * GHC 4.02 and upwards (use `-fglasgow-exts' to compile `Parsers.hs') and * Hugs98 (use `-98' when using `Parsers.hs'). If you want autoconf, a ready-made makefile structure, and much more additional library functionality, then use full CTK. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- COPYLEFT -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this system; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Note: In essence this means that you can use this library in any program whether it is free or proprietary. However, if you modify or extend the library itself, you are bound to distribute these modifications or extensions according to the terms and conditions of the LGPL. For details consult the license itself, which is located in the file `LICENSE.LIB'. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- CREDITS -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Author & Maintainer: Manuel M. T. Chakravarty Thanks to Simon L. Peyton Jones and Roman Lechtchinsky for their helpful suggestions that improved the design and implementation of the `Lexers' module. ================================================ FILE: README.md ================================================ [![Build Status](https://travis-ci.org/haskell/c2hs.svg?branch=master)](https://travis-ci.org/haskell/c2hs) `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. 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). ## Installing To install `c2hs` from Hackage: cabal install c2hs If you like to build from the GitHub repository, see the file `INSTALL`. See the `REGRESSION-SUITE` file for a description of how to run the regression suite for checking C2HS performance against existing Haskell packages that use it. ## License All code **generated by** `c2hs` is under a BSD licence. Hence, `c2hs` is useful for both open and closed source projects. The tool itself is released under the GPLv2. This is the same situation as for the GNU C Compiler. For details, see the file `COPYING`. ================================================ FILE: REGRESSION-SUITE ================================================ C2HS REGRESSION SUITE ~~~~~~~~~~~~~~~~~~~~~ C2HS is flexible enough that it's difficult to write a test suite that covers all the cases of interest to users. As well as a general test suite and tests for individual issues, it makes sense to test for C2HS regressions by installing a range of packages that use C2HS. The regression suite is managed as a single Cabal test suite called regression-suite. This reads a YAML configuration file giving a list of packages to test against. The test suite succeeds if a "cabal install" of each of the test packages succeeds without error, using the current version of C2HS. This process requires care for two reasons: 1. Because C2HS is an FFI tool, packages that use C2HS almost always have dependencies on external libraries, so writing a simple test suite is not straightforward. 2. It's undesireable to install a whole set of Haskell packages for C2HS regression testing into the user's environment. To handle these two issues, the regression-suite test suite behaves as follows: ON TRAVIS - Always run the regression suite. - Install all library dependencies before attempting to install Haskell packages. These dependencies are given in the regression suite configuration file as lists of APT package names, optionally with PPAs to install them from, or as lists of shell commands to use to install the dependencies. ON NON-TRAVIS SYSTEMS - Only run the regression suite if the C2HS_REGRESSION_SUITE environment variable is defined. - Assume that all C library dependencies are already installed. - Set Cabal flags from environment variables called C2HS_REGRESSION_FLAGS_ if these variables exist. The idea is to test for regressions under well-controlled conditions at each commit on Travis, but maintain the possibility of running the regression suite locally as well. ================================================ FILE: Setup.hs ================================================ #!/usr/bin/env runhaskell import Distribution.Simple main = defaultMain ================================================ FILE: TODO ================================================ -*-text-*- C2HS TODO ========= Next: - enum hooks should define cFromEnum/cToEnum as the default marshallers (see comment at GenBind.lookupDftMarshIn). - Especially with function hooks, it is not sufficient to emit line pragmas whenever a new CHS fragment starts. As some hooks expand to multiple lines of Haskell code, we need to reemit the line number of the hook once for each line of Haskell generated from it. - Points raised by PeteG: * The initial comment put by c2hs shouldn't be put in the first line, as this makes it difficult to add {-# OPTIONS #-} pragma to the .chs file, as this pragma must be in the first line. The only sensible solution seems to be to copy the first line of the .chs file on top if it starts with the string "{-# OPTIONS". - Ian requests {#const SYM#} where SYM is a pre-preprocessor symbol to evaluate to the C value of SYM. Main problem is that the value might be of various C types. - Tutorial - GenBind.setGet: How is it justified that `bitsPerField' is fixed to the size of `CInt'? Does the C def guarantee that bitfields types are of the same size? Next Major feature to be added: structure marshalling. - the `hsverb' should be normalised with respect to white space and parenthesis - have an option to compute .chi dependencies; do this on a module-by-module basis generating many small depend files rather than one big one - Pending suggestions from Axel Simon: + succ/pred definitions for enum hooks - marshalling of structs - We need to handle the time stamps of .chi files more carefully; otherwise, we often get lots of unnecessary re-runs of c2hs. - Conceptual problem with import hooks: Currently, everything imported from a .chi file by a binding module is also dumped into its own .chi file. Is is not generally correct, but it would also not be correct to omit everything that has been imported. The conceptually correct solution would be to dump an entry for a type into a .chi file if the corresponding Haskell type is exported by the binding module. To achieve this, we would also need an export hook. Moreover, we may import the same object from different modules, due to an implicit reexport at the moment. Either eliminate those reexports, or we have the same problems as in Haskell to determine object identity. - c2hs has to properly process GNU C "aligned" attributes. Otherwise, it's routine to calculate structure layout may deviate from that of the C compiler, which may lead to nasty bugs in bindings. - the use of get/set hooks with `class'ed newtypes is complicated, as the type doesn't match `Ptr a'; see, e.g. `GtkCList.cListGetNoOfRows' - class methods should be able to get user-defined names (needed for GtkData.chs) - GenBind.mergePtrMap could be improved (see the comment) - {#enum ...#} should create an instance of Storable as follows: instance Storable MyEnum where sizeOf _ = sizeOf (undefined :: CInt) alignment _ = alignment (undefined :: CInt) peek p = liftM cToEnum $ peek (castPtr p :: Ptr CInt) poke p v = poke (castPtr p :: Ptr CInt) (cFromEnum v) - `GenBind.setGet' needs to take `C2HSConfig.bitfieldDirection' into account; otherwise, setting and getting of bitfields won't work on architectures where bitfields start at the MSB (rather than the LSB) - Vorschlag von Axel Krauth : An option with which c2hs prints a list of all functions that have not been bound in a header file. The Position info schould be sufficient to determine this. Maybe also add {#ignore foo#}, which makes it not list a given identifier (for private functions listed in the header). - In `GdkGL.chs', the prefix is not properly removed from the constructors of `GdkGL.Configs'; same problem with `GdkEvents.EventType' - install the executable (c2hs and c2hs-config) with a version number suffix and make a symbolic link for the name without version number (makes installing multiple versions easier) - #define enum's (see below) - intro a safe flag (as opposite to unsafe, but make safe the default) - overload stdAddr etc for ForeignObj (stable ptr & cast) - C2HSMarsh: from qrczak@knm.org.pl (Marcin 'Qrczak' Kowalczyk) mallocForeignObj:: Int -> IO ForeignObj -- malloc + freeing finalizer - C2HSMarsh: (!!!) :: FromAddr a => Ptr a -> Int -> IO a p !!! i = do v <- fixIO $ deref (p `plusAddr` sizeof v * i) return v (Use in GdkColor, then) Part of New FFI, so use that in GdkColor! - C2HSMarhs: for compound structures it is inconvenient that in a pointer-based out, an initial value is needed; thus out :: (Storable a, FromAddr a) => a -> Marsh a Addr out x = malloc x :> addrStd and this is also convenient inp :: ToAddr a => a -> Marsh () Addr inp x = stdAddr x :> free Axel also proposes this byValue :: b -> Marsh () b byValue x = use x :> forget - Axel suggests, 2b. Automatisches Marshalling von Strukturen. Eigentlich mte es doch mglich sein, automatisch Instanzen von Storable fr Strukturen zu erstellen. Falls man mal einen generische Pointer hat, kann man ja mit der ... as ... Methode eigene Marshalling Funktionen zur Verfgung stellen. Oder habe ich da etwas grundstzliches bersehen? Short term ~~~~~~~~~~ * cpp directives on the very first line of the .chs file are ignored because the lexer looks for \n# This is very confusing to users. * The C99 spec says (sec. 6.7.2.1): [#4] Each enumerated type shall be compatible with an integer type. The choice of type is implementation-defined but shall be capable of representing the values of all the members of the enumeration. [...] Hence, c2hs has to be a bit more clever about determining the integral type used to represent an enum. * The definition of `GenBind.HsObjectMap' doesn't take into account that in Haskell a single name can be used for both a type and a class. * See FIXME at `GenBind.mergeMaps'. * Explain the grabbing of cpp -I options from -cppopts= (aka -C) values better in the docu and add something like: I prefer that to giving an option to c2hs and passing it to cpp, because - as you say - you usually already have a variable with the cpp options in your makefile and this way you can easily reuse it. * #define enums in C: siehe unten - scheinen aber wichtig * In pointer hooks after a `->', we currently allow only type identifiers; other forms of Haskell types would be nice, too (especially, `()'). * A function prototype that uses a defined type on its left hand side may declare a function, while that is not obvious from the declaration itself (without also considering the `typedef'). This is not understood by `GenBind' so far. * Why is a stable name an `unsigned long' in C land? How about a `void *' and being able to get the `Addr' also in Haskell land? * if in a binding file erroneously `t->m' is used instead of `t.m' and `t' is the tag of a struct, the error message just complains that there is no type object for called `t'; it would be more user friendly to report in addition that the tag `t' exists, but cannot be used in this expression * Should it be possible to specify a calling convention in context hook? Isn't it a mitake to have explicit calling convention in the FFI? Shouldn't that be adapted automatically depending on the target architecture? * Sven: How about exporting Haskell functions (also dynamic export)? - callback registration function that explicitly have the type of the callback function (from which we might want to generate a foreign export dynamic). * `mapM raise errs' in `lexC' increases the heap usage by a factor of _8_ when running the lexer alone on `gtkext.h' - probably because the whole analysis has to be completed before we can be sure to have no error (and this kills an interlocked produced/consumer scheme for the lexer and whatever function is consuming the tokens). * sizeof and type hooks do only allow defined, but not basic types as arguments. This is not a real problem as C2HS provides all the needed information to circumvent such usage, but it would still be more elegant to support basic types as arguments, too. Middle term ~~~~~~~~~~~ * A hook {#const #} would be nice (as in hsc2hs). Unfortunately, it is not that easy to realise. We need to parse the in the binding module. Moreover, the main value of this would be when the is put into the C field together with `enum define' stuff, so that all pre-processor symbols in it are resolved. However, this can easily give us C compiler errors. A cheap way out would be {#const "C expr"#} to avoid parsing the C expression, but then we can get even more errors during compiling the C. * C->HS might get a lot easier to use by providing as optional marshalling libraries modules that handle often occurring standard stuff like converting `time_t' to `CalendarTime' or handle sockets etc. We would, then, probably like to have a matching Posix or so library. ------------ Pre-1.0 rewrite --------------- Problems: * There are some implicit requirements on the position of binding hooks, which the tool doesn't really enforce: context must be first, context and enum may only occur where a toplevel definition is allowed. (This should be checked before `GenBind' is used.) We can not really check that a hook is in a position where a toplevel definition is allowed (without analysing significant parts of the Haskell code), but we can at least guarantee that these hooks occur in column position 0. * Sven: #define enums in C: Introduce (#enum define SomeEnum {...}#) hooks that collect `#define' symbols into an enumeration type; see also +haskell/4025. One probem: If identifiers with the same lexeme as `SomeEnum' or the enum members are already defined in the C header, we might get conflicts. The problem of this approach is that if the macro expands to something that is not a constant expression C, we will get error messages from the preprocessor, which are strange to the user. Further idea, Michael's: extensible enums There are, however, a number of interesting options supported by gcc -E that might make alternative solutions to the problem feasible. END of ----- Pre-1.0 rewrite --------------- * Do we like direct support for mapping complete structs (if they are sufficiently wellbehaved?) into Haskell data structures - both by generating the Haskell data type definitions and by generating a `cFrom' and a `cTo' routine. The latter would be generated as a cascade of field hooks. H/Direct's formal definition of structure marshalling might be helpful here. * Support for evaluating constants is not complete yet. In this context, it should probably also be checked, when there are two overlapping tags in an enum (this is allowed in C, but is problematic for marshaling). * How about Hugs support? Is it already possible with current Hugs? Release Checklist ~~~~~~~~~~~~~~~~~ (1) In root of working directory, % make tar-c2hs (2) Compile the resulting source distribution with latest ghc stable release: % tar xzf c2hs-x.y.z.tar.gz % cd c2hs-x.y.z % ./configure % make (3) Install and regression testing: - Installation procedure % make install - Tests in build/ghc?/c2hs/tests/ directory (4) Check documentation and add release notes (5) Extended build test: build with older stable release of ghc and with the cvs version (6) Register CVS tags for CTK and C->HS (syntax: Release-c2hs_x_y_z) (7) Make newest `tar' and build rpm (8) Put tar.gz and rpm sources and binaries up on Web page (9) Optionally also release the current version of CTK (10) Update the documentation under the Web page's docu/ directory (11) Announce: haskell@haskell.org, freshmeat.net ================================================ FILE: TODO.CTKlight ================================================ -*-text-*- Compiler Base TODO ================== Next: Short Term: ~~~~~~~~~~~ * See general/UNames.hs for nhc98 induced ugliness; change when nhc98 is fixed * Lexers: For unicode `Char', we need to explicit support for positive and negated ranges such as ['\0'..'\255'] and ['\0'..'\255'] \\ ['a'..'c'], where the latter is usually written [^abc] (see the haskell-cafe discussion). * Roman introduced the class `Printable'. A general class based pretty-print system would be nice. * Parsers: Roman had the idea of allowing boolean functions to disambiguate the parse table where two rules cannot be distinguished by the usual LL mechanism alone (see emails). * Identifiers in any of the intermediate languages that have the same lexeme as a keyword or a predefined identifier should always been pretty-printed in their quoted form. Difficult to know for each IL which identifiers have to be treated specially. We need a kind of IL-dependent exception list. Middle Term: ~~~~~~~~~~~~ * Use a different attribute mechanism. The stuff started for the flatten prototype looks quite promising. Observations: - Current hipar system with a unique in every node => makes it complicated to construct/transform trees, as we always have to clone subtress in a monad. - GHC's system => when attributes of an identifier are updated, the "new" identifiers have to substituted into all expression that contain usage occurrences. * Graph processing support: Does it need to be a new mechanism or can we realise it via Attrs (what kind of generic functions could we provide). One possibility is the use of an `Bool' attribute used to implement fast sets (e.g. marking). (If there is a lot of marking, we might want to realise indexing with attributes via hashing to be able to work with sparse keys and to already have O(1) during attribute table construction.) * `FiniteMap' should be an instance of `Functior' with `fmap = mapFM' * configuration shouldn't be in * FNameOps, FileOps: Introduce an autoconf set variable that determines whether "/" or "\" is used as a delimiter in paths * Lexers: * After a certain number of errors (say 50); abort lexing. * Parsers (maybe similar problem with Lexers): If the grammar is not LL(1), we just get an `ambiguous grammar' error message at runtime without any hint, which part of the grammer might be ambiguous. This is too hard to debug! * In the language-specific `XXXAttrs.hs' modules, the routines for handling the different on the attribute tables have always the same structure; Only the access to the `AttrXXX' datatype is different. It should be possible to generalize them. Moreover, the `referring identifier information' is always needed and might be generalized. * The handling of state could be improved by revising the state modules and using constructor classes and monad transformers. Currently, we only define the state type abstractly when generating a new instance of `CST'. This is in order to be able to use the generic operations, such as I/O, also in the monad instance. But this comprises the security of the monad encapsulation as also the generic functions that allow to extract and copy the state can be used. Ideally, we want to lift generic operations like I/O automagically into the new monad and to protect it from access to its state. Furthermore, some support for stripping and attaching of the type-tag (intro with `newtype') would be nice. ================================================ FILE: appveyor.yml ================================================ build: off before_test: # http://help.appveyor.com/discussions/problems/6312-curl-command-not-found - set PATH=C:\Program Files\Git\mingw64\bin;%PATH% - curl -sS -ostack.zip -L --insecure http://www.stackage.org/stack/windows-i386 - 7z x stack.zip stack.exe clone_folder: "c:\\stack" environment: global: STACK_ROOT: "c:\\sr" test_script: - stack setup > nul - stack init # The ugly echo "" hack is to avoid complaints about 0 being an invalid file # descriptor - echo "" | stack --no-terminal test ================================================ FILE: c2hs.cabal ================================================ Cabal-Version: >= 1.10 Name: c2hs Version: 0.28.8 License: GPL-2 License-File: COPYING Copyright: Copyright (c) 1999-2007 Manuel M T Chakravarty 2005-2013 Duncan Coutts 2008 Benedikt Huber Author: Manuel M T Chakravarty Maintainer: chak@cse.unsw.edu.au, duncan@community.haskell.org, ian@skybluetrades.net, aditya.siram@gmail.com Stability: Stable 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 files and generates Haskell code with foreign imports and marshaling. Unlike writing foreign imports by hand (or using hsc2hs), this ensures that C functions are imported with the correct Haskell types. Category: Development Build-Type: Simple Tested-With: GHC == 9.6.2 GHC == 9.4.5 GHC == 9.2.8 GHC == 9.0.2 GHC == 8.10.7 GHC == 8.8.4 GHC == 8.6.5 GHC == 8.4.4 GHC == 8.2.2 GHC == 8.0.2 GHC == 7.10.3 --TODO: Cabal should allow 'Data-Files' in the executable stanza Data-Files: C2HS.hs Extra-Source-Files: src/C2HS/config.h AUTHORS INSTALL README ChangeLog ChangeLog.old 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/enums/*.chs tests/system/enums/*.h tests/system/enums/*.c tests/system/interruptible/*.chs tests/system/interruptible/*.h tests/system/interruptible/*.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/Makefile tests/bugs/call_capital/*.chs tests/bugs/call_capital/*.h tests/bugs/call_capital/*.c tests/bugs/issue-7/*.chs tests/bugs/issue-7/*.h tests/bugs/issue-9/*.chs tests/bugs/issue-9/*.h tests/bugs/issue-9/*.c tests/bugs/issue-10/*.chs tests/bugs/issue-10/*.h tests/bugs/issue-10/*.c tests/bugs/issue-15/*.chs tests/bugs/issue-15/*.h tests/bugs/issue-15/*.c tests/bugs/issue-16/*.chs tests/bugs/issue-16/*.h tests/bugs/issue-16/*.c tests/bugs/issue-19/*.chs tests/bugs/issue-19/*.h tests/bugs/issue-19/*.c tests/bugs/issue-20/*.chs tests/bugs/issue-20/*.h tests/bugs/issue-20/*.c tests/bugs/issue-22/*.chs tests/bugs/issue-22/*.h tests/bugs/issue-22/*.c tests/bugs/issue-23/*.chs tests/bugs/issue-23/*.h tests/bugs/issue-23/*.c tests/bugs/issue-25/*.chs tests/bugs/issue-29/*.chs tests/bugs/issue-29/*.h tests/bugs/issue-30/*.chs tests/bugs/issue-30/*.h tests/bugs/issue-30/*.c tests/bugs/issue-31/*.chs tests/bugs/issue-31/*.h tests/bugs/issue-31/*.c tests/bugs/issue-32/*.chs tests/bugs/issue-32/*.h tests/bugs/issue-32/*.c tests/bugs/issue-36/*.chs tests/bugs/issue-36/*.h tests/bugs/issue-38/*.chs tests/bugs/issue-38/*.h tests/bugs/issue-38/*.c tests/bugs/issue-43/*.chs tests/bugs/issue-43/*.h tests/bugs/issue-43/*.c tests/bugs/issue-44/*.chs tests/bugs/issue-44/*.h tests/bugs/issue-44/*.c tests/bugs/issue-45/*.chs tests/bugs/issue-45/*.h tests/bugs/issue-45/*.c tests/bugs/issue-46/*.chs tests/bugs/issue-46/*.h tests/bugs/issue-46/*.c tests/bugs/issue-47/*.chs tests/bugs/issue-47/*.h tests/bugs/issue-47/*.c tests/bugs/issue-48/*.chs tests/bugs/issue-48/*.h tests/bugs/issue-48/*.c tests/bugs/issue-51/*.chs tests/bugs/issue-51/*.h tests/bugs/issue-51/*.c tests/bugs/issue-54/*.chs tests/bugs/issue-54/*.h tests/bugs/issue-54/*.c tests/bugs/issue-60/*.chs tests/bugs/issue-60/*.h tests/bugs/issue-60/*.c tests/bugs/issue-62/*.chs tests/bugs/issue-62/*.h tests/bugs/issue-62/*.c tests/bugs/issue-65/*.chs tests/bugs/issue-65/*.h tests/bugs/issue-65/*.c tests/bugs/issue-69/*.chs tests/bugs/issue-69/*.h tests/bugs/issue-69/*.c tests/bugs/issue-70/*.chs tests/bugs/issue-70/*.h tests/bugs/issue-70/*.c tests/bugs/issue-73/*.chs tests/bugs/issue-73/*.h tests/bugs/issue-73/*.c tests/bugs/issue-75/*.chs tests/bugs/issue-75/*.h tests/bugs/issue-75/*.c tests/bugs/issue-79/*.chs tests/bugs/issue-79/*.h tests/bugs/issue-79/*.c tests/bugs/issue-80/*.chs tests/bugs/issue-80/*.h tests/bugs/issue-80/*.c tests/bugs/issue-82/*.chs tests/bugs/issue-83/*.chs tests/bugs/issue-93/*.chs tests/bugs/issue-93/*.h tests/bugs/issue-93/*.c tests/bugs/issue-95/*.chs tests/bugs/issue-95/*.h tests/bugs/issue-95/*.c tests/bugs/issue-96/*.chs tests/bugs/issue-96/*.h tests/bugs/issue-96/*.c tests/bugs/issue-97/*.chs tests/bugs/issue-97/*.h tests/bugs/issue-97/*.c tests/bugs/issue-98/*.chs tests/bugs/issue-98/*.h tests/bugs/issue-98/*.c tests/bugs/issue-102/*.chs tests/bugs/issue-103/*.chs tests/bugs/issue-103/*.h tests/bugs/issue-103/*.c tests/bugs/issue-107/*.chs tests/bugs/issue-113/*.chs tests/bugs/issue-113/*.h tests/bugs/issue-113/*.c tests/bugs/issue-115/*.chs tests/bugs/issue-115/*.h tests/bugs/issue-115/*.c tests/bugs/issue-116/*.chs tests/bugs/issue-116/*.h tests/bugs/issue-116/*.c tests/bugs/issue-117/*.chs tests/bugs/issue-117/*.h tests/bugs/issue-117/*.c tests/bugs/issue-123/*.chs tests/bugs/issue-123/*.h tests/bugs/issue-123/*.c tests/bugs/issue-127/*.chs tests/bugs/issue-127/*.h tests/bugs/issue-127/*.c tests/bugs/issue-128/*.chs tests/bugs/issue-128/*.h tests/bugs/issue-128/*.c tests/bugs/issue-130/*.chs tests/bugs/issue-130/*.h tests/bugs/issue-130/*.c tests/bugs/issue-131/*.chs tests/bugs/issue-131/*.h tests/bugs/issue-131/*.c tests/bugs/issue-133/*.chs tests/bugs/issue-133/*.h tests/bugs/issue-134/*.chs tests/bugs/issue-134/*.h tests/bugs/issue-136/*.chs tests/bugs/issue-136/*.h tests/bugs/issue-136/*.c tests/bugs/issue-140/*.chs tests/bugs/issue-140/*.h tests/bugs/issue-140/*.c tests/bugs/issue-141/*.chs tests/bugs/issue-141/*.h tests/bugs/issue-149/*.chs tests/bugs/issue-149/*.h tests/bugs/issue-149/*.c tests/bugs/issue-151/*.chs tests/bugs/issue-151/*.h tests/bugs/issue-152/*.chs tests/bugs/issue-152/*.h tests/bugs/issue-155/*.chs tests/bugs/issue-155/*.h tests/bugs/issue-180/*.chs tests/bugs/issue-180/*.h tests/bugs/issue-192/*.chs tests/bugs/issue-192/*.h tests/bugs/issue-230/*.chs tests/bugs/issue-230/*.h tests/bugs/issue-230/*.c tests/bugs/issue-242/*.chs tests/bugs/issue-242/*.h tests/bugs/issue-242/*.c tests/bugs/issue-257/*.chs tests/bugs/issue-257/*.h tests/bugs/issue-257/*.c source-repository head type: git location: git://github.com/haskell/c2hs.git flag base3 Executable c2hs Build-Depends: base >= 2 && < 5, bytestring, language-c >= 0.7.1 && < 0.10, filepath, dlist if flag(base3) Build-Depends: base >= 3, process, directory, array, containers, pretty else Build-Depends: base < 3 if !impl(ghc >= 8.0) Build-Depends: fail hs-source-dirs: src main-is: Main.hs other-modules: C2HS.C C2HS.C.Attrs C2HS.C.Builtin C2HS.C.Info C2HS.C.Names C2HS.C.Trav C2HS.CHS C2HS.CHS.Lexer C2HS.Gen.Monad C2HS.Gen.Bind C2HS.Gen.Header C2HS.Gen.Wrapper C2HS.State C2HS.Switches C2HS.Config C2HS.Version Control.StateBase Control.State Control.StateTrans Data.Attributes Data.Errors Data.NameSpaces Paths_c2hs System.CIO Text.Lexers default-extensions: ForeignFunctionInterface c-sources: src/C2HS/config.c --TODO: eliminate the need to suppress these warnings: ghc-options: -Wall -fno-warn-incomplete-patterns if impl(ghc >= 8.0) ghc-options: -Wcompat default-language: Haskell2010 Test-Suite test-bugs type: exitcode-stdio-1.0 hs-source-dirs: tests main-is: test-bugs.hs other-modules: Paths_c2hs build-tools: c2hs build-depends: base, filepath, ghc-paths, test-framework, test-framework-hunit, HUnit, shelly >= 1.9.0, text, transformers default-language: Haskell2010 Test-Suite test-system type: exitcode-stdio-1.0 hs-source-dirs: tests main-is: test-system.hs other-modules: Paths_c2hs build-tools: c2hs build-depends: base, ghc-paths, test-framework, test-framework-hunit, HUnit, shelly >= 1.9.0, text, transformers default-language: Haskell2010 Flag regression description: Enable regression suite build. default: False Executable regression-suite main-is: regression-suite.hs hs-source-dirs: tests if flag(regression) build-depends: base, filepath, shelly >= 1.9.0, text, yaml >= 0.8 else buildable: False default-language: Haskell2010 ================================================ FILE: cabal.haskell-ci ================================================ -- shelly >= 1.9 requires GHC >= 8.0 tests: >= 8.0 ================================================ FILE: custom-setup.hs ================================================ -- -- This Cabal setup script should ONLY be used in cases WHERE: -- -- the bare structure wrapper capability of C2HS is used (i.e. '%' -- characters on pointer type arguments in "fun" hooks); -- -- AND -- -- a version of Cabal is being used that does not allow -- preprocessors to specify extra C sources (versions of -- cabal-install <= 1.22.0.0). -- -- Otherwise Cabal should be able to deal with the extra C sources -- itself. -- -- If in doubt, ask... -- module Main (main) where import Control.Exception (catch) import Control.Monad (forM) import Distribution.PackageDescription (BuildInfo(..), Executable(..), Library(..), PackageDescription(..)) import Distribution.Simple (UserHooks(..), defaultMainWithHooks, simpleUserHooks) import Distribution.Simple.LocalBuildInfo (LocalBuildInfo(..)) import Distribution.Simple.Setup (BuildFlags) -- Test-suites require Cabal-1.10 or greater import Distribution.PackageDescription (TestSuite(..)) -- Benchmarks require Cabal-1.14 or greater import Distribution.PackageDescription (Benchmark(..)) import System.Directory (doesDirectoryExist, getDirectoryContents) import System.Exit (ExitCode) import System.FilePath ((), takeExtensions) main :: IO () main = defaultMainWithHooks simpleUserHooks { buildHook = chsBuildHook } addCSources :: [FilePath] -> BuildInfo -> BuildInfo addCSources newSrcs bi@(BuildInfo { cSources = oldSrcs }) = bi { cSources = newSrcs ++ oldSrcs } hasChsCExtension :: FilePath -> Bool hasChsCExtension file = takeExtensions file == ".chs.c" getRecursiveContents :: FilePath -> IO [FilePath] getRecursiveContents topdir = do topdirExists <- doesDirectoryExist topdir if (not topdirExists) then return [] else do names <- getDirectoryContents topdir let properNames = filter (`notElem` [".", ".."]) names paths <- forM properNames $ \name -> do let path = topdir name isDirectory <- doesDirectoryExist path if isDirectory then getRecursiveContents path else return [path] return (concat paths) chsBuildHook :: PackageDescription -> LocalBuildInfo -> UserHooks -> BuildFlags -> IO () chsBuildHook pd lbi uh bf = hook `catchExitCode` \_ -> hook where hook :: IO () hook = chsBuildHook' pd lbi uh bf catchExitCode :: IO a -> (ExitCode -> IO a) -> IO a catchExitCode = catch chsBuildHook' :: PackageDescription -> LocalBuildInfo -> UserHooks -> BuildFlags -> IO () chsBuildHook' pd@(PackageDescription { library = mbLib , executables = exes , testSuites = tss , benchmarks = bms }) lbi uh bf = do let distBuildDir = buildDir lbi chsCFiles <- fmap (filter hasChsCExtension) $ getRecursiveContents distBuildDir let pd' = pd { library = fmap (\lib -> lib { libBuildInfo = addCSources chsCFiles (libBuildInfo lib) }) mbLib , executables = fmap (\exe -> exe { buildInfo = addCSources chsCFiles (buildInfo exe) }) exes , testSuites = fmap (\ts -> ts { testBuildInfo = addCSources chsCFiles (testBuildInfo ts) }) tss , benchmarks = fmap (\bm -> bm { benchmarkBuildInfo = addCSources chsCFiles (benchmarkBuildInfo bm) }) bms } buildHook simpleUserHooks pd' lbi uh bf ================================================ FILE: doc/Makefile ================================================ # C->Haskell Compiler: documentation makefile # # Author : Manuel M T Chakravarty # Created: 30 October 1999 # # Version $Revision: 1.9 $ from $Date: 2002/07/06 09:59:40 $ # # Copyright (c) [1999..2002] Manuel M T Chakravarty # # This file 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 file 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. # # = DOCU ===================================================================== # # * Nothing is installed at the moment. That has to be done manually. # must be first # default: html XMLLINT=xmllint XMLLINT_OPTIONS=--nonet --noout --valid XSLTPROC=xsltproc XSLTPROC_HTML_OUTDIR=users_guide/ XSLTPROC_HTML_CSS=c2hs.css XSLTPROC_HTML_PARAMS=\ --param use.id.as.filename 1 \ --stringparam base.dir $(XSLTPROC_HTML_OUTDIR) \ --stringparam html.stylesheet $(XSLTPROC_HTML_CSS) XSLTPROC_HTML_STYLESHEET=http://docbook.sourceforge.net/release/xsl/current/html/chunk.xsl XSLTPROC_OPTIONS=--nonet $(XSLTPROC_HTML_PARAMS) $(XSLTPROC_HTML_STYLESHEET) # build targets # .PHONY: html pdf html: c2hs.xml $(XMLLINT) $(XMLLINT_OPTIONS) $< $(XSLTPROC) $(XSLTPROC_OPTIONS) $< cp $(XSLTPROC_HTML_CSS) $(XSLTPROC_HTML_OUTDIR) pdf: c2hs.xml sgml2pdf $< # auxiliary targets # .PHONY: clean clean: -rm -rf users_guide/ c2hs.pdf ================================================ FILE: doc/c2hs.css ================================================ div { font-family: sans-serif; color: black; background: white } h1, h2, h3, h4, h5, h6, p.title { color: #005A9C } h1 { font: 170% sans-serif } h2 { font: 140% sans-serif } h3 { font: 120% sans-serif } h4 { font: bold 100% sans-serif } h5 { font: italic 100% sans-serif } h6 { font: small-caps 100% sans-serif } pre { font-family: monospace; border-width: 1px; border-style: solid; padding: 0.3em } pre.screen { color: #006400 } pre.programlisting { color: maroon } div.example { margin: 1ex 0em; border: solid #412e25 1px; padding: 0ex 0.4em } div.example, div.example-contents { background-color: #fffcf5 } a:link { color: #0000C8 } a:hover { background: #FFFFA8 } a:active { color: #D00000 } a:visited { color: #680098 } ================================================ FILE: doc/c2hs.xml ================================================ c2hs'> ]>
The Binding Generator &C2hs; Manuel Chakravarty chak@cse.unsw.edu.au November 2007 &C2hs; is an interface generator that simplifies the development of Haskell bindings to C libraries. The tool processes existing C header files that determine data layout and function signatures on the C side in conjunction with Haskell modules that specify Haskell-side type signatures and marshaling details. Hooks embedded in the Haskell code signal access to C structures and functions -- they are expanded by the interfacing tool in dependence on information from the corresponding C header file. Another noteworthy property is the lightweight nature of the approach. More background information is available in a research paper discussing &C2hs;, which is at . However, this paper does not cover the more recent advanced features such as function hooks and conditional compilation. Installation It follows a brief discussion of the installation from source. There is, however, a file INSTALL in the source distribution, which is more frequently updated and should be consulted in any case. Where is the Source? The master site of &C2hs; is at . It has all the latest information and sources. Furthermore, it explains how to get access to the &C2hs; Darcs repository and has references to pre-compiled binaries. What Else Do I Need? You need a Haskell system supported by &C2hs;. Currently, this is only the Glasgow Haskell Compiler (GHC), which you can obtain from . Furthermore, you need the Haskell package system Cabal. See the INSTALL file for details on supported versions. To build the documentation, you will also need the SGML Tools, which you find at your nearest sunsite or Linux mirror or at . On an up-to-date Linux system, the tools are probably already installed. I Got Everything, and Now? The short answer is $ tar -xzf package.tar.gz # unpack the sources $ cd package # change to the toplevel directory $ runghc Setup.hs configure # configure the build system $ runghc Setup.hs build # build everything [ Become root if necessary ] $ runghc Setup.hs install # install c2hs In the INSTALL file, there are more details. Optionally, you can build the documentation by issuing make doc and install it with make install-doc. Usage of &C2hs; Let's have a brief look at how to call the tool and how to use the generated interfaces. Usage of &c2hs; &C2hs; is implemented by the executable &c2hs;. The simplest form of usage is c2hs Lib.chs where Lib.chs is the Haskell binding module defining the Haskell interface to a C library together with the required marshalling code. If &c2hs; is invoked in this manner, the binding module must contain a cpp #include directive to determine the C-side interface of the library. Alternatively, a C header file can be specified on the command line, as in c2hs lib.h Lib.chs However, the latter option is only preserved for backwards compatibility and not recommended. If no errors occur, &c2hs; generates three files: a pure Haskell module Lib.hs, which implements the Haskell API of the library a C header file Lib.h which some Haskell systems need to compile the generated Haskell code. a &c2hs; interface file Lib.chi that is used by other binding modules that import Lib.hs using an import hook (see the section on import hooks for details). The executable &c2hs; has a couple more options: Usage: c2hs [ option... ] [header-file] binding-file -C CPPOPTS --cppopts=CPPOPTS pass CPPOPTS to the C preprocessor -c CPP --cpp=CPP use executable CPP to invoke C preprocessor -d TYPE --dump=TYPE dump internal information (for debugging) -h, -? --help brief help (the present message) -i INCLUDE --include=INCLUDE include paths for .chi files -k --keep keep pre-processed C header -l --copy-library copy `C2HS' library module in -o FILE --output=FILE output result to FILE (should end in .hs) -p PLATFORM --platform=PLATFORM platform to use for cross compilation -t PATH --output-dir=PATH place generated files in PATH -v --version show version information --numeric-version show version number The header file must be a C header file matching the given binding file. The dump TYPE can be trace -- trace compiler phases genbind -- trace binding generation ctrav -- trace C declaration traversal chs -- dump the binding file (adds `.dump' to the name) PLATFORM can be x86_64-linux, i686-linux, m68k-palmos The most useful of these is probably --cppopts= (or -C). If the C header file needs any special options (like -D or -I) to go through the C pre-processor, here is the place to pass them. A call may look like this: c2hs --cppopts='-I/some/obscure/dir' --cppopts=-DEXTRA' Lib.chs If you have more than one option that you want to pass to the pre-processor it is best to use multiple --cppopts= flags. That way there is no need to worry about quoting. Often, lib.h will not be in the current directory, but in one of the header file directories. &c2hs; leaves locating the header file to the standard C preprocessor, which usually looks in two places for the header: first, in the standard include directory of the used system, this is usually /usr/include and /usr/local/include; and second, it will look in every directory that is mentioned in a -IDIR option passed to the pre-processor via --cppopts. If the compiled binding module contains import hooks, &C2hs; needs to find the .chi (&C2hs; interface files) produced while compiling the corresponding binding modules. By default, they will be searched for in the current working directory. If they are located elsewhere, the --include=INCLUDE option has to be used to indicate the location, where INCLUDE is a colon-separated list of directories. Multiple such options are admissible. Paths specified later are searched first. Compilation of a Generated Haskell API &C2hs; comes with a marshalling library, called C2HS, which needs to be explicitly imported into Haskell binding modules. The library contains functions that users might use explicitly, but also functions that &C2hs; will generate for some classes of bindings. The library takes the form of a single Haskell module, which &c2hs; places in the same directory as the generated binding whenever it is given the --copy-library (or -l) option. Implementation of Haskell Binding Modules A discussion of binding modules, the principles behind the tool, and a discussion of related work can be found in a research paper located at . All features described in the paper, except enum define hooks are implemented in the tool, but since the publication of the paper, the tool has been extended further. The library interface essentially consists of the new Haskell FFI Marshalling Library. More details about this library are provided in the next section. The remainder of this section describes the hooks that are available in binding modules. Import Hooks {#import [qualified] modid#} Is translated into the same syntactic form in Haskell, which implies that it may be followed by an explicit import list. Moreover, it implies that the module modid is also generated by &C2hs; and instructs the tool to read the file modid.chi. If an explicit output file name is given (--output option), this name determines the basename for the .chi file of the currently translated module. Currently, only pointer hooks generate information that is stored in a .chi file and needs to be incorporated into any client module that makes use of these pointer types. It is, however, regarded as good style to use import hooks for any module generated by &C2hs;. Restriction &C2hs; does not use qualified names. This can be a problem, for example, if two pointer hooks are defined to have the same unqualified Haskell name in two different modules, which are then imported by a third module. To partially work around this problem, it is guaranteed that the declaration of the textually later import hook dominates. Context Hooks {#context [lib = lib] [prefix = prefix]#} Context hooks define a set of global configuration options. Currently, there are two parameters which are both strings lib is a dynamic library that contains symbols needed by the present binding. prefix is an identifier prefix that may be omitted in the lexemes of identifiers referring to C definitions in any binding hook. The is useful as C libraries often use a prefix, such as gtk_, as a form of poor man's name spaces. Any occurrence of underline characters between a prefix and the main part of an identifier must also be dropped. Case is not relevant in a prefix. In case of a conflict of the abbreviation with an explicitly defined identifier, the explicit definition takes preference. Both parameters are optional. An example of a context hook is the following: {#context prefix = "gtk"#} If a binding module contains a binding hook, it must be the first hook in the module. Type Hooks {#type ident#} A type hooks maps a C type to a Haskell type. As an example, consider type GInt = {#type gint#} The type must be a defined type, primitive types, such as int, are not admissible. Sizeof Hooks {#sizeof ident#} A sizeof hooks maps a C type to its size in bytes. As an example, consider gIntSize :: Int gIntSize = {#sizeof gint#} The type must be a defined type, primitive types, such as int, are not admissible. The size of primitive types can always be obtained using Storable.sizeOf. Enumeration Hooks {#enum cid [as hsid] {alias1 , ... , aliasn} [with prefix = pref] [deriving (clid1 , ... , clidn)]#} Rewrite the C enumeration called cid into a Haskell data type declaration, which is made an instance of Enum such that the ordinals match those of the enumeration values in C. This takes explicit enumeration values in the C definitions into account. If hsid is given, this is the name of the Haskell data type. The identifiers clid1 to clidn are added to the deriving clause of the Haskell type. By default, the names of the C enumeration are used for the constructors in Haskell. If alias1 is underscoreToCase, the original C names are capitalised and the use of underscores is rewritten to caps. If it is upcaseFirstLetter or downcaseFirstLetter, the first letter of the original C name changes case correspondingly. It is also possible to combine underscoreToCase with one of upcaseFirstLetter or downcaseFirstLetter. Moreover, alias1 to aliasn may be aliases of the form cid as hsid, which map individual C names to Haskell names. Instead of the global prefix introduced by a context hook, a local prefix pref can optionally be specified. As an example, consider {#enum WindowType {underscoreToCase} deriving (Eq)#} <literal>enum define</literal> hooks Many C libraries do not use enum types, but macro definitions to implement constants. c2hs provides enum define hooks generate a haskell datatype from a collection of macro definitions. {#enum define hsid {alias1 , ... , aliasn} [deriving (clid1 , ... , clidn)]#} Create a haskell datatype hsid, with nullary constructors as given by the aliases alias1 through aliasn. Each alias has to be of the form macrodef as hsid, where hsid is the name of the nullary haskell constructor, and macrodef the C macro which the haskell constructor should map to. The deriving part is handled as in ordinary enum hooks. Here's an example #define X 0 #define Y 1 {#enum define Axis {X as Axis0, Y as Axis1} deriving (Eq,Ord) #} Call Hooks {#call [pure] [unsafe] [interruptible] cid [as (hsid | ^)]#} A call hook rewrites to a call to the C function cid and also ensures that the appropriate foreign import declaration is generated. The tags pure and unsafe specify that the external function is purely functional and cannot re-enter the Haskell runtime, respectively. The interruptible flag is intended to be used in conjunction with the InterruptibleFFI extension. If hsid is present, it is used as the identifier for the foreign declaration, which otherwise defaults to the cid. When instead of hsid, the symbol ^ is given, the cid after conversion from C's underscore notation to a capitalised identifier is used. As an example, consider sin :: Float -> Float sin = {#call pure sin as "_sin"#} Function Hooks {#fun [pure] [unsafe] [interruptible] cid [as (hsid | ^)] [ctxt =>] { parm1 , ... , parmn } -> parm Function hooks are call hooks including parameter marshalling. Thus, the components of a function hook up to and including the as alias are the same as for call hooks. However, an as alias has a different meaning; it specifies the name of the generated Haskell function. The remaining components use literals enclosed in backwards and foward single quotes (` and ') to denote Haskell code fragments (or more precisely, parts of the Haskell type signature for the bound function). The first one is the phrase ctxt preceding =>, which denotes the type context. This is followed by zero or more type and marshalling specifications parm1 to parmn for the function arguments and one parm for the function result. Each such specification parm has the form [inmarsh [* | -]] hsty[&] [outmarsh [*] [-]] where hsty is a Haskell code fragment denoting a Haskell type. The optional information to the left and right of this type determines the marshalling of the corresponding Haskell value to and from C; they are called the in and out marshaller, respectively. Each marshalling specification parm corresponds to one or two arguments of the C function, in the order in which they are given. A marshalling specification in which the symbol & follows the Haskell type corresponds to two C function arguments; otherwise, it corresponds only to one argument. The parm following the left arrow -> determines the marshalling of the result of the C function and may not contain the symbol &. The *- output marshal specification is for monadic actions that must be executed but whose results are discarded. This is very useful, e.g. for checking an error value and throwing an exception if needed. Both inmarsh and outmarsh are identifiers of Haskell marshalling functions. By default they are assumed to be pure functions; if they have to be executed in the IO monad, the function name needs to be followed by a star symbol *. Alternatively, the identifier may be followed by a minus sign -, in which case the Haskell type does not appear as an argument (in marshaller) or result (out marshaller) of the generated Haskell function. In other words, the argument types of the Haskell function is determined by the set of all marshalling specifications where the in marshaller is not followed by a minus sign. Conversely, the result tuple of the Haskell function is determined by the set of all marshalling specifications where the out marshaller is not followed by a minus sign. The order of function arguments and components in the result tuple is the same as the order in which the marshalling specifications are given, with the exception that the value of the result marshaller is always the first component in the result tuple if it is included at all. For a set of commonly occuring Haskell and C type combinations, default marshallers are provided by &C2hs; if no explicit marshaller is given. The out marshaller for function arguments is by default void-. The defaults for the in marshallers for function arguments are as follows: Bool and integral C type (including chars): cFromBool Integral Haskell and integral C type: cIntConv Floating Haskell and floating C type: cFloatConv String and char*: withCString* String and char* with explicit length: withCStringLen* T and T*: with* T and T* where T is an integral type: withIntConv* T and T* where T is a floating type: withFloatConv* Bool and T* where T is an integral type: withFromBool* The defaults for the out marshaller of the result are the converse of the above; i.e. instead of the with functions, the corresponding peek functions are used. Moreover, when the Haskell type is (), the default marshaller is void-. As an example, consider {#fun notebook_query_tab_label_packing as ^ `(NotebookClass nb, WidgetClass cld)' => {notebook `nb' , widget `cld' , alloca- `Bool' peekBool*, alloca- `Bool' peekBool*, alloca- `PackType' peekEnum*} -> `()'#} which results in the Haskell type signature notebookQueryTabLabelPacking :: (NotebookClass nb, WidgetClass cld) => nb -> cld -> IO (Bool, Bool, PackType) which binds the following C function: void gtk_notebook_query_tab_label_packing (GtkNotebook *notebook, GtkWidget *child, gboolean *expand, gboolean *fill, GtkPackType *pack_type); Get Hooks {#get apath#} A get hook supports accessing a member value of a C structure. The hook itself yields a function that, when given the address of a structure of the right type, performs the structure access. The member that is to be extracted is specified by the access path apath. Access paths are formed as follows (following a subset of the C expression syntax): The root of any access path is a simple identifier, which denotes either a type name or struct tag. An access path of the form *apath denotes dereferencing of the pointer yielded by accessing the access path apath. An access path of the form apath.cid specifies that the value of the struct member called cid should be accessed. Finally, an access path of the form apath->cid, as in C, specifies a combination of dereferencing and member selection. For example, we may have visualGetType :: Visual -> IO VisualType visualGetType (Visual vis) = liftM cToEnum $ {#get Visual->type#} vis Set Hooks {#set apath#} Set hooks are formed in the same way as get hooks, but yield a function that assigns a value to a member of a C structure. These functions expect a pointer to the structure as the first and the value to be assigned as the second argument. For example, we may have {#set sockaddr_in.sin_family#} addr_in (cFromEnum AF_NET) Pointer Hooks {#pointer [*] cid [as hsid] [foreign | stable] [newtype | -> hsid2] [nocode]#} A pointer hook facilitates the mapping of C to Haskell pointer types. In particular, it enables the use of ForeignPtr and StablePtr types and defines type name translations for pointers to non-basic types. In general, such a hook establishes an association between the C type cid or *cid and the Haskell type hsid, where the latter defaults to cid if not explicitly given. The identifier cid will usually be a type name, but in the case of *cid may also be a struct, union, or enum tag. If both a type name and a tag of the same name are available, the type name takes precedence. Optionally, the Haskell representation of the pointer can be by a ForeignPtr or StablePtr instead of a plain Ptr. If the newtype tag is given, the Haskell type hsid is defined as a newtype rather than a transparent type synonym. In case of a newtype, the type argument to the Haskell pointer type will be hsid, which gives a cyclic definition, but the type argument is here really only used as a unique type tag. Without newtype, the default type argument is (), but another type can be specified after the symbol ->. For example, we may have {#pointer *GtkObject as Object newtype#} This will generate a new type Object as follows: newtype Object = Object (Ptr Object) which enables exporting Object as an abstract type and facilitates type checking at call sites of imported functions using the encapsulated pointer. The latter is achieved by &C2hs; as follows. The tool remembers the association of the C type *GtkObject with the Haskell type Object, and so, it generates for the C function void gtk_unref_object (GtkObject *obj); the import declaration foreign import gtk_unref_object :: Object -> IO () This function can obviously only be applied to pointers of the right type, and thus, protects against the common mistake of confusing the order of pointer arguments in function calls. However, as the Haskell FFI does not permit to directly pass ForeignPtrs to function calls or return them, the tool will use the type Ptr HsName in this case, where HsName is the Haskell name of the type. So, if we modify the above declaration to be {#pointer *GtkObject as Object foreign newtype#} the type Ptr Object will be used instead of a plain Object in import declarations; i.e. the previous import declaration will become foreign import gtk_unref_object :: Ptr Object -> IO () To simplify the required marshalling code for such pointers, the tool automatically generates a function withObject :: Object -> (Ptr Object -> IO a) -> IO a As an example that does not represent the pointer as an abstract type, consider the C type declaration: typedef struct {int x, y;} *point; We can represent it in Haskell as data Point = Point {x :: Int, y :: Int} {#pointer point as PointPtr -> Point#} which will translate to data Point = Point {x :: Int, y :: Int} type PointPtr = Ptr Point and establish a type association between point and PointPtr. If the keyword nocode is added to the end of a pointer hook, &C2hs; will not emit a type declaration. This is useful when a &C2hs; module wants to make use of an existing type declaration in a binding not generated by &C2hs; (i.e. where there are no .chi files). Restriction The name cid cannot be a basic C type (such as int), it must be a defined name. Class Hooks {#class [hsid1 =>] hsid2 hsid3#} Class hooks facilitate the definition of a single inheritance class hierachy for external pointers including up and down cast functionality. This is meant to be used in cases where the objects referred to by the external pointers are order in such a hierachy in the external API - such structures are encountered in C libraries that provide an object-oriented interface. Each class hook rewrites to a class declaration and one or more instance declarations. All classes in a hierarchy, except the root, will have a superclass identified by hsid1. The new class is given by hsid2 and the corresponding external pointer is identified by hsid3. Both the superclass and the pointer type must already have been defined by binding hooks that precede the class hook. The pointers in a hierachy must either all be foreign pointers or all be normal pointers. Stable pointers are not allowed. Both pointer defined as newtypes and those defined by type synonyms may be used in class declarations and they may be mixed. In the case of synonyms, Haskell's usual restrictions regarding overlapping instance declarations apply. The newly defined class has two members whose names are derived from the type name hsid3. The name of first member is derived from hsid3 by converting the first character to lower case. This function casts from any superclass to the current class. The name of the second member is derived by prefixing hsid3 with the from. It casts from the current class to any superclass. A class hook generates an instance for the pointer in the newly defined class as well as in all its superclasses. As an example, consider {#pointer *GtkObject newtype#} {#class GtkObjectClass GtkObject#} {#pointer *GtkWidget newtype#} {#class GtkObjectClass => GtkWidgetClass GtkWidget#} The second class hook generates an instance for GtkWidget for both the GtkWidgetClass as well as for the GtkObjectClass. CPP Directives and Inline C Code A Haskell binding module may include arbitrary C pre-processor directives using the standard C syntax. The directives are used in two ways: Firstly, they are included in the C header file generated by &C2hs; in exactly the same order in which they appear in the binding module. Secondly, all conditional directives are honoured by &C2hs; in that all Haskell binding code in alternatives that are discarded by the C pre-processor are also discarded by &C2hs;. This latter feature is, for example, useful to maintain different bindings for multiple versions of the same C API in a single Haskell binding module. In addition to C pre-processor directives, vanilla C code can be maintained in a Haskell binding module by bracketing this C code with the pseudo directives #c and #endc. Such inline C code is emitted into the C header generated by &C2hs; at exactly the same position relative to CPP directives as it occurs in the binding module. Pre-processor directives may encompass the #include directive, which can be used instead of specifying a C header file as an argument to c2hs. In particular, this enables the simultaneous use of multiple header files without the need to provide a custom header file that binds them together. If a header file lib.h is specified as an argument to c2hs, the tool will emit the directive #include"lib.h" into the generated C header before any other CPP directive or inline C code. As an artificial example of these features consider the following code: #define VERSION 2 #if (VERSION == 1) foo :: CInt -> CInt foo = {#call pure fooC#} #else foo :: CInt -> CInt -> CInt foo = {#call pure fooC#} #endif #c int fooC (int, int); #endc One of two versions of the Haskell function foo (having different arities) is selected in dependence on the value of the CPP macro VERSION, which in this example is defined in the same file. In realistic code, VERSION would be defined in the header file supplied with the C library that is made accessible from Haskell by a binding module. The above code fragment also includes one line of inline C code that declares a C prototype for fooC. Current limitation of the implementation Inline C code can currently not contain any code blocks; i.e. only declarations as typically found in header files may be included. Grammar Rules The following grammar rules define the syntax of binding hooks: hook -> `{#' inner `#}' inner -> `import' ['qualified'] ident | `context' ctxt | `type' ident | `sizeof' ident | `enum' idalias trans [`with' prefix] [deriving] | `call' [`pure'] [`unsafe'] [`interruptible'] idalias | `fun' [`pure'] [`unsafe'] [`interruptible'] idalias parms | `get' apath | `set' apath | `pointer' ['*'] idalias ptrkind | `class' [ident `=>'] ident ident ctxt -> [`lib' `=' string] [prefix] idalias -> ident [(`as' ident | `^')] prefix -> `prefix' `=' string deriving -> `deriving' `(' ident_1 `,' ... `,' ident_n `)' parms -> [verbhs `=>'] `{' parm_1 `,' ... `,' parm_n `}' `->' parm parm -> [ident_1 [`*' | `-']] verbhs [`&'] [ident_2 [`*'] [`-']] apath -> ident | `*' apath | apath `.' ident | apath `->' ident trans -> `{' alias_1 `,' ... `,' alias_n `}' alias -> `underscoreToCase' | `upcaseFirstLetter' | `downcaseFirstLetter' | ident `as' ident ptrkind -> [`foreign' | `stable'] ['newtype' | '->' ident] Identifier ident follow the lexis of Haskell. They may be enclosed in single quotes to disambiguate them from C->Haskell keywords. Bug Reports and Suggestions There is a tracker for bugs and feature requests: . Alternatively if you prefer email please send your bug reports and suggestions to the C->Haskell List c2hs@haskell.org. A good bug report contains information on the used operating system and Haskell compiler as well as the version of &C2hs; that you have been using. You can obtain the version information by running c2hs --version. If possible a concise example illustrating your problem would be appreciated. Copyright &C2hs; is Copyright (C) [1999..2005] Manuel M. T. Chakravarty &C2hs; License This program 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 program 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 program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Documentation License This manual is Copyright (c) [2000..2005] by Manuel M. T. Chakravarty. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with the no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License". Possible Licenses of Generated Code 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; (i.e. 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. GNU Free Documentation License The GNU Free Documentation License is available at . Release Notes Important changes (especially those affecting the semantics of the tool) are documented in the following. Version 0.15.1 "Rainy Days" New C parser that can parse all of C99 and GNU C Make c2hs integrate better with Cabal (1.2 and later) Adapted to GHC 6.8. Now requires Cabal 1.2. Lots and lots of old code removal Several bug fixes and improvements from Udo Stenzel: allowing variadic functions in structures allowing call and fun hooks for FunPtrs in C structs embedded arrays size calculated correctly Version 0.14.5 "Travelling Lightly" Added nocode directive to pointer hooks Can use structs properly in pointer hooks now (contributed by Jelmer Vernooij) upcaseFirstLetter and downcaseFirstLetter Cross-compiling with --platform flag Gcc's asm construct is supported (contributed by Duncan Coutts) Hierarchical modules syntax in import hooks supported No separately installed marshaling library anymore; as a result binary &C2hs; packages and installations are now independent of the targeted Haskell system New lexer and parser generated with Alex and Happy (contributed by Duncan Coutts) Cabal build system Version 0.13.6 "Pressing Forward" Works with GHC 6.4 and Cabal packages Strings may contain 8-bit characters (e.g. umlauts). Identifier may optionally be put in single quotes. (This is useful if they would otherwise collide with a &C2hs; keyword.) Some smaller bug fixes C chars are treated as integral types for marshalling purposes. If there is no explicit output file specified, the generated header file is put in the same directory as the binding file; otherwise, it goes in the directory where the output file is put. Moreover, the --output-dir option enables the specification of directory where all generated files are to be put. Foreign import declarations include the name of the header file generated by &C2hs; (i.e. it needs neither be passed to the Haskell compiler at the command line nor in an OPTIONS pragma). We allow structs and unions with no declarations. Headers including function bodies are now parsed correctly. Duncan Coutts identified a space leak in the parser whose removal improved performance significantly. Version 0.12.1 "Springtime" Removed support for deprecated C2HS interface and for old versions of the FFI libraries Improved line pragma generation Works with GHC 6.3 Builds on Mac OS X thanks to a patch by Sean Seefried Version 0.11.5 "Powder Snow" Bug fixes Constant expression can now contain enumerators header label removed from context hooks This version of c2hs may overwrite C header files in the current directory. More precisely, if a binding module with the name Foo.chs is processed, a header file with the name Foo.h is generated and will overwrite any file of the same name in the current directory or the directory specified via the -o option. Added support for CPP directives, including special treatment of conditions, and for inline C code; specification of a header file as an argument to c2hs is now option. GHC line pragmas are emitted into generated Haskell code Swap the order of reading the binding module and the C header (i.e. we now read the binding module first) Version 0.10.17 "Altocumulus Stratiformis Perlucidus Undulatus" Worked around a bug in GHC 5.04.1 Solaris-related fix Marshalling support for bit masks represented as enumeration types Added fun hooks as aliases can use ^ convert the orignal identifier with underscore2case In call hooks, the attributes `fun' was replaced by `pure' (`fun' is will still be recognised for a while to ensure backwards compatibility, but it's use is deprecated) GHC's package system is now supported If two import hooks add a type mapping for a pointer hook with the same name, the textual later one dominates. Bug fixes Support for bitfields (they are correctly handled when computing struct offsets and they can be accessed using set and get hooks) Some more support for GNU C extensions ("alignof" and better support "__attribute__") Added class hooks Version 0.9.9 "Blue Ginger" Bug fixes Library names in foreign imports have been removed until the convention of the new FFI is implemented (they are currently silently omitted) Added sizeof hooks; sizeof of type names is now also supported in constant expressions Local prefix for enum hooks; courtesy of Armin Sander Added import hooks The documentation includes a description of binding hooks Added pointer hooks, which were derived from code for a similar feature by Axel Simon; this includes proper treatment of parametrised pointers Integrated deriving option for enum hooks, which was contributed by Axel Simon Adapted to GHC 5.0 Version 0.8.2 "Gentle Moon" Adaptation layer for legacy StablePtr interface Forgot to export FunPtr and associated functions from C2HS Forgot to export some names in C2HSDeprecated Added support for gcc's __builtin_va_list Version 0.8.1 "Gentle Moon" Library adapted to New FFI; the old interface can still be used by importing C2HSDeprecated FFI Library specification added to the documentation Version 0.7.10 "Afterthought" CygWin support; based on suggestions by Anibal Maffioletti Rodrigues de DEUS anibaldedeus@email.com IntConv instances for Int8, Word8, and Char Version 0.7.9 "Afterthought" Debugged the stripping of prefixes from enumerators; prefixes are now generally stripped, independent of whether they can be stripped from all enumerators of a given enumeration type Comma now correctly required after underscoreToCase. This breaks source compatibility with previous versions. Version 0.7.8 Provisional support for GHC 4.08 Corrected constant folding Version 0.7.7 Ignores any occurrence of #pragma. Version 0.7.6 Bug fixes and support for long long. Version 0.7.5 This is mainly a bug fix release. In particular, the space behaviour of &C2hs; has been significantly improved. IMPORTANT NOTE: From this release on, library names in lib tags in context hooks should not contain a suffix (i.e. omit .so etc).
================================================ FILE: doc/man1/c2hs.1 ================================================ .\" Hey Emacs! This file is -*- nroff -*- source. .\" .\" Version $Revision: 1.2 $ from $Date: 2002/09/15 07:00:41 $ .\" .TH C2HS 1 "November 2007" "Version 0.15.1" C\->Haskell .SH NAME c2hs \- C->Haskell Interface Generator .SH SYNOPSIS .B c2hs .RB [ OPTIONS ]... .I header-file .I binding-file .SH DESCRIPTION This manual page briefly describes the .B c2hs command. For more details, refer to the main documentation, which is available in various other formats, including SGML and HTML; see below. .PP .SH OPTIONS The programs follow the usual GNU command line syntax, with long options starting with two dashes (`-'). A summary of options are included below. For a complete description, see the other documentation. .B c2hs accepts the following options: .TP .B \-h, \-?, \-\-help brief help .TP .B \-v, \-\-version show version information .TP .B \-\-numeric\-version show version number .TP .BI \-c \ CPP\fR, \ \-\-cpp= CPP use executable \fICPP\fR to invoke C preprocessor .TP .BR \-C \ CPPOPTS\fR, \ \-\-cppopts= CPPOPTS pass CPPOPTS to the C preprocessor .TP .BI \-o \ FILE\fR, \ \-\-output= FILE output result to \fIFILE\fR (should end in \fI.hs\fR) .TP .BI \-t \ PATH\fR, \ \-\-output\-dir= PATH place generated files in PATH .TP .B \-p \ PLATFORM, \-\-platform=PLATFORM platform to use for cross compilation .TP .B \-k, \-\-keep keep pre-processed C header .TP .B \-l, \-\-copy\-library copy `C2HS' library module to the current directory .TP .BR \-d \ TYPE\fR, \ \-\-dump= TYPE dump internal information (for debugging), where TYPE is one of: .RS .IP "\(bu \fBtrace\fR" 10 trace compiler phases .IP "\(bu \fBgenbind\fR" 10 trace binding generation .IP "\(bu \fBctrav\fR" 10 trace C declaration traversal .IP "\(bu \fBchs\fR" 10 dump the binding file (adds \fI.dump\fR to the name) .RE .PP .I header-file is the header file belonging to the marshalled library. It must end with suffix .IR .h . .I binding-file is the corresponding Haskell binding file, which must end with suffix .IR .chs . .I PLATFORM The platform name can be one of: .IR x86_64-linux . .IR i686-linux . .IR m68k-palmos . This allows for cross-compilation, assuming the rest of your toolchain supports that. The default is the current host platform. The most useful of these options is probably .B \-\-cppopts (or .BR \-C ). If the C header file needs any special options (like \-D or \-I) to go through the C pre-processor, here is the place to pass them. .SH EXAMPLES The easiest way to use the C->Haskell Interface Generator is via .I Cabal. Cabal knows about .I .chs files and will run .B c2hs automatically, passing the appropriate flags. When used directly, .Bc2hs is usually called as: .B c2hs .I lib.h Lib.chs where .I lib.h is the header file and .I Lib.chs the Haskell binding module, which define the C- and Haskell-side interface, respectively. If no errors occur, the result is a pure Haskell module .IR Lib.hs , which implements the Haskell API of the library. A more advanced call may look like this: .BR "c2hs" \ \-\-cppopts=\-I\fI/some/obscure/dir\fR \-\-cppopts=\-DEXTRA .I lib.h Lib.chs Often, .I lib.h will not be in the current directory, but in one of the header file directories. Apart from the current directory, C->Haskell looks in two places for the header: first, in the standard include directory of the used system, this is usually .IR /usr/include " and " /usr/local/include ; and second, it will look in every directory that is mentioned in a .RI \-I DIR option passed to the pre-processor via .BR \-\-cppopts . .SH CAVEATS If you have more than one option that you want to give to the pre-processor, use multiple .BR \-\-cppopts= \ flags. .SH "SEE ALSO" User guide .I /usr/share/doc/c2hs-0.15.1/html/c2hs.html Home page .I http://www.cse.unsw.edu.au/~chak/haskell/c2hs/ .SH "BUGS" Please report bugs and feature requests in the c2hs trac .I http://hackage.haskell.org/trac/c2hs/ or to the C->Haskell mailing list .I c2hs@haskell.org .SH COPYRIGHT C->Haskell Version 0.15.1 Copyright (c) [1999..2007] Manuel M. T. Chakravarty .SH AUTHOR This manual page was mainly assembled from the original documentation. It was written by Michael Weber for the Debian GNU/Linux system (but may be used by others). ================================================ FILE: examples/libghttpHS/Ghttp.chs ================================================ -- GhttpHS: Haskell binding to the Gnome HTTP library -*-haskell-*- -- -- Author : Manuel M. T. Chakravarty -- Created: 5 August 99 -- -- Copyright (c) [1999..2000] Manuel M. T. Chakravarty -- -- This library is free software; you can redistribute it and/or -- modify it under the terms of the GNU Library General Public -- License as published by the Free Software Foundation; either -- version 2 of the License, or (at your option) any later version. -- -- This library 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 -- Library General Public License for more details. -- --- DESCRIPTION --------------------------------------------------------------- -- -- The C library `libghttp' provides a set of common http functions needed at -- the client and the server end of an http connection. The Haskell binding -- is generated with the help of the C->Haskell tool - always modify the -- original .chs file, _not_ the generated .hs file. -- -- This library is fully compliant with HTTP 1.1 as defined in the draft 5 -- update of RFC 2068. -- --- DOCU ---------------------------------------------------------------------- -- -- language: Haskell 98 & C->HS binding hooks (v0.7.5) -- -- ** Stylistic warning: In the definition of `CurrentStatus', the field -- labels do not contain the name of the data type to which they belong. -- This is _not_ good practice in larger interfaces, because in Haskell -- such field labels pollute the global name space. -- --- TODO ---------------------------------------------------------------------- -- -- * When and by whom is the memory area passed to `ghttp_set_body' be freed; -- how about the string returned from `ghttp_get_body'? -- -- * Conversion of `time_t' misses for `parseDate'. -- module Ghttp (Request, URI, Type(..), SyncMode(..), Status(..), Proc(..), CurrentStatus(..), requestNew, requestDestroy, uriValidate, setURI, setProxy, setType, setBody, setSync, prepare, setChunksize, setHeader, process, getStatus, getHeader, close, clean, getSocket, getBody, getError, {-parseDate,-} setAuthinfo, setProxyAuthinfo) where -- C->HS marshalling library -- import C2HS import Monad (liftM, when) import IOExts (unsafePerformIO) {#context lib="libghttp" prefix="ghttp"#} -- data structures -- --------------- -- abstract handle for a http request object (EXPORTED ABSTRACTLY) -- newtype Request = Request Addr -- Uniform Resource Indicators (EXPORTED) -- type URI = String -- body type (EXPORTED) -- {#enum ghttp_type as Type {underscoreToCase}#} -- synchronous/asynchronous mode (EXPORTED) -- {#enum sync_mode as SyncMode {underscoreToCase}#} -- request status (EXPORTED) -- {#enum status as Status {underscoreToCase}#} -- describes the activity of a request (EXPORTED) -- {#enum proc as Proc {underscoreToCase}#} -- status descriptor (EXPORTED) -- data CurrentStatus = CurrentStatus { proc :: Proc, -- What's it doing? bytesRead :: Int, -- How many bytes have been read? bytesTotal :: Int -- How many bytes total? } -- error types -- invalidURI, illegalRequest :: String invalidURI = "Ghttp: The Uniform Resource Indicator is invalid." illegalRequest = "Ghttp: The request is illegal or unsupported." -- functions -- --------- -- create a new request object (EXPORTED) -- requestNew :: IO Request requestNew = liftM Request {#call unsafe request_new#} -- delete a current request object (EXPORTED) -- requestDestroy :: Request -> IO () requestDestroy (Request reqa) = {#call unsafe request_destroy#} reqa -- validate a uri (EXPORTED) -- uriValidate :: URI -> Bool uriValidate uri = let res = unsafePerformIO $ {#call unsafe uri_validate#} `marsh1_` (stdAddr uri :> free) in res == -1 -- set a uri in a request (EXPORTED) -- -- * raise an exception if the URI is not valid -- setURI :: Request -> URI -> IO () setURI (Request reqa) uri = {#call unsafe set_uri#} reqa `marsh1_` (stdAddr uri :> free) `ifNegRaise_` invalidURI -- set a proxy for a request (EXPORTED) -- -- * raise an exception if the request is not valid -- setProxy :: Request -> URI -> IO () setProxy (Request reqa) uri = {#call unsafe set_proxy#} reqa `marsh1_` (stdAddr uri :> free) `ifNegRaise_` illegalRequest -- set a request type (EXPORTED) -- -- * raise an exception if the request is not valid -- setType :: Request -> Type -> IO () setType (Request reqa) rtype = {#call unsafe set_type#} reqa (cFromEnum rtype) `ifNegRaise_` illegalRequest -- set the body (EXPORTED) -- -- * raise an exception if the request is not valid -- setBody :: Request -> String -> IO () setBody (Request reqa) body = do (box, len) <- listToAddrWithLen body {#call unsafe set_body#} reqa box (cFromInt len) `ifNegRaise_` illegalRequest -- set whether or not you want to use sync or async mode (EXPORTED) -- -- * raise an exception if the request is not valid -- setSync :: Request -> SyncMode -> IO () setSync (Request reqa) smode = {#call unsafe set_sync#} reqa (cFromEnum smode) `ifNegRaise_` illegalRequest -- Prepare a request; call this before trying to process a request or if you -- change the uri (EXPORTED) -- -- * raise an exception if the request is not valid -- prepare :: Request -> IO () prepare (Request reqa) = {#call unsafe prepare#} reqa `ifNegRaise_` illegalRequest -- set the chunk size; you might want to do this to optimize for different -- connection speeds (EXPORTED) -- setChunksize :: Request -> Int -> IO () setChunksize (Request reqa) size = {#call unsafe set_chunksize#} reqa (cFromInt size) -- set a random request header (EXPORTED) -- setHeader :: Request -> String -> String -> IO () setHeader (Request reqa) hdr val = {#call unsafe set_header#} reqa `marsh2_` (stdAddr hdr :> free) $ (stdAddr val :> free) -- process a request (EXPORTED) -- process :: Request -> IO Status process (Request reqa) = liftM cToEnum $ {#call unsafe process#} reqa -- get the status of a request (EXPORTED) -- getStatus :: Request -> IO CurrentStatus getStatus (Request reqa) = {#call unsafe ghttpHS_get_status #} reqa >>= cFromCurrentStatus -- get the value of a random response header (EXPORTED) -- getHeader :: Request -> String -> IO String getHeader (Request reqa) hdr = {#call unsafe get_header#} reqa `marsh1_` (stdAddr hdr :> free) >>= addrStd -- abort a currently running request (EXPORTED) -- -- * raise an exception if the request is not valid -- close :: Request -> IO () close (Request reqa) = {#call unsafe close#} reqa `ifNegRaise_` illegalRequest -- clean a request (EXPORTED) -- clean :: Request -> IO () clean (Request reqa) = {#call unsafe clean#} reqa -- get the socket associated with a particular connection (EXPORTED) -- -- * raise an exception if the request is not valid -- getSocket :: Request -> IO Int getSocket (Request reqa) = {#call unsafe get_socket#} reqa `ifNegRaise` illegalRequest -- get the return entity body (EXPORTED) -- -- * this includes getting the length with `ghttp_get_body_len', as the string -- is not necessarily \0 terminated -- getBody :: Request -> IO String getBody (Request reqa) = do bodyAddr <- {#call unsafe get_body#} reqa `ifNullRaise` illegalRequest bodyLen <- {#call unsafe get_body_len#} reqa addrWithLenToList bodyAddr (cToInt bodyLen) -- get an error message for a request that has failed (EXPORTED) -- getError :: Request -> IO String getError (Request reqa) = {#call unsafe get_error#} reqa >>= addrStd -- parse a date string that is one of the standard date formats (EXPORTED) -- {-parseDate :: String -> CalendarTime parseDate str = do time_t <- {#call unsafe parse_date#} `fromString` str time <- toCalendarTime -} -- return the status code (EXPORTED) -- statusCode :: Request -> IO Int statusCode (Request reqa) = liftM cToInt $ {#call unsafe status_code#} reqa -- return the reason phrase (EXPORTED) -- -- * raise an exception if the request is not valid -- reasonPhrase :: Request -> IO String reasonPhrase (Request reqa) = ({#call unsafe reason_phrase#} reqa `ifNullRaise` illegalRequest ) >>= addrStd -- set your username/password pair (EXPORTED) -- -- * raise an exception if the request is not valid -- setAuthinfo :: Request -> String -> String -> IO () setAuthinfo (Request reqa) user pass = ({#call unsafe set_authinfo#} reqa `marsh2_` (stdAddr user :> free) $ (stdAddr pass :> free) ) `ifNegRaise_` illegalRequest -- set your username/password pair for proxy (EXPORTED) -- -- * raise an exception if the request is not valid -- setProxyAuthinfo :: Request -> String -> String -> IO () setProxyAuthinfo (Request reqa) user pass = ({#call unsafe set_proxy_authinfo#} reqa `marsh2_` (stdAddr user :> free) $ (stdAddr pass :> free) ) `ifNegRaise_` illegalRequest -- auxiliary marshalling function -- ------------------------------- -- marshal the elements of a `ghttp_current_status' struct to Haskell land -- -- * frees the C struct -- cFromCurrentStatus :: Addr -> IO CurrentStatus cFromCurrentStatus csPtr = do proc <- liftM cToEnum$ {#get current_status.proc#} csPtr read <- liftM cToInt $ {#get current_status.bytes_read#} csPtr total<- liftM cToInt $ {#get current_status.bytes_total#} csPtr free csPtr return $ CurrentStatus { proc = proc, bytesRead = read, bytesTotal = total } ================================================ FILE: examples/libghttpHS/Makefile ================================================ # GnomeHaskell bindings: Gnome HTTP library # # Author : Manuel M. T. Chakravarty # Created: 8 October 1999 # # Copyright (c) 1999 Manuel M. T. Chakravarty # # This file 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 file 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. # # = DOCU ===================================================================== # # = TODO ===================================================================== # # * Let configure do the dirty work; how about automake # the commented out variants are to be used if the directory is moved out of # the C->HS source tree # GHC=ghc #C2HS=c2hs C2HS=../../c2hs GHTTP_HEADER=ghttpHS.h #HCFLAGS=`c2hs-config --cflags` HCFLAGS=-i../../lib -fglasgow-exts OBJS=Ghttp.o ghttpHS.o Ghttp.hs: Ghttp.chs ghttpHS.h $(C2HS) $(GHTTP_HEADER) Ghttp.chs Ghttp.o: Ghttp.hs ghttpHS.h $(GHC) '-#include"ghttpHS.h"' $(HCFLAGS) -c $< ghttpHS.o: ghttpHS.h ghttpHS.c libghttpHS.a: $(OBJS) -$(RM) $@ $(AR) -crs $@ $(OBJS) ================================================ FILE: examples/libghttpHS/ghttpHS.c ================================================ /* Auxiliary C code for Ghttp. * * Copyright (c) 1999 Manuel M. T. Chakravarty * * This is required due to the inability of GHC's FFI to pass structures from C * to Haskell. */ #include "ghttpHS.h" ghttp_current_status *ghttpHS_get_status (ghttp_request *a_request) { ghttp_current_status *status; status = (ghttp_current_status *) malloc (sizeof (ghttp_current_status)); if (!status) { printf ("Ghttp: ghttpHS_get_status: Out of memory!"); exit (1); } *status = ghttp_get_status (a_request); return status; } ================================================ FILE: examples/libghttpHS/ghttpHS.h ================================================ /* Auxiliary C code for Ghttp. * * Copyright (c) 1999 Manuel M. T. Chakravarty * * This is required due to the inability of GHC's FFI to pass structures from C * to Haskell. */ #ifndef __GHTTPHS_H__ #define __GHTTPHS_H__ #include /* returns a reference to a newly allocated memory area holding the result of * the corresponding vanilla `libghttp' function */ ghttp_current_status *ghttpHS_get_status (ghttp_request *a_request); #endif /* __GHTTPHS_H__ */ ================================================ FILE: import-handling.md ================================================ ## Potentially breaking changes: import handling #### The problem Previous releases of C2HS had an annoying misfeature -- you had to manage the imports of Haskell library functions in C2HS-generated code yourself. Suppose you had the following code in a `.chs` file: ``` haskell #include "issue44.h" {#pointer *foo as ^ foreign newtype#} ``` where the contents of the `issue44.h` header are: ``` c typedef struct { int a; } foo; ``` Running C2HS would then generate the following Haskell code: ``` haskell newtype Foo = Foo (ForeignPtr (Foo)) withFoo :: Foo -> (Ptr Foo -> IO b) -> IO b withFoo (Foo fptr) = withForeignPtr fptr ``` Note the use of the names `ForeignPtr`, `Ptr` and `withForeignPtr`. These come from the Haskell library modules `Foreign.Ptr` and `Foreign.ForeignPtr`, but C2HS didn't generate any `import` declarations to make these modules accessible. This meant that there would normally be a bit of back and forth when writing C2HS code: write your bindings, run C2HS, try compiling with GHC, have the compile fail because of missing imports, add the imports to your `.chs` file and repeat. Kind of annoying. As well as being annoying, the lack of import declaration generation meant that it was sometimes impossible to make internal changes to the way that C2HS binds to C functions without breaking existing user code. The example that finally drove me to try to fix this was issue 130 (https://github.com/haskell/c2hs/issues/130) that required a change that would lead to most C2HS code now needing to import `unsafePerformIO`. It didn't seem like a good idea to push a change like that (that would break more or less all C2HS code out there!) without fixing the import problem (so that the change for issue #130 could happen transparently to all existing working C2HS code). #### The solution The solution I ended up with is pretty simple, but I think it's robust. For the example above, C2HS now generates the following Haskell code: ``` haskell import qualified Foreign.ForeignPtr as C2HSImp import qualified Foreign.Ptr as C2HSImp newtype Foo = Foo (C2HSImp.ForeignPtr (Foo)) withFoo :: Foo -> (C2HSImp.Ptr Foo -> IO b) -> IO b withFoo (Foo fptr) = C2HSImp.withForeignPtr fptr ``` All library symbols needed to generate Haskell binding code are now qualified under the name `C2HSImp` and the relevant library modules are imported qualified as `C2HSImp`. The end result of this is that you still need to import modules only for names that you explicitly use (so if you use `alloca` in an input marshaller, you need to import `Foreign.Marshal.Alloc`). All external names that C2HS uses in code that it generates should be imported automatically. #### Potential complaints 1. Modules compiled with `-Werror` may now fail because of unused import warnings. This was something I had to deal with for most of the C2HS test cases (since they all imported the required library modules and they're mostly compiled with `-Werror`), but since the community consensus seems to be that `-Werror` shouldn't be used in released code, I think it's reasonable to allow the possibility of this kind of breakage. 2. It's possible that the code I wrote for deciding where to put the extra import declarations isn't quite perfect. I tried a couple of different solutions, but ended up with a hand-made "find the first safe place to add imports" function that relies quite heavily on the details of C2HS's CHS file parser. I did try a solution based on `haskell-src-exts`, but this didn't work very well, because `haskell-src-exts` doesn't support all available GHC extensions and I would have needed some mechanism to propagate extension information from Cabal files to C2HS to make the parsing work. These changes have been tested reasonably extensively -- all of the core C2HS tests pass, and the following packages are known to work (they're all in the regression suite): abcBridge, alsa-mixer, cuda, cufft, gnome-keyring, gnuidn, haskell-mpi, hnetcdf, hpuz, hsndfile, hsshellscript, igraph, libssh2. I'll be adding more packages to the regression suite, but if there's a package you're particularly concerned about that's not on this list, let me know. ================================================ FILE: regression-suite-vm/Vagrantfile ================================================ Vagrant.configure("2") do |config| config.vm.box = "c2hs-regression-suite.box" config.vm.provider :virtualbox do |vb| vb.gui = false vb.customize ["modifyvm", :id, "--memory", "2048"] vb.customize ["modifyvm", :id, "--cpus", "2"] end end ================================================ FILE: regression-suite-vm/Vagrantfile-full ================================================ $script = <