{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- The t'GI.Pango.Structs.EngineScriptInfo.EngineScriptInfo' structure contains
-- information about how the shaper covers a particular script.

#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif

module GI.Pango.Structs.EngineScriptInfo
    ( 

-- * Exported types
    EngineScriptInfo(..)                    ,
    newZeroEngineScriptInfo                 ,


 -- * Methods
-- ** Overloaded methods #method:Overloaded methods#

#if defined(ENABLE_OVERLOADING)
    ResolveEngineScriptInfoMethod           ,
#endif




 -- * Properties
-- ** langs #attr:langs#
-- | a semicolon separated list of languages that this
-- engine handles for this script. This may be empty,
-- in which case the engine is saying that it is a
-- fallback choice for all languages for this range,
-- but should not be used if another engine
-- indicates that it is specific for the language for
-- a given code point. An entry in this list of \"*\"
-- indicates that this engine is specific to all
-- languages for this range.

    clearEngineScriptInfoLangs              ,
#if defined(ENABLE_OVERLOADING)
    engineScriptInfo_langs                  ,
#endif
    getEngineScriptInfoLangs                ,
    setEngineScriptInfoLangs                ,


-- ** script #attr:script#
-- | a t'GI.Pango.Enums.Script'. The value 'GI.Pango.Enums.ScriptCommon' has
-- the special meaning here of \"all scripts\"

#if defined(ENABLE_OVERLOADING)
    engineScriptInfo_script                 ,
#endif
    getEngineScriptInfoScript               ,
    setEngineScriptInfoScript               ,




    ) 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.BasicTypes as B.Types
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.GI.Base.Signals as B.Signals
import qualified Control.Monad.IO.Class as MIO
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 qualified GHC.OverloadedLabels as OL

import {-# SOURCE #-} qualified GI.Pango.Enums as Pango.Enums

-- | Memory-managed wrapper type.
newtype EngineScriptInfo = EngineScriptInfo (SP.ManagedPtr EngineScriptInfo)
    deriving (EngineScriptInfo -> EngineScriptInfo -> Bool
(EngineScriptInfo -> EngineScriptInfo -> Bool)
-> (EngineScriptInfo -> EngineScriptInfo -> Bool)
-> Eq EngineScriptInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EngineScriptInfo -> EngineScriptInfo -> Bool
$c/= :: EngineScriptInfo -> EngineScriptInfo -> Bool
== :: EngineScriptInfo -> EngineScriptInfo -> Bool
$c== :: EngineScriptInfo -> EngineScriptInfo -> Bool
Eq)

instance SP.ManagedPtrNewtype EngineScriptInfo where
    toManagedPtr :: EngineScriptInfo -> ManagedPtr EngineScriptInfo
toManagedPtr (EngineScriptInfo ManagedPtr EngineScriptInfo
p) = ManagedPtr EngineScriptInfo
p

instance BoxedPtr EngineScriptInfo where
    boxedPtrCopy :: EngineScriptInfo -> IO EngineScriptInfo
boxedPtrCopy = \EngineScriptInfo
p -> EngineScriptInfo
-> (Ptr EngineScriptInfo -> IO EngineScriptInfo)
-> IO EngineScriptInfo
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr EngineScriptInfo
p (Int -> Ptr EngineScriptInfo -> IO (Ptr EngineScriptInfo)
forall a. (HasCallStack, CallocPtr a) => Int -> Ptr a -> IO (Ptr a)
copyBytes Int
16 (Ptr EngineScriptInfo -> IO (Ptr EngineScriptInfo))
-> (Ptr EngineScriptInfo -> IO EngineScriptInfo)
-> Ptr EngineScriptInfo
-> IO EngineScriptInfo
forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> (ManagedPtr EngineScriptInfo -> EngineScriptInfo)
-> Ptr EngineScriptInfo -> IO EngineScriptInfo
forall a.
(HasCallStack, BoxedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
B.ManagedPtr.wrapPtr ManagedPtr EngineScriptInfo -> EngineScriptInfo
EngineScriptInfo)
    boxedPtrFree :: EngineScriptInfo -> IO ()
boxedPtrFree = \EngineScriptInfo
x -> EngineScriptInfo -> (Ptr EngineScriptInfo -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
SP.withManagedPtr EngineScriptInfo
x Ptr EngineScriptInfo -> IO ()
forall a. Ptr a -> IO ()
SP.freeMem
instance CallocPtr EngineScriptInfo where
    boxedPtrCalloc :: IO (Ptr EngineScriptInfo)
boxedPtrCalloc = Int -> IO (Ptr EngineScriptInfo)
forall a. Int -> IO (Ptr a)
callocBytes Int
16


-- | Construct a `EngineScriptInfo` struct initialized to zero.
newZeroEngineScriptInfo :: MonadIO m => m EngineScriptInfo
newZeroEngineScriptInfo :: m EngineScriptInfo
newZeroEngineScriptInfo = IO EngineScriptInfo -> m EngineScriptInfo
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO EngineScriptInfo -> m EngineScriptInfo)
-> IO EngineScriptInfo -> m EngineScriptInfo
forall a b. (a -> b) -> a -> b
$ IO (Ptr EngineScriptInfo)
forall a. CallocPtr a => IO (Ptr a)
boxedPtrCalloc IO (Ptr EngineScriptInfo)
-> (Ptr EngineScriptInfo -> IO EngineScriptInfo)
-> IO EngineScriptInfo
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (ManagedPtr EngineScriptInfo -> EngineScriptInfo)
-> Ptr EngineScriptInfo -> IO EngineScriptInfo
forall a.
(HasCallStack, BoxedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapPtr ManagedPtr EngineScriptInfo -> EngineScriptInfo
EngineScriptInfo

instance tag ~ 'AttrSet => Constructible EngineScriptInfo tag where
    new :: (ManagedPtr EngineScriptInfo -> EngineScriptInfo)
-> [AttrOp EngineScriptInfo tag] -> m EngineScriptInfo
new ManagedPtr EngineScriptInfo -> EngineScriptInfo
_ [AttrOp EngineScriptInfo tag]
attrs = do
        EngineScriptInfo
o <- m EngineScriptInfo
forall (m :: * -> *). MonadIO m => m EngineScriptInfo
newZeroEngineScriptInfo
        EngineScriptInfo -> [AttrOp EngineScriptInfo 'AttrSet] -> m ()
forall o (m :: * -> *).
MonadIO m =>
o -> [AttrOp o 'AttrSet] -> m ()
GI.Attributes.set EngineScriptInfo
o [AttrOp EngineScriptInfo tag]
[AttrOp EngineScriptInfo 'AttrSet]
attrs
        EngineScriptInfo -> m EngineScriptInfo
forall (m :: * -> *) a. Monad m => a -> m a
return EngineScriptInfo
o


-- | Get the value of the “@script@” field.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.get' engineScriptInfo #script
-- @
getEngineScriptInfoScript :: MonadIO m => EngineScriptInfo -> m Pango.Enums.Script
getEngineScriptInfoScript :: EngineScriptInfo -> m Script
getEngineScriptInfoScript EngineScriptInfo
s = IO Script -> m Script
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Script -> m Script) -> IO Script -> m Script
forall a b. (a -> b) -> a -> b
$ EngineScriptInfo
-> (Ptr EngineScriptInfo -> IO Script) -> IO Script
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr EngineScriptInfo
s ((Ptr EngineScriptInfo -> IO Script) -> IO Script)
-> (Ptr EngineScriptInfo -> IO Script) -> IO Script
forall a b. (a -> b) -> a -> b
$ \Ptr EngineScriptInfo
ptr -> do
    CInt
val <- Ptr CInt -> IO CInt
forall a. Storable a => Ptr a -> IO a
peek (Ptr EngineScriptInfo
ptr Ptr EngineScriptInfo -> Int -> Ptr CInt
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0) :: IO CInt
    let val' :: Script
val' = (Int -> Script
forall a. Enum a => Int -> a
toEnum (Int -> Script) -> (CInt -> Int) -> CInt -> Script
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CInt
val
    Script -> IO Script
forall (m :: * -> *) a. Monad m => a -> m a
return Script
val'

-- | Set the value of the “@script@” field.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.set' engineScriptInfo [ #script 'Data.GI.Base.Attributes.:=' value ]
-- @
setEngineScriptInfoScript :: MonadIO m => EngineScriptInfo -> Pango.Enums.Script -> m ()
setEngineScriptInfoScript :: EngineScriptInfo -> Script -> m ()
setEngineScriptInfoScript EngineScriptInfo
s Script
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ EngineScriptInfo -> (Ptr EngineScriptInfo -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr EngineScriptInfo
s ((Ptr EngineScriptInfo -> IO ()) -> IO ())
-> (Ptr EngineScriptInfo -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr EngineScriptInfo
ptr -> do
    let val' :: CInt
val' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Script -> Int) -> Script -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Script -> Int
forall a. Enum a => a -> Int
fromEnum) Script
val
    Ptr CInt -> CInt -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr EngineScriptInfo
ptr Ptr EngineScriptInfo -> Int -> Ptr CInt
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0) (CInt
val' :: CInt)

#if defined(ENABLE_OVERLOADING)
data EngineScriptInfoScriptFieldInfo
instance AttrInfo EngineScriptInfoScriptFieldInfo where
    type AttrBaseTypeConstraint EngineScriptInfoScriptFieldInfo = (~) EngineScriptInfo
    type AttrAllowedOps EngineScriptInfoScriptFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint EngineScriptInfoScriptFieldInfo = (~) Pango.Enums.Script
    type AttrTransferTypeConstraint EngineScriptInfoScriptFieldInfo = (~)Pango.Enums.Script
    type AttrTransferType EngineScriptInfoScriptFieldInfo = Pango.Enums.Script
    type AttrGetType EngineScriptInfoScriptFieldInfo = Pango.Enums.Script
    type AttrLabel EngineScriptInfoScriptFieldInfo = "script"
    type AttrOrigin EngineScriptInfoScriptFieldInfo = EngineScriptInfo
    attrGet = getEngineScriptInfoScript
    attrSet = setEngineScriptInfoScript
    attrConstruct = undefined
    attrClear = undefined
    attrTransfer _ v = do
        return v

engineScriptInfo_script :: AttrLabelProxy "script"
engineScriptInfo_script = AttrLabelProxy

#endif


-- | Get the value of the “@langs@” field.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.get' engineScriptInfo #langs
-- @
getEngineScriptInfoLangs :: MonadIO m => EngineScriptInfo -> m (Maybe T.Text)
getEngineScriptInfoLangs :: EngineScriptInfo -> m (Maybe Text)
getEngineScriptInfoLangs EngineScriptInfo
s = IO (Maybe Text) -> m (Maybe Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Text) -> m (Maybe Text))
-> IO (Maybe Text) -> m (Maybe Text)
forall a b. (a -> b) -> a -> b
$ EngineScriptInfo
-> (Ptr EngineScriptInfo -> IO (Maybe Text)) -> IO (Maybe Text)
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr EngineScriptInfo
s ((Ptr EngineScriptInfo -> IO (Maybe Text)) -> IO (Maybe Text))
-> (Ptr EngineScriptInfo -> IO (Maybe Text)) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \Ptr EngineScriptInfo
ptr -> do
    CString
val <- Ptr CString -> IO CString
forall a. Storable a => Ptr a -> IO a
peek (Ptr EngineScriptInfo
ptr Ptr EngineScriptInfo -> Int -> Ptr CString
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8) :: IO CString
    Maybe Text
result <- CString -> (CString -> IO Text) -> IO (Maybe Text)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
SP.convertIfNonNull CString
val ((CString -> IO Text) -> IO (Maybe Text))
-> (CString -> IO Text) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \CString
val' -> do
        Text
val'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
val'
        Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
val''
    Maybe Text -> IO (Maybe Text)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Text
result

-- | Set the value of the “@langs@” field.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.set' engineScriptInfo [ #langs 'Data.GI.Base.Attributes.:=' value ]
-- @
setEngineScriptInfoLangs :: MonadIO m => EngineScriptInfo -> CString -> m ()
setEngineScriptInfoLangs :: EngineScriptInfo -> CString -> m ()
setEngineScriptInfoLangs EngineScriptInfo
s CString
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ EngineScriptInfo -> (Ptr EngineScriptInfo -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr EngineScriptInfo
s ((Ptr EngineScriptInfo -> IO ()) -> IO ())
-> (Ptr EngineScriptInfo -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr EngineScriptInfo
ptr -> do
    Ptr CString -> CString -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr EngineScriptInfo
ptr Ptr EngineScriptInfo -> Int -> Ptr CString
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8) (CString
val :: CString)

-- | Set the value of the “@langs@” field to `Nothing`.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.clear' #langs
-- @
clearEngineScriptInfoLangs :: MonadIO m => EngineScriptInfo -> m ()
clearEngineScriptInfoLangs :: EngineScriptInfo -> m ()
clearEngineScriptInfoLangs EngineScriptInfo
s = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ EngineScriptInfo -> (Ptr EngineScriptInfo -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr EngineScriptInfo
s ((Ptr EngineScriptInfo -> IO ()) -> IO ())
-> (Ptr EngineScriptInfo -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr EngineScriptInfo
ptr -> do
    Ptr CString -> CString -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr EngineScriptInfo
ptr Ptr EngineScriptInfo -> Int -> Ptr CString
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8) (CString
forall a. Ptr a
FP.nullPtr :: CString)

#if defined(ENABLE_OVERLOADING)
data EngineScriptInfoLangsFieldInfo
instance AttrInfo EngineScriptInfoLangsFieldInfo where
    type AttrBaseTypeConstraint EngineScriptInfoLangsFieldInfo = (~) EngineScriptInfo
    type AttrAllowedOps EngineScriptInfoLangsFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint EngineScriptInfoLangsFieldInfo = (~) CString
    type AttrTransferTypeConstraint EngineScriptInfoLangsFieldInfo = (~)CString
    type AttrTransferType EngineScriptInfoLangsFieldInfo = CString
    type AttrGetType EngineScriptInfoLangsFieldInfo = Maybe T.Text
    type AttrLabel EngineScriptInfoLangsFieldInfo = "langs"
    type AttrOrigin EngineScriptInfoLangsFieldInfo = EngineScriptInfo
    attrGet = getEngineScriptInfoLangs
    attrSet = setEngineScriptInfoLangs
    attrConstruct = undefined
    attrClear = clearEngineScriptInfoLangs
    attrTransfer _ v = do
        return v

engineScriptInfo_langs :: AttrLabelProxy "langs"
engineScriptInfo_langs = AttrLabelProxy

#endif



#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList EngineScriptInfo
type instance O.AttributeList EngineScriptInfo = EngineScriptInfoAttributeList
type EngineScriptInfoAttributeList = ('[ '("script", EngineScriptInfoScriptFieldInfo), '("langs", EngineScriptInfoLangsFieldInfo)] :: [(Symbol, *)])
#endif

#if defined(ENABLE_OVERLOADING)
type family ResolveEngineScriptInfoMethod (t :: Symbol) (o :: *) :: * where
    ResolveEngineScriptInfoMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveEngineScriptInfoMethod t EngineScriptInfo, O.MethodInfo info EngineScriptInfo p) => OL.IsLabel t (EngineScriptInfo -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod @info
#else
    fromLabel _ = O.overloadedMethod @info
#endif

#endif