{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.Graphene.Structs.Size
(
Size(..) ,
newZeroSize ,
noSize ,
#if defined(ENABLE_OVERLOADING)
ResolveSizeMethod ,
#endif
sizeAlloc ,
#if defined(ENABLE_OVERLOADING)
SizeEqualMethodInfo ,
#endif
sizeEqual ,
#if defined(ENABLE_OVERLOADING)
SizeFreeMethodInfo ,
#endif
sizeFree ,
#if defined(ENABLE_OVERLOADING)
SizeInitMethodInfo ,
#endif
sizeInit ,
#if defined(ENABLE_OVERLOADING)
SizeInitFromSizeMethodInfo ,
#endif
sizeInitFromSize ,
#if defined(ENABLE_OVERLOADING)
SizeInterpolateMethodInfo ,
#endif
sizeInterpolate ,
#if defined(ENABLE_OVERLOADING)
SizeScaleMethodInfo ,
#endif
sizeScale ,
sizeZero ,
getSizeHeight ,
setSizeHeight ,
#if defined(ENABLE_OVERLOADING)
size_height ,
#endif
getSizeWidth ,
setSizeWidth ,
#if defined(ENABLE_OVERLOADING)
size_width ,
#endif
) 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.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 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
newtype Size = Size (ManagedPtr Size)
deriving (Size -> Size -> Bool
(Size -> Size -> Bool) -> (Size -> Size -> Bool) -> Eq Size
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Size -> Size -> Bool
$c/= :: Size -> Size -> Bool
== :: Size -> Size -> Bool
$c== :: Size -> Size -> Bool
Eq)
foreign import ccall "graphene_size_get_type" c_graphene_size_get_type ::
IO GType
instance BoxedObject Size where
boxedType :: Size -> IO GType
boxedType _ = IO GType
c_graphene_size_get_type
instance B.GValue.IsGValue Size where
toGValue :: Size -> IO GValue
toGValue o :: Size
o = do
GType
gtype <- IO GType
c_graphene_size_get_type
Size -> (Ptr Size -> IO GValue) -> IO GValue
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr Size
o (GType -> (GValue -> Ptr Size -> IO ()) -> Ptr Size -> IO GValue
forall a. GType -> (GValue -> a -> IO ()) -> a -> IO GValue
B.GValue.buildGValue GType
gtype GValue -> Ptr Size -> IO ()
forall a. GValue -> Ptr a -> IO ()
B.GValue.set_boxed)
fromGValue :: GValue -> IO Size
fromGValue gv :: GValue
gv = do
Ptr Size
ptr <- GValue -> IO (Ptr Size)
forall b. GValue -> IO (Ptr b)
B.GValue.get_boxed GValue
gv :: IO (Ptr Size)
(ManagedPtr Size -> Size) -> Ptr Size -> IO Size
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
B.ManagedPtr.newBoxed ManagedPtr Size -> Size
Size Ptr Size
ptr
newZeroSize :: MonadIO m => m Size
newZeroSize :: m Size
newZeroSize = IO Size -> m Size
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Size -> m Size) -> IO Size -> m Size
forall a b. (a -> b) -> a -> b
$ Int -> IO (Ptr Size)
forall a. BoxedObject a => Int -> IO (Ptr a)
callocBoxedBytes 8 IO (Ptr Size) -> (Ptr Size -> IO Size) -> IO Size
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (ManagedPtr Size -> Size) -> Ptr Size -> IO Size
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Size -> Size
Size
instance tag ~ 'AttrSet => Constructible Size tag where
new :: (ManagedPtr Size -> Size) -> [AttrOp Size tag] -> m Size
new _ attrs :: [AttrOp Size tag]
attrs = do
Size
o <- m Size
forall (m :: * -> *). MonadIO m => m Size
newZeroSize
Size -> [AttrOp Size 'AttrSet] -> m ()
forall o (m :: * -> *).
MonadIO m =>
o -> [AttrOp o 'AttrSet] -> m ()
GI.Attributes.set Size
o [AttrOp Size tag]
[AttrOp Size 'AttrSet]
attrs
Size -> m Size
forall (m :: * -> *) a. Monad m => a -> m a
return Size
o
noSize :: Maybe Size
noSize :: Maybe Size
noSize = Maybe Size
forall a. Maybe a
Nothing
getSizeWidth :: MonadIO m => Size -> m Float
getSizeWidth :: Size -> m Float
getSizeWidth s :: Size
s = IO Float -> m Float
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
$ Size -> (Ptr Size -> IO Float) -> IO Float
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr Size
s ((Ptr Size -> IO Float) -> IO Float)
-> (Ptr Size -> IO Float) -> IO Float
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr Size
ptr -> do
CFloat
val <- Ptr CFloat -> IO CFloat
forall a. Storable a => Ptr a -> IO a
peek (Ptr Size
ptr Ptr Size -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0) :: IO CFloat
let val' :: Float
val' = CFloat -> Float
forall a b. (Real a, Fractional b) => a -> b
realToFrac CFloat
val
Float -> IO Float
forall (m :: * -> *) a. Monad m => a -> m a
return Float
val'
setSizeWidth :: MonadIO m => Size -> Float -> m ()
setSizeWidth :: Size -> Float -> m ()
setSizeWidth s :: Size
s val :: Float
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ Size -> (Ptr Size -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr Size
s ((Ptr Size -> IO ()) -> IO ()) -> (Ptr Size -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr Size
ptr -> do
let val' :: CFloat
val' = Float -> CFloat
forall a b. (Real a, Fractional b) => a -> b
realToFrac Float
val
Ptr CFloat -> CFloat -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr Size
ptr Ptr Size -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0) (CFloat
val' :: CFloat)
#if defined(ENABLE_OVERLOADING)
data SizeWidthFieldInfo
instance AttrInfo SizeWidthFieldInfo where
type AttrBaseTypeConstraint SizeWidthFieldInfo = (~) Size
type AttrAllowedOps SizeWidthFieldInfo = '[ 'AttrSet, 'AttrGet]
type AttrSetTypeConstraint SizeWidthFieldInfo = (~) Float
type AttrTransferTypeConstraint SizeWidthFieldInfo = (~)Float
type AttrTransferType SizeWidthFieldInfo = Float
type AttrGetType SizeWidthFieldInfo = Float
type AttrLabel SizeWidthFieldInfo = "width"
type AttrOrigin SizeWidthFieldInfo = Size
attrGet = getSizeWidth
attrSet = setSizeWidth
attrConstruct = undefined
attrClear = undefined
attrTransfer _ v = do
return v
size_width :: AttrLabelProxy "width"
size_width = AttrLabelProxy
#endif
getSizeHeight :: MonadIO m => Size -> m Float
getSizeHeight :: Size -> m Float
getSizeHeight s :: Size
s = IO Float -> m Float
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
$ Size -> (Ptr Size -> IO Float) -> IO Float
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr Size
s ((Ptr Size -> IO Float) -> IO Float)
-> (Ptr Size -> IO Float) -> IO Float
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr Size
ptr -> do
CFloat
val <- Ptr CFloat -> IO CFloat
forall a. Storable a => Ptr a -> IO a
peek (Ptr Size
ptr Ptr Size -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 4) :: IO CFloat
let val' :: Float
val' = CFloat -> Float
forall a b. (Real a, Fractional b) => a -> b
realToFrac CFloat
val
Float -> IO Float
forall (m :: * -> *) a. Monad m => a -> m a
return Float
val'
setSizeHeight :: MonadIO m => Size -> Float -> m ()
setSizeHeight :: Size -> Float -> m ()
setSizeHeight s :: Size
s val :: Float
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ Size -> (Ptr Size -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr Size
s ((Ptr Size -> IO ()) -> IO ()) -> (Ptr Size -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr Size
ptr -> do
let val' :: CFloat
val' = Float -> CFloat
forall a b. (Real a, Fractional b) => a -> b
realToFrac Float
val
Ptr CFloat -> CFloat -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr Size
ptr Ptr Size -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 4) (CFloat
val' :: CFloat)
#if defined(ENABLE_OVERLOADING)
data SizeHeightFieldInfo
instance AttrInfo SizeHeightFieldInfo where
type AttrBaseTypeConstraint SizeHeightFieldInfo = (~) Size
type AttrAllowedOps SizeHeightFieldInfo = '[ 'AttrSet, 'AttrGet]
type AttrSetTypeConstraint SizeHeightFieldInfo = (~) Float
type AttrTransferTypeConstraint SizeHeightFieldInfo = (~)Float
type AttrTransferType SizeHeightFieldInfo = Float
type AttrGetType SizeHeightFieldInfo = Float
type AttrLabel SizeHeightFieldInfo = "height"
type AttrOrigin SizeHeightFieldInfo = Size
attrGet = getSizeHeight
attrSet = setSizeHeight
attrConstruct = undefined
attrClear = undefined
attrTransfer _ v = do
return v
size_height :: AttrLabelProxy "height"
size_height = AttrLabelProxy
#endif
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList Size
type instance O.AttributeList Size = SizeAttributeList
type SizeAttributeList = ('[ '("width", SizeWidthFieldInfo), '("height", SizeHeightFieldInfo)] :: [(Symbol, *)])
#endif
foreign import ccall "graphene_size_alloc" graphene_size_alloc ::
IO (Ptr Size)
sizeAlloc ::
(B.CallStack.HasCallStack, MonadIO m) =>
m Size
sizeAlloc :: m Size
sizeAlloc = IO Size -> m Size
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Size -> m Size) -> IO Size -> m Size
forall a b. (a -> b) -> a -> b
$ do
Ptr Size
result <- IO (Ptr Size)
graphene_size_alloc
Text -> Ptr Size -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "sizeAlloc" Ptr Size
result
Size
result' <- ((ManagedPtr Size -> Size) -> Ptr Size -> IO Size
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Size -> Size
Size) Ptr Size
result
Size -> IO Size
forall (m :: * -> *) a. Monad m => a -> m a
return Size
result'
#if defined(ENABLE_OVERLOADING)
#endif
foreign import ccall "graphene_size_equal" graphene_size_equal ::
Ptr Size ->
Ptr Size ->
IO CInt
sizeEqual ::
(B.CallStack.HasCallStack, MonadIO m) =>
Size
-> Size
-> m Bool
sizeEqual :: Size -> Size -> m Bool
sizeEqual a :: Size
a b :: Size
b = 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 Size
a' <- Size -> IO (Ptr Size)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Size
a
Ptr Size
b' <- Size -> IO (Ptr Size)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Size
b
CInt
result <- Ptr Size -> Ptr Size -> IO CInt
graphene_size_equal Ptr Size
a' Ptr Size
b'
let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
Size -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Size
a
Size -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Size
b
Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'
#if defined(ENABLE_OVERLOADING)
data SizeEqualMethodInfo
instance (signature ~ (Size -> m Bool), MonadIO m) => O.MethodInfo SizeEqualMethodInfo Size signature where
overloadedMethod = sizeEqual
#endif
foreign import ccall "graphene_size_free" graphene_size_free ::
Ptr Size ->
IO ()
sizeFree ::
(B.CallStack.HasCallStack, MonadIO m) =>
Size
-> m ()
sizeFree :: Size -> m ()
sizeFree s :: Size
s = 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 Size
s' <- Size -> IO (Ptr Size)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Size
s
Ptr Size -> IO ()
graphene_size_free Ptr Size
s'
Size -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Size
s
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data SizeFreeMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo SizeFreeMethodInfo Size signature where
overloadedMethod = sizeFree
#endif
foreign import ccall "graphene_size_init" graphene_size_init ::
Ptr Size ->
CFloat ->
CFloat ->
IO (Ptr Size)
sizeInit ::
(B.CallStack.HasCallStack, MonadIO m) =>
Size
-> Float
-> Float
-> m Size
sizeInit :: Size -> Float -> Float -> m Size
sizeInit s :: Size
s width :: Float
width height :: Float
height = IO Size -> m Size
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Size -> m Size) -> IO Size -> m Size
forall a b. (a -> b) -> a -> b
$ do
Ptr Size
s' <- Size -> IO (Ptr Size)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Size
s
let width' :: CFloat
width' = Float -> CFloat
forall a b. (Real a, Fractional b) => a -> b
realToFrac Float
width
let height' :: CFloat
height' = Float -> CFloat
forall a b. (Real a, Fractional b) => a -> b
realToFrac Float
height
Ptr Size
result <- Ptr Size -> CFloat -> CFloat -> IO (Ptr Size)
graphene_size_init Ptr Size
s' CFloat
width' CFloat
height'
Text -> Ptr Size -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "sizeInit" Ptr Size
result
Size
result' <- ((ManagedPtr Size -> Size) -> Ptr Size -> IO Size
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr Size -> Size
Size) Ptr Size
result
Size -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Size
s
Size -> IO Size
forall (m :: * -> *) a. Monad m => a -> m a
return Size
result'
#if defined(ENABLE_OVERLOADING)
data SizeInitMethodInfo
instance (signature ~ (Float -> Float -> m Size), MonadIO m) => O.MethodInfo SizeInitMethodInfo Size signature where
overloadedMethod = sizeInit
#endif
foreign import ccall "graphene_size_init_from_size" graphene_size_init_from_size ::
Ptr Size ->
Ptr Size ->
IO (Ptr Size)
sizeInitFromSize ::
(B.CallStack.HasCallStack, MonadIO m) =>
Size
-> Size
-> m Size
sizeInitFromSize :: Size -> Size -> m Size
sizeInitFromSize s :: Size
s src :: Size
src = IO Size -> m Size
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Size -> m Size) -> IO Size -> m Size
forall a b. (a -> b) -> a -> b
$ do
Ptr Size
s' <- Size -> IO (Ptr Size)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Size
s
Ptr Size
src' <- Size -> IO (Ptr Size)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Size
src
Ptr Size
result <- Ptr Size -> Ptr Size -> IO (Ptr Size)
graphene_size_init_from_size Ptr Size
s' Ptr Size
src'
Text -> Ptr Size -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "sizeInitFromSize" Ptr Size
result
Size
result' <- ((ManagedPtr Size -> Size) -> Ptr Size -> IO Size
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr Size -> Size
Size) Ptr Size
result
Size -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Size
s
Size -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Size
src
Size -> IO Size
forall (m :: * -> *) a. Monad m => a -> m a
return Size
result'
#if defined(ENABLE_OVERLOADING)
data SizeInitFromSizeMethodInfo
instance (signature ~ (Size -> m Size), MonadIO m) => O.MethodInfo SizeInitFromSizeMethodInfo Size signature where
overloadedMethod = sizeInitFromSize
#endif
foreign import ccall "graphene_size_interpolate" graphene_size_interpolate ::
Ptr Size ->
Ptr Size ->
CDouble ->
Ptr Size ->
IO ()
sizeInterpolate ::
(B.CallStack.HasCallStack, MonadIO m) =>
Size
-> Size
-> Double
-> m (Size)
sizeInterpolate :: Size -> Size -> Double -> m Size
sizeInterpolate a :: Size
a b :: Size
b factor :: Double
factor = IO Size -> m Size
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Size -> m Size) -> IO Size -> m Size
forall a b. (a -> b) -> a -> b
$ do
Ptr Size
a' <- Size -> IO (Ptr Size)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Size
a
Ptr Size
b' <- Size -> IO (Ptr Size)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Size
b
let factor' :: CDouble
factor' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
factor
Ptr Size
res <- Int -> IO (Ptr Size)
forall a. BoxedObject a => Int -> IO (Ptr a)
callocBoxedBytes 8 :: IO (Ptr Size)
Ptr Size -> Ptr Size -> CDouble -> Ptr Size -> IO ()
graphene_size_interpolate Ptr Size
a' Ptr Size
b' CDouble
factor' Ptr Size
res
Size
res' <- ((ManagedPtr Size -> Size) -> Ptr Size -> IO Size
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Size -> Size
Size) Ptr Size
res
Size -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Size
a
Size -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Size
b
Size -> IO Size
forall (m :: * -> *) a. Monad m => a -> m a
return Size
res'
#if defined(ENABLE_OVERLOADING)
data SizeInterpolateMethodInfo
instance (signature ~ (Size -> Double -> m (Size)), MonadIO m) => O.MethodInfo SizeInterpolateMethodInfo Size signature where
overloadedMethod = sizeInterpolate
#endif
foreign import ccall "graphene_size_scale" graphene_size_scale ::
Ptr Size ->
CFloat ->
Ptr Size ->
IO ()
sizeScale ::
(B.CallStack.HasCallStack, MonadIO m) =>
Size
-> Float
-> m (Size)
sizeScale :: Size -> Float -> m Size
sizeScale s :: Size
s factor :: Float
factor = IO Size -> m Size
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Size -> m Size) -> IO Size -> m Size
forall a b. (a -> b) -> a -> b
$ do
Ptr Size
s' <- Size -> IO (Ptr Size)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Size
s
let factor' :: CFloat
factor' = Float -> CFloat
forall a b. (Real a, Fractional b) => a -> b
realToFrac Float
factor
Ptr Size
res <- Int -> IO (Ptr Size)
forall a. BoxedObject a => Int -> IO (Ptr a)
callocBoxedBytes 8 :: IO (Ptr Size)
Ptr Size -> CFloat -> Ptr Size -> IO ()
graphene_size_scale Ptr Size
s' CFloat
factor' Ptr Size
res
Size
res' <- ((ManagedPtr Size -> Size) -> Ptr Size -> IO Size
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Size -> Size
Size) Ptr Size
res
Size -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Size
s
Size -> IO Size
forall (m :: * -> *) a. Monad m => a -> m a
return Size
res'
#if defined(ENABLE_OVERLOADING)
data SizeScaleMethodInfo
instance (signature ~ (Float -> m (Size)), MonadIO m) => O.MethodInfo SizeScaleMethodInfo Size signature where
overloadedMethod = sizeScale
#endif
foreign import ccall "graphene_size_zero" graphene_size_zero ::
IO (Ptr Size)
sizeZero ::
(B.CallStack.HasCallStack, MonadIO m) =>
m Size
sizeZero :: m Size
sizeZero = IO Size -> m Size
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Size -> m Size) -> IO Size -> m Size
forall a b. (a -> b) -> a -> b
$ do
Ptr Size
result <- IO (Ptr Size)
graphene_size_zero
Text -> Ptr Size -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "sizeZero" Ptr Size
result
Size
result' <- ((ManagedPtr Size -> Size) -> Ptr Size -> IO Size
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr Size -> Size
Size) Ptr Size
result
Size -> IO Size
forall (m :: * -> *) a. Monad m => a -> m a
return Size
result'
#if defined(ENABLE_OVERLOADING)
#endif
#if defined(ENABLE_OVERLOADING)
type family ResolveSizeMethod (t :: Symbol) (o :: *) :: * where
ResolveSizeMethod "equal" o = SizeEqualMethodInfo
ResolveSizeMethod "free" o = SizeFreeMethodInfo
ResolveSizeMethod "init" o = SizeInitMethodInfo
ResolveSizeMethod "initFromSize" o = SizeInitFromSizeMethodInfo
ResolveSizeMethod "interpolate" o = SizeInterpolateMethodInfo
ResolveSizeMethod "scale" o = SizeScaleMethodInfo
ResolveSizeMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveSizeMethod t Size, O.MethodInfo info Size p) => OL.IsLabel t (Size -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod @info
#else
fromLabel _ = O.overloadedMethod @info
#endif
#endif