{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.Graphene.Structs.Sphere
(
Sphere(..) ,
newZeroSphere ,
#if defined(ENABLE_OVERLOADING)
ResolveSphereMethod ,
#endif
sphereAlloc ,
#if defined(ENABLE_OVERLOADING)
SphereContainsPointMethodInfo ,
#endif
sphereContainsPoint ,
#if defined(ENABLE_OVERLOADING)
SphereDistanceMethodInfo ,
#endif
sphereDistance ,
#if defined(ENABLE_OVERLOADING)
SphereEqualMethodInfo ,
#endif
sphereEqual ,
#if defined(ENABLE_OVERLOADING)
SphereFreeMethodInfo ,
#endif
sphereFree ,
#if defined(ENABLE_OVERLOADING)
SphereGetBoundingBoxMethodInfo ,
#endif
sphereGetBoundingBox ,
#if defined(ENABLE_OVERLOADING)
SphereGetCenterMethodInfo ,
#endif
sphereGetCenter ,
#if defined(ENABLE_OVERLOADING)
SphereGetRadiusMethodInfo ,
#endif
sphereGetRadius ,
#if defined(ENABLE_OVERLOADING)
SphereInitMethodInfo ,
#endif
sphereInit ,
#if defined(ENABLE_OVERLOADING)
SphereInitFromPointsMethodInfo ,
#endif
sphereInitFromPoints ,
#if defined(ENABLE_OVERLOADING)
SphereInitFromVectorsMethodInfo ,
#endif
sphereInitFromVectors ,
#if defined(ENABLE_OVERLOADING)
SphereIsEmptyMethodInfo ,
#endif
sphereIsEmpty ,
#if defined(ENABLE_OVERLOADING)
SphereTranslateMethodInfo ,
#endif
sphereTranslate ,
) 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.Box as Graphene.Box
import {-# SOURCE #-} qualified GI.Graphene.Structs.Point as Graphene.Point
import {-# SOURCE #-} qualified GI.Graphene.Structs.Point3D as Graphene.Point3D
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
import {-# SOURCE #-} qualified GI.Graphene.Structs.Vec3 as Graphene.Vec3
import {-# SOURCE #-} qualified GI.Graphene.Structs.Vec4 as Graphene.Vec4
#else
import {-# SOURCE #-} qualified GI.Graphene.Structs.Box as Graphene.Box
import {-# SOURCE #-} qualified GI.Graphene.Structs.Point3D as Graphene.Point3D
import {-# SOURCE #-} qualified GI.Graphene.Structs.Vec3 as Graphene.Vec3
#endif
newtype Sphere = Sphere (SP.ManagedPtr Sphere)
deriving (Sphere -> Sphere -> Bool
(Sphere -> Sphere -> Bool)
-> (Sphere -> Sphere -> Bool) -> Eq Sphere
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Sphere -> Sphere -> Bool
== :: Sphere -> Sphere -> Bool
$c/= :: Sphere -> Sphere -> Bool
/= :: Sphere -> Sphere -> Bool
Eq)
instance SP.ManagedPtrNewtype Sphere where
toManagedPtr :: Sphere -> ManagedPtr Sphere
toManagedPtr (Sphere ManagedPtr Sphere
p) = ManagedPtr Sphere
p
foreign import ccall "graphene_sphere_get_type" c_graphene_sphere_get_type ::
IO GType
type instance O.ParentTypes Sphere = '[]
instance O.HasParentTypes Sphere
instance B.Types.TypedObject Sphere where
glibType :: IO GType
glibType = IO GType
c_graphene_sphere_get_type
instance B.Types.GBoxed Sphere
instance B.GValue.IsGValue (Maybe Sphere) where
gvalueGType_ :: IO GType
gvalueGType_ = IO GType
c_graphene_sphere_get_type
gvalueSet_ :: Ptr GValue -> Maybe Sphere -> IO ()
gvalueSet_ Ptr GValue
gv Maybe Sphere
P.Nothing = Ptr GValue -> Ptr Sphere -> IO ()
forall a. Ptr GValue -> Ptr a -> IO ()
B.GValue.set_boxed Ptr GValue
gv (Ptr Sphere
forall a. Ptr a
FP.nullPtr :: FP.Ptr Sphere)
gvalueSet_ Ptr GValue
gv (P.Just Sphere
obj) = Sphere -> (Ptr Sphere -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr Sphere
obj (Ptr GValue -> Ptr Sphere -> IO ()
forall a. Ptr GValue -> Ptr a -> IO ()
B.GValue.set_boxed Ptr GValue
gv)
gvalueGet_ :: Ptr GValue -> IO (Maybe Sphere)
gvalueGet_ Ptr GValue
gv = do
ptr <- Ptr GValue -> IO (Ptr Sphere)
forall b. Ptr GValue -> IO (Ptr b)
B.GValue.get_boxed Ptr GValue
gv :: IO (Ptr Sphere)
if ptr /= FP.nullPtr
then P.Just <$> B.ManagedPtr.newBoxed Sphere ptr
else return P.Nothing
newZeroSphere :: MonadIO m => m Sphere
newZeroSphere :: forall (m :: * -> *). MonadIO m => m Sphere
newZeroSphere = IO Sphere -> m Sphere
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Sphere -> m Sphere) -> IO Sphere -> m Sphere
forall a b. (a -> b) -> a -> b
$ Int -> IO (Ptr Sphere)
forall a. GBoxed a => Int -> IO (Ptr a)
callocBoxedBytes Int
20 IO (Ptr Sphere) -> (Ptr Sphere -> IO Sphere) -> IO Sphere
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (ManagedPtr Sphere -> Sphere) -> Ptr Sphere -> IO Sphere
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Sphere -> Sphere
Sphere
instance tag ~ 'AttrSet => Constructible Sphere tag where
new :: forall (m :: * -> *).
MonadIO m =>
(ManagedPtr Sphere -> Sphere) -> [AttrOp Sphere tag] -> m Sphere
new ManagedPtr Sphere -> Sphere
_ [AttrOp Sphere tag]
attrs = do
o <- m Sphere
forall (m :: * -> *). MonadIO m => m Sphere
newZeroSphere
GI.Attributes.set o attrs
return o
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList Sphere
type instance O.AttributeList Sphere = SphereAttributeList
type SphereAttributeList = ('[ ] :: [(Symbol, DK.Type)])
#endif
foreign import ccall "graphene_sphere_alloc" graphene_sphere_alloc ::
IO (Ptr Sphere)
sphereAlloc ::
(B.CallStack.HasCallStack, MonadIO m) =>
m Sphere
sphereAlloc :: forall (m :: * -> *). (HasCallStack, MonadIO m) => m Sphere
sphereAlloc = IO Sphere -> m Sphere
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Sphere -> m Sphere) -> IO Sphere -> m Sphere
forall a b. (a -> b) -> a -> b
$ do
result <- IO (Ptr Sphere)
graphene_sphere_alloc
checkUnexpectedReturnNULL "sphereAlloc" result
result' <- (wrapBoxed Sphere) result
return result'
#if defined(ENABLE_OVERLOADING)
#endif
foreign import ccall "graphene_sphere_contains_point" graphene_sphere_contains_point ::
Ptr Sphere ->
Ptr Graphene.Point3D.Point3D ->
IO CInt
sphereContainsPoint ::
(B.CallStack.HasCallStack, MonadIO m) =>
Sphere
-> Graphene.Point3D.Point3D
-> m Bool
sphereContainsPoint :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Sphere -> Point3D -> m Bool
sphereContainsPoint Sphere
s Point3D
point = 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
s' <- Sphere -> IO (Ptr Sphere)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Sphere
s
point' <- unsafeManagedPtrGetPtr point
result <- graphene_sphere_contains_point s' point'
let result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
touchManagedPtr s
touchManagedPtr point
return result'
#if defined(ENABLE_OVERLOADING)
data SphereContainsPointMethodInfo
instance (signature ~ (Graphene.Point3D.Point3D -> m Bool), MonadIO m) => O.OverloadedMethod SphereContainsPointMethodInfo Sphere signature where
overloadedMethod = sphereContainsPoint
instance O.OverloadedMethodInfo SphereContainsPointMethodInfo Sphere where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Graphene.Structs.Sphere.sphereContainsPoint",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-graphene-1.0.8/docs/GI-Graphene-Structs-Sphere.html#v:sphereContainsPoint"
})
#endif
foreign import ccall "graphene_sphere_distance" graphene_sphere_distance ::
Ptr Sphere ->
Ptr Graphene.Point3D.Point3D ->
IO CFloat
sphereDistance ::
(B.CallStack.HasCallStack, MonadIO m) =>
Sphere
-> Graphene.Point3D.Point3D
-> m Float
sphereDistance :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Sphere -> Point3D -> m Float
sphereDistance Sphere
s Point3D
point = IO Float -> m Float
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Float -> m Float) -> IO Float -> m Float
forall a b. (a -> b) -> a -> b
$ do
s' <- Sphere -> IO (Ptr Sphere)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Sphere
s
point' <- unsafeManagedPtrGetPtr point
result <- graphene_sphere_distance s' point'
let result' = CFloat -> Float
forall a b. (Real a, Fractional b) => a -> b
realToFrac CFloat
result
touchManagedPtr s
touchManagedPtr point
return result'
#if defined(ENABLE_OVERLOADING)
data SphereDistanceMethodInfo
instance (signature ~ (Graphene.Point3D.Point3D -> m Float), MonadIO m) => O.OverloadedMethod SphereDistanceMethodInfo Sphere signature where
overloadedMethod = sphereDistance
instance O.OverloadedMethodInfo SphereDistanceMethodInfo Sphere where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Graphene.Structs.Sphere.sphereDistance",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-graphene-1.0.8/docs/GI-Graphene-Structs-Sphere.html#v:sphereDistance"
})
#endif
foreign import ccall "graphene_sphere_equal" graphene_sphere_equal ::
Ptr Sphere ->
Ptr Sphere ->
IO CInt
sphereEqual ::
(B.CallStack.HasCallStack, MonadIO m) =>
Sphere
-> Sphere
-> m Bool
sphereEqual :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Sphere -> Sphere -> m Bool
sphereEqual Sphere
a Sphere
b = 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
a' <- Sphere -> IO (Ptr Sphere)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Sphere
a
b' <- unsafeManagedPtrGetPtr b
result <- graphene_sphere_equal a' b'
let result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
touchManagedPtr a
touchManagedPtr b
return result'
#if defined(ENABLE_OVERLOADING)
data SphereEqualMethodInfo
instance (signature ~ (Sphere -> m Bool), MonadIO m) => O.OverloadedMethod SphereEqualMethodInfo Sphere signature where
overloadedMethod = sphereEqual
instance O.OverloadedMethodInfo SphereEqualMethodInfo Sphere where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Graphene.Structs.Sphere.sphereEqual",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-graphene-1.0.8/docs/GI-Graphene-Structs-Sphere.html#v:sphereEqual"
})
#endif
foreign import ccall "graphene_sphere_free" graphene_sphere_free ::
Ptr Sphere ->
IO ()
sphereFree ::
(B.CallStack.HasCallStack, MonadIO m) =>
Sphere
-> m ()
sphereFree :: forall (m :: * -> *). (HasCallStack, MonadIO m) => Sphere -> m ()
sphereFree Sphere
s = 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
s' <- Sphere -> IO (Ptr Sphere)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Sphere
s
graphene_sphere_free s'
touchManagedPtr s
return ()
#if defined(ENABLE_OVERLOADING)
data SphereFreeMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.OverloadedMethod SphereFreeMethodInfo Sphere signature where
overloadedMethod = sphereFree
instance O.OverloadedMethodInfo SphereFreeMethodInfo Sphere where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Graphene.Structs.Sphere.sphereFree",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-graphene-1.0.8/docs/GI-Graphene-Structs-Sphere.html#v:sphereFree"
})
#endif
foreign import ccall "graphene_sphere_get_bounding_box" graphene_sphere_get_bounding_box ::
Ptr Sphere ->
Ptr Graphene.Box.Box ->
IO ()
sphereGetBoundingBox ::
(B.CallStack.HasCallStack, MonadIO m) =>
Sphere
-> m (Graphene.Box.Box)
sphereGetBoundingBox :: forall (m :: * -> *). (HasCallStack, MonadIO m) => Sphere -> m Box
sphereGetBoundingBox Sphere
s = IO Box -> m Box
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Box -> m Box) -> IO Box -> m Box
forall a b. (a -> b) -> a -> b
$ do
s' <- Sphere -> IO (Ptr Sphere)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Sphere
s
box <- SP.callocBoxedBytes 32 :: IO (Ptr Graphene.Box.Box)
graphene_sphere_get_bounding_box s' box
box' <- (wrapBoxed Graphene.Box.Box) box
touchManagedPtr s
return box'
#if defined(ENABLE_OVERLOADING)
data SphereGetBoundingBoxMethodInfo
instance (signature ~ (m (Graphene.Box.Box)), MonadIO m) => O.OverloadedMethod SphereGetBoundingBoxMethodInfo Sphere signature where
overloadedMethod = sphereGetBoundingBox
instance O.OverloadedMethodInfo SphereGetBoundingBoxMethodInfo Sphere where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Graphene.Structs.Sphere.sphereGetBoundingBox",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-graphene-1.0.8/docs/GI-Graphene-Structs-Sphere.html#v:sphereGetBoundingBox"
})
#endif
foreign import ccall "graphene_sphere_get_center" graphene_sphere_get_center ::
Ptr Sphere ->
Ptr Graphene.Point3D.Point3D ->
IO ()
sphereGetCenter ::
(B.CallStack.HasCallStack, MonadIO m) =>
Sphere
-> m (Graphene.Point3D.Point3D)
sphereGetCenter :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Sphere -> m Point3D
sphereGetCenter Sphere
s = IO Point3D -> m Point3D
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Point3D -> m Point3D) -> IO Point3D -> m Point3D
forall a b. (a -> b) -> a -> b
$ do
s' <- Sphere -> IO (Ptr Sphere)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Sphere
s
center <- SP.callocBoxedBytes 12 :: IO (Ptr Graphene.Point3D.Point3D)
graphene_sphere_get_center s' center
center' <- (wrapBoxed Graphene.Point3D.Point3D) center
touchManagedPtr s
return center'
#if defined(ENABLE_OVERLOADING)
data SphereGetCenterMethodInfo
instance (signature ~ (m (Graphene.Point3D.Point3D)), MonadIO m) => O.OverloadedMethod SphereGetCenterMethodInfo Sphere signature where
overloadedMethod = sphereGetCenter
instance O.OverloadedMethodInfo SphereGetCenterMethodInfo Sphere where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Graphene.Structs.Sphere.sphereGetCenter",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-graphene-1.0.8/docs/GI-Graphene-Structs-Sphere.html#v:sphereGetCenter"
})
#endif
foreign import ccall "graphene_sphere_get_radius" graphene_sphere_get_radius ::
Ptr Sphere ->
IO CFloat
sphereGetRadius ::
(B.CallStack.HasCallStack, MonadIO m) =>
Sphere
-> m Float
sphereGetRadius :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Sphere -> m Float
sphereGetRadius Sphere
s = IO Float -> m Float
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Float -> m Float) -> IO Float -> m Float
forall a b. (a -> b) -> a -> b
$ do
s' <- Sphere -> IO (Ptr Sphere)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Sphere
s
result <- graphene_sphere_get_radius s'
let result' = CFloat -> Float
forall a b. (Real a, Fractional b) => a -> b
realToFrac CFloat
result
touchManagedPtr s
return result'
#if defined(ENABLE_OVERLOADING)
data SphereGetRadiusMethodInfo
instance (signature ~ (m Float), MonadIO m) => O.OverloadedMethod SphereGetRadiusMethodInfo Sphere signature where
overloadedMethod = sphereGetRadius
instance O.OverloadedMethodInfo SphereGetRadiusMethodInfo Sphere where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Graphene.Structs.Sphere.sphereGetRadius",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-graphene-1.0.8/docs/GI-Graphene-Structs-Sphere.html#v:sphereGetRadius"
})
#endif
foreign import ccall "graphene_sphere_init" graphene_sphere_init ::
Ptr Sphere ->
Ptr Graphene.Point3D.Point3D ->
CFloat ->
IO (Ptr Sphere)
sphereInit ::
(B.CallStack.HasCallStack, MonadIO m) =>
Sphere
-> Maybe (Graphene.Point3D.Point3D)
-> Float
-> m Sphere
sphereInit :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Sphere -> Maybe Point3D -> Float -> m Sphere
sphereInit Sphere
s Maybe Point3D
center Float
radius = IO Sphere -> m Sphere
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Sphere -> m Sphere) -> IO Sphere -> m Sphere
forall a b. (a -> b) -> a -> b
$ do
s' <- Sphere -> IO (Ptr Sphere)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Sphere
s
maybeCenter <- case center of
Maybe Point3D
Nothing -> Ptr Point3D -> IO (Ptr Point3D)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Point3D
forall a. Ptr a
FP.nullPtr
Just Point3D
jCenter -> do
jCenter' <- Point3D -> IO (Ptr Point3D)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Point3D
jCenter
return jCenter'
let radius' = Float -> CFloat
forall a b. (Real a, Fractional b) => a -> b
realToFrac Float
radius
result <- graphene_sphere_init s' maybeCenter radius'
checkUnexpectedReturnNULL "sphereInit" result
result' <- (newBoxed Sphere) result
touchManagedPtr s
whenJust center touchManagedPtr
return result'
#if defined(ENABLE_OVERLOADING)
data SphereInitMethodInfo
instance (signature ~ (Maybe (Graphene.Point3D.Point3D) -> Float -> m Sphere), MonadIO m) => O.OverloadedMethod SphereInitMethodInfo Sphere signature where
overloadedMethod = sphereInit
instance O.OverloadedMethodInfo SphereInitMethodInfo Sphere where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Graphene.Structs.Sphere.sphereInit",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-graphene-1.0.8/docs/GI-Graphene-Structs-Sphere.html#v:sphereInit"
})
#endif
foreign import ccall "graphene_sphere_init_from_points" graphene_sphere_init_from_points ::
Ptr Sphere ->
Word32 ->
Ptr Graphene.Point3D.Point3D ->
Ptr Graphene.Point3D.Point3D ->
IO (Ptr Sphere)
sphereInitFromPoints ::
(B.CallStack.HasCallStack, MonadIO m) =>
Sphere
-> [Graphene.Point3D.Point3D]
-> Maybe (Graphene.Point3D.Point3D)
-> m Sphere
sphereInitFromPoints :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Sphere -> [Point3D] -> Maybe Point3D -> m Sphere
sphereInitFromPoints Sphere
s [Point3D]
points Maybe Point3D
center = IO Sphere -> m Sphere
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Sphere -> m Sphere) -> IO Sphere -> m Sphere
forall a b. (a -> b) -> a -> b
$ do
let nPoints :: Word32
nPoints = Int -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Word32) -> Int -> Word32
forall a b. (a -> b) -> a -> b
$ [Point3D] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
P.length [Point3D]
points
s' <- Sphere -> IO (Ptr Sphere)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Sphere
s
points' <- mapM unsafeManagedPtrGetPtr points
points'' <- packBlockArray 12 points'
maybeCenter <- case center of
Maybe Point3D
Nothing -> Ptr Point3D -> IO (Ptr Point3D)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Point3D
forall a. Ptr a
FP.nullPtr
Just Point3D
jCenter -> do
jCenter' <- Point3D -> IO (Ptr Point3D)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Point3D
jCenter
return jCenter'
result <- graphene_sphere_init_from_points s' nPoints points'' maybeCenter
checkUnexpectedReturnNULL "sphereInitFromPoints" result
result' <- (newBoxed Sphere) result
touchManagedPtr s
mapM_ touchManagedPtr points
whenJust center touchManagedPtr
freeMem points''
return result'
#if defined(ENABLE_OVERLOADING)
data SphereInitFromPointsMethodInfo
instance (signature ~ ([Graphene.Point3D.Point3D] -> Maybe (Graphene.Point3D.Point3D) -> m Sphere), MonadIO m) => O.OverloadedMethod SphereInitFromPointsMethodInfo Sphere signature where
overloadedMethod = sphereInitFromPoints
instance O.OverloadedMethodInfo SphereInitFromPointsMethodInfo Sphere where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Graphene.Structs.Sphere.sphereInitFromPoints",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-graphene-1.0.8/docs/GI-Graphene-Structs-Sphere.html#v:sphereInitFromPoints"
})
#endif
foreign import ccall "graphene_sphere_init_from_vectors" graphene_sphere_init_from_vectors ::
Ptr Sphere ->
Word32 ->
Ptr Graphene.Vec3.Vec3 ->
Ptr Graphene.Point3D.Point3D ->
IO (Ptr Sphere)
sphereInitFromVectors ::
(B.CallStack.HasCallStack, MonadIO m) =>
Sphere
-> [Graphene.Vec3.Vec3]
-> Maybe (Graphene.Point3D.Point3D)
-> m Sphere
sphereInitFromVectors :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Sphere -> [Vec3] -> Maybe Point3D -> m Sphere
sphereInitFromVectors Sphere
s [Vec3]
vectors Maybe Point3D
center = IO Sphere -> m Sphere
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Sphere -> m Sphere) -> IO Sphere -> m Sphere
forall a b. (a -> b) -> a -> b
$ do
let nVectors :: Word32
nVectors = Int -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Word32) -> Int -> Word32
forall a b. (a -> b) -> a -> b
$ [Vec3] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
P.length [Vec3]
vectors
s' <- Sphere -> IO (Ptr Sphere)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Sphere
s
vectors' <- mapM unsafeManagedPtrGetPtr vectors
vectors'' <- packBlockArray 16 vectors'
maybeCenter <- case center of
Maybe Point3D
Nothing -> Ptr Point3D -> IO (Ptr Point3D)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Point3D
forall a. Ptr a
FP.nullPtr
Just Point3D
jCenter -> do
jCenter' <- Point3D -> IO (Ptr Point3D)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Point3D
jCenter
return jCenter'
result <- graphene_sphere_init_from_vectors s' nVectors vectors'' maybeCenter
checkUnexpectedReturnNULL "sphereInitFromVectors" result
result' <- (newBoxed Sphere) result
touchManagedPtr s
mapM_ touchManagedPtr vectors
whenJust center touchManagedPtr
freeMem vectors''
return result'
#if defined(ENABLE_OVERLOADING)
data SphereInitFromVectorsMethodInfo
instance (signature ~ ([Graphene.Vec3.Vec3] -> Maybe (Graphene.Point3D.Point3D) -> m Sphere), MonadIO m) => O.OverloadedMethod SphereInitFromVectorsMethodInfo Sphere signature where
overloadedMethod = sphereInitFromVectors
instance O.OverloadedMethodInfo SphereInitFromVectorsMethodInfo Sphere where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Graphene.Structs.Sphere.sphereInitFromVectors",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-graphene-1.0.8/docs/GI-Graphene-Structs-Sphere.html#v:sphereInitFromVectors"
})
#endif
foreign import ccall "graphene_sphere_is_empty" graphene_sphere_is_empty ::
Ptr Sphere ->
IO CInt
sphereIsEmpty ::
(B.CallStack.HasCallStack, MonadIO m) =>
Sphere
-> m Bool
sphereIsEmpty :: forall (m :: * -> *). (HasCallStack, MonadIO m) => Sphere -> m Bool
sphereIsEmpty Sphere
s = 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
s' <- Sphere -> IO (Ptr Sphere)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Sphere
s
result <- graphene_sphere_is_empty s'
let result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
touchManagedPtr s
return result'
#if defined(ENABLE_OVERLOADING)
data SphereIsEmptyMethodInfo
instance (signature ~ (m Bool), MonadIO m) => O.OverloadedMethod SphereIsEmptyMethodInfo Sphere signature where
overloadedMethod = sphereIsEmpty
instance O.OverloadedMethodInfo SphereIsEmptyMethodInfo Sphere where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Graphene.Structs.Sphere.sphereIsEmpty",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-graphene-1.0.8/docs/GI-Graphene-Structs-Sphere.html#v:sphereIsEmpty"
})
#endif
foreign import ccall "graphene_sphere_translate" graphene_sphere_translate ::
Ptr Sphere ->
Ptr Graphene.Point3D.Point3D ->
Ptr Sphere ->
IO ()
sphereTranslate ::
(B.CallStack.HasCallStack, MonadIO m) =>
Sphere
-> Graphene.Point3D.Point3D
-> m (Sphere)
sphereTranslate :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Sphere -> Point3D -> m Sphere
sphereTranslate Sphere
s Point3D
point = IO Sphere -> m Sphere
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Sphere -> m Sphere) -> IO Sphere -> m Sphere
forall a b. (a -> b) -> a -> b
$ do
s' <- Sphere -> IO (Ptr Sphere)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Sphere
s
point' <- unsafeManagedPtrGetPtr point
res <- SP.callocBoxedBytes 20 :: IO (Ptr Sphere)
graphene_sphere_translate s' point' res
res' <- (wrapBoxed Sphere) res
touchManagedPtr s
touchManagedPtr point
return res'
#if defined(ENABLE_OVERLOADING)
data SphereTranslateMethodInfo
instance (signature ~ (Graphene.Point3D.Point3D -> m (Sphere)), MonadIO m) => O.OverloadedMethod SphereTranslateMethodInfo Sphere signature where
overloadedMethod = sphereTranslate
instance O.OverloadedMethodInfo SphereTranslateMethodInfo Sphere where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Graphene.Structs.Sphere.sphereTranslate",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-graphene-1.0.8/docs/GI-Graphene-Structs-Sphere.html#v:sphereTranslate"
})
#endif
#if defined(ENABLE_OVERLOADING)
type family ResolveSphereMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
ResolveSphereMethod "containsPoint" o = SphereContainsPointMethodInfo
ResolveSphereMethod "distance" o = SphereDistanceMethodInfo
ResolveSphereMethod "equal" o = SphereEqualMethodInfo
ResolveSphereMethod "free" o = SphereFreeMethodInfo
ResolveSphereMethod "init" o = SphereInitMethodInfo
ResolveSphereMethod "initFromPoints" o = SphereInitFromPointsMethodInfo
ResolveSphereMethod "initFromVectors" o = SphereInitFromVectorsMethodInfo
ResolveSphereMethod "isEmpty" o = SphereIsEmptyMethodInfo
ResolveSphereMethod "translate" o = SphereTranslateMethodInfo
ResolveSphereMethod "getBoundingBox" o = SphereGetBoundingBoxMethodInfo
ResolveSphereMethod "getCenter" o = SphereGetCenterMethodInfo
ResolveSphereMethod "getRadius" o = SphereGetRadiusMethodInfo
ResolveSphereMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveSphereMethod t Sphere, O.OverloadedMethod info Sphere p) => OL.IsLabel t (Sphere -> 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 ~ ResolveSphereMethod t Sphere, O.OverloadedMethod info Sphere p, R.HasField t Sphere p) => R.HasField t Sphere p where
getField = O.overloadedMethod @info
#endif
instance (info ~ ResolveSphereMethod t Sphere, O.OverloadedMethodInfo info Sphere) => OL.IsLabel t (O.MethodProxy info Sphere) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.MethodProxy
#else
fromLabel _ = O.MethodProxy
#endif
#endif