packages feed

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

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

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

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

import Control.Exception (bracket_)
import DearImGui.Raw (ImS16)
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" "ImGuiDebugAllocEntry" #-} ImGuiDebugAllocEntry = ImGuiDebugAllocEntry
  { frameCount :: CInt
  , allocCount :: ImS16
  , freeCount :: ImS16
  }
  deriving (Eq, Show)
instance Storable ImGuiDebugAllocEntry where
  sizeOf _    = #{size ImGuiDebugAllocEntry}
  alignment _ = #{alignment ImGuiDebugAllocEntry}
  peek p = ImGuiDebugAllocEntry <$> #{peek ImGuiDebugAllocEntry, FrameCount} p <*> #{peek ImGuiDebugAllocEntry, AllocCount} p <*> #{peek ImGuiDebugAllocEntry, FreeCount} p
  poke p v = do
    #{poke ImGuiDebugAllocEntry, FrameCount} p v.frameCount
    #{poke ImGuiDebugAllocEntry, AllocCount} p v.allocCount
    #{poke ImGuiDebugAllocEntry, FreeCount} p v.freeCount

instance HasField "frameCount" (Ptr ImGuiDebugAllocEntry) (Ptr CInt) where
  getField = #{ptr ImGuiDebugAllocEntry, FrameCount}

instance HasField "allocCount" (Ptr ImGuiDebugAllocEntry) (Ptr ImS16) where
  getField = #{ptr ImGuiDebugAllocEntry, AllocCount}

instance HasField "freeCount" (Ptr ImGuiDebugAllocEntry) (Ptr ImS16) where
  getField = #{ptr ImGuiDebugAllocEntry, FreeCount}

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

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

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