Hello community,

here is the log from the commit of package ghc-inline-c for openSUSE:Factory 
checked in at 2017-02-11 01:41:08
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/ghc-inline-c (Old)
 and      /work/SRC/openSUSE:Factory/.ghc-inline-c.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "ghc-inline-c"

Changes:
--------
--- /work/SRC/openSUSE:Factory/ghc-inline-c/ghc-inline-c.changes        
2016-11-10 13:22:15.000000000 +0100
+++ /work/SRC/openSUSE:Factory/.ghc-inline-c.new/ghc-inline-c.changes   
2017-02-11 01:41:10.233116977 +0100
@@ -1,0 +2,5 @@
+Thu Jan 26 16:21:52 UTC 2017 - [email protected]
+
+- Update to version 0.5.6.1 with cabal2obs.
+
+-------------------------------------------------------------------

Old:
----
  inline-c-0.5.5.9.tar.gz

New:
----
  inline-c-0.5.6.1.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ ghc-inline-c.spec ++++++
--- /var/tmp/diff_new_pack.iPgqdf/_old  2017-02-11 01:41:11.744903654 +0100
+++ /var/tmp/diff_new_pack.iPgqdf/_new  2017-02-11 01:41:11.744903654 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package ghc-inline-c
 #
-# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -19,7 +19,7 @@
 %global pkg_name inline-c
 %bcond_with tests
 Name:           ghc-%{pkg_name}
-Version:        0.5.5.9
+Version:        0.5.6.1
 Release:        0
 Summary:        Write Haskell source files including C code inline. No FFI 
required
 License:        MIT

++++++ inline-c-0.5.5.9.tar.gz -> inline-c-0.5.6.1.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/inline-c-0.5.5.9/README.md 
new/inline-c-0.5.6.1/README.md
--- old/inline-c-0.5.5.9/README.md      2016-06-15 11:26:10.000000000 +0200
+++ new/inline-c-0.5.6.1/README.md      2017-01-21 13:30:18.000000000 +0100
@@ -307,9 +307,10 @@
 Each module that uses at least one of the `inline-c` functions gets a C
 file associated to it, where the filename of said file will be the same
 as the module but with a C extension.  This C file must be built after
-the Haskell code and linked appropriately.  If you use cabal, all you
-have to do is declare each associated C file in the `.cabal` file and
-you are good.
+the Haskell code and linked appropriately.
+
+If you use cabal, you **must** manually declare each associated C file in
+the `c-sources` section of the `.cabal` file and you are good.
 
 For example we might have
 
@@ -317,10 +318,13 @@
 executable foo
   main-is:             Main.hs, Foo.hs, Bar.hs
   hs-source-dirs:      src
+
+  -- IMPORTANT!
   -- Here the corresponding C sources must be listed for every module
   -- that uses C code.  In this example, Main.hs and Bar.hs do, but
   -- Foo.hs does not.
   c-sources:           src/Main.c, src/Bar.c
+
   -- These flags will be passed to the C compiler
   cc-options:          -Wall -O2
   -- Libraries to link the code with.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/inline-c-0.5.5.9/changelog.md 
new/inline-c-0.5.6.1/changelog.md
--- old/inline-c-0.5.5.9/changelog.md   2016-09-15 13:28:42.000000000 +0200
+++ new/inline-c-0.5.6.1/changelog.md   2017-01-21 13:30:18.000000000 +0100
@@ -1,3 +1,4 @@
+- 0.5.6.0: Add `ForeignPtr` anti-quoter
 - 0.5.5.9: Make tests work with QuickCheck < 2.9
 - 0.5.5.8: Add workaround for QuickCheck-2.9 bug. See issue #51
 - 0.5.5.2: Add docs regarding internals. See issue #41.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/inline-c-0.5.5.9/inline-c.cabal 
new/inline-c-0.5.6.1/inline-c.cabal
--- old/inline-c-0.5.5.9/inline-c.cabal 2016-09-15 13:28:42.000000000 +0200
+++ new/inline-c-0.5.6.1/inline-c.cabal 2017-01-21 13:30:18.000000000 +0100
@@ -1,5 +1,5 @@
 name:                inline-c
-version:             0.5.5.9
+version:             0.5.6.1
 synopsis:            Write Haskell source files including C code inline. No 
FFI required.
 description:         See 
<https://github.com/fpco/inline-c/blob/master/README.md>.
 license:             MIT
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/inline-c-0.5.5.9/src/Language/C/Inline/Context.hs 
new/inline-c-0.5.6.1/src/Language/C/Inline/Context.hs
--- old/inline-c-0.5.5.9/src/Language/C/Inline/Context.hs       2016-07-04 
11:41:41.000000000 +0200
+++ new/inline-c-0.5.6.1/src/Language/C/Inline/Context.hs       2017-01-21 
13:30:18.000000000 +0100
@@ -35,6 +35,7 @@
     -- * 'Context'
   , Context(..)
   , baseCtx
+  , fptrCtx
   , funCtx
   , vecCtx
   , VecCtx(..)
@@ -47,6 +48,7 @@
 import           Control.Monad.Trans.Maybe (MaybeT, runMaybeT)
 import qualified Data.ByteString as BS
 import qualified Data.ByteString.Unsafe as BS
