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

instance (IOGRFieldDefn a, FPtr a) =>
         Castable (a) (Ptr RawOGRFieldDefn)
         where
        cast :: forall r. a -> (Ptr RawOGRFieldDefn -> IO r) -> IO r
cast a
x Ptr RawOGRFieldDefn -> IO r
f = Ptr RawOGRFieldDefn -> IO r
f (Ptr (Raw a) -> Ptr RawOGRFieldDefn
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 RawOGRFieldDefn -> (a -> IO r) -> IO r
uncast Ptr RawOGRFieldDefn
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 RawOGRFieldDefn -> Ptr (Raw a)
forall a b. Ptr a -> Ptr b
castPtr Ptr RawOGRFieldDefn
x))

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