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