packages feed

dear-imgui-raw-1.0.0: src/DearImGui/Raw/ImGuiTableSortSpecs.hsc

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

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

module DearImGui.Raw.ImGuiTableSortSpecs
  ( ImGuiTableSortSpecs (..)
  , destroy
  , init
  , withDefault
  ) where

import Control.Exception (bracket_)
import DearImGui.Raw.ImGuiTableColumnSortSpecs (ImGuiTableColumnSortSpecs)
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.h"

-- structs (opaque)

data {-# CTYPE "dcimgui_nodefaultargfunctions.h" "ImGuiTableSortSpecs" #-} ImGuiTableSortSpecs = ImGuiTableSortSpecs
  { specs :: Ptr ImGuiTableColumnSortSpecs
  , specsCount :: CInt
  , specsDirty :: CBool
  }
  deriving (Eq, Show)
instance Storable ImGuiTableSortSpecs where
  sizeOf _    = #{size ImGuiTableSortSpecs}
  alignment _ = #{alignment ImGuiTableSortSpecs}
  peek p = ImGuiTableSortSpecs <$> #{peek ImGuiTableSortSpecs, Specs} p <*> #{peek ImGuiTableSortSpecs, SpecsCount} p <*> #{peek ImGuiTableSortSpecs, SpecsDirty} p
  poke p v = do
    #{poke ImGuiTableSortSpecs, Specs} p v.specs
    #{poke ImGuiTableSortSpecs, SpecsCount} p v.specsCount
    #{poke ImGuiTableSortSpecs, SpecsDirty} p v.specsDirty

instance HasField "specs" (Ptr ImGuiTableSortSpecs) (Ptr (Ptr ImGuiTableColumnSortSpecs)) where
  getField = #{ptr ImGuiTableSortSpecs, Specs}

instance HasField "specsCount" (Ptr ImGuiTableSortSpecs) (Ptr CInt) where
  getField = #{ptr ImGuiTableSortSpecs, SpecsCount}

instance HasField "specsDirty" (Ptr ImGuiTableSortSpecs) (Ptr CBool) where
  getField = #{ptr ImGuiTableSortSpecs, SpecsDirty}

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

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

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