packages feed

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

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

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

module DearImGui.Raw.Internal.ImGuiListClipperRange
  ( ImGuiListClipperRange (..)
  , c_fromIndices
  , c_fromPositions
  , destroy
  , fromIndices
  , fromPositions
  , init
  , withDefault
  ) where

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

-- by-value
data {-# CTYPE "dcimgui_nodefaultargfunctions_internal.h" "ImGuiListClipperRange" #-} ImGuiListClipperRange = ImGuiListClipperRange
  { min :: CInt
  , max :: CInt
  , posToIndexConvert :: CBool
  , posToIndexOffsetMin :: ImS8
  , posToIndexOffsetMax :: ImS8
  }
  deriving (Eq, Show)
instance Storable ImGuiListClipperRange where
  sizeOf _    = #{size ImGuiListClipperRange}
  alignment _ = #{alignment ImGuiListClipperRange}
  peek p = ImGuiListClipperRange <$> #{peek ImGuiListClipperRange, Min} p <*> #{peek ImGuiListClipperRange, Max} p <*> #{peek ImGuiListClipperRange, PosToIndexConvert} p <*> #{peek ImGuiListClipperRange, PosToIndexOffsetMin} p <*> #{peek ImGuiListClipperRange, PosToIndexOffsetMax} p
  poke p v = do
    #{poke ImGuiListClipperRange, Min} p v.min
    #{poke ImGuiListClipperRange, Max} p v.max
    #{poke ImGuiListClipperRange, PosToIndexConvert} p v.posToIndexConvert
    #{poke ImGuiListClipperRange, PosToIndexOffsetMin} p v.posToIndexOffsetMin
    #{poke ImGuiListClipperRange, PosToIndexOffsetMax} p v.posToIndexOffsetMax

instance HasField "min" (Ptr ImGuiListClipperRange) (Ptr CInt) where
  getField = #{ptr ImGuiListClipperRange, Min}

instance HasField "max" (Ptr ImGuiListClipperRange) (Ptr CInt) where
  getField = #{ptr ImGuiListClipperRange, Max}

instance HasField "posToIndexConvert" (Ptr ImGuiListClipperRange) (Ptr CBool) where
  getField = #{ptr ImGuiListClipperRange, PosToIndexConvert}

instance HasField "posToIndexOffsetMin" (Ptr ImGuiListClipperRange) (Ptr ImS8) where
  getField = #{ptr ImGuiListClipperRange, PosToIndexOffsetMin}

instance HasField "posToIndexOffsetMax" (Ptr ImGuiListClipperRange) (Ptr ImS8) where
  getField = #{ptr ImGuiListClipperRange, PosToIndexOffsetMax}

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

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

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

-- functions

foreign import capi unsafe "DearImGuiWrappers.h ImGuiListClipperRange_FromIndices_wrap"
  c_fromIndices
    :: CInt -- ^ min
    -> CInt -- ^ max
    -> (Ptr ImGuiListClipperRange) -- ^ out
    -> IO ()

fromIndices
  :: CInt -- ^ min
  -> CInt -- ^ max
  -> IO ImGuiListClipperRange
fromIndices min_ max_ =
  alloca $ \outPtr -> c_fromIndices min_ max_ outPtr >> peek outPtr

foreign import capi unsafe "DearImGuiWrappers.h ImGuiListClipperRange_FromPositions_wrap"
  c_fromPositions
    :: Float -- ^ y1
    -> Float -- ^ y2
    -> CInt -- ^ off_min
    -> CInt -- ^ off_max
    -> (Ptr ImGuiListClipperRange) -- ^ out
    -> IO ()

fromPositions
  :: Float -- ^ y1
  -> Float -- ^ y2
  -> CInt -- ^ off_min
  -> CInt -- ^ off_max
  -> IO ImGuiListClipperRange
fromPositions y1 y2 off_min off_max =
  alloca $ \outPtr -> c_fromPositions y1 y2 off_min off_max outPtr >> peek outPtr