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

class (ITNamed a) => ITKey a where

upcastTKey :: forall a . (FPtr a, ITKey a) => a -> TKey
upcastTKey :: forall a. (FPtr a, ITKey a) => a -> TKey
upcastTKey a
h
  = let fh :: Ptr (Raw a)
fh = a -> Ptr (Raw a)
forall a. FPtr a => a -> Ptr (Raw a)
get_fptr a
h
        Ptr RawTKey
fh2 :: Ptr RawTKey = Ptr (Raw a) -> Ptr RawTKey
forall a b. Ptr a -> Ptr b
castPtr Ptr (Raw a)
fh
      in Ptr (Raw TKey) -> TKey
forall a. FPtr a => Ptr (Raw a) -> a
cast_fptr_to_obj Ptr (Raw TKey)
Ptr RawTKey
fh2

downcastTKey :: forall a . (FPtr a, ITKey a) => TKey -> a
downcastTKey :: forall a. (FPtr a, ITKey a) => TKey -> a
downcastTKey TKey
h
  = let fh :: Ptr (Raw TKey)
fh = TKey -> Ptr (Raw TKey)
forall a. FPtr a => a -> Ptr (Raw a)
get_fptr TKey
h
        fh2 :: Ptr (Raw a)
fh2 = Ptr RawTKey -> Ptr (Raw a)
forall a b. Ptr a -> Ptr b
castPtr Ptr (Raw TKey)
Ptr RawTKey
fh
      in Ptr (Raw a) -> a
forall a. FPtr a => Ptr (Raw a) -> a
cast_fptr_to_obj Ptr (Raw a)
fh2