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