packages feed

HROOT-core-0.9: src/HROOT/Core/TSystem/Interface.hs

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

class ITNamed a => ITSystem a where
        processEvents :: a -> IO CInt

upcastTSystem :: forall a . (FPtr a, ITSystem a) => a -> TSystem
upcastTSystem h
  = let fh = get_fptr h
        fh2 :: Ptr RawTSystem = castPtr fh
      in cast_fptr_to_obj fh2

downcastTSystem :: forall a . (FPtr a, ITSystem a) => TSystem -> a
downcastTSystem h
  = let fh = get_fptr h
        fh2 = castPtr fh
      in cast_fptr_to_obj fh2