packages feed

C-structs 0.2.0.2 → 0.2.0.3

raw patch · 6 files changed

+29/−9 lines, 6 filesdep ~template-haskellPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: template-haskell

API changes (from Hackage documentation)

Files

C-structs.cabal view
@@ -1,5 +1,5 @@ Name: C-structs-Version: 0.2.0.2+Version: 0.2.0.3 Cabal-Version: >= 1.10 License: MIT License-file: LICENSE@@ -13,12 +13,12 @@     This package is part of the development efforts for the Python library     Pythas. Pythas provides an interface to import Haskell modules.     .-    Note: As of GHC 8.10 structs cannot be passed by value, only by reference.+    Note: As of GHC 9.2 structs cannot be passed by value, only by reference. Maintainer: s.plakolb@gmail.com Category: foreign, c, structures, data Build-Type: Simple Extra-Source-Files: README.md, CHANGELOG.md, test/libs/c_test.c, test/libs/c_test.h-Tested-With: GHC==8.10.1, GHC==8.8.3, GHC==8.6.5, GHC==8.4.4, GHC==8.2.2, GHC==8.0.2, GHC==7.10.3, GHC==7.8.4, GHC==7.6.3, GHC==7.4.2, GHC==7.2.2, GHC==7.0.4+Tested-With: GHC==9.2.4, GHC==9.0.2, GHC==8.10.1, GHC==8.8.3, GHC==8.6.5, GHC==8.4.4, GHC==8.2.2, GHC==8.0.2, GHC==7.10.3, GHC==7.8.4, GHC==7.6.3, GHC==7.4.2, GHC==7.2.2, GHC==7.0.4  Source-Repository head     type: git@@ -37,7 +37,7 @@     Default-Language: Haskell2010     Build-Depends:         base >= 3.0.0 && < 5.0.0,-        template-haskell >= 2.2 && < 2.17+        template-haskell >= 2.2 && < 2.20     HS-Source-Dirs: src  Test-Suite unit-tests@@ -62,7 +62,7 @@         base         >= 3.0 && < 5.0,         HUnit        >= 1.2 && < 1.7,         QuickCheck   >= 2.10 && < 2.15,-        template-haskell >= 2.2 && < 2.17,+        template-haskell >= 2.2 && < 2.20,         test-framework  >= 0.4.1 && < 0.9,         test-framework-hunit >= 0.2.6 && < 0.4,         test-framework-quickcheck2 >= 0.3.0.4 && < 0.4
CHANGELOG.md view
@@ -1,3 +1,5 @@+v0.2.0.3: Update dependencies and testing for GHC 9.2+ v0.2.0.1: Remove re-exports of Foreign.C.Storable and Foreign.C.Ptr members  v0.1.0.2: Better Haddock and a fixed C-test template for GHC < 8.0
README.md view
@@ -1,11 +1,11 @@-# C-Structs in Haskell [![Haskell CI](https://github.com/pinselimo/cstructs-in-haskell/actions/workflows/haskell.yml/badge.svg)](https://github.com/pinselimo/cstructs-in-haskell/actions/workflows/haskell.yml) [![Hackage CI](https://matrix.hackage.haskell.org/api/v2/packages/C-structs/badge)](https://matrix.hackage.haskell.org/package/C-structs) [![Hackage Version](https://img.shields.io/hackage/v/C-structs.svg?label=Hackage)](http://hackage.haskell.org/package/C-structs) [![Dependencies of latest version on Hackage](https://img.shields.io/hackage-deps/v/C-structs.svg)](https://hackage.haskell.org/package/C-structs)+# C-Structs in Haskell [![Haskell CI](https://github.com/pinselimo/cstructs-in-haskell/actions/workflows/haskell.yml/badge.svg)](https://github.com/pinselimo/cstructs-in-haskell/actions/workflows/haskell.yml) <!-- [![Hackage CI](https://matrix.hackage.haskell.org/api/v2/packages/C-structs/badge)](https://matrix.hackage.haskell.org/package/C-structs) --> [![Hackage Version](https://img.shields.io/hackage/v/C-structs.svg?label=Hackage)](http://hackage.haskell.org/package/C-structs) [![Dependencies of latest version on Hackage](https://img.shields.io/hackage-deps/v/C-structs.svg)](https://hackage.haskell.org/package/C-structs)  C-structs lets you create dynamically typed and correctly padded C structs in Haskell. These can be used for FFI calls, imports and exports. This package is part of the development efforts for the Python library [```Pythas```](https://github.com/pinselimo/Pythas/). Pythas provides an interface to import Haskell modules. -Note: As of GHC 8.10 structs cannot be passed by value, [only by reference](https://wiki.haskell.org/Foreign_Function_Interface#Foreign_types).+Note: As of GHC 9.2 structs cannot be passed by value, [only by reference](https://wiki.haskell.org/Foreign_Function_Interface#Foreign_types).  ## Usage 
src/Foreign/C/Structs/Templates.hs view
@@ -57,7 +57,11 @@ structTypeT nfields = DataD [] (structType nfields) tyVars Nothing [constructor] [deriv] #endif     where+#if __GLASGOW_HASKELL__ < 900           tyVars    = map PlainTV $ take nfields $ fieldnames ""+#else+          tyVars    = map (flip PlainTV ()) $ take nfields $ fieldnames ""+#endif            constructor = RecC (structType nfields) $ take nfields records @@ -130,7 +134,11 @@            clause = Clause [VarP ptr] (NormalB body) [] +#if __GLASGOW_HASKELL__ < 900           body = DoE $ initial ++ concat gotos ++ final+#else+          body = DoE Nothing $ initial ++ concat gotos ++ final+#endif            initial = [ BindS (VarP $ head vars) (AppE (VarE 'peek) castPtr')                     , BindS (VarP $ head ptrs) (AppE (AppE (VarE 'next) $ VarE ptr) $ VarE $ head vars)@@ -150,13 +158,23 @@     where           vars = take nfields $ fieldnames "" +          types = take nfields $ fieldnames "_ty"+           ptrs = tail $ take nfields $ fieldnames "_ptr"            clause = Clause patterns (NormalB body) [] +#if __GLASGOW_HASKELL__ < 902           patterns = [VarP ptr, ConP (structType nfields) (map VarP vars)]+#else+          patterns = [VarP ptr, ConP (structType nfields) (map VarT types) (map VarP vars)]+#endif +#if __GLASGOW_HASKELL__ < 900           body = DoE $ [init_poke, init_next] ++ concat gotos ++ [final]+#else+          body = DoE Nothing $ [init_poke, init_next] ++ concat gotos ++ [final]+#endif            init_poke = NoBindS                     $ AppE cast_poke_ptr (VarE $ head vars)
src/Foreign/C/Structs/Types.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE TemplateHaskell, ScopedTypeVariables, TypeApplications #-} {- | Module          : Foreign.C.Structs.Types Description     : Create C structs from Haskell
test/UnitTests.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE TemplateHaskell, ScopedTypeVariables, TypeApplications #-} module UnitTests (     tests ) where