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

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

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