packages feed

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

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

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

module DearImGui.Raw.ImDrawCmd
  ( ImDrawCmd (..)
  , destroy
  , getTexID
  , init
  , withDefault
  ) where

import Control.Exception (bracket_)
import DearImGui.Raw (ImDrawCallback, ImTextureID)
import DearImGui.Raw.ImTextureRef (ImTextureRef)
import DearImGui.Raw.ImVec4 (ImVec4)
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" "ImDrawCmd" #-} ImDrawCmd = ImDrawCmd
  { clipRect :: ImVec4
  , texRef :: ImTextureRef
  , vtxOffset :: CUInt
  , idxOffset :: CUInt
  , elemCount :: CUInt
  , userCallback :: ImDrawCallback
  , userCallbackData :: Ptr ()
  , userCallbackDataSize :: CInt
  , userCallbackDataOffset :: CInt
  }
  deriving (Eq, Show)
instance Storable ImDrawCmd where
  sizeOf _    = #{size ImDrawCmd}
  alignment _ = #{alignment ImDrawCmd}
  peek p = ImDrawCmd <$> #{peek ImDrawCmd, ClipRect} p <*> #{peek ImDrawCmd, TexRef} p <*> #{peek ImDrawCmd, VtxOffset} p <*> #{peek ImDrawCmd, IdxOffset} p <*> #{peek ImDrawCmd, ElemCount} p <*> #{peek ImDrawCmd, UserCallback} p <*> #{peek ImDrawCmd, UserCallbackData} p <*> #{peek ImDrawCmd, UserCallbackDataSize} p <*> #{peek ImDrawCmd, UserCallbackDataOffset} p
  poke p v = do
    #{poke ImDrawCmd, ClipRect} p v.clipRect
    #{poke ImDrawCmd, TexRef} p v.texRef
    #{poke ImDrawCmd, VtxOffset} p v.vtxOffset
    #{poke ImDrawCmd, IdxOffset} p v.idxOffset
    #{poke ImDrawCmd, ElemCount} p v.elemCount
    #{poke ImDrawCmd, UserCallback} p v.userCallback
    #{poke ImDrawCmd, UserCallbackData} p v.userCallbackData
    #{poke ImDrawCmd, UserCallbackDataSize} p v.userCallbackDataSize
    #{poke ImDrawCmd, UserCallbackDataOffset} p v.userCallbackDataOffset

instance HasField "clipRect" (Ptr ImDrawCmd) (Ptr ImVec4) where
  getField = #{ptr ImDrawCmd, ClipRect}

instance HasField "texRef" (Ptr ImDrawCmd) (Ptr ImTextureRef) where
  getField = #{ptr ImDrawCmd, TexRef}

instance HasField "vtxOffset" (Ptr ImDrawCmd) (Ptr CUInt) where
  getField = #{ptr ImDrawCmd, VtxOffset}

instance HasField "idxOffset" (Ptr ImDrawCmd) (Ptr CUInt) where
  getField = #{ptr ImDrawCmd, IdxOffset}

instance HasField "elemCount" (Ptr ImDrawCmd) (Ptr CUInt) where
  getField = #{ptr ImDrawCmd, ElemCount}

instance HasField "userCallback" (Ptr ImDrawCmd) (Ptr ImDrawCallback) where
  getField = #{ptr ImDrawCmd, UserCallback}

instance HasField "userCallbackData" (Ptr ImDrawCmd) (Ptr (Ptr ())) where
  getField = #{ptr ImDrawCmd, UserCallbackData}

instance HasField "userCallbackDataSize" (Ptr ImDrawCmd) (Ptr CInt) where
  getField = #{ptr ImDrawCmd, UserCallbackDataSize}

instance HasField "userCallbackDataOffset" (Ptr ImDrawCmd) (Ptr CInt) where
  getField = #{ptr ImDrawCmd, UserCallbackDataOffset}

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

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

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

-- functions

-- C: ImTextureID GetTexID(const ImDrawCmd* self)
foreign import capi safe "dcimgui_nodefaultargfunctions.h ImDrawCmd_GetTexID"
  getTexID
    :: (Ptr ImDrawCmd) -- ^ self
    -> IO ImTextureID