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

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

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