packages feed

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

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

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

module DearImGui.Raw.Internal.ImGuiMultiSelectState
  ( ImGuiMultiSelectState (..)
  , destroy
  , init
  , withDefault
  ) where

import Control.Exception (bracket_)
import DearImGui.Raw (ImGuiID, ImGuiSelectionUserData, ImS8)
import DearImGui.Raw.Internal.ImGuiWindow (ImGuiWindow)
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" "ImGuiMultiSelectState" #-} ImGuiMultiSelectState = ImGuiMultiSelectState
  { window :: Ptr ImGuiWindow
  , iD :: ImGuiID
  , lastFrameActive :: CInt
  , lastSelectionSize :: CInt
  , rangeSelected :: ImS8
  , navIdSelected :: ImS8
  , rangeSrcItem :: ImGuiSelectionUserData
  , navIdItem :: ImGuiSelectionUserData
  }
  deriving (Eq, Show)
instance Storable ImGuiMultiSelectState where
  sizeOf _    = #{size ImGuiMultiSelectState}
  alignment _ = #{alignment ImGuiMultiSelectState}
  peek p = ImGuiMultiSelectState <$> #{peek ImGuiMultiSelectState, Window} p <*> #{peek ImGuiMultiSelectState, ID} p <*> #{peek ImGuiMultiSelectState, LastFrameActive} p <*> #{peek ImGuiMultiSelectState, LastSelectionSize} p <*> #{peek ImGuiMultiSelectState, RangeSelected} p <*> #{peek ImGuiMultiSelectState, NavIdSelected} p <*> #{peek ImGuiMultiSelectState, RangeSrcItem} p <*> #{peek ImGuiMultiSelectState, NavIdItem} p
  poke p v = do
    #{poke ImGuiMultiSelectState, Window} p v.window
    #{poke ImGuiMultiSelectState, ID} p v.iD
    #{poke ImGuiMultiSelectState, LastFrameActive} p v.lastFrameActive
    #{poke ImGuiMultiSelectState, LastSelectionSize} p v.lastSelectionSize
    #{poke ImGuiMultiSelectState, RangeSelected} p v.rangeSelected
    #{poke ImGuiMultiSelectState, NavIdSelected} p v.navIdSelected
    #{poke ImGuiMultiSelectState, RangeSrcItem} p v.rangeSrcItem
    #{poke ImGuiMultiSelectState, NavIdItem} p v.navIdItem

instance HasField "window" (Ptr ImGuiMultiSelectState) (Ptr (Ptr ImGuiWindow)) where
  getField = #{ptr ImGuiMultiSelectState, Window}

instance HasField "iD" (Ptr ImGuiMultiSelectState) (Ptr ImGuiID) where
  getField = #{ptr ImGuiMultiSelectState, ID}

instance HasField "lastFrameActive" (Ptr ImGuiMultiSelectState) (Ptr CInt) where
  getField = #{ptr ImGuiMultiSelectState, LastFrameActive}

instance HasField "lastSelectionSize" (Ptr ImGuiMultiSelectState) (Ptr CInt) where
  getField = #{ptr ImGuiMultiSelectState, LastSelectionSize}

instance HasField "rangeSelected" (Ptr ImGuiMultiSelectState) (Ptr ImS8) where
  getField = #{ptr ImGuiMultiSelectState, RangeSelected}

instance HasField "navIdSelected" (Ptr ImGuiMultiSelectState) (Ptr ImS8) where
  getField = #{ptr ImGuiMultiSelectState, NavIdSelected}

instance HasField "rangeSrcItem" (Ptr ImGuiMultiSelectState) (Ptr ImGuiSelectionUserData) where
  getField = #{ptr ImGuiMultiSelectState, RangeSrcItem}

instance HasField "navIdItem" (Ptr ImGuiMultiSelectState) (Ptr ImGuiSelectionUserData) where
  getField = #{ptr ImGuiMultiSelectState, NavIdItem}

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

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

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