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

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

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