packages feed

dear-imgui-raw-internal-1.0.0: src/DearImGui/Raw/Internal/ImGuiInputEventText.hsc

{-# LANGUAGE CApiFFI #-}
{-# LANGUAGE PatternSynonyms #-}

-- This file was generated by dear-bindings-ffi. Do not edit by hand.

module DearImGui.Raw.Internal.ImGuiInputEventText
  ( ImGuiInputEventText (..)
  , 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)

newtype {-# CTYPE "dcimgui_nodefaultargfunctions_internal.h" "ImGuiInputEventText" #-} ImGuiInputEventText = ImGuiInputEventText
  { char :: CUInt
  }
  deriving (Eq, Show)
instance Storable ImGuiInputEventText where
  sizeOf _    = #{size ImGuiInputEventText}
  alignment _ = #{alignment ImGuiInputEventText}
  peek p = ImGuiInputEventText <$> #{peek ImGuiInputEventText, Char} p
  poke p v = do
    #{poke ImGuiInputEventText, Char} p v.char

instance HasField "char" (Ptr ImGuiInputEventText) (Ptr CUInt) where
  getField = #{ptr ImGuiInputEventText, Char}

foreign import capi unsafe "DearImGuiWrappers.h ImGuiInputEventText_Init_wrap"
  init
    :: Ptr ImGuiInputEventText
    -> IO ()

foreign import capi unsafe "DearImGuiWrappers.h ImGuiInputEventText_Destroy_wrap"
  destroy
    :: Ptr ImGuiInputEventText
    -> IO ()

withDefault :: (Ptr ImGuiInputEventText -> IO a) -> IO a
withDefault k = alloca $ \p -> bracket_ (init p) (destroy p) (k p)