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