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