packages feed

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

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

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

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

import Control.Exception (bracket_)
import DearImGui.Raw (ImS16)
import DearImGui.Raw.Internal.ImGuiDebugAllocEntry (ImGuiDebugAllocEntry)
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 ImGuiDebugAllocInfo
instance Storable ImGuiDebugAllocInfo where
  sizeOf _    = #{size ImGuiDebugAllocInfo}
  alignment _ = #{alignment ImGuiDebugAllocInfo}
  peek _ = error "ImGuiDebugAllocInfo: opaque struct, peek not supported in v0"
  poke _ _ = error "ImGuiDebugAllocInfo: opaque struct, poke not supported in v0"

instance HasField "totalAllocCount" (Ptr ImGuiDebugAllocInfo) (Ptr CInt) where
  getField = #{ptr ImGuiDebugAllocInfo, TotalAllocCount}

instance HasField "totalFreeCount" (Ptr ImGuiDebugAllocInfo) (Ptr CInt) where
  getField = #{ptr ImGuiDebugAllocInfo, TotalFreeCount}

instance HasField "lastEntriesIdx" (Ptr ImGuiDebugAllocInfo) (Ptr ImS16) where
  getField = #{ptr ImGuiDebugAllocInfo, LastEntriesIdx}

instance HasField "lastEntriesBuf" (Ptr ImGuiDebugAllocInfo) (Ptr ImGuiDebugAllocEntry) where
  getField = #{ptr ImGuiDebugAllocInfo, LastEntriesBuf}

lastEntriesBufLength :: Int
lastEntriesBufLength = #{const 6}

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

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

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