+import           Data.Coerce
 import           Data.Int (Int8, Int16, Int32, Int64)
 import qualified Data.Map as Map
 import           Data.Monoid ((<>))
@@ -55,6 +57,7 @@
 import qualified Data.Vector.Storable.Mutable as VM
 import           Data.Word (Word8, Word16, Word32, Word64)
 import           Foreign.C.Types
+import           Foreign.ForeignPtr (withForeignPtr)
 import           Foreign.Ptr (Ptr, FunPtr, freeHaskellFunPtr)
 import           Foreign.Storable (Storable)
 import qualified Language.Haskell.TH as TH
@@ -290,6 +293,24 @@
     Nothing -> fail $ "Cannot convert C type (" ++ err ++ ")"
     Just hsType -> return hsType
 
+-- | This 'Context' adds support for 'ForeignPtr' arguments. It adds a unique
+-- marshaller called @fptr-ptr@. For example, @$fptr-ptr:$(int *x)@ extracts 
the
+-- bare C pointer out of foreign pointer @x@.
+fptrCtx :: Context
+fptrCtx = mempty
+  { ctxAntiQuoters = Map.fromList [("fptr-ptr", SomeAntiQuoter fptrAntiQuoter)]
+  }
+
+fptrAntiQuoter :: AntiQuoter HaskellIdentifier
+fptrAntiQuoter = AntiQuoter
+  { aqParser = cDeclAqParser
+  , aqMarshaller = \purity cTypes cTy cId -> do
+      hsTy <- convertType_ "fptrCtx" purity cTypes cTy
+      hsExp <- getHsVariable "fptrCtx" cId
+      hsExp' <- [| withForeignPtr (coerce $(return hsExp)) |]
+      return (hsTy, hsExp')
+  }
+
 -- | This 'Context' includes a 'AntiQuoter' that removes the need for
 -- explicitely creating 'FunPtr's, named @"fun"@.
 --
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/inline-c-0.5.5.9/src/Language/C/Inline.hs 
new/inline-c-0.5.6.1/src/Language/C/Inline.hs
--- old/inline-c-0.5.5.9/src/Language/C/Inline.hs       2016-07-04 
11:38:47.000000000 +0200
+++ new/inline-c-0.5.6.1/src/Language/C/Inline.hs       2017-01-21 
13:30:18.000000000 +0100
@@ -25,6 +25,7 @@
     -- * Contexts
     Context
   , baseCtx
+  , fptrCtx
   , funCtx
   , vecCtx
   , bsCtx
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/inline-c-0.5.5.9/test/tests.c 
new/inline-c-0.5.6.1/test/tests.c
--- old/inline-c-0.5.5.9/test/tests.c   2016-09-15 13:27:24.000000000 +0200
+++ new/inline-c-0.5.6.1/test/tests.c   2017-01-21 13:30:18.000000000 +0100
@@ -146,12 +146,7 @@
 }
 
 
-int inline_c_Main_22_dbf060cb8fa2b86c6c6838ef9b645ac20f38ba79(int 
_e4_inline_c_0) {
-return ( _e4_inline_c_0 );
-}
-
-
-int inline_c_Main_23_2421969c444755bea2c6f2060e0921ce7f3d16d7(int 
PreludemaxBound_2e_inline_c_0) {
-return ( PreludemaxBound_2e_inline_c_0 );
+int inline_c_Main_22_a3bae806835fddf243d045e57f2ba979bc7961cc(int 
foobar_inline_c_0) {
+return ( foobar_inline_c_0 );
 }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/inline-c-0.5.5.9/test/tests.hs 
new/inline-c-0.5.6.1/test/tests.hs
--- old/inline-c-0.5.5.9/test/tests.hs  2016-06-15 11:26:10.000000000 +0200
+++ new/inline-c-0.5.6.1/test/tests.hs  2017-01-21 13:30:18.000000000 +0100
@@ -6,6 +6,8 @@
 import           Data.Monoid ((<>))
 import qualified Data.Vector.Storable.Mutable as V
 import           Foreign.C.Types
+import           Foreign.ForeignPtr (mallocForeignPtrBytes)
+import           Foreign.ForeignPtr.Unsafe (unsafeForeignPtrToPtr)
 import qualified Language.Haskell.TH as TH
 import           Prelude
 import qualified Test.Hspec as Hspec
@@ -22,7 +24,7 @@
 
 import           Dummy
 
-C.context (C.baseCtx <> C.funCtx <> C.vecCtx <> C.bsCtx)
+C.context (C.baseCtx <> C.fptrCtx <> C.funCtx <> C.vecCtx <> C.bsCtx)
 
 C.include "<math.h>"
 C.include "<stddef.h>"
@@ -106,6 +108,10 @@
       let y = 9
       u32 <- [C.exp| uint32_t { $(uint32_t y) * 7 } |]
       u32 `Hspec.shouldBe` 63
+    Hspec.it "foreign pointer argument" $ do
+      fptr <- mallocForeignPtrBytes 32
+      ptr <- [C.exp| int* { $fptr-ptr:(int *fptr) } |]
+      ptr `Hspec.shouldBe` unsafeForeignPtrToPtr fptr
     Hspec.it "function pointer argument" $ do
       let ackermann m n
             | m == 0 = n + 1


Reply via email to