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