{-# LANGUAGE ForeignFunctionInterface, TypeFamilies, MultiParamTypeClasses, 
             FlexibleInstances, TypeSynonymInstances, 
             EmptyDataDecls, ExistentialQuantification, ScopedTypeVariables #-}

-- module HROOT.Class.Interface where

module HROOT.Core.TGlobal.Interface where


import Data.Word
import Foreign.C
import Foreign.Ptr
import Foreign.ForeignPtr
import FFICXX.Runtime.Cast

import HROOT.Core.TGlobal.RawType

import HROOT.Core.TDictionary.Interface
---- ============ ----



class (ITDictionary a) => ITGlobal a where

instance Existable TGlobal where
  data Exist TGlobal = forall a. (FPtr a, ITGlobal a) => ETGlobal a

upcastTGlobal :: (FPtr a, ITGlobal a) => a -> TGlobal
upcastTGlobal h = let fh = get_fptr h
                      fh2 :: ForeignPtr RawTGlobal = castForeignPtr fh
                  in cast_fptr_to_obj fh2

downcastTGlobal :: (FPtr a, ITGlobal a) => TGlobal -> a 
downcastTGlobal h = let fh = get_fptr h
                        fh2 = castForeignPtr fh
                    in cast_fptr_to_obj fh2