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

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

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