{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.Graphene.Structs.Quad
(
Quad(..) ,
newZeroQuad ,
#if defined(ENABLE_OVERLOADING)
ResolveQuadMethod ,
#endif
quadAlloc ,
#if defined(ENABLE_OVERLOADING)
QuadBoundsMethodInfo ,
#endif
quadBounds ,
#if defined(ENABLE_OVERLOADING)
QuadContainsMethodInfo ,
#endif
quadContains ,
#if defined(ENABLE_OVERLOADING)
QuadFreeMethodInfo ,
#endif
quadFree ,
#if defined(ENABLE_OVERLOADING)
QuadGetPointMethodInfo ,
#endif
quadGetPoint ,
#if defined(ENABLE_OVERLOADING)
QuadInitMethodInfo ,
#endif
quadInit ,
#if defined(ENABLE_OVERLOADING)
QuadInitFromPointsMethodInfo ,
#endif
quadInitFromPoints ,
#if defined(ENABLE_OVERLOADING)
QuadInitFromRectMethodInfo ,
#endif
quadInitFromRect ,
) 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.GHashTable as B.GHT
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.Kind as DK
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
import qualified Data.Word as DW
import qualified Data.Int as DI
import qualified System.Posix.Types as SPT
import qualified Foreign.C.Types as FCT
#if MIN_VERSION_base(4,18,0)
import {-# SOURCE #-} qualified GI.Graphene.Structs.Point as Graphene.Point
import {-# SOURCE #-} qualified GI.Graphene.Structs.Rect as Graphene.Rect
import {-# SOURCE #-} qualified GI.Graphene.Structs.Size as Graphene.Size
import {-# SOURCE #-} qualified GI.Graphene.Structs.Vec2 as Graphene.Vec2
#else
import {-# SOURCE #-} qualified GI.Graphene.Structs.Point as Graphene.Point
import {-# SOURCE #-} qualified GI.Graphene.Structs.Rect as Graphene.Rect
#endif
newtype Quad = Quad (SP.ManagedPtr Quad)
deriving (Quad -> Quad -> Bool
(Quad -> Quad -> Bool) -> (Quad -> Quad -> Bool) -> Eq Quad
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Quad -> Quad -> Bool
== :: Quad -> Quad -> Bool
$c/= :: Quad -> Quad -> Bool
/= :: Quad -> Quad -> Bool
Eq)
instance SP.ManagedPtrNewtype Quad where
toManagedPtr :: Quad -> ManagedPtr Quad
toManagedPtr (Quad ManagedPtr Quad
p) = ManagedPtr Quad
p
foreign import ccall "graphene_quad_get_type" c_graphene_quad_get_type ::
IO GType
type instance O.ParentTypes Quad = '[]
instance O.HasParentTypes Quad
instance B.Types.TypedObject Quad where
glibType :: IO GType
glibType = IO GType
c_graphene_quad_get_type
instance B.Types.GBoxed Quad
instance B.GValue.IsGValue (Maybe Quad) where
gvalueGType_ :: IO GType
gvalueGType_ = IO GType
c_graphene_quad_get_type
gvalueSet_ :: Ptr GValue -> Maybe Quad -> IO ()
gvalueSet_ Ptr GValue
gv Maybe Quad
P.Nothing = Ptr GValue -> Ptr Quad -> IO ()
forall a. Ptr GValue -> Ptr a -> IO ()
B.GValue.set_boxed Ptr GValue
gv (Ptr Quad
forall a. Ptr a
FP.nullPtr :: FP.Ptr Quad)
gvalueSet_ Ptr GValue
gv (P.Just Quad
obj) = Quad -> (Ptr Quad -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr Quad
obj (Ptr GValue -> Ptr Quad -> IO ()
forall a. Ptr GValue -> Ptr a -> IO ()
B.GValue.set_boxed Ptr GValue
gv)
gvalueGet_ :: Ptr GValue -> IO (Maybe Quad)
gvalueGet_ Ptr GValue
gv = do
ptr <- Ptr GValue -> IO (Ptr Quad)
forall b. Ptr GValue -> IO (Ptr b)
B.GValue.get_boxed Ptr GValue
gv :: IO (Ptr Quad)
if ptr /= FP.nullPtr
then P.Just <$> B.ManagedPtr.newBoxed Quad ptr
else return P.Nothing
newZeroQuad :: MonadIO m => m Quad
newZeroQuad :: forall (m :: * -> *). MonadIO m => m Quad
newZeroQuad = IO Quad -> m Quad
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Quad -> m Quad) -> IO Quad -> m Quad
forall a b. (a -> b) -> a -> b
$ Int -> IO (Ptr Quad)
forall a. GBoxed a => Int -> IO (Ptr a)
callocBoxedBytes Int
32 IO (Ptr Quad) -> (Ptr Quad -> IO Quad) -> IO Quad
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (ManagedPtr Quad -> Quad) -> Ptr Quad -> IO Quad
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Quad -> Quad
Quad
instance tag ~ 'AttrSet => Constructible Quad tag where
new :: forall (m :: * -> *).
MonadIO m =>
(ManagedPtr Quad -> Quad) -> [AttrOp Quad tag] -> m Quad
new ManagedPtr Quad -> Quad
_ [AttrOp Quad tag]
attrs = do
o <- m Quad
forall (m :: * -> *). MonadIO m => m Quad
newZeroQuad
GI.Attributes.set o attrs
return o
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList Quad
type instance O.AttributeList Quad = QuadAttributeList
type QuadAttributeList = ('[ ] :: [(Symbol, DK.Type)])
#endif
foreign import ccall "graphene_quad_alloc" graphene_quad_alloc ::
IO (Ptr Quad)
quadAlloc ::
(B.CallStack.HasCallStack, MonadIO m) =>
m Quad
quadAlloc :: forall (m :: * -> *). (HasCallStack, MonadIO m) => m Quad
quadAlloc = IO Quad -> m Quad
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Quad -> m Quad) -> IO Quad -> m Quad
forall a b. (a -> b) -> a -> b
$ do
result <- IO (Ptr Quad)
graphene_quad_alloc
checkUnexpectedReturnNULL "quadAlloc" result
result' <- (wrapBoxed Quad) result
return result'
#if defined(ENABLE_OVERLOADING)
#endif
foreign import ccall "graphene_quad_bounds" graphene_quad_bounds ::
Ptr Quad ->
Ptr Graphene.Rect.Rect ->
IO ()
quadBounds ::
(B.CallStack.HasCallStack, MonadIO m) =>
Quad
-> m (Graphene.Rect.Rect)
quadBounds :: forall (m :: * -> *). (HasCallStack, MonadIO m) => Quad -> m Rect
quadBounds Quad
q = IO Rect -> m Rect
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Rect -> m Rect) -> IO Rect -> m Rect
forall a b. (a -> b) -> a -> b
$ do
q' <- Quad -> IO (Ptr Quad)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Quad
q
r <- SP.callocBoxedBytes 16 :: IO (Ptr Graphene.Rect.Rect)
graphene_quad_bounds q' r
r' <- (wrapBoxed Graphene.Rect.Rect) r
touchManagedPtr q
return r'
#if defined(ENABLE_OVERLOADING)
data QuadBoundsMethodInfo
instance (signature ~ (m (Graphene.Rect.Rect)), MonadIO m) => O.OverloadedMethod QuadBoundsMethodInfo Quad signature where
overloadedMethod = quadBounds
instance O.OverloadedMethodInfo QuadBoundsMethodInfo Quad where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Graphene.Structs.Quad.quadBounds",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-graphene-1.0.8/docs/GI-Graphene-Structs-Quad.html#v:quadBounds"
})
#endif
foreign import ccall "graphene_quad_contains" graphene_quad_contains ::
Ptr Quad ->
Ptr Graphene.Point.Point ->
IO CInt
quadContains ::
(B.CallStack.HasCallStack, MonadIO m) =>
Quad
-> Graphene.Point.Point
-> m Bool
quadContains :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Quad -> Point -> m Bool
quadContains Quad
q Point
p = IO Bool -> m Bool
forall a. IO a -> m a
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
q' <- Quad -> IO (Ptr Quad)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Quad
q
p' <- unsafeManagedPtrGetPtr p
result <- graphene_quad_contains q' p'
let result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
touchManagedPtr q
touchManagedPtr p
return result'
#if defined(ENABLE_OVERLOADING)
data QuadContainsMethodInfo
instance (signature ~ (Graphene.Point.Point -> m Bool), MonadIO m) => O.OverloadedMethod QuadContainsMethodInfo Quad signature where
overloadedMethod = quadContains
instance O.OverloadedMethodInfo QuadContainsMethodInfo Quad where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Graphene.Structs.Quad.quadContains",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-graphene-1.0.8/docs/GI-Graphene-Structs-Quad.html#v:quadContains"
})
#endif
foreign import ccall "graphene_quad_free" graphene_quad_free ::
Ptr Quad ->
IO ()
quadFree ::
(B.CallStack.HasCallStack, MonadIO m) =>
Quad
-> m ()
quadFree :: forall (m :: * -> *). (HasCallStack, MonadIO m) => Quad -> m ()
quadFree Quad
q = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
q' <- Quad -> IO (Ptr Quad)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Quad
q
graphene_quad_free q'
touchManagedPtr q
return ()
#if defined(ENABLE_OVERLOADING)
data QuadFreeMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.OverloadedMethod QuadFreeMethodInfo Quad signature where
overloadedMethod = quadFree
instance O.OverloadedMethodInfo QuadFreeMethodInfo Quad where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Graphene.Structs.Quad.quadFree",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-graphene-1.0.8/docs/GI-Graphene-Structs-Quad.html#v:quadFree"
})
#endif
foreign import ccall "graphene_quad_get_point" graphene_quad_get_point ::
Ptr Quad ->
Word32 ->
IO (Ptr Graphene.Point.Point)
quadGetPoint ::
(B.CallStack.HasCallStack, MonadIO m) =>
Quad
-> Word32
-> m Graphene.Point.Point
quadGetPoint :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Quad -> Word32 -> m Point
quadGetPoint Quad
q Word32
index_ = IO Point -> m Point
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Point -> m Point) -> IO Point -> m Point
forall a b. (a -> b) -> a -> b
$ do
q' <- Quad -> IO (Ptr Quad)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Quad
q
result <- graphene_quad_get_point q' index_
checkUnexpectedReturnNULL "quadGetPoint" result
result' <- (newBoxed Graphene.Point.Point) result
touchManagedPtr q
return result'
#if defined(ENABLE_OVERLOADING)
data QuadGetPointMethodInfo
instance (signature ~ (Word32 -> m Graphene.Point.Point), MonadIO m) => O.OverloadedMethod QuadGetPointMethodInfo Quad signature where
overloadedMethod = quadGetPoint
instance O.OverloadedMethodInfo QuadGetPointMethodInfo Quad where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Graphene.Structs.Quad.quadGetPoint",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-graphene-1.0.8/docs/GI-Graphene-Structs-Quad.html#v:quadGetPoint"
})
#endif
foreign import ccall "graphene_quad_init" graphene_quad_init ::
Ptr Quad ->
Ptr Graphene.Point.Point ->
Ptr Graphene.Point.Point ->
Ptr Graphene.Point.Point ->
Ptr Graphene.Point.Point ->
IO (Ptr Quad)
quadInit ::
(B.CallStack.HasCallStack, MonadIO m) =>
Quad
-> Graphene.Point.Point
-> Graphene.Point.Point
-> Graphene.Point.Point
-> Graphene.Point.Point
-> m Quad
quadInit :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Quad -> Point -> Point -> Point -> Point -> m Quad
quadInit Quad
q Point
p1 Point
p2 Point
p3 Point
p4 = IO Quad -> m Quad
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Quad -> m Quad) -> IO Quad -> m Quad
forall a b. (a -> b) -> a -> b
$ do
q' <- Quad -> IO (Ptr Quad)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Quad
q
p1' <- unsafeManagedPtrGetPtr p1
p2' <- unsafeManagedPtrGetPtr p2
p3' <- unsafeManagedPtrGetPtr p3
p4' <- unsafeManagedPtrGetPtr p4
result <- graphene_quad_init q' p1' p2' p3' p4'
checkUnexpectedReturnNULL "quadInit" result
result' <- (newBoxed Quad) result
touchManagedPtr q
touchManagedPtr p1
touchManagedPtr p2
touchManagedPtr p3
touchManagedPtr p4
return result'
#if defined(ENABLE_OVERLOADING)
data QuadInitMethodInfo
instance (signature ~ (Graphene.Point.Point -> Graphene.Point.Point -> Graphene.Point.Point -> Graphene.Point.Point -> m Quad), MonadIO m) => O.OverloadedMethod QuadInitMethodInfo Quad signature where
overloadedMethod = quadInit
instance O.OverloadedMethodInfo QuadInitMethodInfo Quad where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Graphene.Structs.Quad.quadInit",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-graphene-1.0.8/docs/GI-Graphene-Structs-Quad.html#v:quadInit"
})
#endif
foreign import ccall "graphene_quad_init_from_points" graphene_quad_init_from_points ::
Ptr Quad ->
Ptr Graphene.Point.Point ->
IO (Ptr Quad)
quadInitFromPoints ::
(B.CallStack.HasCallStack, MonadIO m) =>
Quad
-> [Graphene.Point.Point]
-> m Quad
quadInitFromPoints :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Quad -> [Point] -> m Quad
quadInitFromPoints Quad
q [Point]
points = IO Quad -> m Quad
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Quad -> m Quad) -> IO Quad -> m Quad
forall a b. (a -> b) -> a -> b
$ do
q' <- Quad -> IO (Ptr Quad)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Quad
q
points' <- mapM unsafeManagedPtrGetPtr points
points'' <- packBlockArray 8 points'
result <- graphene_quad_init_from_points q' points''
checkUnexpectedReturnNULL "quadInitFromPoints" result
result' <- (newBoxed Quad) result
touchManagedPtr q
mapM_ touchManagedPtr points
freeMem points''
return result'
#if defined(ENABLE_OVERLOADING)
data QuadInitFromPointsMethodInfo
instance (signature ~ ([Graphene.Point.Point] -> m Quad), MonadIO m) => O.OverloadedMethod QuadInitFromPointsMethodInfo Quad signature where
overloadedMethod = quadInitFromPoints
instance O.OverloadedMethodInfo QuadInitFromPointsMethodInfo Quad where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Graphene.Structs.Quad.quadInitFromPoints",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-graphene-1.0.8/docs/GI-Graphene-Structs-Quad.html#v:quadInitFromPoints"
})
#endif
foreign import ccall "graphene_quad_init_from_rect" graphene_quad_init_from_rect ::
Ptr Quad ->
Ptr Graphene.Rect.Rect ->
IO (Ptr Quad)
quadInitFromRect ::
(B.CallStack.HasCallStack, MonadIO m) =>
Quad
-> Graphene.Rect.Rect
-> m Quad
quadInitFromRect :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Quad -> Rect -> m Quad
quadInitFromRect Quad
q Rect
r = IO Quad -> m Quad
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Quad -> m Quad) -> IO Quad -> m Quad
forall a b. (a -> b) -> a -> b
$ do
q' <- Quad -> IO (Ptr Quad)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Quad
q
r' <- unsafeManagedPtrGetPtr r
result <- graphene_quad_init_from_rect q' r'
checkUnexpectedReturnNULL "quadInitFromRect" result
result' <- (newBoxed Quad) result
touchManagedPtr q
touchManagedPtr r
return result'
#if defined(ENABLE_OVERLOADING)
data QuadInitFromRectMethodInfo
instance (signature ~ (Graphene.Rect.Rect -> m Quad), MonadIO m) => O.OverloadedMethod QuadInitFromRectMethodInfo Quad signature where
overloadedMethod = quadInitFromRect
instance O.OverloadedMethodInfo QuadInitFromRectMethodInfo Quad where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Graphene.Structs.Quad.quadInitFromRect",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-graphene-1.0.8/docs/GI-Graphene-Structs-Quad.html#v:quadInitFromRect"
})
#endif
#if defined(ENABLE_OVERLOADING)
type family ResolveQuadMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
ResolveQuadMethod "bounds" o = QuadBoundsMethodInfo
ResolveQuadMethod "contains" o = QuadContainsMethodInfo
ResolveQuadMethod "free" o = QuadFreeMethodInfo
ResolveQuadMethod "init" o = QuadInitMethodInfo
ResolveQuadMethod "initFromPoints" o = QuadInitFromPointsMethodInfo
ResolveQuadMethod "initFromRect" o = QuadInitFromRectMethodInfo
ResolveQuadMethod "getPoint" o = QuadGetPointMethodInfo
ResolveQuadMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveQuadMethod t Quad, O.OverloadedMethod info Quad p) => OL.IsLabel t (Quad -> 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 ~ ResolveQuadMethod t Quad, O.OverloadedMethod info Quad p, R.HasField t Quad p) => R.HasField t Quad p where
getField = O.overloadedMethod @info
#endif
instance (info ~ ResolveQuadMethod t Quad, O.OverloadedMethodInfo info Quad) => OL.IsLabel t (O.MethodProxy info Quad) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.MethodProxy
#else
fromLabel _ = O.MethodProxy
#endif
#endif