packages feed

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

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

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

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

import Control.Exception (bracket_)
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
newtype {-# CTYPE "dcimgui_nodefaultargfunctions_internal.h" "ImVec1" #-} ImVec1 = ImVec1
  { x :: Float
  }
  deriving (Eq, Show)
instance Storable ImVec1 where
  sizeOf _    = #{size ImVec1}
  alignment _ = #{alignment ImVec1}
  peek p = ImVec1 <$> #{peek ImVec1, x} p
  poke p v = do
    #{poke ImVec1, x} p v.x

instance HasField "x" (Ptr ImVec1) (Ptr Float) where
  getField = #{ptr ImVec1, x}

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

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

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