{- | 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 #PangoItem structure stores information about a segment of text. -} module GI.Pango.Structs.Item ( -- * Exported types Item(..) , newZeroItem , noItem , -- * Methods -- ** itemCopy ItemCopyMethodInfo , itemCopy , -- ** itemFree ItemFreeMethodInfo , itemFree , -- ** itemNew itemNew , -- ** itemSplit ItemSplitMethodInfo , itemSplit , -- * Properties -- ** Analysis itemReadAnalysis , -- ** Length itemReadLength , -- ** NumChars itemReadNumChars , -- ** Offset itemReadOffset , ) where import Prelude () import Data.GI.Base.ShortPrelude import qualified Data.Text as T import qualified Data.ByteString.Char8 as B import qualified Data.Map as Map import GI.Pango.Types import GI.Pango.Callbacks newtype Item = Item (ForeignPtr Item) foreign import ccall "pango_item_get_type" c_pango_item_get_type :: IO GType instance BoxedObject Item where boxedType _ = c_pango_item_get_type -- | Construct a `Item` struct initialized to zero. newZeroItem :: MonadIO m => m Item newZeroItem = liftIO $ callocBoxedBytes 64 >>= wrapBoxed Item noItem :: Maybe Item noItem = Nothing itemReadOffset :: Item -> IO Int32 itemReadOffset s = withManagedPtr s $ \ptr -> do val <- peek (ptr `plusPtr` 0) :: IO Int32 return val itemReadLength :: Item -> IO Int32 itemReadLength s = withManagedPtr s $ \ptr -> do val <- peek (ptr `plusPtr` 4) :: IO Int32 return val itemReadNumChars :: Item -> IO Int32 itemReadNumChars s = withManagedPtr s $ \ptr -> do val <- peek (ptr `plusPtr` 8) :: IO Int32 return val itemReadAnalysis :: Item -> IO Analysis itemReadAnalysis s = withManagedPtr s $ \ptr -> do val <- peek (ptr `plusPtr` 16) :: IO (Ptr Analysis) val' <- (newPtr 48 Analysis) val return val' -- method Item::new -- method type : Constructor -- Args : [] -- Lengths : [] -- returnType : TInterface "Pango" "Item" -- throws : False -- Skip return : False foreign import ccall "pango_item_new" pango_item_new :: IO (Ptr Item) itemNew :: (MonadIO m) => m Item -- result itemNew = liftIO $ do result <- pango_item_new checkUnexpectedReturnNULL "pango_item_new" result result' <- (wrapBoxed Item) result return result' -- method Item::copy -- method type : OrdinaryMethod -- Args : [Arg {argCName = "_obj", argType = TInterface "Pango" "Item", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : TInterface "Pango" "Item" -- throws : False -- Skip return : False foreign import ccall "pango_item_copy" pango_item_copy :: Ptr Item -> -- _obj : TInterface "Pango" "Item" IO (Ptr Item) itemCopy :: (MonadIO m) => Item -- _obj -> m Item -- result itemCopy _obj = liftIO $ do let _obj' = unsafeManagedPtrGetPtr _obj result <- pango_item_copy _obj' checkUnexpectedReturnNULL "pango_item_copy" result result' <- (wrapBoxed Item) result touchManagedPtr _obj return result' data ItemCopyMethodInfo instance (signature ~ (m Item), MonadIO m) => MethodInfo ItemCopyMethodInfo Item signature where overloadedMethod _ = itemCopy -- method Item::free -- method type : OrdinaryMethod -- Args : [Arg {argCName = "_obj", argType = TInterface "Pango" "Item", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : TBasicType TVoid -- throws : False -- Skip return : False foreign import ccall "pango_item_free" pango_item_free :: Ptr Item -> -- _obj : TInterface "Pango" "Item" IO () itemFree :: (MonadIO m) => Item -- _obj -> m () -- result itemFree _obj = liftIO $ do let _obj' = unsafeManagedPtrGetPtr _obj pango_item_free _obj' touchManagedPtr _obj return () data ItemFreeMethodInfo instance (signature ~ (m ()), MonadIO m) => MethodInfo ItemFreeMethodInfo Item signature where overloadedMethod _ = itemFree -- method Item::split -- method type : OrdinaryMethod -- Args : [Arg {argCName = "_obj", argType = TInterface "Pango" "Item", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "split_index", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "split_offset", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : TInterface "Pango" "Item" -- throws : False -- Skip return : False foreign import ccall "pango_item_split" pango_item_split :: Ptr Item -> -- _obj : TInterface "Pango" "Item" Int32 -> -- split_index : TBasicType TInt32 Int32 -> -- split_offset : TBasicType TInt32 IO (Ptr Item) itemSplit :: (MonadIO m) => Item -- _obj -> Int32 -- splitIndex -> Int32 -- splitOffset -> m Item -- result itemSplit _obj splitIndex splitOffset = liftIO $ do let _obj' = unsafeManagedPtrGetPtr _obj result <- pango_item_split _obj' splitIndex splitOffset checkUnexpectedReturnNULL "pango_item_split" result result' <- (wrapBoxed Item) result touchManagedPtr _obj return result' data ItemSplitMethodInfo instance (signature ~ (Int32 -> Int32 -> m Item), MonadIO m) => MethodInfo ItemSplitMethodInfo Item signature where overloadedMethod _ = itemSplit type family ResolveItemMethod (t :: Symbol) (o :: *) :: * where ResolveItemMethod "copy" o = ItemCopyMethodInfo ResolveItemMethod "free" o = ItemFreeMethodInfo ResolveItemMethod "split" o = ItemSplitMethodInfo ResolveItemMethod l o = MethodResolutionFailed l o instance (info ~ ResolveItemMethod t Item, MethodInfo info Item p) => IsLabelProxy t (Item -> p) where fromLabelProxy _ = overloadedMethod (MethodProxy :: MethodProxy info) #if MIN_VERSION_base(4,9,0) instance (info ~ ResolveItemMethod t Item, MethodInfo info Item p) => IsLabel t (Item -> p) where fromLabel _ = overloadedMethod (MethodProxy :: MethodProxy info) #endif