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