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