{-# LINE 1 "Graphics/Rendering/FreeType/Internal/Memory.hsc" #-}
{-# LANGUAGE ForeignFunctionInterface #-}
{-# LINE 2 "Graphics/Rendering/FreeType/Internal/Memory.hsc" #-}
module Graphics.Rendering.FreeType.Internal.Memory
( FT_MemoryRec(..)
, FT_Memory
) where

import Foreign hiding (free, realloc)
import Foreign.C.Types
import Foreign.Storable


{-# LINE 12 "Graphics/Rendering/FreeType/Internal/Memory.hsc" #-}

{-# LINE 13 "Graphics/Rendering/FreeType/Internal/Memory.hsc" #-}


{-# LINE 15 "Graphics/Rendering/FreeType/Internal/Memory.hsc" #-}

{-# LINE 16 "Graphics/Rendering/FreeType/Internal/Memory.hsc" #-}

type FT_Alloc_Func   = FunPtr (FT_Memory -> CLong -> IO (Ptr ()))
type FT_Free_Func    = FunPtr (FT_Memory -> Ptr () -> IO ())
type FT_Realloc_Func = FunPtr
  (FT_Memory -> CLong -> CLong -> Ptr () -> IO (Ptr ()))
                     

type FT_Memory = Ptr FT_MemoryRec
data FT_MemoryRec = FT_MemoryRec
  { user    :: Ptr ()
  , alloc   :: FT_Alloc_Func
  , free    :: FT_Free_Func
  , realloc :: FT_Realloc_Func
  }

instance Storable FT_MemoryRec where
  sizeOf    _ = (16)
{-# LINE 33 "Graphics/Rendering/FreeType/Internal/Memory.hsc" #-}
  alignment _ = 4
{-# LINE 34 "Graphics/Rendering/FreeType/Internal/Memory.hsc" #-}
  peek ptr = do
    user'    <- ((\hsc_ptr -> peekByteOff hsc_ptr 0)) ptr
{-# LINE 36 "Graphics/Rendering/FreeType/Internal/Memory.hsc" #-}
    alloc'   <- ((\hsc_ptr -> peekByteOff hsc_ptr 4)) ptr
{-# LINE 37 "Graphics/Rendering/FreeType/Internal/Memory.hsc" #-}
    free'    <- ((\hsc_ptr -> peekByteOff hsc_ptr 8)) ptr
{-# LINE 38 "Graphics/Rendering/FreeType/Internal/Memory.hsc" #-}
    realloc'  <- ((\hsc_ptr -> peekByteOff hsc_ptr 12)) ptr
{-# LINE 39 "Graphics/Rendering/FreeType/Internal/Memory.hsc" #-}
    return $ FT_MemoryRec
      { user = user'
      , alloc = alloc'
      , free = free'
      , realloc = realloc'
      }
  poke ptr val = do
    ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) ptr (user val)
{-# LINE 47 "Graphics/Rendering/FreeType/Internal/Memory.hsc" #-}
    ((\hsc_ptr -> pokeByteOff hsc_ptr 4)) ptr (alloc val)
{-# LINE 48 "Graphics/Rendering/FreeType/Internal/Memory.hsc" #-}
    ((\hsc_ptr -> pokeByteOff hsc_ptr 8)) ptr (free val)
{-# LINE 49 "Graphics/Rendering/FreeType/Internal/Memory.hsc" #-}
    ((\hsc_ptr -> pokeByteOff hsc_ptr 12)) ptr (realloc val)
{-# LINE 50 "Graphics/Rendering/FreeType/Internal/Memory.hsc" #-}