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