{- | Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte License : LGPL-2.1 Maintainer : Iñaki García Etxebarria (garetxe@gmail.com) The 'GI.Pango.Structs.Coverage.Coverage' structure represents a map from Unicode characters to 'GI.Pango.Enums.CoverageLevel'. It is an opaque structure with no public fields. -} module GI.Pango.Structs.Coverage ( -- * Exported types Coverage(..) , noCoverage , -- * Methods -- ** get #method:get# CoverageGetMethodInfo , coverageGet , -- ** max #method:max# CoverageMaxMethodInfo , coverageMax , -- ** set #method:set# CoverageSetMethodInfo , coverageSet , -- ** toBytes #method:toBytes# CoverageToBytesMethodInfo , coverageToBytes , -- ** unref #method:unref# CoverageUnrefMethodInfo , coverageUnref , ) where import Data.GI.Base.ShortPrelude import qualified Data.GI.Base.ShortPrelude as SP import qualified Data.GI.Base.Overloading as O import qualified Prelude as P import qualified Data.GI.Base.Attributes as GI.Attributes import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr import qualified Data.GI.Base.GError as B.GError import qualified Data.GI.Base.GVariant as B.GVariant import qualified Data.GI.Base.GParamSpec as B.GParamSpec import qualified Data.GI.Base.CallStack as B.CallStack import qualified Data.Text as T import qualified Data.ByteString.Char8 as B import qualified Data.Map as Map import qualified Foreign.Ptr as FP import {-# SOURCE #-} qualified GI.Pango.Enums as Pango.Enums newtype Coverage = Coverage (ManagedPtr Coverage) -- XXX Wrapping a foreign struct/union with no known destructor or size, leak? instance WrappedPtr Coverage where wrappedPtrCalloc = return nullPtr wrappedPtrCopy = return wrappedPtrFree = Nothing noCoverage :: Maybe Coverage noCoverage = Nothing instance O.HasAttributeList Coverage type instance O.AttributeList Coverage = CoverageAttributeList type CoverageAttributeList = ('[ ] :: [(Symbol, *)]) -- method Coverage::get -- method type : OrdinaryMethod -- Args : [Arg {argCName = "coverage", argType = TInterface (Name {namespace = "Pango", name = "Coverage"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PangoCoverage", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "index_", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the index to check", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "Pango", name = "CoverageLevel"})) -- throws : False -- Skip return : False foreign import ccall "pango_coverage_get" pango_coverage_get :: Ptr Coverage -> -- coverage : TInterface (Name {namespace = "Pango", name = "Coverage"}) Int32 -> -- index_ : TBasicType TInt IO CUInt {- | Determine whether a particular index is covered by /@coverage@/ -} coverageGet :: (B.CallStack.HasCallStack, MonadIO m) => Coverage {- ^ /@coverage@/: a 'GI.Pango.Structs.Coverage.Coverage' -} -> Int32 {- ^ /@index_@/: the index to check -} -> m Pango.Enums.CoverageLevel {- ^ __Returns:__ the coverage level of /@coverage@/ for character /@index_@/. -} coverageGet coverage index_ = liftIO $ do coverage' <- unsafeManagedPtrGetPtr coverage result <- pango_coverage_get coverage' index_ let result' = (toEnum . fromIntegral) result touchManagedPtr coverage return result' data CoverageGetMethodInfo instance (signature ~ (Int32 -> m Pango.Enums.CoverageLevel), MonadIO m) => O.MethodInfo CoverageGetMethodInfo Coverage signature where overloadedMethod _ = coverageGet -- method Coverage::max -- method type : OrdinaryMethod -- Args : [Arg {argCName = "coverage", argType = TInterface (Name {namespace = "Pango", name = "Coverage"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PangoCoverage", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "other", argType = TInterface (Name {namespace = "Pango", name = "Coverage"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "another #PangoCoverage", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "pango_coverage_max" pango_coverage_max :: Ptr Coverage -> -- coverage : TInterface (Name {namespace = "Pango", name = "Coverage"}) Ptr Coverage -> -- other : TInterface (Name {namespace = "Pango", name = "Coverage"}) IO () {- | Set the coverage for each index in /@coverage@/ to be the max (better) value of the current coverage for the index and the coverage for the corresponding index in /@other@/. -} coverageMax :: (B.CallStack.HasCallStack, MonadIO m) => Coverage {- ^ /@coverage@/: a 'GI.Pango.Structs.Coverage.Coverage' -} -> Coverage {- ^ /@other@/: another 'GI.Pango.Structs.Coverage.Coverage' -} -> m () coverageMax coverage other = liftIO $ do coverage' <- unsafeManagedPtrGetPtr coverage other' <- unsafeManagedPtrGetPtr other pango_coverage_max coverage' other' touchManagedPtr coverage touchManagedPtr other return () data CoverageMaxMethodInfo instance (signature ~ (Coverage -> m ()), MonadIO m) => O.MethodInfo CoverageMaxMethodInfo Coverage signature where overloadedMethod _ = coverageMax -- method Coverage::set -- method type : OrdinaryMethod -- Args : [Arg {argCName = "coverage", argType = TInterface (Name {namespace = "Pango", name = "Coverage"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PangoCoverage", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "index_", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the index to modify", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "level", argType = TInterface (Name {namespace = "Pango", name = "CoverageLevel"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the new level for @index_", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "pango_coverage_set" pango_coverage_set :: Ptr Coverage -> -- coverage : TInterface (Name {namespace = "Pango", name = "Coverage"}) Int32 -> -- index_ : TBasicType TInt CUInt -> -- level : TInterface (Name {namespace = "Pango", name = "CoverageLevel"}) IO () {- | Modify a particular index within /@coverage@/ -} coverageSet :: (B.CallStack.HasCallStack, MonadIO m) => Coverage {- ^ /@coverage@/: a 'GI.Pango.Structs.Coverage.Coverage' -} -> Int32 {- ^ /@index_@/: the index to modify -} -> Pango.Enums.CoverageLevel {- ^ /@level@/: the new level for /@index_@/ -} -> m () coverageSet coverage index_ level = liftIO $ do coverage' <- unsafeManagedPtrGetPtr coverage let level' = (fromIntegral . fromEnum) level pango_coverage_set coverage' index_ level' touchManagedPtr coverage return () data CoverageSetMethodInfo instance (signature ~ (Int32 -> Pango.Enums.CoverageLevel -> m ()), MonadIO m) => O.MethodInfo CoverageSetMethodInfo Coverage signature where overloadedMethod _ = coverageSet -- method Coverage::to_bytes -- method type : OrdinaryMethod -- Args : [Arg {argCName = "coverage", argType = TInterface (Name {namespace = "Pango", name = "Coverage"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PangoCoverage", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "bytes", argType = TCArray False (-1) 2 (TBasicType TUInt8), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "\n location to store result (must be freed with g_free())", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "n_bytes", argType = TBasicType TInt, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "location to store size of result", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}] -- Lengths : [Arg {argCName = "n_bytes", argType = TBasicType TInt, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "location to store size of result", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "pango_coverage_to_bytes" pango_coverage_to_bytes :: Ptr Coverage -> -- coverage : TInterface (Name {namespace = "Pango", name = "Coverage"}) Ptr (Ptr Word8) -> -- bytes : TCArray False (-1) 2 (TBasicType TUInt8) Ptr Int32 -> -- n_bytes : TBasicType TInt IO () {- | Convert a 'GI.Pango.Structs.Coverage.Coverage' structure into a flat binary format -} coverageToBytes :: (B.CallStack.HasCallStack, MonadIO m) => Coverage {- ^ /@coverage@/: a 'GI.Pango.Structs.Coverage.Coverage' -} -> m (ByteString) coverageToBytes coverage = liftIO $ do coverage' <- unsafeManagedPtrGetPtr coverage bytes <- allocMem :: IO (Ptr (Ptr Word8)) nBytes <- allocMem :: IO (Ptr Int32) pango_coverage_to_bytes coverage' bytes nBytes nBytes' <- peek nBytes bytes' <- peek bytes bytes'' <- (unpackByteStringWithLength nBytes') bytes' freeMem bytes' touchManagedPtr coverage freeMem bytes freeMem nBytes return bytes'' data CoverageToBytesMethodInfo instance (signature ~ (m (ByteString)), MonadIO m) => O.MethodInfo CoverageToBytesMethodInfo Coverage signature where overloadedMethod _ = coverageToBytes -- method Coverage::unref -- method type : OrdinaryMethod -- Args : [Arg {argCName = "coverage", argType = TInterface (Name {namespace = "Pango", name = "Coverage"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PangoCoverage", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "pango_coverage_unref" pango_coverage_unref :: Ptr Coverage -> -- coverage : TInterface (Name {namespace = "Pango", name = "Coverage"}) IO () {- | Decrease the reference count on the 'GI.Pango.Structs.Coverage.Coverage' by one. If the result is zero, free the coverage and all associated memory. -} coverageUnref :: (B.CallStack.HasCallStack, MonadIO m) => Coverage {- ^ /@coverage@/: a 'GI.Pango.Structs.Coverage.Coverage' -} -> m () coverageUnref coverage = liftIO $ do coverage' <- unsafeManagedPtrGetPtr coverage pango_coverage_unref coverage' touchManagedPtr coverage return () data CoverageUnrefMethodInfo instance (signature ~ (m ()), MonadIO m) => O.MethodInfo CoverageUnrefMethodInfo Coverage signature where overloadedMethod _ = coverageUnref type family ResolveCoverageMethod (t :: Symbol) (o :: *) :: * where ResolveCoverageMethod "get" o = CoverageGetMethodInfo ResolveCoverageMethod "max" o = CoverageMaxMethodInfo ResolveCoverageMethod "set" o = CoverageSetMethodInfo ResolveCoverageMethod "toBytes" o = CoverageToBytesMethodInfo ResolveCoverageMethod "unref" o = CoverageUnrefMethodInfo ResolveCoverageMethod l o = O.MethodResolutionFailed l o instance (info ~ ResolveCoverageMethod t Coverage, O.MethodInfo info Coverage p) => O.IsLabelProxy t (Coverage -> p) where fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info) #if MIN_VERSION_base(4,9,0) instance (info ~ ResolveCoverageMethod t Coverage, O.MethodInfo info Coverage p) => O.IsLabel t (Coverage -> p) where fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info) #endif