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

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

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