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