packages feed

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

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

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

module DearImGui.Raw.Internal.ImVec2i
  ( ImVec2i (..)
  , destroy
  , init
  , withDefault
  ) where

import Control.Exception (bracket_)
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" "ImVec2i" #-} ImVec2i = ImVec2i
  { x :: CInt
  , y :: CInt
  }
  deriving (Eq, Show)
instance Storable ImVec2i where
  sizeOf _    = #{size ImVec2i}
  alignment _ = #{alignment ImVec2i}
  peek p = ImVec2i <$> #{peek ImVec2i, x} p <*> #{peek ImVec2i, y} p
  poke p v = do
    #{poke ImVec2i, x} p v.x
    #{poke ImVec2i, y} p v.y

instance HasField "x" (Ptr ImVec2i) (Ptr CInt) where
  getField = #{ptr ImVec2i, x}

instance HasField "y" (Ptr ImVec2i) (Ptr CInt) where
  getField = #{ptr ImVec2i, y}

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

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

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