{-# LANGUAGE FlexibleInstances, FlexibleContexts, TypeFamilies, MultiParamTypeClasses, OverlappingInstances, IncoherentInstances #-} module HROOT.Graf.TAttImage.Cast where import Foreign.Ptr import FFICXX.Runtime.Cast import System.IO.Unsafe import HROOT.Graf.TAttImage.RawType import HROOT.Graf.TAttImage.Interface instance (ITAttImage a, FPtr a) => Castable (a) (Ptr RawTAttImage) where cast :: forall r. a -> (Ptr RawTAttImage -> IO r) -> IO r cast a x Ptr RawTAttImage -> IO r f = Ptr RawTAttImage -> IO r f (Ptr (Raw a) -> Ptr RawTAttImage forall a b. Ptr a -> Ptr b castPtr (a -> Ptr (Raw a) forall a. FPtr a => a -> Ptr (Raw a) get_fptr a x)) uncast :: forall r. Ptr RawTAttImage -> (a -> IO r) -> IO r uncast Ptr RawTAttImage x a -> IO r f = a -> IO r f (Ptr (Raw a) -> a forall a. FPtr a => Ptr (Raw a) -> a cast_fptr_to_obj (Ptr RawTAttImage -> Ptr (Raw a) forall a b. Ptr a -> Ptr b castPtr Ptr RawTAttImage x)) instance () => Castable (TAttImage) (Ptr RawTAttImage) where cast :: forall r. TAttImage -> (Ptr RawTAttImage -> IO r) -> IO r cast TAttImage x Ptr RawTAttImage -> IO r f = Ptr RawTAttImage -> IO r f (Ptr RawTAttImage -> Ptr RawTAttImage forall a b. Ptr a -> Ptr b castPtr (TAttImage -> Ptr (Raw TAttImage) forall a. FPtr a => a -> Ptr (Raw a) get_fptr TAttImage x)) uncast :: forall r. Ptr RawTAttImage -> (TAttImage -> IO r) -> IO r uncast Ptr RawTAttImage x TAttImage -> IO r f = TAttImage -> IO r f (Ptr (Raw TAttImage) -> TAttImage forall a. FPtr a => Ptr (Raw a) -> a cast_fptr_to_obj (Ptr RawTAttImage -> Ptr RawTAttImage forall a b. Ptr a -> Ptr b castPtr Ptr RawTAttImage x))