{-# LANGUAGE FlexibleInstances, FlexibleContexts, TypeFamilies,
  MultiParamTypeClasses, OverlappingInstances, IncoherentInstances
  #-}
module GDAL.OGRLayer.Cast where
import Foreign.Ptr
import FFICXX.Runtime.Cast
import System.IO.Unsafe
import GDAL.OGRLayer.RawType
import GDAL.OGRLayer.Interface

instance (IOGRLayer a, FPtr a) => Castable (a) (Ptr RawOGRLayer)
         where
        cast :: forall r. a -> (Ptr RawOGRLayer -> IO r) -> IO r
cast a
x Ptr RawOGRLayer -> IO r
f = Ptr RawOGRLayer -> IO r
f (Ptr (Raw a) -> Ptr RawOGRLayer
forall a b. Ptr a -> Ptr b
castPtr (a -> Ptr (Raw a)
forall a. FPtr a => a -> Ptr (Raw a)
get_fptr a
x))
        uncast :: forall r. Ptr RawOGRLayer -> (a -> IO r) -> IO r
uncast Ptr RawOGRLayer
x a -> IO r
f = a -> IO r
f (Ptr (Raw a) -> a
forall a. FPtr a => Ptr (Raw a) -> a
cast_fptr_to_obj (Ptr RawOGRLayer -> Ptr (Raw a)
forall a b. Ptr a -> Ptr b
castPtr Ptr RawOGRLayer
x))

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