    -- GENERATED by C->Haskell Compiler, version 0.28.8 Switcheroo, 25 November 2017 (Haskell)
    -- Edit the ORIGNAL .chs file instead!

    {-# LINE 1 "./GI/Cairo/Render/Internal/Region.chs" #-}
    -----------------------------------------------------------------------------
    -- |
    -- Module      :  GI.Cairo.Render.Internal.Region
    -- Copyright   :  (c) Hamish Mackenzie 2013
    -- License     :  BSD-style (see doc/COPYRIGHT)
    --
    -- Maintainer  :
    -- Stability   :  experimental
    -- Portability :  portable
    --
    -- Region functions.
    -----------------------------------------------------------------------------

    module GI.Cairo.Render.Internal.Region where
    import qualified Foreign.C.Types as C2HSImp

    import GI.Cairo.Render.Types
    {-# LINE 20 "./GI/Cairo/Render/Internal/Region.chs" #-}

    import Foreign
    import Foreign.C
    import qualified Foreign.C.Types as C2HSImp
    import qualified Foreign.Ptr as C2HSImp
    import qualified Foreign.Storable as C2HSImp

    {-# LINE 28 "./GI/Cairo/Render/Internal/Region.chs" #-}

    regionCreateRectangles :: [RectangleInt] -> IO Region
    regionCreateRectangles [RectangleInt]
    rects =
        [RectangleInt]
    -> (Int -> Ptr RectangleInt -> IO Region) -> IO Region
    forall a b. Storable a => [a] -> (Int -> Ptr a -> IO b) -> IO b
    withArrayLen [RectangleInt]
    rects ((Int -> Ptr RectangleInt -> IO Region) -> IO Region)
    -> (Int -> Ptr RectangleInt -> IO Region) -> IO Region
    forall a b. (a -> b) -> a -> b
    $ \ Int
    n Ptr RectangleInt
    ptr ->
            Ptr RectangleInt -> CInt -> IO RegionPtr
    cairo_region_create_rectangles Ptr RectangleInt
    ptr (Int -> CInt
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral Int
    n) IO RegionPtr -> (RegionPtr -> IO Region) -> IO Region
    forall a b. IO a -> (a -> IO b) -> IO b
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= RegionPtr -> IO Region
    mkRegion

    regionCreate :: IO ((Region))
    regionCreate :: IO Region
    regionCreate =
      IO RegionPtr
    regionCreate'_ IO RegionPtr -> (RegionPtr -> IO Region) -> IO Region
    forall a b. IO a -> (a -> IO b) -> IO b
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \RegionPtr
    res ->
      RegionPtr -> IO Region
    mkRegion RegionPtr
    res IO Region -> (Region -> IO Region) -> IO Region
    forall a b. IO a -> (a -> IO b) -> IO b
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \Region
    res' ->
      Region -> IO Region
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Region
    res')

    {-# LINE 34 "./GI/Cairo/Render/Internal/Region.chs" #-}

    regionCreateRectangle :: (RectangleInt) -> IO ((Region))
    regionCreateRectangle a1 =
      with a1 $ \a1' ->
      regionCreateRectangle'_ a1' >>= \res ->
      mkRegion res >>= \res' ->
      return (res')

    {-# LINE 35 "./GI/Cairo/Render/Internal/Region.chs" #-}

    regionCopy :: (Region) -> IO ((Region))
    regionCopy a1 =
      withRegion a1 $ \a1' ->
      regionCopy'_ a1' >>= \res ->
      mkRegion res >>= \res' ->
      return (res')

    {-# LINE 36 "./GI/Cairo/Render/Internal/Region.chs" #-}

    regionDestroy :: (Region) -> IO ()
    regionDestroy a1 =
      withRegion a1 $ \a1' ->
      regionDestroy'_ a1' >>
      return ()

    {-# LINE 37 "./GI/Cairo/Render/Internal/Region.chs" #-}

    regionReference :: (Region) -> IO ()
    regionReference a1 =
      withRegion a1 $ \a1' ->
      regionReference'_ a1' >>
      return ()

    {-# LINE 38 "./GI/Cairo/Render/Internal/Region.chs" #-}

    regionStatus :: (Region) -> IO ((Status))
    regionStatus a1 =
      withRegion a1 $ \a1' ->
      regionStatus'_ a1' >>= \res ->
      let {res' = cToEnum res} in
      return (res')

    {-# LINE 39 "./GI/Cairo/Render/Internal/Region.chs" #-}

    regionGetExtents :: (Region) -> IO ((RectangleInt))
    regionGetExtents a1 =
      withRegion a1 $ \a1' ->
      alloca $ \a2' ->
      regionGetExtents'_ a1' a2' >>
      peek  a2'>>= \a2'' ->
      return (a2'')

    {-# LINE 40 "./GI/Cairo/Render/Internal/Region.chs" #-}

    regionNumRectangles :: (Region) -> IO ((Int))
    regionNumRectangles a1 =
      withRegion a1 $ \a1' ->
      regionNumRectangles'_ a1' >>= \res ->
      let {res' = fromIntegral res} in
      return (res')

    {-# LINE 41 "./GI/Cairo/Render/Internal/Region.chs" #-}

    regionGetRectangle :: (Region) -> (Int) -> IO ((RectangleInt))
    regionGetRectangle a1 a2 =
      withRegion a1 $ \a1' ->
      let {a2' = fromIntegral a2} in
      alloca $ \a3' ->
      regionGetRectangle'_ a1' a2' a3' >>
      peek  a3'>>= \a3'' ->
      return (a3'')

    {-# LINE 42 "./GI/Cairo/Render/Internal/Region.chs" #-}

    regionIsEmpty :: (Region) -> IO ((Bool))
    regionIsEmpty a1 =
      withRegion a1 $ \a1' ->
      regionIsEmpty'_ a1' >>= \res ->
      let {res' = cToBool res} in
      return (res')

    {-# LINE 43 "./GI/Cairo/Render/Internal/Region.chs" #-}

    regionContainsPoint :: (Region) -> (Int) -> (Int) -> IO ((Bool))
    regionContainsPoint a1 a2 a3 =
      withRegion a1 $ \a1' ->
      let {a2' = fromIntegral a2} in
      let {a3' = fromIntegral a3} in
      regionContainsPoint'_ a1' a2' a3' >>= \res ->
      let {res' = cToBool res} in
      return (res')

    {-# LINE 44 "./GI/Cairo/Render/Internal/Region.chs" #-}

    regionContainsRectangle :: (Region) -> (RectangleInt) -> IO ((RegionOverlap))
    regionContainsRectangle a1 a2 =
      withRegion a1 $ \a1' ->
      with a2 $ \a2' ->
      regionContainsRectangle'_ a1' a2' >>= \res ->
      let {res' = cToEnum res} in
      return (res')

    {-# LINE 45 "./GI/Cairo/Render/Internal/Region.chs" #-}

    regionEqual :: (Region) -> (Region) -> IO ((Bool))
    regionEqual a1 a2 =
      withRegion a1 $ \a1' ->
      withRegion a2 $ \a2' ->
      regionEqual'_ a1' a2' >>= \res ->
      let {res' = cToBool res} in
      return (res')

    {-# LINE 46 "./GI/Cairo/Render/Internal/Region.chs" #-}

    regionTranslate :: (Region) -> (Int) -> (Int) -> IO ()
    regionTranslate a1 a2 a3 =
      withRegion a1 $ \a1' ->
      let {a2' = fromIntegral a2} in
      let {a3' = fromIntegral a3} in
      regionTranslate'_ a1' a2' a3' >>
      return ()

    {-# LINE 47 "./GI/Cairo/Render/Internal/Region.chs" #-}

    regionIntersect :: (Region) -> (Region) -> IO ((Status))
    regionIntersect a1 a2 =
      withRegion a1 $ \a1' ->
      withRegion a2 $ \a2' ->
      regionIntersect'_ a1' a2' >>= \res ->
      let {res' = cToEnum res} in
      return (res')

    {-# LINE 48 "./GI/Cairo/Render/Internal/Region.chs" #-}

    regionIntersectRectangle :: (Region) -> (RectangleInt) -> IO ((Status))
    regionIntersectRectangle a1 a2 =
      withRegion a1 $ \a1' ->
      with a2 $ \a2' ->
      regionIntersectRectangle'_ a1' a2' >>= \res ->
      let {res' = cToEnum res} in
      return (res')

    {-# LINE 49 "./GI/Cairo/Render/Internal/Region.chs" #-}

    regionSubtract :: (Region) -> (Region) -> IO ((Status))
    regionSubtract a1 a2 =
      withRegion a1 $ \a1' ->
      withRegion a2 $ \a2' ->
      regionSubtract'_ a1' a2' >>= \res ->
      let {res' = cToEnum res} in
      return (res')

    {-# LINE 50 "./GI/Cairo/Render/Internal/Region.chs" #-}

    regionSubtractRectangle :: (Region) -> (RectangleInt) -> IO ((Status))
    regionSubtractRectangle a1 a2 =
      withRegion a1 $ \a1' ->
      with a2 $ \a2' ->
      regionSubtractRectangle'_ a1' a2' >>= \res ->
      let {res' = cToEnum res} in
      return (res')

    {-# LINE 51 "./GI/Cairo/Render/Internal/Region.chs" #-}

    regionUnion :: (Region) -> (Region) -> IO ((Status))
    regionUnion a1 a2 =
      withRegion a1 $ \a1' ->
      withRegion a2 $ \a2' ->
      regionUnion'_ a1' a2' >>= \res ->
      let {res' = cToEnum res} in
      return (res')

    {-# LINE 52 "./GI/Cairo/Render/Internal/Region.chs" #-}

    regionUnionRectangle :: (Region) -> (RectangleInt) -> IO ((Status))
    regionUnionRectangle a1 a2 =
      withRegion a1 $ \a1' ->
      with a2 $ \a2' ->
      regionUnionRectangle'_ a1' a2' >>= \res ->
      let {res' = cToEnum res} in
      return (res')

    {-# LINE 53 "./GI/Cairo/Render/Internal/Region.chs" #-}

    regionXor :: (Region) -> (Region) -> IO ((Status))
    regionXor a1 a2 =
      withRegion a1 $ \a1' ->
      withRegion a2 $ \a2' ->
      regionXor'_ a1' a2' >>= \res ->
      let {res' = cToEnum res} in
      return (res')

    {-# LINE 54 "./GI/Cairo/Render/Internal/Region.chs" #-}

    regionXorRectangle :: (Region) -> (RectangleInt) -> IO ((Status))
    regionXorRectangle a1 a2 =
      withRegion a1 $ \a1' ->
      with a2 $ \a2' ->
      regionXorRectangle'_ a1' a2' >>= \res ->
      let {res' = cToEnum res} in
      return (res')

    {-# LINE 55 "./GI/Cairo/Render/Internal/Region.chs" #-}

    foreign import ccall safe "GI/Cairo/Render/Internal/Region.chs.h cairo_region_create_rectangles"
      cairo_region_create_rectangles :: ((RectangleIntPtr) -> (C2HSImp.CInt -> (IO (RegionPtr))))

    foreign import ccall safe "GI/Cairo/Render/Internal/Region.chs.h cairo_region_create"
      regionCreate'_ :: (IO (RegionPtr))

    foreign import ccall safe "GI/Cairo/Render/Internal/Region.chs.h cairo_region_create_rectangle"
      regionCreateRectangle'_ :: ((RectangleIntPtr) -> (IO (RegionPtr)))

    foreign import ccall safe "GI/Cairo/Render/Internal/Region.chs.h cairo_region_copy"
      regionCopy'_ :: ((RegionPtr) -> (IO (RegionPtr)))

    foreign import ccall safe "GI/Cairo/Render/Internal/Region.chs.h cairo_region_destroy"
      regionDestroy'_ :: ((RegionPtr) -> (IO ()))

    foreign import ccall safe "GI/Cairo/Render/Internal/Region.chs.h cairo_region_reference"
      regionReference'_ :: ((RegionPtr) -> (IO (RegionPtr)))

    foreign import ccall safe "GI/Cairo/Render/Internal/Region.chs.h cairo_region_status"
      regionStatus'_ :: ((RegionPtr) -> (IO C2HSImp.CInt))

    foreign import ccall safe "GI/Cairo/Render/Internal/Region.chs.h cairo_region_get_extents"
      regionGetExtents'_ :: ((RegionPtr) -> ((RectangleIntPtr) -> (IO ())))

    foreign import ccall safe "GI/Cairo/Render/Internal/Region.chs.h cairo_region_num_rectangles"
      regionNumRectangles'_ :: ((RegionPtr) -> (IO C2HSImp.CInt))

    foreign import ccall safe "GI/Cairo/Render/Internal/Region.chs.h cairo_region_get_rectangle"
      regionGetRectangle'_ :: ((RegionPtr) -> (C2HSImp.CInt -> ((RectangleIntPtr) -> (IO ()))))

    foreign import ccall safe "GI/Cairo/Render/Internal/Region.chs.h cairo_region_is_empty"
      regionIsEmpty'_ :: ((RegionPtr) -> (IO C2HSImp.CInt))

    foreign import ccall safe "GI/Cairo/Render/Internal/Region.chs.h cairo_region_contains_point"
      regionContainsPoint'_ :: ((RegionPtr) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (IO C2HSImp.CInt))))

    foreign import ccall safe "GI/Cairo/Render/Internal/Region.chs.h cairo_region_contains_rectangle"
      regionContainsRectangle'_ :: ((RegionPtr) -> ((RectangleIntPtr) -> (IO C2HSImp.CInt)))

    foreign import ccall safe "GI/Cairo/Render/Internal/Region.chs.h cairo_region_equal"
      regionEqual'_ :: ((RegionPtr) -> ((RegionPtr) -> (IO C2HSImp.CInt)))

    foreign import ccall safe "GI/Cairo/Render/Internal/Region.chs.h cairo_region_translate"
      regionTranslate'_ :: ((RegionPtr) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (IO ()))))

    foreign import ccall safe "GI/Cairo/Render/Internal/Region.chs.h cairo_region_intersect"
      regionIntersect'_ :: ((RegionPtr) -> ((RegionPtr) -> (IO C2HSImp.CInt)))

    foreign import ccall safe "GI/Cairo/Render/Internal/Region.chs.h cairo_region_intersect_rectangle"
      regionIntersectRectangle'_ :: ((RegionPtr) -> ((RectangleIntPtr) -> (IO C2HSImp.CInt)))

    foreign import ccall safe "GI/Cairo/Render/Internal/Region.chs.h cairo_region_subtract"
      regionSubtract'_ :: ((RegionPtr) -> ((RegionPtr) -> (IO C2HSImp.CInt)))

    foreign import ccall safe "GI/Cairo/Render/Internal/Region.chs.h cairo_region_subtract_rectangle"
      regionSubtractRectangle'_ :: ((RegionPtr) -> ((RectangleIntPtr) -> (IO C2HSImp.CInt)))

    foreign import ccall safe "GI/Cairo/Render/Internal/Region.chs.h cairo_region_union"
      regionUnion'_ :: ((RegionPtr) -> ((RegionPtr) -> (IO C2HSImp.CInt)))

    foreign import ccall safe "GI/Cairo/Render/Internal/Region.chs.h cairo_region_union_rectangle"
      regionUnionRectangle'_ :: ((RegionPtr) -> ((RectangleIntPtr) -> (IO C2HSImp.CInt)))

    foreign import ccall safe "GI/Cairo/Render/Internal/Region.chs.h cairo_region_xor"
      regionXor'_ :: ((RegionPtr) -> ((RegionPtr) -> (IO C2HSImp.CInt)))

    foreign import ccall safe "GI/Cairo/Render/Internal/Region.chs.h cairo_region_xor_rectangle"
      regionXorRectangle'_ :: ((RegionPtr) -> ((RectangleIntPtr) -> (IO C2HSImp.CInt)))