packages feed

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

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

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

module DearImGui.Raw.Internal.ImGuiKeyRoutingTable
  ( ImGuiKeyRoutingTable
  , clear
  , destroy
  , indexLength
  , init
  , withDefault
  ) where

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

instance HasField "index" (Ptr ImGuiKeyRoutingTable) (Ptr ImGuiKeyRoutingIndex) where
  getField = #{ptr ImGuiKeyRoutingTable, Index}

indexLength :: Int
indexLength = #{const ImGuiKey_NamedKey_COUNT}

instance HasField "entries" (Ptr ImGuiKeyRoutingTable) (Ptr (ImVector ImGuiKeyRoutingData)) where
  getField = #{ptr ImGuiKeyRoutingTable, Entries}

instance HasField "entriesNext" (Ptr ImGuiKeyRoutingTable) (Ptr (ImVector ImGuiKeyRoutingData)) where
  getField = #{ptr ImGuiKeyRoutingTable, EntriesNext}

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

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

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

-- functions

-- C: void Clear(ImGuiKeyRoutingTable* self)
foreign import capi unsafe "dcimgui_nodefaultargfunctions_internal.h ImGuiKeyRoutingTable_Clear"
  clear
    :: (Ptr ImGuiKeyRoutingTable) -- ^ self
    -> IO ()