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

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

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