dear-imgui-raw-1.0.0: src/DearImGui/Raw/ImVector.hsc
{-# LANGUAGE CApiFFI #-}
-- This file was generated by dear-bindings-ffi. Do not edit by hand.
module DearImGui.Raw.ImVector
( ImVector (..)
) where
import Foreign.C.Types
import Foreign.Ptr (Ptr, castPtr, plusPtr)
import Foreign.Storable (Storable (..))
import GHC.Records (HasField (..))
#include "dcimgui_nodefaultargfunctions.h"
-- | Generic counterpart to dear_bindings's flattened
-- @ImVector_T@ instantiations. Layout is invariant in @t@
-- because the C struct only holds @T*@; field offsets are read
-- off the reference instantiation @ImVector_ImDrawChannel@.
data ImVector t = ImVector
{ size :: CInt
, capacity :: CInt
, dataPtr :: Ptr t
}
deriving (Eq, Show)
instance Storable (ImVector t) where
sizeOf _ = #{size ImVector_ImDrawChannel}
alignment _ = #{alignment ImVector_ImDrawChannel}
peek p = ImVector
<$> #{peek ImVector_ImDrawChannel, Size} p
<*> #{peek ImVector_ImDrawChannel, Capacity} p
<*> (castPtr <$> #{peek ImVector_ImDrawChannel, Data} p)
poke p v = do
#{poke ImVector_ImDrawChannel, Size} p v.size
#{poke ImVector_ImDrawChannel, Capacity} p v.capacity
#{poke ImVector_ImDrawChannel, Data} p (castPtr v.dataPtr)
instance HasField "size" (Ptr (ImVector t)) (Ptr CInt) where
getField = #{ptr ImVector_ImDrawChannel, Size}
instance HasField "capacity" (Ptr (ImVector t)) (Ptr CInt) where
getField = #{ptr ImVector_ImDrawChannel, Capacity}
instance HasField "dataPtr" (Ptr (ImVector t)) (Ptr (Ptr t)) where
getField = #{ptr ImVector_ImDrawChannel, Data}