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