{-# LANGUAGE CApiFFI #-}
{-# LANGUAGE PatternSynonyms #-}
-- This file was generated by dear-bindings-ffi. Do not edit by hand.
module DearImGui.Raw.ImPlot.Point
( Point (..)
, destroy
, init
, withDefault
) where
import Control.Exception (bracket_)
import Foreign.Marshal.Alloc (alloca)
import Foreign.Ptr (Ptr, plusPtr)
import Foreign.Storable (Storable (..))
import GHC.Records (HasField (..))
import Prelude hiding (init)
#include "dcimgui_implot.h"
-- structs (opaque)
-- by-value
data {-# CTYPE "dcimgui_implot.h" "ImPlotPoint" #-} Point = Point
{ x :: Double
, y :: Double
}
deriving (Eq, Show)
instance Storable Point where
sizeOf _ = #{size ImPlotPoint}
alignment _ = #{alignment ImPlotPoint}
peek p = Point <$> #{peek ImPlotPoint, x} p <*> #{peek ImPlotPoint, y} p
poke p v = do
#{poke ImPlotPoint, x} p v.x
#{poke ImPlotPoint, y} p v.y
instance HasField "x" (Ptr Point) (Ptr Double) where
getField = #{ptr ImPlotPoint, x}
instance HasField "y" (Ptr Point) (Ptr Double) where
getField = #{ptr ImPlotPoint, y}
foreign import capi unsafe "DearImGuiWrappers.h ImPlotPoint_Init_wrap"
init
:: Ptr Point
-> IO ()
foreign import capi unsafe "DearImGuiWrappers.h ImPlotPoint_Destroy_wrap"
destroy
:: Ptr Point
-> IO ()
withDefault :: (Ptr Point -> IO a) -> IO a
withDefault k = alloca $ \p -> bracket_ (init p) (destroy p) (k p)