packages feed

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

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

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

module DearImGui.Raw.ImGuiStorage
  ( ImGuiStorage (..)
  , buildSortByKey
  , clear
  , destroy
  , getBool
  , getBoolRef
  , getFloat
  , getFloatRef
  , getInt
  , getIntRef
  , getVoidPtr
  , getVoidPtrRef
  , init
  , setAllInt
  , setBool
  , setFloat
  , setInt
  , setVoidPtr
  , withDefault
  ) where

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

newtype {-# CTYPE "dcimgui_nodefaultargfunctions.h" "ImGuiStorage" #-} ImGuiStorage = ImGuiStorage
  { data_ :: ImVector ImGuiStoragePair
  }
  deriving (Eq, Show)
instance Storable ImGuiStorage where
  sizeOf _    = #{size ImGuiStorage}
  alignment _ = #{alignment ImGuiStorage}
  peek p = ImGuiStorage <$> #{peek ImGuiStorage, Data} p
  poke p v = do
    #{poke ImGuiStorage, Data} p v.data_

instance HasField "data_" (Ptr ImGuiStorage) (Ptr (ImVector ImGuiStoragePair)) where
  getField = #{ptr ImGuiStorage, Data}

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

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

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

-- functions

-- C: void BuildSortByKey(ImGuiStorage* self)
foreign import capi unsafe "dcimgui_nodefaultargfunctions.h ImGuiStorage_BuildSortByKey"
  buildSortByKey
    :: (Ptr ImGuiStorage) -- ^ self
    -> IO ()

-- C: void Clear(ImGuiStorage* self)
foreign import capi unsafe "dcimgui_nodefaultargfunctions.h ImGuiStorage_Clear"
  clear
    :: (Ptr ImGuiStorage) -- ^ self
    -> IO ()

-- C: bool GetBool(const ImGuiStorage* self, ImGuiID key, bool default_val)
foreign import capi unsafe "dcimgui_nodefaultargfunctions.h ImGuiStorage_GetBool"
  getBool
    :: (Ptr ImGuiStorage) -- ^ self
    -> ImGuiID -- ^ key
    -> CBool -- ^ default_val
    -> IO CBool

-- C: bool* GetBoolRef(ImGuiStorage* self, ImGuiID key, bool default_val)
foreign import capi unsafe "dcimgui_nodefaultargfunctions.h ImGuiStorage_GetBoolRef"
  getBoolRef
    :: (Ptr ImGuiStorage) -- ^ self
    -> ImGuiID -- ^ key
    -> CBool -- ^ default_val
    -> IO (Ptr CBool)

-- C: float GetFloat(const ImGuiStorage* self, ImGuiID key, float default_val)
foreign import capi unsafe "dcimgui_nodefaultargfunctions.h ImGuiStorage_GetFloat"
  getFloat
    :: (Ptr ImGuiStorage) -- ^ self
    -> ImGuiID -- ^ key
    -> Float -- ^ default_val
    -> IO Float

-- C: float* GetFloatRef(ImGuiStorage* self, ImGuiID key, float default_val)
foreign import capi unsafe "dcimgui_nodefaultargfunctions.h ImGuiStorage_GetFloatRef"
  getFloatRef
    :: (Ptr ImGuiStorage) -- ^ self
    -> ImGuiID -- ^ key
    -> Float -- ^ default_val
    -> IO (Ptr Float)

-- C: int GetInt(const ImGuiStorage* self, ImGuiID key, int default_val)
foreign import capi unsafe "dcimgui_nodefaultargfunctions.h ImGuiStorage_GetInt"
  getInt
    :: (Ptr ImGuiStorage) -- ^ self
    -> ImGuiID -- ^ key
    -> CInt -- ^ default_val
    -> IO CInt

-- C: int* GetIntRef(ImGuiStorage* self, ImGuiID key, int default_val)
foreign import capi unsafe "dcimgui_nodefaultargfunctions.h ImGuiStorage_GetIntRef"
  getIntRef
    :: (Ptr ImGuiStorage) -- ^ self
    -> ImGuiID -- ^ key
    -> CInt -- ^ default_val
    -> IO (Ptr CInt)

-- C: void* GetVoidPtr(const ImGuiStorage* self, ImGuiID key)
foreign import capi unsafe "dcimgui_nodefaultargfunctions.h ImGuiStorage_GetVoidPtr"
  getVoidPtr
    :: (Ptr ImGuiStorage) -- ^ self
    -> ImGuiID -- ^ key
    -> IO (Ptr ())

-- C: void** GetVoidPtrRef(ImGuiStorage* self, ImGuiID key, void* default_val)
foreign import capi unsafe "dcimgui_nodefaultargfunctions.h ImGuiStorage_GetVoidPtrRef"
  getVoidPtrRef
    :: (Ptr ImGuiStorage) -- ^ self
    -> ImGuiID -- ^ key
    -> (Ptr ()) -- ^ default_val
    -> IO (Ptr (Ptr ()))

-- C: void SetAllInt(ImGuiStorage* self, int val)
foreign import capi unsafe "dcimgui_nodefaultargfunctions.h ImGuiStorage_SetAllInt"
  setAllInt
    :: (Ptr ImGuiStorage) -- ^ self
    -> CInt -- ^ val
    -> IO ()

-- C: void SetBool(ImGuiStorage* self, ImGuiID key, bool val)
foreign import capi unsafe "dcimgui_nodefaultargfunctions.h ImGuiStorage_SetBool"
  setBool
    :: (Ptr ImGuiStorage) -- ^ self
    -> ImGuiID -- ^ key
    -> CBool -- ^ val
    -> IO ()

-- C: void SetFloat(ImGuiStorage* self, ImGuiID key, float val)
foreign import capi unsafe "dcimgui_nodefaultargfunctions.h ImGuiStorage_SetFloat"
  setFloat
    :: (Ptr ImGuiStorage) -- ^ self
    -> ImGuiID -- ^ key
    -> Float -- ^ val
    -> IO ()

-- C: void SetInt(ImGuiStorage* self, ImGuiID key, int val)
foreign import capi unsafe "dcimgui_nodefaultargfunctions.h ImGuiStorage_SetInt"
  setInt
    :: (Ptr ImGuiStorage) -- ^ self
    -> ImGuiID -- ^ key
    -> CInt -- ^ val
    -> IO ()

-- C: void SetVoidPtr(ImGuiStorage* self, ImGuiID key, void* val)
foreign import capi unsafe "dcimgui_nodefaultargfunctions.h ImGuiStorage_SetVoidPtr"
  setVoidPtr
    :: (Ptr ImGuiStorage) -- ^ self
    -> ImGuiID -- ^ key
    -> (Ptr ()) -- ^ val
    -> IO ()