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

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

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