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

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

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