packages feed

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

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

class IDeletable a => ITArray a

upcastTArray :: forall a . (FPtr a, ITArray a) => a -> TArray
upcastTArray h
  = let fh = get_fptr h
        fh2 :: Ptr RawTArray = castPtr fh
      in cast_fptr_to_obj fh2

downcastTArray :: forall a . (FPtr a, ITArray a) => TArray -> a
downcastTArray h
  = let fh = get_fptr h
        fh2 = castPtr fh
      in cast_fptr_to_obj fh2