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

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

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