{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.Pango.Structs.Language
(
Language(..) ,
#if defined(ENABLE_OVERLOADING)
ResolveLanguageMethod ,
#endif
languageFromString ,
languageGetDefault ,
#if defined(ENABLE_OVERLOADING)
LanguageGetSampleStringMethodInfo ,
#endif
languageGetSampleString ,
#if defined(ENABLE_OVERLOADING)
LanguageIncludesScriptMethodInfo ,
#endif
languageIncludesScript ,
#if defined(ENABLE_OVERLOADING)
LanguageMatchesMethodInfo ,
#endif
languageMatches ,
#if defined(ENABLE_OVERLOADING)
LanguageToStringMethodInfo ,
#endif
languageToString ,
) 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
newtype Language = Language (SP.ManagedPtr Language)
deriving (Language -> Language -> Bool
(Language -> Language -> Bool)
-> (Language -> Language -> Bool) -> Eq Language
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Language -> Language -> Bool
$c/= :: Language -> Language -> Bool
== :: Language -> Language -> Bool
$c== :: Language -> Language -> Bool
Eq)
instance SP.ManagedPtrNewtype Language where
toManagedPtr :: Language -> ManagedPtr Language
toManagedPtr (Language ManagedPtr Language
p) = ManagedPtr Language
p
foreign import ccall "pango_language_get_type" c_pango_language_get_type ::
IO GType
type instance O.ParentTypes Language = '[]
instance O.HasParentTypes Language
instance B.Types.TypedObject Language where
glibType :: IO GType
glibType = IO GType
c_pango_language_get_type
instance B.Types.GBoxed Language
instance B.GValue.IsGValue Language where
toGValue :: Language -> IO GValue
toGValue Language
o = do
GType
gtype <- IO GType
c_pango_language_get_type
Language -> (Ptr Language -> IO GValue) -> IO GValue
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr Language
o (GType
-> (GValue -> Ptr Language -> IO ()) -> Ptr Language -> IO GValue
forall a. GType -> (GValue -> a -> IO ()) -> a -> IO GValue
B.GValue.buildGValue GType
gtype GValue -> Ptr Language -> IO ()
forall a. GValue -> Ptr a -> IO ()
B.GValue.set_boxed)
fromGValue :: GValue -> IO Language
fromGValue GValue
gv = do
Ptr Language
ptr <- GValue -> IO (Ptr Language)
forall b. GValue -> IO (Ptr b)
B.GValue.get_boxed GValue
gv :: IO (Ptr Language)
(ManagedPtr Language -> Language) -> Ptr Language -> IO Language
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
B.ManagedPtr.newBoxed ManagedPtr Language -> Language
Language Ptr Language
ptr
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList Language
type instance O.AttributeList Language = LanguageAttributeList
type LanguageAttributeList = ('[ ] :: [(Symbol, *)])
#endif
foreign import ccall "pango_language_get_sample_string" pango_language_get_sample_string ::
Ptr Language ->
IO CString
languageGetSampleString ::
(B.CallStack.HasCallStack, MonadIO m) =>
Language
-> m T.Text
languageGetSampleString :: Language -> m Text
languageGetSampleString Language
language = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
Ptr Language
language' <- Language -> IO (Ptr Language)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Language
language
CString
result <- Ptr Language -> IO CString
pango_language_get_sample_string Ptr Language
language'
Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"languageGetSampleString" CString
result
Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
Language -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Language
language
Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'
#if defined(ENABLE_OVERLOADING)
data LanguageGetSampleStringMethodInfo
instance (signature ~ (m T.Text), MonadIO m) => O.MethodInfo LanguageGetSampleStringMethodInfo Language signature where
overloadedMethod = languageGetSampleString
#endif
foreign import ccall "pango_language_includes_script" pango_language_includes_script ::
Ptr Language ->
CInt ->
IO CInt
languageIncludesScript ::
(B.CallStack.HasCallStack, MonadIO m) =>
Language
-> Pango.Enums.Script
-> m Bool
languageIncludesScript :: Language -> Script -> m Bool
languageIncludesScript Language
language Script
script = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
Ptr Language
language' <- Language -> IO (Ptr Language)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Language
language
let script' :: CInt
script' = (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
script
CInt
result <- Ptr Language -> CInt -> IO CInt
pango_language_includes_script Ptr Language
language' CInt
script'
let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
Language -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Language
language
Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'
#if defined(ENABLE_OVERLOADING)
data LanguageIncludesScriptMethodInfo
instance (signature ~ (Pango.Enums.Script -> m Bool), MonadIO m) => O.MethodInfo LanguageIncludesScriptMethodInfo Language signature where
overloadedMethod = languageIncludesScript
#endif
foreign import ccall "pango_language_matches" pango_language_matches ::
Ptr Language ->
CString ->
IO CInt
languageMatches ::
(B.CallStack.HasCallStack, MonadIO m) =>
Language
-> T.Text
-> m Bool
languageMatches :: Language -> Text -> m Bool
languageMatches Language
language Text
rangeList = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
Ptr Language
language' <- Language -> IO (Ptr Language)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Language
language
CString
rangeList' <- Text -> IO CString
textToCString Text
rangeList
CInt
result <- Ptr Language -> CString -> IO CInt
pango_language_matches Ptr Language
language' CString
rangeList'
let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
Language -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Language
language
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
rangeList'
Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'
#if defined(ENABLE_OVERLOADING)
data LanguageMatchesMethodInfo
instance (signature ~ (T.Text -> m Bool), MonadIO m) => O.MethodInfo LanguageMatchesMethodInfo Language signature where
overloadedMethod = languageMatches
#endif
foreign import ccall "pango_language_to_string" pango_language_to_string ::
Ptr Language ->
IO CString
languageToString ::
(B.CallStack.HasCallStack, MonadIO m) =>
Language
-> m T.Text
languageToString :: Language -> m Text
languageToString Language
language = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
Ptr Language
language' <- Language -> IO (Ptr Language)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Language
language
CString
result <- Ptr Language -> IO CString
pango_language_to_string Ptr Language
language'
Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"languageToString" CString
result
Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
Language -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Language
language
Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'
#if defined(ENABLE_OVERLOADING)
data LanguageToStringMethodInfo
instance (signature ~ (m T.Text), MonadIO m) => O.MethodInfo LanguageToStringMethodInfo Language signature where
overloadedMethod = languageToString
#endif
foreign import ccall "pango_language_from_string" pango_language_from_string ::
CString ->
IO (Ptr Language)
languageFromString ::
(B.CallStack.HasCallStack, MonadIO m) =>
Maybe (T.Text)
-> m (Maybe Language)
languageFromString :: Maybe Text -> m (Maybe Language)
languageFromString Maybe Text
language = IO (Maybe Language) -> m (Maybe Language)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Language) -> m (Maybe Language))
-> IO (Maybe Language) -> m (Maybe Language)
forall a b. (a -> b) -> a -> b
$ do
CString
maybeLanguage <- case Maybe Text
language of
Maybe Text
Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
Just Text
jLanguage -> do
CString
jLanguage' <- Text -> IO CString
textToCString Text
jLanguage
CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jLanguage'
Ptr Language
result <- CString -> IO (Ptr Language)
pango_language_from_string CString
maybeLanguage
Maybe Language
maybeResult <- Ptr Language
-> (Ptr Language -> IO Language) -> IO (Maybe Language)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr Language
result ((Ptr Language -> IO Language) -> IO (Maybe Language))
-> (Ptr Language -> IO Language) -> IO (Maybe Language)
forall a b. (a -> b) -> a -> b
$ \Ptr Language
result' -> do
Language
result'' <- ((ManagedPtr Language -> Language) -> Ptr Language -> IO Language
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr Language -> Language
Language) Ptr Language
result'
Language -> IO Language
forall (m :: * -> *) a. Monad m => a -> m a
return Language
result''
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeLanguage
Maybe Language -> IO (Maybe Language)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Language
maybeResult
#if defined(ENABLE_OVERLOADING)
#endif
foreign import ccall "pango_language_get_default" pango_language_get_default ::
IO (Ptr Language)
languageGetDefault ::
(B.CallStack.HasCallStack, MonadIO m) =>
m Language
languageGetDefault :: m Language
languageGetDefault = IO Language -> m Language
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Language -> m Language) -> IO Language -> m Language
forall a b. (a -> b) -> a -> b
$ do
Ptr Language
result <- IO (Ptr Language)
pango_language_get_default
Text -> Ptr Language -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"languageGetDefault" Ptr Language
result
Language
result' <- ((ManagedPtr Language -> Language) -> Ptr Language -> IO Language
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr Language -> Language
Language) Ptr Language
result
Language -> IO Language
forall (m :: * -> *) a. Monad m => a -> m a
return Language
result'
#if defined(ENABLE_OVERLOADING)
#endif
#if defined(ENABLE_OVERLOADING)
type family ResolveLanguageMethod (t :: Symbol) (o :: *) :: * where
ResolveLanguageMethod "includesScript" o = LanguageIncludesScriptMethodInfo
ResolveLanguageMethod "matches" o = LanguageMatchesMethodInfo
ResolveLanguageMethod "toString" o = LanguageToStringMethodInfo
ResolveLanguageMethod "getSampleString" o = LanguageGetSampleStringMethodInfo
ResolveLanguageMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveLanguageMethod t Language, O.MethodInfo info Language p) => OL.IsLabel t (Language -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod @info
#else
fromLabel _ = O.overloadedMethod @info
#endif
#endif