dear-imgui-raw-internal-1.0.0: src/DearImGui/Raw/Internal/ImVec2ih.hsc
{-# LANGUAGE CApiFFI #-}
{-# LANGUAGE PatternSynonyms #-}
-- This file was generated by dear-bindings-ffi. Do not edit by hand.
module DearImGui.Raw.Internal.ImVec2ih
( ImVec2ih (..)
, destroy
, init
, withDefault
) where
import Control.Exception (bracket_)
import Foreign.C.Types
import Foreign.Marshal.Alloc (alloca)
import Foreign.Ptr (Ptr, plusPtr)
import Foreign.Storable (Storable (..))
import GHC.Records (HasField (..))
import Prelude hiding (init)
#include "dcimgui_nodefaultargfunctions_internal.h"
-- structs (opaque)
-- by-value
data {-# CTYPE "dcimgui_nodefaultargfunctions_internal.h" "ImVec2ih" #-} ImVec2ih = ImVec2ih
{ x :: CShort
, y :: CShort
}
deriving (Eq, Show)
instance Storable ImVec2ih where
sizeOf _ = #{size ImVec2ih}
alignment _ = #{alignment ImVec2ih}
peek p = ImVec2ih <$> #{peek ImVec2ih, x} p <*> #{peek ImVec2ih, y} p
poke p v = do
#{poke ImVec2ih, x} p v.x
#{poke ImVec2ih, y} p v.y
instance HasField "x" (Ptr ImVec2ih) (Ptr CShort) where
getField = #{ptr ImVec2ih, x}
instance HasField "y" (Ptr ImVec2ih) (Ptr CShort) where
getField = #{ptr ImVec2ih, y}
foreign import capi unsafe "DearImGuiWrappers.h ImVec2ih_Init_wrap"
init
:: Ptr ImVec2ih
-> IO ()
foreign import capi unsafe "DearImGuiWrappers.h ImVec2ih_Destroy_wrap"
destroy
:: Ptr ImVec2ih
-> IO ()
withDefault :: (Ptr ImVec2ih -> IO a) -> IO a
withDefault k = alloca $ \p -> bracket_ (init p) (destroy p) (k p)