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