packages feed

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

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

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

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

import Control.Exception (bracket_)
import DearImGui.Raw (ImU32)
import DearImGui.Raw.Internal (ImGuiTableColumnIdx)
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" "ImGuiTableCellData" #-} ImGuiTableCellData = ImGuiTableCellData
  { bgColor :: ImU32
  , column :: ImGuiTableColumnIdx
  }
  deriving (Eq, Show)
instance Storable ImGuiTableCellData where
  sizeOf _    = #{size ImGuiTableCellData}
  alignment _ = #{alignment ImGuiTableCellData}
  peek p = ImGuiTableCellData <$> #{peek ImGuiTableCellData, BgColor} p <*> #{peek ImGuiTableCellData, Column} p
  poke p v = do
    #{poke ImGuiTableCellData, BgColor} p v.bgColor
    #{poke ImGuiTableCellData, Column} p v.column

instance HasField "bgColor" (Ptr ImGuiTableCellData) (Ptr ImU32) where
  getField = #{ptr ImGuiTableCellData, BgColor}

instance HasField "column" (Ptr ImGuiTableCellData) (Ptr ImGuiTableColumnIdx) where
  getField = #{ptr ImGuiTableCellData, Column}

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

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

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