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

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

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