packages feed

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

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

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

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

data {-# CTYPE "dcimgui_nodefaultargfunctions_internal.h" "ImGuiIDStackTool" #-} ImGuiIDStackTool = ImGuiIDStackTool
  { optHexEncodeNonAsciiChars :: CBool
  , optCopyToClipboardOnCtrlC :: CBool
  , lastActiveFrame :: CInt
  , copyToClipboardLastTime :: Float
  }
  deriving (Eq, Show)
instance Storable ImGuiIDStackTool where
  sizeOf _    = #{size ImGuiIDStackTool}
  alignment _ = #{alignment ImGuiIDStackTool}
  peek p = ImGuiIDStackTool <$> #{peek ImGuiIDStackTool, OptHexEncodeNonAsciiChars} p <*> #{peek ImGuiIDStackTool, OptCopyToClipboardOnCtrlC} p <*> #{peek ImGuiIDStackTool, LastActiveFrame} p <*> #{peek ImGuiIDStackTool, CopyToClipboardLastTime} p
  poke p v = do
    #{poke ImGuiIDStackTool, OptHexEncodeNonAsciiChars} p v.optHexEncodeNonAsciiChars
    #{poke ImGuiIDStackTool, OptCopyToClipboardOnCtrlC} p v.optCopyToClipboardOnCtrlC
    #{poke ImGuiIDStackTool, LastActiveFrame} p v.lastActiveFrame
    #{poke ImGuiIDStackTool, CopyToClipboardLastTime} p v.copyToClipboardLastTime

instance HasField "optHexEncodeNonAsciiChars" (Ptr ImGuiIDStackTool) (Ptr CBool) where
  getField = #{ptr ImGuiIDStackTool, OptHexEncodeNonAsciiChars}

instance HasField "optCopyToClipboardOnCtrlC" (Ptr ImGuiIDStackTool) (Ptr CBool) where
  getField = #{ptr ImGuiIDStackTool, OptCopyToClipboardOnCtrlC}

instance HasField "lastActiveFrame" (Ptr ImGuiIDStackTool) (Ptr CInt) where
  getField = #{ptr ImGuiIDStackTool, LastActiveFrame}

instance HasField "copyToClipboardLastTime" (Ptr ImGuiIDStackTool) (Ptr Float) where
  getField = #{ptr ImGuiIDStackTool, CopyToClipboardLastTime}

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

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

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