packages feed

inline-c-cpp 0.5.0.1 → 0.5.0.2

raw patch · 3 files changed

+65/−3 lines, 3 filesnew-uploader

Files

inline-c-cpp.cabal view
@@ -1,6 +1,6 @@ cabal-version:       2.2 name:                inline-c-cpp-version:             0.5.0.1+version:             0.5.0.2 synopsis:            Lets you embed C++ code into Haskell. description:         Utilities to inline C++ code into Haskell using inline-c.  See                      tests for example on how to build.@@ -10,7 +10,7 @@ maintainer:          f@mazzo.li copyright:           (c) 2015-2016 FP Complete Corporation, (c) 2017-2019 Francesco Mazzoli category:            FFI-tested-with:         GHC == 8.4.4, GHC == 8.6.5, GHC == 8.8.4, GHC == 8.10.2+tested-with:         GHC == 9.2.8, GHC == 9.4.7, GHC == 9.6.2 build-type:          Simple extra-source-files:  test/*.h @@ -47,6 +47,11 @@     extra-libraries: c++     -- avoid https://gitlab.haskell.org/ghc/ghc/issues/11829     ld-options:  -Wl,-keep_dwarf_unwind+    -- Same issue, new fix https://gitlab.haskell.org/ghc/ghc/-/merge_requests/7247+    -- Probably will be redundant in >=9.4 https://gitlab.haskell.org/ghc/ghc/-/merge_requests/7423+    if impl(ghc >= 9.2.2 && < 9.4)+      ghc-options:+        -fcompact-unwind    if impl(ghc >= 8.10)     ghc-options:
src/Language/C/Inline/Cpp/Exception.hs view
@@ -210,9 +210,10 @@  tryBlockQuoteExp :: QuasiQuoter -> String -> Q Exp tryBlockQuoteExp block blockStr = do-  let (ty, body) = C.splitTypedC blockStr+  let (ty, body, bodyLineShift) = C.splitTypedC blockStr   _ <- C.include "HaskellException.hxx"   basePtrVarName <- newName "basePtr"+  there <- location   let inlineCStr = unlines         [ ty ++ " {"         , "  void** __inline_c_cpp_base_ptr__ = $(void** " ++ nameBase basePtrVarName ++ ");"@@ -223,7 +224,9 @@         , "  HaskellException** __inline_c_cpp_haskellexception__ = (HaskellException**)(__inline_c_cpp_base_ptr__ + 4);"         , "  *__inline_c_cpp_exception_type__ = 0;"         , "  try {"+        , C.lineDirective (C.shiftLines (bodyLineShift - 1) there)         , body+        , C.lineDirective $(C.here)         , "  } catch (const HaskellException &e) {"         , "    *__inline_c_cpp_exception_type__ = " ++ show ExTypeHaskellException ++ ";"         , "    *__inline_c_cpp_haskellexception__ = new HaskellException(e);"
test/tests.hs view
@@ -284,6 +284,60 @@        result `shouldBeRight` 0xDEADBEEF +    Hspec.it "code can contain preprocessor directives" $ do+      result <- try $ [C.throwBlock| int {+          #ifndef THE_MACRO_THAT_HAS_NOT_BEEN_DEFINED+          return 0xDEADBEEF;+          #else+          return 0xBEEFCAFE;+          #endif+        } |]++      result `shouldBeRight` 0xDEADBEEF++    {- Manual test cases for testing lineDirective and splitTypedC -- For CI, uncomment this line.++    Hspec.it "error reporting test case" $ do+      result <- try $ [C.throwBlock| int { 0 = 0; return 0xDEADBEEF; /* Test this line. */}|]+      result `shouldBeRight` 0xDEADBEEF++    Hspec.it "error reporting test case" $ do+      result <- try $ [C.throwBlock| int+        { 1 = 1; return 0xDEADBEEF; /* Test this line. */}+      |]+      result `shouldBeRight` 0xDEADBEEF++    Hspec.it "error reporting test case" $ do+      result <- try $ [C.throwBlock| int+        {+          2 = 2; /* Test this line. */+          return 0xDEADBEEF;+        }+      |]+      result `shouldBeRight` 0xDEADBEEF++    Hspec.it "error reporting test case" $ do+      result <- try $ [C.throwBlock|+        int+        {+          3 = 3;  /* Test this line. */+          return 0xDEADBEEF;+        }+      |]+      result `shouldBeRight` 0xDEADBEEF++    Hspec.it "error reporting test case" $ do+      result <- try $ [C.throwBlock|++        int+        {+          4 = 4;  /* Test this line. */+          return 0xDEADBEEF;+        }+      |]+      result `shouldBeRight` 0xDEADBEEF+    -- For CI, uncomment this line. -}+   Hspec.describe "Macros" $ do     Hspec.it "generated std::vector instances work correctly" $ do       intVec <- StdVector.new @C.CInt