packages feed

haskell-gi 0.21.3 → 0.21.4

raw patch · 4 files changed

+26/−20 lines, 4 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Data.GI.CodeGen.Conversions: getIsScalar :: Type -> CodeGen Bool

Files

ChangeLog.md view
@@ -1,3 +1,7 @@+### 0.21.4+++ Try to guess signedness of enums and flags on the C side, fixes [#184](https://github.com/haskell-gi/haskell-gi/issues/184).+ ### 0.21.3  + Do not add nodes in overrides if a node with the same name already exists, fixes [#171](https://github.com/haskell-gi/haskell-gi/issues/171).
haskell-gi.cabal view
@@ -1,5 +1,5 @@ name:                haskell-gi-version:             0.21.3+version:             0.21.4 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.
lib/Data/GI/CodeGen/Conversions.hs view
@@ -26,7 +26,6 @@     , maybeNullConvert     , nullPtrForType -    , getIsScalar     , typeAllocInfo     , TypeAllocInfo(..) @@ -378,7 +377,7 @@   hToF_PackedType t (packer <> "PtrArray") transfer  hToF (TCArray zt _ _ t@(TInterface _)) transfer = do-  isScalar <- getIsScalar t+  isScalar <- typeIsEnumOrFlag t   let packer = if zt                then "packZeroTerminated"                else "pack"@@ -562,7 +561,7 @@ fToH (TCArray True _ _ t@(TCArray{})) transfer =   fToH_PackedType t "unpackZeroTerminatedPtrArray" transfer fToH (TCArray True _ _ t@(TInterface _)) transfer = do-  isScalar <- getIsScalar t+  isScalar <- typeIsEnumOrFlag t   if isScalar   then fToH_PackedType t "unpackZeroTerminatedStorableArray" transfer   else fToH_PackedType t "unpackZeroTerminatedPtrArray" transfer@@ -642,7 +641,7 @@                          "unpackStorableArrayWithLength " <> length     TInterface _ -> do            a <- findAPI t-           isScalar <- getIsScalar t+           isScalar <- typeIsEnumOrFlag t            hType <- haskellType t            fType <- foreignType t            innerConstructor <- fToH' t a hType fType transfer@@ -843,21 +842,24 @@ foreignType (TInterface (Name "GObject" "Value")) =   return $ ptr $ "GValue" `con` [] foreignType t@(TInterface n) = do-  isScalar <- getIsScalar t-  if isScalar-  then return $ "CUInt" `con` []-  else do-    api <- getAPI t-    case api of-      APICallback _ -> do-         tname <- qualifiedSymbol (callbackCType $ name n) n-         return (funptr $ tname `con` [])-      _ -> do-         tname <- qualifiedAPI n-         return (ptr $ tname `con` [])+  api <- getAPI t+  let enumIsSigned e = any (< 0) (map enumMemberValue (enumMembers e))+      ctypeForEnum e = if enumIsSigned e+                       then "CInt"+                       else "CUInt"+  case api of+    APIEnum e -> return $ (ctypeForEnum e) `con` []+    APIFlags (Flags e) -> return $ (ctypeForEnum e) `con` []+    APICallback _ -> do+      tname <- qualifiedSymbol (callbackCType $ name n) n+      return (funptr $ tname `con` [])+    _ -> do+      tname <- qualifiedAPI n+      return (ptr $ tname `con` []) -getIsScalar :: Type -> CodeGen Bool-getIsScalar t = do+-- | Whether the give type corresponds to an enum or flag.+typeIsEnumOrFlag :: Type -> CodeGen Bool+typeIsEnumOrFlag t = do   a <- findAPI t   case a of     Nothing -> return False
lib/Data/GI/CodeGen/Haddock.hs view
@@ -215,7 +215,7 @@         Nothing -> "/No description available in the introspection data./"   description <> case sinceVersion doc of                    Nothing -> ""-                   Just ver -> "\n\n@since " <> ver+                   Just ver -> "\n\n/Since: " <> ver <> "/"  -- | Write the given documentation into generated code. writeDocumentation :: RelativeDocPosition -> Documentation -> CodeGen ()