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