{-# LANGUAGE FlexibleInstances, FlexibleContexts, TypeFamilies, MultiParamTypeClasses, OverlappingInstances, IncoherentInstances #-} module HROOT.Graf.TBox.Cast where import Foreign.Ptr import FFICXX.Runtime.Cast import System.IO.Unsafe import HROOT.Graf.TBox.RawType import HROOT.Graf.TBox.Interface instance (ITBox a, FPtr a) => Castable (a) (Ptr RawTBox) where cast x f = f (castPtr (get_fptr x)) uncast x f = f (cast_fptr_to_obj (castPtr x)) instance () => Castable (TBox) (Ptr RawTBox) where cast x f = f (castPtr (get_fptr x)) uncast x f = f (cast_fptr_to_obj (castPtr x))