{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.Clutter.Structs.Knot
(
Knot(..) ,
newZeroKnot ,
#if defined(ENABLE_OVERLOADING)
ResolveKnotMethod ,
#endif
#if defined(ENABLE_OVERLOADING)
KnotCopyMethodInfo ,
#endif
knotCopy ,
#if defined(ENABLE_OVERLOADING)
KnotEqualMethodInfo ,
#endif
knotEqual ,
#if defined(ENABLE_OVERLOADING)
KnotFreeMethodInfo ,
#endif
knotFree ,
getKnotX ,
#if defined(ENABLE_OVERLOADING)
knot_x ,
#endif
setKnotX ,
getKnotY ,
#if defined(ENABLE_OVERLOADING)
knot_y ,
#endif
setKnotY ,
) 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.GArray as B.GArray
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.Coerce as Coerce
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 qualified GHC.Records as R
newtype Knot = Knot (SP.ManagedPtr Knot)
deriving (Knot -> Knot -> Bool
(Knot -> Knot -> Bool) -> (Knot -> Knot -> Bool) -> Eq Knot
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Knot -> Knot -> Bool
$c/= :: Knot -> Knot -> Bool
== :: Knot -> Knot -> Bool
$c== :: Knot -> Knot -> Bool
Eq)
instance SP.ManagedPtrNewtype Knot where
toManagedPtr :: Knot -> ManagedPtr Knot
toManagedPtr (Knot ManagedPtr Knot
p) = ManagedPtr Knot
p
foreign import ccall "clutter_knot_get_type" c_clutter_knot_get_type ::
IO GType
type instance O.ParentTypes Knot = '[]
instance O.HasParentTypes Knot
instance B.Types.TypedObject Knot where
glibType :: IO GType
glibType = IO GType
c_clutter_knot_get_type
instance B.Types.GBoxed Knot
instance B.GValue.IsGValue (Maybe Knot) where
gvalueGType_ :: IO GType
gvalueGType_ = IO GType
c_clutter_knot_get_type
gvalueSet_ :: Ptr GValue -> Maybe Knot -> IO ()
gvalueSet_ Ptr GValue
gv Maybe Knot
P.Nothing = Ptr GValue -> Ptr Knot -> IO ()
forall a. Ptr GValue -> Ptr a -> IO ()
B.GValue.set_boxed Ptr GValue
gv (Ptr Knot
forall a. Ptr a
FP.nullPtr :: FP.Ptr Knot)
gvalueSet_ Ptr GValue
gv (P.Just Knot
obj) = Knot -> (Ptr Knot -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr Knot
obj (Ptr GValue -> Ptr Knot -> IO ()
forall a. Ptr GValue -> Ptr a -> IO ()
B.GValue.set_boxed Ptr GValue
gv)
gvalueGet_ :: Ptr GValue -> IO (Maybe Knot)
gvalueGet_ Ptr GValue
gv = do
Ptr Knot
ptr <- Ptr GValue -> IO (Ptr Knot)
forall b. Ptr GValue -> IO (Ptr b)
B.GValue.get_boxed Ptr GValue
gv :: IO (Ptr Knot)
if Ptr Knot
ptr Ptr Knot -> Ptr Knot -> Bool
forall a. Eq a => a -> a -> Bool
/= Ptr Knot
forall a. Ptr a
FP.nullPtr
then Knot -> Maybe Knot
forall a. a -> Maybe a
P.Just (Knot -> Maybe Knot) -> IO Knot -> IO (Maybe Knot)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ManagedPtr Knot -> Knot) -> Ptr Knot -> IO Knot
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
B.ManagedPtr.newBoxed ManagedPtr Knot -> Knot
Knot Ptr Knot
ptr
else Maybe Knot -> IO (Maybe Knot)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Knot
forall a. Maybe a
P.Nothing
newZeroKnot :: MonadIO m => m Knot
newZeroKnot :: forall (m :: * -> *). MonadIO m => m Knot
newZeroKnot = IO Knot -> m Knot
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Knot -> m Knot) -> IO Knot -> m Knot
forall a b. (a -> b) -> a -> b
$ Int -> IO (Ptr Knot)
forall a. GBoxed a => Int -> IO (Ptr a)
callocBoxedBytes Int
8 IO (Ptr Knot) -> (Ptr Knot -> IO Knot) -> IO Knot
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (ManagedPtr Knot -> Knot) -> Ptr Knot -> IO Knot
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Knot -> Knot
Knot
instance tag ~ 'AttrSet => Constructible Knot tag where
new :: forall (m :: * -> *).
MonadIO m =>
(ManagedPtr Knot -> Knot) -> [AttrOp Knot tag] -> m Knot
new ManagedPtr Knot -> Knot
_ [AttrOp Knot tag]
attrs = do
Knot
o <- m Knot
forall (m :: * -> *). MonadIO m => m Knot
newZeroKnot
Knot -> [AttrOp Knot 'AttrSet] -> m ()
forall o (m :: * -> *).
MonadIO m =>
o -> [AttrOp o 'AttrSet] -> m ()
GI.Attributes.set Knot
o [AttrOp Knot tag]
[AttrOp Knot 'AttrSet]
attrs
Knot -> m Knot
forall (m :: * -> *) a. Monad m => a -> m a
return Knot
o
getKnotX :: MonadIO m => Knot -> m Int32
getKnotX :: forall (m :: * -> *). MonadIO m => Knot -> m Int32
getKnotX Knot
s = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ Knot -> (Ptr Knot -> IO Int32) -> IO Int32
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr Knot
s ((Ptr Knot -> IO Int32) -> IO Int32)
-> (Ptr Knot -> IO Int32) -> IO Int32
forall a b. (a -> b) -> a -> b
$ \Ptr Knot
ptr -> do
Int32
val <- Ptr Int32 -> IO Int32
forall a. Storable a => Ptr a -> IO a
peek (Ptr Knot
ptr Ptr Knot -> Int -> Ptr Int32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0) :: IO Int32
Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
val
setKnotX :: MonadIO m => Knot -> Int32 -> m ()
setKnotX :: forall (m :: * -> *). MonadIO m => Knot -> Int32 -> m ()
setKnotX Knot
s Int32
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ Knot -> (Ptr Knot -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr Knot
s ((Ptr Knot -> IO ()) -> IO ()) -> (Ptr Knot -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Knot
ptr -> do
Ptr Int32 -> Int32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr Knot
ptr Ptr Knot -> Int -> Ptr Int32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0) (Int32
val :: Int32)
#if defined(ENABLE_OVERLOADING)
data KnotXFieldInfo
instance AttrInfo KnotXFieldInfo where
type AttrBaseTypeConstraint KnotXFieldInfo = (~) Knot
type AttrAllowedOps KnotXFieldInfo = '[ 'AttrSet, 'AttrGet]
type AttrSetTypeConstraint KnotXFieldInfo = (~) Int32
type AttrTransferTypeConstraint KnotXFieldInfo = (~)Int32
type AttrTransferType KnotXFieldInfo = Int32
type AttrGetType KnotXFieldInfo = Int32
type AttrLabel KnotXFieldInfo = "x"
type AttrOrigin KnotXFieldInfo = Knot
attrGet = getKnotX
attrSet = setKnotX
attrConstruct = undefined
attrClear = undefined
attrTransfer _ v = do
return v
dbgAttrInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Clutter.Structs.Knot.x"
, O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-clutter-1.0.2/docs/GI-Clutter-Structs-Knot.html#g:attr:x"
})
knot_x :: AttrLabelProxy "x"
knot_x = AttrLabelProxy
#endif
getKnotY :: MonadIO m => Knot -> m Int32
getKnotY :: forall (m :: * -> *). MonadIO m => Knot -> m Int32
getKnotY Knot
s = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ Knot -> (Ptr Knot -> IO Int32) -> IO Int32
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr Knot
s ((Ptr Knot -> IO Int32) -> IO Int32)
-> (Ptr Knot -> IO Int32) -> IO Int32
forall a b. (a -> b) -> a -> b
$ \Ptr Knot
ptr -> do
Int32
val <- Ptr Int32 -> IO Int32
forall a. Storable a => Ptr a -> IO a
peek (Ptr Knot
ptr Ptr Knot -> Int -> Ptr Int32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
4) :: IO Int32
Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
val
setKnotY :: MonadIO m => Knot -> Int32 -> m ()
setKnotY :: forall (m :: * -> *). MonadIO m => Knot -> Int32 -> m ()
setKnotY Knot
s Int32
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ Knot -> (Ptr Knot -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr Knot
s ((Ptr Knot -> IO ()) -> IO ()) -> (Ptr Knot -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Knot
ptr -> do
Ptr Int32 -> Int32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr Knot
ptr Ptr Knot -> Int -> Ptr Int32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
4) (Int32
val :: Int32)
#if defined(ENABLE_OVERLOADING)
data KnotYFieldInfo
instance AttrInfo KnotYFieldInfo where
type AttrBaseTypeConstraint KnotYFieldInfo = (~) Knot
type AttrAllowedOps KnotYFieldInfo = '[ 'AttrSet, 'AttrGet]
type AttrSetTypeConstraint KnotYFieldInfo = (~) Int32
type AttrTransferTypeConstraint KnotYFieldInfo = (~)Int32
type AttrTransferType KnotYFieldInfo = Int32
type AttrGetType KnotYFieldInfo = Int32
type AttrLabel KnotYFieldInfo = "y"
type AttrOrigin KnotYFieldInfo = Knot
attrGet = getKnotY
attrSet = setKnotY
attrConstruct = undefined
attrClear = undefined
attrTransfer _ v = do
return v
dbgAttrInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Clutter.Structs.Knot.y"
, O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-clutter-1.0.2/docs/GI-Clutter-Structs-Knot.html#g:attr:y"
})
knot_y :: AttrLabelProxy "y"
knot_y = AttrLabelProxy
#endif
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList Knot
type instance O.AttributeList Knot = KnotAttributeList
type KnotAttributeList = ('[ '("x", KnotXFieldInfo), '("y", KnotYFieldInfo)] :: [(Symbol, *)])
#endif
foreign import ccall "clutter_knot_copy" clutter_knot_copy ::
Ptr Knot ->
IO (Ptr Knot)
knotCopy ::
(B.CallStack.HasCallStack, MonadIO m) =>
Knot
-> m Knot
knotCopy :: forall (m :: * -> *). (HasCallStack, MonadIO m) => Knot -> m Knot
knotCopy Knot
knot = IO Knot -> m Knot
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Knot -> m Knot) -> IO Knot -> m Knot
forall a b. (a -> b) -> a -> b
$ do
Ptr Knot
knot' <- Knot -> IO (Ptr Knot)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Knot
knot
Ptr Knot
result <- Ptr Knot -> IO (Ptr Knot)
clutter_knot_copy Ptr Knot
knot'
Text -> Ptr Knot -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"knotCopy" Ptr Knot
result
Knot
result' <- ((ManagedPtr Knot -> Knot) -> Ptr Knot -> IO Knot
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Knot -> Knot
Knot) Ptr Knot
result
Knot -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Knot
knot
Knot -> IO Knot
forall (m :: * -> *) a. Monad m => a -> m a
return Knot
result'
#if defined(ENABLE_OVERLOADING)
data KnotCopyMethodInfo
instance (signature ~ (m Knot), MonadIO m) => O.OverloadedMethod KnotCopyMethodInfo Knot signature where
overloadedMethod = knotCopy
instance O.OverloadedMethodInfo KnotCopyMethodInfo Knot where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Clutter.Structs.Knot.knotCopy",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-clutter-1.0.2/docs/GI-Clutter-Structs-Knot.html#v:knotCopy"
})
#endif
foreign import ccall "clutter_knot_equal" clutter_knot_equal ::
Ptr Knot ->
Ptr Knot ->
IO CInt
knotEqual ::
(B.CallStack.HasCallStack, MonadIO m) =>
Knot
-> Knot
-> m Bool
knotEqual :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Knot -> Knot -> m Bool
knotEqual Knot
knotA Knot
knotB = 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 Knot
knotA' <- Knot -> IO (Ptr Knot)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Knot
knotA
Ptr Knot
knotB' <- Knot -> IO (Ptr Knot)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Knot
knotB
CInt
result <- Ptr Knot -> Ptr Knot -> IO CInt
clutter_knot_equal Ptr Knot
knotA' Ptr Knot
knotB'
let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
Knot -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Knot
knotA
Knot -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Knot
knotB
Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'
#if defined(ENABLE_OVERLOADING)
data KnotEqualMethodInfo
instance (signature ~ (Knot -> m Bool), MonadIO m) => O.OverloadedMethod KnotEqualMethodInfo Knot signature where
overloadedMethod = knotEqual
instance O.OverloadedMethodInfo KnotEqualMethodInfo Knot where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Clutter.Structs.Knot.knotEqual",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-clutter-1.0.2/docs/GI-Clutter-Structs-Knot.html#v:knotEqual"
})
#endif
foreign import ccall "clutter_knot_free" clutter_knot_free ::
Ptr Knot ->
IO ()
knotFree ::
(B.CallStack.HasCallStack, MonadIO m) =>
Knot
-> m ()
knotFree :: forall (m :: * -> *). (HasCallStack, MonadIO m) => Knot -> m ()
knotFree Knot
knot = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
Ptr Knot
knot' <- Knot -> IO (Ptr Knot)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Knot
knot
Ptr Knot -> IO ()
clutter_knot_free Ptr Knot
knot'
Knot -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Knot
knot
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data KnotFreeMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.OverloadedMethod KnotFreeMethodInfo Knot signature where
overloadedMethod = knotFree
instance O.OverloadedMethodInfo KnotFreeMethodInfo Knot where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Clutter.Structs.Knot.knotFree",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-clutter-1.0.2/docs/GI-Clutter-Structs-Knot.html#v:knotFree"
})
#endif
#if defined(ENABLE_OVERLOADING)
type family ResolveKnotMethod (t :: Symbol) (o :: *) :: * where
ResolveKnotMethod "copy" o = KnotCopyMethodInfo
ResolveKnotMethod "equal" o = KnotEqualMethodInfo
ResolveKnotMethod "free" o = KnotFreeMethodInfo
ResolveKnotMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveKnotMethod t Knot, O.OverloadedMethod info Knot p) => OL.IsLabel t (Knot -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod @info
#else
fromLabel _ = O.overloadedMethod @info
#endif
#if MIN_VERSION_base(4,13,0)
instance (info ~ ResolveKnotMethod t Knot, O.OverloadedMethod info Knot p, R.HasField t Knot p) => R.HasField t Knot p where
getField = O.overloadedMethod @info
#endif
instance (info ~ ResolveKnotMethod t Knot, O.OverloadedMethodInfo info Knot) => OL.IsLabel t (O.MethodProxy info Knot) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.MethodProxy
#else
fromLabel _ = O.MethodProxy
#endif
#endif