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

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

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