{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.Poppler.Structs.Point
(
Point(..) ,
newZeroPoint ,
#if defined(ENABLE_OVERLOADING)
ResolvePointMethod ,
#endif
#if defined(ENABLE_OVERLOADING)
PointCopyMethodInfo ,
#endif
pointCopy ,
#if defined(ENABLE_OVERLOADING)
PointFreeMethodInfo ,
#endif
pointFree ,
pointNew ,
getPointX ,
#if defined(ENABLE_OVERLOADING)
point_x ,
#endif
setPointX ,
getPointY ,
#if defined(ENABLE_OVERLOADING)
point_y ,
#endif
setPointY ,
) 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.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 Point = Point (SP.ManagedPtr Point)
deriving (Point -> Point -> Bool
(Point -> Point -> Bool) -> (Point -> Point -> Bool) -> Eq Point
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Point -> Point -> Bool
$c/= :: Point -> Point -> Bool
== :: Point -> Point -> Bool
$c== :: Point -> Point -> Bool
Eq)
instance SP.ManagedPtrNewtype Point where
toManagedPtr :: Point -> ManagedPtr Point
toManagedPtr (Point ManagedPtr Point
p) = ManagedPtr Point
p
foreign import ccall "poppler_point_get_type" c_poppler_point_get_type ::
IO GType
type instance O.ParentTypes Point = '[]
instance O.HasParentTypes Point
instance B.Types.TypedObject Point where
glibType :: IO GType
glibType = IO GType
c_poppler_point_get_type
instance B.Types.GBoxed Point
instance B.GValue.IsGValue Point where
toGValue :: Point -> IO GValue
toGValue Point
o = do
GType
gtype <- IO GType
c_poppler_point_get_type
Point -> (Ptr Point -> IO GValue) -> IO GValue
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr Point
o (GType -> (GValue -> Ptr Point -> IO ()) -> Ptr Point -> IO GValue
forall a. GType -> (GValue -> a -> IO ()) -> a -> IO GValue
B.GValue.buildGValue GType
gtype GValue -> Ptr Point -> IO ()
forall a. GValue -> Ptr a -> IO ()
B.GValue.set_boxed)
fromGValue :: GValue -> IO Point
fromGValue GValue
gv = do
Ptr Point
ptr <- GValue -> IO (Ptr Point)
forall b. GValue -> IO (Ptr b)
B.GValue.get_boxed GValue
gv :: IO (Ptr Point)
(ManagedPtr Point -> Point) -> Ptr Point -> IO Point
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
B.ManagedPtr.newBoxed ManagedPtr Point -> Point
Point Ptr Point
ptr
newZeroPoint :: MonadIO m => m Point
newZeroPoint :: m Point
newZeroPoint = IO Point -> m Point
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
$ Int -> IO (Ptr Point)
forall a. GBoxed a => Int -> IO (Ptr a)
callocBoxedBytes Int
16 IO (Ptr Point) -> (Ptr Point -> IO Point) -> IO Point
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (ManagedPtr Point -> Point) -> Ptr Point -> IO Point
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Point -> Point
Point
instance tag ~ 'AttrSet => Constructible Point tag where
new :: (ManagedPtr Point -> Point) -> [AttrOp Point tag] -> m Point
new ManagedPtr Point -> Point
_ [AttrOp Point tag]
attrs = do
Point
o <- m Point
forall (m :: * -> *). MonadIO m => m Point
newZeroPoint
Point -> [AttrOp Point 'AttrSet] -> m ()
forall o (m :: * -> *).
MonadIO m =>
o -> [AttrOp o 'AttrSet] -> m ()
GI.Attributes.set Point
o [AttrOp Point tag]
[AttrOp Point 'AttrSet]
attrs
Point -> m Point
forall (m :: * -> *) a. Monad m => a -> m a
return Point
o
getPointX :: MonadIO m => Point -> m Double
getPointX :: Point -> m Double
getPointX Point
s = IO Double -> m Double
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Double -> m Double) -> IO Double -> m Double
forall a b. (a -> b) -> a -> b
$ Point -> (Ptr Point -> IO Double) -> IO Double
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr Point
s ((Ptr Point -> IO Double) -> IO Double)
-> (Ptr Point -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr Point
ptr -> do
CDouble
val <- Ptr CDouble -> IO CDouble
forall a. Storable a => Ptr a -> IO a
peek (Ptr Point
ptr Ptr Point -> Int -> Ptr CDouble
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0) :: IO CDouble
let val' :: Double
val' = CDouble -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac CDouble
val
Double -> IO Double
forall (m :: * -> *) a. Monad m => a -> m a
return Double
val'
setPointX :: MonadIO m => Point -> Double -> m ()
setPointX :: Point -> Double -> m ()
setPointX Point
s Double
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ Point -> (Ptr Point -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr Point
s ((Ptr Point -> IO ()) -> IO ()) -> (Ptr Point -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Point
ptr -> do
let val' :: CDouble
val' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
val
Ptr CDouble -> CDouble -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr Point
ptr Ptr Point -> Int -> Ptr CDouble
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0) (CDouble
val' :: CDouble)
#if defined(ENABLE_OVERLOADING)
data PointXFieldInfo
instance AttrInfo PointXFieldInfo where
type AttrBaseTypeConstraint PointXFieldInfo = (~) Point
type AttrAllowedOps PointXFieldInfo = '[ 'AttrSet, 'AttrGet]
type AttrSetTypeConstraint PointXFieldInfo = (~) Double
type AttrTransferTypeConstraint PointXFieldInfo = (~)Double
type AttrTransferType PointXFieldInfo = Double
type AttrGetType PointXFieldInfo = Double
type AttrLabel PointXFieldInfo = "x"
type AttrOrigin PointXFieldInfo = Point
attrGet = getPointX
attrSet = setPointX
attrConstruct = undefined
attrClear = undefined
attrTransfer _ v = do
return v
point_x :: AttrLabelProxy "x"
point_x = AttrLabelProxy
#endif
getPointY :: MonadIO m => Point -> m Double
getPointY :: Point -> m Double
getPointY Point
s = IO Double -> m Double
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Double -> m Double) -> IO Double -> m Double
forall a b. (a -> b) -> a -> b
$ Point -> (Ptr Point -> IO Double) -> IO Double
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr Point
s ((Ptr Point -> IO Double) -> IO Double)
-> (Ptr Point -> IO Double) -> IO Double
forall a b. (a -> b) -> a -> b
$ \Ptr Point
ptr -> do
CDouble
val <- Ptr CDouble -> IO CDouble
forall a. Storable a => Ptr a -> IO a
peek (Ptr Point
ptr Ptr Point -> Int -> Ptr CDouble
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8) :: IO CDouble
let val' :: Double
val' = CDouble -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac CDouble
val
Double -> IO Double
forall (m :: * -> *) a. Monad m => a -> m a
return Double
val'
setPointY :: MonadIO m => Point -> Double -> m ()
setPointY :: Point -> Double -> m ()
setPointY Point
s Double
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ Point -> (Ptr Point -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr Point
s ((Ptr Point -> IO ()) -> IO ()) -> (Ptr Point -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Point
ptr -> do
let val' :: CDouble
val' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
val
Ptr CDouble -> CDouble -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr Point
ptr Ptr Point -> Int -> Ptr CDouble
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8) (CDouble
val' :: CDouble)
#if defined(ENABLE_OVERLOADING)
data PointYFieldInfo
instance AttrInfo PointYFieldInfo where
type AttrBaseTypeConstraint PointYFieldInfo = (~) Point
type AttrAllowedOps PointYFieldInfo = '[ 'AttrSet, 'AttrGet]
type AttrSetTypeConstraint PointYFieldInfo = (~) Double
type AttrTransferTypeConstraint PointYFieldInfo = (~)Double
type AttrTransferType PointYFieldInfo = Double
type AttrGetType PointYFieldInfo = Double
type AttrLabel PointYFieldInfo = "y"
type AttrOrigin PointYFieldInfo = Point
attrGet = getPointY
attrSet = setPointY
attrConstruct = undefined
attrClear = undefined
attrTransfer _ v = do
return v
point_y :: AttrLabelProxy "y"
point_y = AttrLabelProxy
#endif
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList Point
type instance O.AttributeList Point = PointAttributeList
type PointAttributeList = ('[ '("x", PointXFieldInfo), '("y", PointYFieldInfo)] :: [(Symbol, *)])
#endif
foreign import ccall "poppler_point_new" poppler_point_new ::
IO (Ptr Point)
pointNew ::
(B.CallStack.HasCallStack, MonadIO m) =>
m Point
pointNew :: m Point
pointNew = IO Point -> m Point
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
Ptr Point
result <- IO (Ptr Point)
poppler_point_new
Text -> Ptr Point -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"pointNew" Ptr Point
result
Point
result' <- ((ManagedPtr Point -> Point) -> Ptr Point -> IO Point
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Point -> Point
Point) Ptr Point
result
Point -> IO Point
forall (m :: * -> *) a. Monad m => a -> m a
return Point
result'
#if defined(ENABLE_OVERLOADING)
#endif
foreign import ccall "poppler_point_copy" poppler_point_copy ::
Ptr Point ->
IO (Ptr Point)
pointCopy ::
(B.CallStack.HasCallStack, MonadIO m) =>
Point
-> m Point
pointCopy :: Point -> m Point
pointCopy Point
point = IO Point -> m Point
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
Ptr Point
point' <- Point -> IO (Ptr Point)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Point
point
Ptr Point
result <- Ptr Point -> IO (Ptr Point)
poppler_point_copy Ptr Point
point'
Text -> Ptr Point -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"pointCopy" Ptr Point
result
Point
result' <- ((ManagedPtr Point -> Point) -> Ptr Point -> IO Point
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Point -> Point
Point) Ptr Point
result
Point -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Point
point
Point -> IO Point
forall (m :: * -> *) a. Monad m => a -> m a
return Point
result'
#if defined(ENABLE_OVERLOADING)
data PointCopyMethodInfo
instance (signature ~ (m Point), MonadIO m) => O.MethodInfo PointCopyMethodInfo Point signature where
overloadedMethod = pointCopy
#endif
foreign import ccall "poppler_point_free" poppler_point_free ::
Ptr Point ->
IO ()
pointFree ::
(B.CallStack.HasCallStack, MonadIO m) =>
Point
-> m ()
pointFree :: Point -> m ()
pointFree Point
point = 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 Point
point' <- Point -> IO (Ptr Point)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Point
point
Ptr Point -> IO ()
poppler_point_free Ptr Point
point'
Point -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Point
point
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data PointFreeMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo PointFreeMethodInfo Point signature where
overloadedMethod = pointFree
#endif
#if defined(ENABLE_OVERLOADING)
type family ResolvePointMethod (t :: Symbol) (o :: *) :: * where
ResolvePointMethod "copy" o = PointCopyMethodInfo
ResolvePointMethod "free" o = PointFreeMethodInfo
ResolvePointMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolvePointMethod t Point, O.MethodInfo info Point p) => OL.IsLabel t (Point -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod @info
#else
fromLabel _ = O.overloadedMethod @info
#endif
#endif