packages feed

haskell-gi 0.26.2 → 0.26.3

raw patch · 5 files changed

+35/−22 lines, 5 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

haskell-gi.cabal view
@@ -1,5 +1,5 @@ name:                haskell-gi-version:             0.26.2+version:             0.26.3 synopsis:            Generate Haskell bindings for GObject Introspection capable libraries description:         Generate Haskell bindings for GObject Introspection capable libraries. This includes most notably                      Gtk+, but many other libraries in the GObject ecosystem provide introspection data too.@@ -20,7 +20,7 @@ custom-setup  setup-depends:    base >= 4 && <5,-   Cabal,+   Cabal == 3.*,    cabal-doctest >= 1  source-repository head
lib/Data/GI/CodeGen/Code.hs view
@@ -71,6 +71,7 @@ import Control.Applicative ((<$>)) import Data.Monoid (Monoid(..)) #endif+import Control.Monad (forM, unless, when) import Control.Monad.Reader import Control.Monad.State.Strict import Control.Monad.Except
lib/Data/GI/CodeGen/Overrides.hs view
@@ -11,6 +11,7 @@ import Data.Traversable (traverse) #endif +import Control.Monad (foldM) import Control.Monad.Except import Control.Monad.State import Control.Monad.Writer (WriterT, execWriterT, tell)
lib/Data/GI/CodeGen/Signal.hs view
@@ -99,7 +99,8 @@         maybeOwner       forM_ (args cb) $ \arg -> do         ht <- foreignType $ argType arg-        let ht' = if direction arg /= DirectionIn+        let ht' = if direction arg /= DirectionIn &&+                     not (argCallerAllocates arg)                   then ptr ht                   else ht         line $ typeShow ht' <> " ->"@@ -276,7 +277,7 @@ -- callback for ScopeTypeCall, or a destroy notifier for -- ScopeTypeNotified). genCallbackWrapper :: Text -> Callable -> Text ->-                      Maybe Text -> ExcCodeGen ()+                      Maybe Text -> CodeGen e () genCallbackWrapper subsec cb name' maybeOwner = group $ do   let wrapperName = callbackHaskellToForeign name'       (hInArgs, _) = callableHInArgs cb WithClosures@@ -308,7 +309,12 @@                   then T.unwords $ ["gi'cb", "gi'selfPtr"] <> cArgNames <> ["_"]                   else T.unwords $ ["gi'funptrptr", "gi'cb"] <> cArgNames     line $ wrapperName <> " " <> allArgs <> " = do"-    indent $ do+    handleCGExc (\e -> indent $ do+                   line $ "-- XXX Could not generate callback wrapper for "+                          <> name'+                   printCGError e+                   line $ "P.error \"The bindings for " <> wrapperName <> " could not be generated, function unsupported.\""+                ) $ indent $ do       hInNames <- forM hInArgs (prepareArgForCall cb)        let maybeReturn = case returnType cb of
lib/Data/GI/CodeGen/Struct.hs view
@@ -33,7 +33,8 @@                                      callbackHaskellToForeign,                                      callbackWrapperAllocator,                                      haddockAttrAnchor, moduleLocation,-                                     hackageModuleLink)+                                     hackageModuleLink,+                                     normalizedAPIName)  import Data.GI.CodeGen.Type import Data.GI.CodeGen.Util@@ -257,24 +258,27 @@          <> ") ("  <> nullPtr <> " :: " <> fType <> ")"  -- | Return whether the given type corresponds to a callback that does--- not throw exceptions. See [Note: Callables that throw] for the--- reason why we do not try to wrap callbacks that throw exceptions.-isRegularCallback :: Type -> CodeGen e Bool+-- not throw exceptions. If it is, return the callback itself. See+-- [Note: Callables that throw] for the reason why we do not try to+-- wrap callbacks that throw exceptions.+isRegularCallback :: Type -> CodeGen e (Maybe Callback) isRegularCallback t@(TInterface _) = do   api <- getAPI t   case api of-    APICallback (Callback {cbCallable = callable}) ->-      return (not $ callableThrows callable)-    _ -> return False-isRegularCallback _ = return False+    APICallback callback@(Callback {cbCallable = callable}) ->+      if callableThrows callable+      then return Nothing+      else return (Just callback)+    _ -> return Nothing+isRegularCallback _ = return Nothing  -- | The types accepted by the allocating set function -- 'Data.GI.Base.Attributes.(:&=)'. fieldTransferTypeConstraint :: Type -> CodeGen e Text fieldTransferTypeConstraint t = do   isPtr <- typeIsPtr t-  isRegularCallback <- isRegularCallback t-  inType <- if isPtr && not isRegularCallback+  maybeRegularCallback <- isRegularCallback t+  inType <- if isPtr && not (isJust maybeRegularCallback)             then typeShow <$> foreignType t             else typeShow <$> isoHaskellType t   return $ "(~)" <> if T.any (== ' ') inType@@ -297,15 +301,16 @@ -- | Generate the field transfer function, which marshals Haskell -- values to types that we can set, even if we need to allocate memory. genFieldTransfer :: Text -> Type -> CodeGen e ()-genFieldTransfer var t@(TInterface tn@(Name _ n)) = do-  isRegularCallback <- isRegularCallback t-  if isRegularCallback-    then do-      wrapper <- qualifiedSymbol (callbackHaskellToForeign n) tn-      maker <- qualifiedSymbol (callbackWrapperAllocator n) tn+genFieldTransfer var t@(TInterface tn) = do+  maybeRegularCallback <- isRegularCallback t+  case maybeRegularCallback of+    Just callback -> do+      let Name _ name' = normalizedAPIName (APICallback callback) tn+      wrapper <- qualifiedSymbol (callbackHaskellToForeign name') tn+      maker <- qualifiedSymbol (callbackWrapperAllocator name') tn       line $ maker <> " " <>         parenthesize (wrapper <> " Nothing " <> var)-    else line $ "return " <> var+    Nothing -> line $ "return " <> var genFieldTransfer var _ = line $ "return " <> var  -- | Haskell name for the field