{-# LANGUAGE FlexibleInstances, FlexibleContexts, TypeFamilies, MultiParamTypeClasses, OverlappingInstances, IncoherentInstances #-} module OGDF.EdgeElement.Cast where import Foreign.Ptr import FFICXX.Runtime.Cast import System.IO.Unsafe import OGDF.EdgeElement.RawType import OGDF.EdgeElement.Interface instance (IEdgeElement a, FPtr a) => Castable (a) (Ptr RawEdgeElement) where cast :: forall r. a -> (Ptr RawEdgeElement -> IO r) -> IO r cast a x Ptr RawEdgeElement -> IO r f = Ptr RawEdgeElement -> IO r f (Ptr (Raw a) -> Ptr RawEdgeElement 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 RawEdgeElement -> (a -> IO r) -> IO r uncast Ptr RawEdgeElement 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 RawEdgeElement -> Ptr (Raw a) forall a b. Ptr a -> Ptr b castPtr Ptr RawEdgeElement x)) instance () => Castable (EdgeElement) (Ptr RawEdgeElement) where cast :: forall r. EdgeElement -> (Ptr RawEdgeElement -> IO r) -> IO r cast EdgeElement x Ptr RawEdgeElement -> IO r f = Ptr RawEdgeElement -> IO r f (Ptr RawEdgeElement -> Ptr RawEdgeElement forall a b. Ptr a -> Ptr b castPtr (EdgeElement -> Ptr (Raw EdgeElement) forall a. FPtr a => a -> Ptr (Raw a) get_fptr EdgeElement x)) uncast :: forall r. Ptr RawEdgeElement -> (EdgeElement -> IO r) -> IO r uncast Ptr RawEdgeElement x EdgeElement -> IO r f = EdgeElement -> IO r f (Ptr (Raw EdgeElement) -> EdgeElement forall a. FPtr a => Ptr (Raw a) -> a cast_fptr_to_obj (Ptr RawEdgeElement -> Ptr RawEdgeElement forall a b. Ptr a -> Ptr b castPtr Ptr RawEdgeElement x))