packages feed

HROOT-graf-0.9: src/HROOT/Graf/TBRIK/Interface.hs

{-# LANGUAGE EmptyDataDecls, ExistentialQuantification,
  FlexibleContexts, FlexibleInstances, ForeignFunctionInterface,
  MultiParamTypeClasses, ScopedTypeVariables, TypeFamilies,
  TypeSynonymInstances #-}
module HROOT.Graf.TBRIK.Interface where
import Data.Word
import Foreign.C
import Foreign.Ptr
import FFICXX.Runtime.Cast
import HROOT.Graf.TBRIK.RawType
import HROOT.Graf.TShape.Interface

class ITShape a => ITBRIK a

upcastTBRIK :: forall a . (FPtr a, ITBRIK a) => a -> TBRIK
upcastTBRIK h
  = let fh = get_fptr h
        fh2 :: Ptr RawTBRIK = castPtr fh
      in cast_fptr_to_obj fh2

downcastTBRIK :: forall a . (FPtr a, ITBRIK a) => TBRIK -> a
downcastTBRIK h
  = let fh = get_fptr h
        fh2 = castPtr fh
      in cast_fptr_to_obj fh2