{-# LANGUAGE EmptyDataDecls, FlexibleInstances,
  MultiParamTypeClasses, TypeFamilies #-}
module STD.MapIterator.Template where
import Foreign.C.Types
import Foreign.Ptr
import FFICXX.Runtime.Cast
import STD.Pair.Template

data RawMapIterator tpk tpv

newtype MapIterator tpk tpv = MapIterator (Ptr
                                             (RawMapIterator tpk tpv))

class () => IMapIterator tpk tpv where
        deRef :: MapIterator tpk tpv -> IO (Pair tpk tpv)
        
        increment :: MapIterator tpk tpv -> IO (MapIterator tpk tpv)

instance () => FPtr (MapIterator tpk tpv) where
        type Raw (MapIterator tpk tpv) = RawMapIterator tpk tpv
        get_fptr :: MapIterator tpk tpv -> Ptr (Raw (MapIterator tpk tpv))
get_fptr (MapIterator Ptr (RawMapIterator tpk tpv)
ptr) = Ptr (Raw (MapIterator tpk tpv))
Ptr (RawMapIterator tpk tpv)
ptr
        cast_fptr_to_obj :: Ptr (Raw (MapIterator tpk tpv)) -> MapIterator tpk tpv
cast_fptr_to_obj = Ptr (Raw (MapIterator tpk tpv)) -> MapIterator tpk tpv
Ptr (RawMapIterator tpk tpv) -> MapIterator tpk tpv
forall tpk tpv. Ptr (RawMapIterator tpk tpv) -> MapIterator tpk tpv
MapIterator

instance () =>
         Castable (MapIterator tpk tpv) (Ptr (RawMapIterator tpk tpv))
         where
        cast :: forall r.
MapIterator tpk tpv
-> (Ptr (RawMapIterator tpk tpv) -> IO r) -> IO r
cast MapIterator tpk tpv
x Ptr (RawMapIterator tpk tpv) -> IO r
f = Ptr (RawMapIterator tpk tpv) -> IO r
f (Ptr (RawMapIterator tpk tpv) -> Ptr (RawMapIterator tpk tpv)
forall a b. Ptr a -> Ptr b
castPtr (MapIterator tpk tpv -> Ptr (Raw (MapIterator tpk tpv))
forall a. FPtr a => a -> Ptr (Raw a)
get_fptr MapIterator tpk tpv
x))
        uncast :: forall r.
Ptr (RawMapIterator tpk tpv)
-> (MapIterator tpk tpv -> IO r) -> IO r
uncast Ptr (RawMapIterator tpk tpv)
x MapIterator tpk tpv -> IO r
f = MapIterator tpk tpv -> IO r
f (Ptr (Raw (MapIterator tpk tpv)) -> MapIterator tpk tpv
forall a. FPtr a => Ptr (Raw a) -> a
cast_fptr_to_obj (Ptr (RawMapIterator tpk tpv) -> Ptr (RawMapIterator tpk tpv)
forall a b. Ptr a -> Ptr b
castPtr Ptr (RawMapIterator tpk tpv)
x))