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

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

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