{-# LANGUAGE FlexibleInstances, FlexibleContexts, TypeFamilies, 
             MultiParamTypeClasses, OverlappingInstances, IncoherentInstances #-}

module HROOT.Class.TApplication.Cast where


import Foreign.Ptr
import Foreign.ForeignPtr
import HROOT.TypeCast
import System.IO.Unsafe

import HROOT.Class.TApplication.RawType
import HROOT.Class.TApplication.Interface

instance (ITApplication a, FPtr a) => Castable a (Ptr RawTApplication) where
  cast = unsafeForeignPtrToPtr . castForeignPtr . get_fptr
  uncast = cast_fptr_to_obj . castForeignPtr . unsafePerformIO . newForeignPtr_ 

instance Castable TApplication (Ptr RawTApplication) where
  cast = unsafeForeignPtrToPtr . castForeignPtr . get_fptr
  uncast = cast_fptr_to_obj . castForeignPtr . unsafePerformIO . newForeignPtr_