module Graphics.Rendering.Cairo.Internal.Utilities where
import Graphics.Rendering.Cairo.Types
import Foreign
import Foreign.C
import System.IO.Unsafe (unsafePerformIO)
import Codec.Binary.UTF8.String
import Data.Char (ord, chr)
import Data.Text (Text)
import Data.ByteString (useAsCString)
import qualified Data.Text.Encoding as T (encodeUtf8)
statusToString :: Status -> IO (String)
statusToString a1 =
let {a1' = cFromEnum a1} in
statusToString'_ a1' >>= \res ->
peekCString res >>= \res' ->
return (res')
version :: Int
version =
let {res = version'_} in
let {res' = cIntConv res} in
(res')
versionString :: String
versionString =
unsafePerformIO $
let {res = versionString'_} in
peekCString res >>= \res' ->
return (res')
class CairoString s where
withUTFString :: s -> (CString -> IO a) -> IO a
instance CairoString [Char] where
withUTFString = withCAString . encodeString
instance CairoString Text where
withUTFString s = useAsCString (T.encodeUtf8 s)
foreign import ccall safe "dist/build/Graphics/Rendering/Cairo/Internal/Utilities.h cairo_status_to_string"
statusToString'_ :: (CInt -> (IO (Ptr CChar)))
foreign import ccall safe "dist/build/Graphics/Rendering/Cairo/Internal/Utilities.h cairo_version"
version'_ :: CInt
foreign import ccall safe "dist/build/Graphics/Rendering/Cairo/Internal/Utilities.h cairo_version_string"
versionString'_ :: (Ptr CChar)