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

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

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