dear-imgui-raw-internal-1.0.0: src/DearImGui/Raw/Internal/ImGuiLocEntry.hsc
{-# LANGUAGE CApiFFI #-}
{-# LANGUAGE PatternSynonyms #-}
-- This file was generated by dear-bindings-ffi. Do not edit by hand.
module DearImGui.Raw.Internal.ImGuiLocEntry
( ImGuiLocEntry (..)
, destroy
, init
, withDefault
) where
import Control.Exception (bracket_)
import DearImGui.Raw.Internal.Enums.ImGuiLocKey (ImGuiLocKey)
import Foreign.C.String (CString)
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)
data {-# CTYPE "dcimgui_nodefaultargfunctions_internal.h" "ImGuiLocEntry" #-} ImGuiLocEntry = ImGuiLocEntry
{ key :: ImGuiLocKey
, text :: CString
}
deriving (Eq, Show)
instance Storable ImGuiLocEntry where
sizeOf _ = #{size ImGuiLocEntry}
alignment _ = #{alignment ImGuiLocEntry}
peek p = ImGuiLocEntry <$> #{peek ImGuiLocEntry, Key} p <*> #{peek ImGuiLocEntry, Text} p
poke p v = do
#{poke ImGuiLocEntry, Key} p v.key
#{poke ImGuiLocEntry, Text} p v.text
instance HasField "key" (Ptr ImGuiLocEntry) (Ptr ImGuiLocKey) where
getField = #{ptr ImGuiLocEntry, Key}
instance HasField "text" (Ptr ImGuiLocEntry) (Ptr CString) where
getField = #{ptr ImGuiLocEntry, Text}
foreign import capi unsafe "DearImGuiWrappers.h ImGuiLocEntry_Init_wrap"
init
:: Ptr ImGuiLocEntry
-> IO ()
foreign import capi unsafe "DearImGuiWrappers.h ImGuiLocEntry_Destroy_wrap"
destroy
:: Ptr ImGuiLocEntry
-> IO ()
withDefault :: (Ptr ImGuiLocEntry -> IO a) -> IO a
withDefault k = alloca $ \p -> bracket_ (init p) (destroy p) (k p)