{-# LANGUAGE FlexibleInstances, FlexibleContexts, TypeFamilies,
  MultiParamTypeClasses, OverlappingInstances, IncoherentInstances
  #-}
module HROOT.Hist.TAxis.Cast where
import Foreign.Ptr
import FFICXX.Runtime.Cast
import System.IO.Unsafe
import HROOT.Hist.TAxis.RawType
import HROOT.Hist.TAxis.Interface

instance (ITAxis a, FPtr a) => Castable (a) (Ptr RawTAxis) where
        cast :: forall r. a -> (Ptr RawTAxis -> IO r) -> IO r
cast a
x Ptr RawTAxis -> IO r
f = Ptr RawTAxis -> IO r
f (Ptr (Raw a) -> Ptr RawTAxis
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 RawTAxis -> (a -> IO r) -> IO r
uncast Ptr RawTAxis
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 RawTAxis -> Ptr (Raw a)
forall a b. Ptr a -> Ptr b
castPtr Ptr RawTAxis
x))

instance () => Castable (TAxis) (Ptr RawTAxis) where
        cast :: forall r. TAxis -> (Ptr RawTAxis -> IO r) -> IO r
cast TAxis
x Ptr RawTAxis -> IO r
f = Ptr RawTAxis -> IO r
f (Ptr RawTAxis -> Ptr RawTAxis
forall a b. Ptr a -> Ptr b
castPtr (TAxis -> Ptr (Raw TAxis)
forall a. FPtr a => a -> Ptr (Raw a)
get_fptr TAxis
x))
        uncast :: forall r. Ptr RawTAxis -> (TAxis -> IO r) -> IO r
uncast Ptr RawTAxis
x TAxis -> IO r
f = TAxis -> IO r
f (Ptr (Raw TAxis) -> TAxis
forall a. FPtr a => Ptr (Raw a) -> a
cast_fptr_to_obj (Ptr RawTAxis -> Ptr RawTAxis
forall a b. Ptr a -> Ptr b
castPtr Ptr RawTAxis
x))