{-# LANGUAGE FlexibleInstances, FlexibleContexts, TypeFamilies, MultiParamTypeClasses, OverlappingInstances, IncoherentInstances #-} module HROOT.Core.TDirectory.Cast where import Foreign.Ptr import FFICXX.Runtime.Cast import System.IO.Unsafe import HROOT.Core.TDirectory.RawType import HROOT.Core.TDirectory.Interface instance (ITDirectory a, FPtr a) => Castable (a) (Ptr RawTDirectory) where cast :: forall r. a -> (Ptr RawTDirectory -> IO r) -> IO r cast a x Ptr RawTDirectory -> IO r f = Ptr RawTDirectory -> IO r f (Ptr (Raw a) -> Ptr RawTDirectory 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 RawTDirectory -> (a -> IO r) -> IO r uncast Ptr RawTDirectory 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 RawTDirectory -> Ptr (Raw a) forall a b. Ptr a -> Ptr b castPtr Ptr RawTDirectory x)) instance () => Castable (TDirectory) (Ptr RawTDirectory) where cast :: forall r. TDirectory -> (Ptr RawTDirectory -> IO r) -> IO r cast TDirectory x Ptr RawTDirectory -> IO r f = Ptr RawTDirectory -> IO r f (Ptr RawTDirectory -> Ptr RawTDirectory forall a b. Ptr a -> Ptr b castPtr (TDirectory -> Ptr (Raw TDirectory) forall a. FPtr a => a -> Ptr (Raw a) get_fptr TDirectory x)) uncast :: forall r. Ptr RawTDirectory -> (TDirectory -> IO r) -> IO r uncast Ptr RawTDirectory x TDirectory -> IO r f = TDirectory -> IO r f (Ptr (Raw TDirectory) -> TDirectory forall a. FPtr a => Ptr (Raw a) -> a cast_fptr_to_obj (Ptr RawTDirectory -> Ptr RawTDirectory forall a b. Ptr a -> Ptr b castPtr Ptr RawTDirectory x))