packages feed

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

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

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

module DearImGui.Raw.ImFontGlyph
  ( ImFontGlyph
  , 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.h"

-- structs (opaque)

data ImFontGlyph
instance Storable ImFontGlyph where
  sizeOf _    = #{size ImFontGlyph}
  alignment _ = #{alignment ImFontGlyph}
  peek _ = error "ImFontGlyph: opaque struct, peek not supported in v0"
  poke _ _ = error "ImFontGlyph: opaque struct, poke not supported in v0"

instance HasField "advanceX" (Ptr ImFontGlyph) (Ptr Float) where
  getField = #{ptr ImFontGlyph, AdvanceX}

instance HasField "x0" (Ptr ImFontGlyph) (Ptr Float) where
  getField = #{ptr ImFontGlyph, X0}

instance HasField "y0" (Ptr ImFontGlyph) (Ptr Float) where
  getField = #{ptr ImFontGlyph, Y0}

instance HasField "x1" (Ptr ImFontGlyph) (Ptr Float) where
  getField = #{ptr ImFontGlyph, X1}

instance HasField "y1" (Ptr ImFontGlyph) (Ptr Float) where
  getField = #{ptr ImFontGlyph, Y1}

instance HasField "u0" (Ptr ImFontGlyph) (Ptr Float) where
  getField = #{ptr ImFontGlyph, U0}

instance HasField "v0" (Ptr ImFontGlyph) (Ptr Float) where
  getField = #{ptr ImFontGlyph, V0}

instance HasField "u1" (Ptr ImFontGlyph) (Ptr Float) where
  getField = #{ptr ImFontGlyph, U1}

instance HasField "v1" (Ptr ImFontGlyph) (Ptr Float) where
  getField = #{ptr ImFontGlyph, V1}

instance HasField "packId" (Ptr ImFontGlyph) (Ptr CInt) where
  getField = #{ptr ImFontGlyph, PackId}

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

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

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