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