packages feed

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

{-# LANGUAGE CApiFFI #-}

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

module DearImGui.Raw.Internal.ImPool
  ( ImPool (..)
  ) where

import DearImGui.Raw.ImGuiStorage (ImGuiStorage)
import DearImGui.Raw.ImVector (ImVector)
import Foreign.C.Types
import Foreign.Storable (Storable (..))

#include "dcimgui_nodefaultargfunctions_internal.h"

-- | Generic counterpart to dear_bindings's flattened
-- @ImPool_T@ instantiations. Wraps an 'ImVector' of @t@ plus the
-- shared 'ImGuiStorage' index and free-list bookkeeping.
data ImPool t = ImPool
  { buf        :: ImVector t
  , storage    :: ImGuiStorage
  , freeIdx    :: CInt
  , aliveCount :: CInt
  }
  deriving (Eq, Show)

instance Storable (ImPool t) where
  sizeOf _    = #{size ImPool_ImGuiMultiSelectState}
  alignment _ = #{alignment ImPool_ImGuiMultiSelectState}
  peek p = ImPool
    <$> #{peek ImPool_ImGuiMultiSelectState, Buf} p
    <*> #{peek ImPool_ImGuiMultiSelectState, Map} p
    <*> #{peek ImPool_ImGuiMultiSelectState, FreeIdx} p
    <*> #{peek ImPool_ImGuiMultiSelectState, AliveCount} p
  poke p v = do
    #{poke ImPool_ImGuiMultiSelectState, Buf} p v.buf
    #{poke ImPool_ImGuiMultiSelectState, Map} p v.storage
    #{poke ImPool_ImGuiMultiSelectState, FreeIdx} p v.freeIdx
    #{poke ImPool_ImGuiMultiSelectState, AliveCount} p v.aliveCount