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