-- | Copyright  : Will Thompson and Iñaki García Etxebarria
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria

#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif

module GI.Gsk.Callbacks
    ( 

 -- * Signals


-- ** ParseErrorFunc #signal:ParseErrorFunc#

    C_ParseErrorFunc                        ,
    ParseErrorFunc                          ,
    ParseErrorFunc_WithClosures             ,
    drop_closures_ParseErrorFunc            ,
    dynamic_ParseErrorFunc                  ,
    genClosure_ParseErrorFunc               ,
    mk_ParseErrorFunc                       ,
    noParseErrorFunc                        ,
    noParseErrorFunc_WithClosures           ,
    wrap_ParseErrorFunc                     ,


-- ** PathForeachFunc #signal:PathForeachFunc#

    C_PathForeachFunc                       ,
    PathForeachFunc                         ,
    PathForeachFunc_WithClosures            ,
    drop_closures_PathForeachFunc           ,
    dynamic_PathForeachFunc                 ,
    genClosure_PathForeachFunc              ,
    mk_PathForeachFunc                      ,
    noPathForeachFunc                       ,
    noPathForeachFunc_WithClosures          ,
    wrap_PathForeachFunc                    ,


-- ** PathIntersectionFunc #signal:PathIntersectionFunc#

    C_PathIntersectionFunc                  ,
    PathIntersectionFunc                    ,
    PathIntersectionFunc_WithClosures       ,
    drop_closures_PathIntersectionFunc      ,
    dynamic_PathIntersectionFunc            ,
    genClosure_PathIntersectionFunc         ,
    mk_PathIntersectionFunc                 ,
    noPathIntersectionFunc                  ,
    noPathIntersectionFunc_WithClosures     ,
    wrap_PathIntersectionFunc               ,




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.BasicTypes as B.Types
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GArray as B.GArray
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GHashTable as B.GHT
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.GI.Base.Signals as B.Signals
import qualified Control.Monad.IO.Class as MIO
import qualified Data.Coerce as Coerce
import qualified Data.Text as T
import qualified Data.Kind as DK
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
import qualified GHC.OverloadedLabels as OL
import qualified GHC.Records as R
import qualified Data.Word as DW
import qualified Data.Int as DI
import qualified System.Posix.Types as SPT
import qualified Foreign.C.Types as FCT

-- Workaround for https://gitlab.haskell.org/ghc/ghc/-/issues/23392
#if MIN_VERSION_base(4,18,0)
import qualified GI.Cairo.Structs.Context as Cairo.Context
import qualified GI.GLib.Structs.String as GLib.String
import qualified GI.Graphene.Structs.Point as Graphene.Point
import qualified GI.Graphene.Structs.Rect as Graphene.Rect
import qualified GI.Graphene.Structs.Vec2 as Graphene.Vec2
import {-# SOURCE #-} qualified GI.Gsk.Enums as Gsk.Enums
import {-# SOURCE #-} qualified GI.Gsk.Flags as Gsk.Flags
import {-# SOURCE #-} qualified GI.Gsk.Structs.ParseLocation as Gsk.ParseLocation
import {-# SOURCE #-} qualified GI.Gsk.Structs.Path as Gsk.Path
import {-# SOURCE #-} qualified GI.Gsk.Structs.PathMeasure as Gsk.PathMeasure
import {-# SOURCE #-} qualified GI.Gsk.Structs.PathPoint as Gsk.PathPoint
import {-# SOURCE #-} qualified GI.Gsk.Structs.Stroke as Gsk.Stroke

#else
import qualified GI.Graphene.Structs.Point as Graphene.Point
import {-# SOURCE #-} qualified GI.Gsk.Enums as Gsk.Enums
import {-# SOURCE #-} qualified GI.Gsk.Structs.ParseLocation as Gsk.ParseLocation
import {-# SOURCE #-} qualified GI.Gsk.Structs.Path as Gsk.Path
import {-# SOURCE #-} qualified GI.Gsk.Structs.PathPoint as Gsk.PathPoint

#endif

-- callback PathIntersectionFunc
{- Callable
  { returnType = Just (TBasicType TBoolean)
  , returnMayBeNull = False
  , returnTransfer = TransferNothing
  , returnDocumentation =
      Documentation
        { rawDocText =
            Just
              "true to continue iterating, false to\n  stop the iteration and not call the function again"
        , sinceVersion = Nothing
        }
  , args =
      [ Arg
          { argCName = "path1"
          , argType = TInterface Name { namespace = "Gsk" , name = "Path" }
          , argCType = Just "GskPath*"
          , direction = DirectionIn
          , mayBeNull = False
          , argDoc =
              Documentation
                { rawDocText = Just "the first path" , sinceVersion = Nothing }
          , argScope = ScopeTypeInvalid
          , argClosure = -1
          , argDestroy = -1
          , argCallerAllocates = False
          , argCallbackUserData = False
          , transfer = TransferNothing
          }
      , Arg
          { argCName = "point1"
          , argType =
              TInterface Name { namespace = "Gsk" , name = "PathPoint" }
          , argCType = Just "const GskPathPoint*"
          , direction = DirectionIn
          , mayBeNull = False
          , argDoc =
              Documentation
                { rawDocText = Just "the intersection as point on @path1"
                , sinceVersion = Nothing
                }
          , argScope = ScopeTypeInvalid
          , argClosure = -1
          , argDestroy = -1
          , argCallerAllocates = False
          , argCallbackUserData = False
          , transfer = TransferNothing
          }
      , Arg
          { argCName = "path2"
          , argType = TInterface Name { namespace = "Gsk" , name = "Path" }
          , argCType = Just "GskPath*"
          , direction = DirectionIn
          , mayBeNull = False
          , argDoc =
              Documentation
                { rawDocText = Just "the second path" , sinceVersion = Nothing }
          , argScope = ScopeTypeInvalid
          , argClosure = -1
          , argDestroy = -1
          , argCallerAllocates = False
          , argCallbackUserData = False
          , transfer = TransferNothing
          }
      , Arg
          { argCName = "point2"
          , argType =
              TInterface Name { namespace = "Gsk" , name = "PathPoint" }
          , argCType = Just "const GskPathPoint*"
          , direction = DirectionIn
          , mayBeNull = False
          , argDoc =
              Documentation
                { rawDocText = Just "the intersection as point on @path2"
                , sinceVersion = Nothing
                }
          , argScope = ScopeTypeInvalid
          , argClosure = -1
          , argDestroy = -1
          , argCallerAllocates = False
          , argCallbackUserData = False
          , transfer = TransferNothing
          }
      , Arg
          { argCName = "kind"
          , argType =
              TInterface Name { namespace = "Gsk" , name = "PathIntersection" }
          , argCType = Just "GskPathIntersection"
          , direction = DirectionIn
          , mayBeNull = False
          , argDoc =
              Documentation
                { rawDocText = Just "the nature of the intersection"
                , sinceVersion = Nothing
                }
          , argScope = ScopeTypeInvalid
          , argClosure = -1
          , argDestroy = -1
          , argCallerAllocates = False
          , argCallbackUserData = False
          , transfer = TransferNothing
          }
      , Arg
          { argCName = "user_data"
          , argType = TBasicType TPtr
          , argCType = Just "gpointer"
          , direction = DirectionIn
          , mayBeNull = True
          , argDoc =
              Documentation
                { rawDocText = Just "user data" , sinceVersion = Nothing }
          , argScope = ScopeTypeInvalid
          , argClosure = -1
          , argDestroy = -1
          , argCallerAllocates = False
          , argCallbackUserData = True
          , transfer = TransferNothing
          }
      ]
  , skipReturn = False
  , callableThrows = False
  , callableDeprecated = Nothing
  , callableDocumentation =
      Documentation
        { rawDocText =
            Just
              "Prototype of the callback to iterate through the\nintersections of two paths."
        , sinceVersion = Just "4.20"
        }
  , callableResolvable = Nothing
  }
-}
-- | Type for the callback on the (unwrapped) C side.
type C_PathIntersectionFunc =
    Ptr Gsk.Path.Path ->
    Ptr Gsk.PathPoint.PathPoint ->
    Ptr Gsk.Path.Path ->
    Ptr Gsk.PathPoint.PathPoint ->
    CUInt ->
    Ptr () ->
    IO CInt

-- Args: [ Arg
--           { argCName = "path1"
--           , argType = TInterface Name { namespace = "Gsk" , name = "Path" }
--           , argCType = Just "GskPath*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the first path" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "point1"
--           , argType =
--               TInterface Name { namespace = "Gsk" , name = "PathPoint" }
--           , argCType = Just "const GskPathPoint*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the intersection as point on @path1"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "path2"
--           , argType = TInterface Name { namespace = "Gsk" , name = "Path" }
--           , argCType = Just "GskPath*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the second path" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "point2"
--           , argType =
--               TInterface Name { namespace = "Gsk" , name = "PathPoint" }
--           , argCType = Just "const GskPathPoint*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the intersection as point on @path2"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "kind"
--           , argType =
--               TInterface Name { namespace = "Gsk" , name = "PathIntersection" }
--           , argCType = Just "GskPathIntersection"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the nature of the intersection"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "user_data"
--           , argType = TBasicType TPtr
--           , argCType = Just "gpointer"
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "user data" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = True
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_PathIntersectionFunc :: FunPtr C_PathIntersectionFunc -> C_PathIntersectionFunc

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_PathIntersectionFunc ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    FunPtr C_PathIntersectionFunc
    -> Gsk.Path.Path
    -- ^ /@path1@/: the first path
    -> Gsk.PathPoint.PathPoint
    -- ^ /@point1@/: the intersection as point on /@path1@/
    -> Gsk.Path.Path
    -- ^ /@path2@/: the second path
    -> Gsk.PathPoint.PathPoint
    -- ^ /@point2@/: the intersection as point on /@path2@/
    -> Gsk.Enums.PathIntersection
    -- ^ /@kind@/: the nature of the intersection
    -> Ptr ()
    -- ^ /@userData@/: user data
    -> m Bool
    -- ^ __Returns:__ true to continue iterating, false to
    --   stop the iteration and not call the function again
dynamic_PathIntersectionFunc :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
FunPtr C_PathIntersectionFunc
-> Path
-> PathPoint
-> Path
-> PathPoint
-> PathIntersection
-> Ptr ()
-> m Bool
dynamic_PathIntersectionFunc FunPtr C_PathIntersectionFunc
__funPtr Path
path1 PathPoint
point1 Path
path2 PathPoint
point2 PathIntersection
kind Ptr ()
userData = IO Bool -> m Bool
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    path1' <- Path -> IO (Ptr Path)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Path
path1
    point1' <- unsafeManagedPtrGetPtr point1
    path2' <- unsafeManagedPtrGetPtr path2
    point2' <- unsafeManagedPtrGetPtr point2
    let kind' = (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CUInt)
-> (PathIntersection -> Int) -> PathIntersection -> CUInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PathIntersection -> Int
forall a. Enum a => a -> Int
fromEnum) PathIntersection
kind
    result <- (__dynamic_C_PathIntersectionFunc __funPtr) path1' point1' path2' point2' kind' userData
    let result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    touchManagedPtr path1
    touchManagedPtr point1
    touchManagedPtr path2
    touchManagedPtr point2
    return result'

-- | Generate a function pointer callable from C code, from a `C_PathIntersectionFunc`.
foreign import ccall "wrapper"
    mk_PathIntersectionFunc :: C_PathIntersectionFunc -> IO (FunPtr C_PathIntersectionFunc)

-- | Prototype of the callback to iterate through the
-- intersections of two paths.
-- 
-- /Since: 4.20/
type PathIntersectionFunc =
    Gsk.Path.Path
    -- ^ /@path1@/: the first path
    -> Gsk.PathPoint.PathPoint
    -- ^ /@point1@/: the intersection as point on /@path1@/
    -> Gsk.Path.Path
    -- ^ /@path2@/: the second path
    -> Gsk.PathPoint.PathPoint
    -- ^ /@point2@/: the intersection as point on /@path2@/
    -> Gsk.Enums.PathIntersection
    -- ^ /@kind@/: the nature of the intersection
    -> IO Bool
    -- ^ __Returns:__ true to continue iterating, false to
    --   stop the iteration and not call the function again

-- | A convenience synonym for @`Nothing` :: `Maybe` `PathIntersectionFunc`@.
noPathIntersectionFunc :: Maybe PathIntersectionFunc
noPathIntersectionFunc :: Maybe PathIntersectionFunc
noPathIntersectionFunc = Maybe PathIntersectionFunc
forall a. Maybe a
Nothing

-- | Prototype of the callback to iterate through the
-- intersections of two paths.
-- 
-- /Since: 4.20/
type PathIntersectionFunc_WithClosures =
    Gsk.Path.Path
    -- ^ /@path1@/: the first path
    -> Gsk.PathPoint.PathPoint
    -- ^ /@point1@/: the intersection as point on /@path1@/
    -> Gsk.Path.Path
    -- ^ /@path2@/: the second path
    -> Gsk.PathPoint.PathPoint
    -- ^ /@point2@/: the intersection as point on /@path2@/
    -> Gsk.Enums.PathIntersection
    -- ^ /@kind@/: the nature of the intersection
    -> Ptr ()
    -- ^ /@userData@/: user data
    -> IO Bool
    -- ^ __Returns:__ true to continue iterating, false to
    --   stop the iteration and not call the function again

-- | A convenience synonym for @`Nothing` :: `Maybe` `PathIntersectionFunc_WithClosures`@.
noPathIntersectionFunc_WithClosures :: Maybe PathIntersectionFunc_WithClosures
noPathIntersectionFunc_WithClosures :: Maybe PathIntersectionFunc_WithClosures
noPathIntersectionFunc_WithClosures = Maybe PathIntersectionFunc_WithClosures
forall a. Maybe a
Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_PathIntersectionFunc :: PathIntersectionFunc -> PathIntersectionFunc_WithClosures
drop_closures_PathIntersectionFunc :: PathIntersectionFunc -> PathIntersectionFunc_WithClosures
drop_closures_PathIntersectionFunc PathIntersectionFunc
_f Path
path1 PathPoint
point1 Path
path2 PathPoint
point2 PathIntersection
kind Ptr ()
_ = PathIntersectionFunc
_f Path
path1 PathPoint
point1 Path
path2 PathPoint
point2 PathIntersection
kind

-- | Wrap the callback into a `GClosure`.
genClosure_PathIntersectionFunc :: MonadIO m => PathIntersectionFunc -> m (GClosure C_PathIntersectionFunc)
genClosure_PathIntersectionFunc :: forall (m :: * -> *).
MonadIO m =>
PathIntersectionFunc -> m (GClosure C_PathIntersectionFunc)
genClosure_PathIntersectionFunc PathIntersectionFunc
cb = IO (GClosure C_PathIntersectionFunc)
-> m (GClosure C_PathIntersectionFunc)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (GClosure C_PathIntersectionFunc)
 -> m (GClosure C_PathIntersectionFunc))
-> IO (GClosure C_PathIntersectionFunc)
-> m (GClosure C_PathIntersectionFunc)
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: PathIntersectionFunc_WithClosures
cb' = PathIntersectionFunc -> PathIntersectionFunc_WithClosures
drop_closures_PathIntersectionFunc PathIntersectionFunc
cb
    let cb'' :: C_PathIntersectionFunc
cb'' = Maybe (Ptr (FunPtr C_PathIntersectionFunc))
-> PathIntersectionFunc_WithClosures -> C_PathIntersectionFunc
wrap_PathIntersectionFunc Maybe (Ptr (FunPtr C_PathIntersectionFunc))
forall a. Maybe a
Nothing PathIntersectionFunc_WithClosures
cb'
    C_PathIntersectionFunc -> IO (FunPtr C_PathIntersectionFunc)
mk_PathIntersectionFunc C_PathIntersectionFunc
cb'' IO (FunPtr C_PathIntersectionFunc)
-> (FunPtr C_PathIntersectionFunc
    -> IO (GClosure C_PathIntersectionFunc))
-> IO (GClosure C_PathIntersectionFunc)
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= FunPtr C_PathIntersectionFunc
-> IO (GClosure C_PathIntersectionFunc)
forall (m :: * -> *) a. MonadIO m => FunPtr a -> m (GClosure a)
B.GClosure.newGClosure


-- | Wrap a `PathIntersectionFunc` into a `C_PathIntersectionFunc`.
wrap_PathIntersectionFunc :: 
    Maybe (Ptr (FunPtr C_PathIntersectionFunc)) ->
    PathIntersectionFunc_WithClosures ->
    C_PathIntersectionFunc
wrap_PathIntersectionFunc :: Maybe (Ptr (FunPtr C_PathIntersectionFunc))
-> PathIntersectionFunc_WithClosures -> C_PathIntersectionFunc
wrap_PathIntersectionFunc Maybe (Ptr (FunPtr C_PathIntersectionFunc))
gi'funptrptr PathIntersectionFunc_WithClosures
gi'cb Ptr Path
path1 Ptr PathPoint
point1 Ptr Path
path2 Ptr PathPoint
point2 CUInt
kind Ptr ()
userData = do
    Ptr Path -> (Path -> IO CInt) -> IO CInt
forall a b.
(HasCallStack, ManagedPtrNewtype a) =>
Ptr a -> (a -> IO b) -> IO b
B.ManagedPtr.withTransient  Ptr Path
path1 ((Path -> IO CInt) -> IO CInt) -> (Path -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Path
path1' -> do
        Ptr PathPoint -> (PathPoint -> IO CInt) -> IO CInt
forall a b.
(HasCallStack, ManagedPtrNewtype a) =>
Ptr a -> (a -> IO b) -> IO b
B.ManagedPtr.withTransient  Ptr PathPoint
point1 ((PathPoint -> IO CInt) -> IO CInt)
-> (PathPoint -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \PathPoint
point1' -> do
            Ptr Path -> (Path -> IO CInt) -> IO CInt
forall a b.
(HasCallStack, ManagedPtrNewtype a) =>
Ptr a -> (a -> IO b) -> IO b
B.ManagedPtr.withTransient  Ptr Path
path2 ((Path -> IO CInt) -> IO CInt) -> (Path -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Path
path2' -> do
                Ptr PathPoint -> (PathPoint -> IO CInt) -> IO CInt
forall a b.
(HasCallStack, ManagedPtrNewtype a) =>
Ptr a -> (a -> IO b) -> IO b
B.ManagedPtr.withTransient  Ptr PathPoint
point2 ((PathPoint -> IO CInt) -> IO CInt)
-> (PathPoint -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \PathPoint
point2' -> do
                    let kind' :: PathIntersection
kind' = (Int -> PathIntersection
forall a. Enum a => Int -> a
toEnum (Int -> PathIntersection)
-> (CUInt -> Int) -> CUInt -> PathIntersection
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CUInt
kind
                    result <- PathIntersectionFunc_WithClosures
gi'cb  Path
path1' PathPoint
point1' Path
path2' PathPoint
point2' PathIntersection
kind' Ptr ()
userData
                    maybeReleaseFunPtr gi'funptrptr
                    let result' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
P.fromIntegral (Int -> CInt) -> (Bool -> Int) -> Bool -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Int
forall a. Enum a => a -> Int
P.fromEnum) Bool
result
                    return result'


-- callback PathForeachFunc
{- Callable
  { returnType = Just (TBasicType TBoolean)
  , returnMayBeNull = False
  , returnTransfer = TransferNothing
  , returnDocumentation =
      Documentation
        { rawDocText =
            Just
              "%TRUE to continue iterating the path, %FALSE to\n  immediately abort and not call the function again."
        , sinceVersion = Nothing
        }
  , args =
      [ Arg
          { argCName = "op"
          , argType =
              TInterface Name { namespace = "Gsk" , name = "PathOperation" }
          , argCType = Just "GskPathOperation"
          , direction = DirectionIn
          , mayBeNull = False
          , argDoc =
              Documentation
                { rawDocText = Just "The operation" , sinceVersion = Nothing }
          , argScope = ScopeTypeInvalid
          , argClosure = -1
          , argDestroy = -1
          , argCallerAllocates = False
          , argCallbackUserData = False
          , transfer = TransferNothing
          }
      , Arg
          { argCName = "pts"
          , argType =
              TCArray
                False
                (-1)
                2
                (TInterface Name { namespace = "Graphene" , name = "Point" })
          , argCType = Just "const graphene_point_t*"
          , direction = DirectionIn
          , mayBeNull = False
          , argDoc =
              Documentation
                { rawDocText = Just "The points of the operation"
                , sinceVersion = Nothing
                }
          , argScope = ScopeTypeInvalid
          , argClosure = -1
          , argDestroy = -1
          , argCallerAllocates = False
          , argCallbackUserData = False
          , transfer = TransferNothing
          }
      , Arg
          { argCName = "n_pts"
          , argType = TBasicType TSize
          , argCType = Just "gsize"
          , direction = DirectionIn
          , mayBeNull = False
          , argDoc =
              Documentation
                { rawDocText = Just "The number of points"
                , sinceVersion = Nothing
                }
          , argScope = ScopeTypeInvalid
          , argClosure = -1
          , argDestroy = -1
          , argCallerAllocates = False
          , argCallbackUserData = False
          , transfer = TransferNothing
          }
      , Arg
          { argCName = "weight"
          , argType = TBasicType TFloat
          , argCType = Just "float"
          , direction = DirectionIn
          , mayBeNull = False
          , argDoc =
              Documentation
                { rawDocText =
                    Just "The weight for conic curves, or unused if not a conic curve"
                , sinceVersion = Nothing
                }
          , argScope = ScopeTypeInvalid
          , argClosure = -1
          , argDestroy = -1
          , argCallerAllocates = False
          , argCallbackUserData = False
          , transfer = TransferNothing
          }
      , Arg
          { argCName = "user_data"
          , argType = TBasicType TPtr
          , argCType = Just "gpointer"
          , direction = DirectionIn
          , mayBeNull = True
          , argDoc =
              Documentation
                { rawDocText = Just "The user data provided with the function"
                , sinceVersion = Nothing
                }
          , argScope = ScopeTypeInvalid
          , argClosure = -1
          , argDestroy = -1
          , argCallerAllocates = False
          , argCallbackUserData = True
          , transfer = TransferNothing
          }
      ]
  , skipReturn = False
  , callableThrows = False
  , callableDeprecated = Nothing
  , callableDocumentation =
      Documentation
        { rawDocText =
            Just
              "Type of the callback to iterate through the operations of a path.\n\nFor each operation, the callback is given the @op itself, the points\nthat the operation is applied to in @pts, and a @weight for conic\ncurves. The @n_pts argument is somewhat redundant, since the number\nof points can be inferred from the operation.\n\nEach contour of the path starts with a @GSK_PATH_MOVE operation.\nClosed contours end with a @GSK_PATH_CLOSE operation."
        , sinceVersion = Nothing
        }
  , callableResolvable = Nothing
  }
-}
-- | Type for the callback on the (unwrapped) C side.
type C_PathForeachFunc =
    CUInt ->
    Ptr Graphene.Point.Point ->
    FCT.CSize ->
    CFloat ->
    Ptr () ->
    IO CInt

-- Args: [ Arg
--           { argCName = "op"
--           , argType =
--               TInterface Name { namespace = "Gsk" , name = "PathOperation" }
--           , argCType = Just "GskPathOperation"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "The operation" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "pts"
--           , argType =
--               TCArray
--                 False
--                 (-1)
--                 2
--                 (TInterface Name { namespace = "Graphene" , name = "Point" })
--           , argCType = Just "const graphene_point_t*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "The points of the operation"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "n_pts"
--           , argType = TBasicType TSize
--           , argCType = Just "gsize"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "The number of points"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "weight"
--           , argType = TBasicType TFloat
--           , argCType = Just "float"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "The weight for conic curves, or unused if not a conic curve"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "user_data"
--           , argType = TBasicType TPtr
--           , argCType = Just "gpointer"
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "The user data provided with the function"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = True
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: [ Arg
--              { argCName = "n_pts"
--              , argType = TBasicType TSize
--              , argCType = Just "gsize"
--              , direction = DirectionIn
--              , mayBeNull = False
--              , argDoc =
--                  Documentation
--                    { rawDocText = Just "The number of points"
--                    , sinceVersion = Nothing
--                    }
--              , argScope = ScopeTypeInvalid
--              , argClosure = -1
--              , argDestroy = -1
--              , argCallerAllocates = False
--              , argCallbackUserData = False
--              , transfer = TransferNothing
--              }
--          ]
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_PathForeachFunc :: FunPtr C_PathForeachFunc -> C_PathForeachFunc

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_PathForeachFunc ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    FunPtr C_PathForeachFunc
    -> Gsk.Enums.PathOperation
    -- ^ /@op@/: The operation
    -> [Graphene.Point.Point]
    -- ^ /@pts@/: The points of the operation
    -> Float
    -- ^ /@weight@/: The weight for conic curves, or unused if not a conic curve
    -> Ptr ()
    -- ^ /@userData@/: The user data provided with the function
    -> m Bool
    -- ^ __Returns:__ 'P.True' to continue iterating the path, 'P.False' to
    --   immediately abort and not call the function again.
dynamic_PathForeachFunc :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
FunPtr C_PathForeachFunc
-> PathOperation -> [Point] -> Float -> Ptr () -> m Bool
dynamic_PathForeachFunc FunPtr C_PathForeachFunc
__funPtr PathOperation
op [Point]
pts Float
weight Ptr ()
userData = IO Bool -> m Bool
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    let nPts :: CSize
nPts = Int -> CSize
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CSize) -> Int -> CSize
forall a b. (a -> b) -> a -> b
$ [Point] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
P.length [Point]
pts
    let op' :: CUInt
op' = (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CUInt) -> (PathOperation -> Int) -> PathOperation -> CUInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PathOperation -> Int
forall a. Enum a => a -> Int
fromEnum) PathOperation
op
    pts' <- (Point -> IO (Ptr Point)) -> [Point] -> IO [Ptr Point]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM Point -> IO (Ptr Point)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr [Point]
pts
    pts'' <- packBlockArray 8 pts'
    let weight' = Float -> CFloat
forall a b. (Real a, Fractional b) => a -> b
realToFrac Float
weight
    result <- (__dynamic_C_PathForeachFunc __funPtr) op' pts'' nPts weight' userData
    let result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    mapM_ touchManagedPtr pts
    freeMem pts''
    return result'

-- | Generate a function pointer callable from C code, from a `C_PathForeachFunc`.
foreign import ccall "wrapper"
    mk_PathForeachFunc :: C_PathForeachFunc -> IO (FunPtr C_PathForeachFunc)

-- | Type of the callback to iterate through the operations of a path.
-- 
-- For each operation, the callback is given the /@op@/ itself, the points
-- that the operation is applied to in /@pts@/, and a /@weight@/ for conic
-- curves. The /@nPts@/ argument is somewhat redundant, since the number
-- of points can be inferred from the operation.
-- 
-- Each contour of the path starts with a /@gSKPATHMOVE@/ operation.
-- Closed contours end with a /@gSKPATHCLOSE@/ operation.
type PathForeachFunc =
    Gsk.Enums.PathOperation
    -- ^ /@op@/: The operation
    -> [Graphene.Point.Point]
    -- ^ /@pts@/: The points of the operation
    -> Float
    -- ^ /@weight@/: The weight for conic curves, or unused if not a conic curve
    -> IO Bool
    -- ^ __Returns:__ 'P.True' to continue iterating the path, 'P.False' to
    --   immediately abort and not call the function again.

-- | A convenience synonym for @`Nothing` :: `Maybe` `PathForeachFunc`@.
noPathForeachFunc :: Maybe PathForeachFunc
noPathForeachFunc :: Maybe PathForeachFunc
noPathForeachFunc = Maybe PathForeachFunc
forall a. Maybe a
Nothing

-- | Type of the callback to iterate through the operations of a path.
-- 
-- For each operation, the callback is given the /@op@/ itself, the points
-- that the operation is applied to in /@pts@/, and a /@weight@/ for conic
-- curves. The /@nPts@/ argument is somewhat redundant, since the number
-- of points can be inferred from the operation.
-- 
-- Each contour of the path starts with a /@gSKPATHMOVE@/ operation.
-- Closed contours end with a /@gSKPATHCLOSE@/ operation.
type PathForeachFunc_WithClosures =
    Gsk.Enums.PathOperation
    -- ^ /@op@/: The operation
    -> [Graphene.Point.Point]
    -- ^ /@pts@/: The points of the operation
    -> Float
    -- ^ /@weight@/: The weight for conic curves, or unused if not a conic curve
    -> Ptr ()
    -- ^ /@userData@/: The user data provided with the function
    -> IO Bool
    -- ^ __Returns:__ 'P.True' to continue iterating the path, 'P.False' to
    --   immediately abort and not call the function again.

-- | A convenience synonym for @`Nothing` :: `Maybe` `PathForeachFunc_WithClosures`@.
noPathForeachFunc_WithClosures :: Maybe PathForeachFunc_WithClosures
noPathForeachFunc_WithClosures :: Maybe PathForeachFunc_WithClosures
noPathForeachFunc_WithClosures = Maybe PathForeachFunc_WithClosures
forall a. Maybe a
Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_PathForeachFunc :: PathForeachFunc -> PathForeachFunc_WithClosures
drop_closures_PathForeachFunc :: PathForeachFunc -> PathForeachFunc_WithClosures
drop_closures_PathForeachFunc PathForeachFunc
_f PathOperation
op [Point]
pts Float
weight Ptr ()
_ = PathForeachFunc
_f PathOperation
op [Point]
pts Float
weight

-- | Wrap the callback into a `GClosure`.
genClosure_PathForeachFunc :: MonadIO m => PathForeachFunc -> m (GClosure C_PathForeachFunc)
genClosure_PathForeachFunc :: forall (m :: * -> *).
MonadIO m =>
PathForeachFunc -> m (GClosure C_PathForeachFunc)
genClosure_PathForeachFunc PathForeachFunc
cb = IO (GClosure C_PathForeachFunc) -> m (GClosure C_PathForeachFunc)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (GClosure C_PathForeachFunc) -> m (GClosure C_PathForeachFunc))
-> IO (GClosure C_PathForeachFunc)
-> m (GClosure C_PathForeachFunc)
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: PathForeachFunc_WithClosures
cb' = PathForeachFunc -> PathForeachFunc_WithClosures
drop_closures_PathForeachFunc PathForeachFunc
cb
    let cb'' :: C_PathForeachFunc
cb'' = Maybe (Ptr (FunPtr C_PathForeachFunc))
-> PathForeachFunc_WithClosures -> C_PathForeachFunc
wrap_PathForeachFunc Maybe (Ptr (FunPtr C_PathForeachFunc))
forall a. Maybe a
Nothing PathForeachFunc_WithClosures
cb'
    C_PathForeachFunc -> IO (FunPtr C_PathForeachFunc)
mk_PathForeachFunc C_PathForeachFunc
cb'' IO (FunPtr C_PathForeachFunc)
-> (FunPtr C_PathForeachFunc -> IO (GClosure C_PathForeachFunc))
-> IO (GClosure C_PathForeachFunc)
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= FunPtr C_PathForeachFunc -> IO (GClosure C_PathForeachFunc)
forall (m :: * -> *) a. MonadIO m => FunPtr a -> m (GClosure a)
B.GClosure.newGClosure


-- | Wrap a `PathForeachFunc` into a `C_PathForeachFunc`.
wrap_PathForeachFunc :: 
    Maybe (Ptr (FunPtr C_PathForeachFunc)) ->
    PathForeachFunc_WithClosures ->
    C_PathForeachFunc
wrap_PathForeachFunc :: Maybe (Ptr (FunPtr C_PathForeachFunc))
-> PathForeachFunc_WithClosures -> C_PathForeachFunc
wrap_PathForeachFunc Maybe (Ptr (FunPtr C_PathForeachFunc))
gi'funptrptr PathForeachFunc_WithClosures
gi'cb CUInt
op Ptr Point
pts CSize
nPts CFloat
weight Ptr ()
userData = do
    let op' :: PathOperation
op' = (Int -> PathOperation
forall a. Enum a => Int -> a
toEnum (Int -> PathOperation) -> (CUInt -> Int) -> CUInt -> PathOperation
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CUInt
op
    pts' <- (Int -> CSize -> Ptr Point -> IO [Ptr Point]
forall a b.
(Integral a, GBoxed b) =>
Int -> a -> Ptr b -> IO [Ptr b]
unpackBoxedArrayWithLength Int
8 CSize
nPts) Ptr Point
pts
    pts'' <- mapM (newBoxed Graphene.Point.Point) pts'
    let weight' = CFloat -> Float
forall a b. (Real a, Fractional b) => a -> b
realToFrac CFloat
weight
    result <- gi'cb  op' pts'' weight' userData
    maybeReleaseFunPtr gi'funptrptr
    let result' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
P.fromIntegral (Int -> CInt) -> (Bool -> Int) -> Bool -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Int
forall a. Enum a => a -> Int
P.fromEnum) Bool
result
    return result'


-- callback ParseErrorFunc
{- Callable
  { returnType = Nothing
  , returnMayBeNull = False
  , returnTransfer = TransferNothing
  , returnDocumentation =
      Documentation { rawDocText = Nothing , sinceVersion = Nothing }
  , args =
      [ Arg
          { argCName = "start"
          , argType =
              TInterface Name { namespace = "Gsk" , name = "ParseLocation" }
          , argCType = Just "const GskParseLocation*"
          , direction = DirectionIn
          , mayBeNull = False
          , argDoc =
              Documentation
                { rawDocText = Just "start of the error location"
                , sinceVersion = Nothing
                }
          , argScope = ScopeTypeInvalid
          , argClosure = -1
          , argDestroy = -1
          , argCallerAllocates = False
          , argCallbackUserData = False
          , transfer = TransferNothing
          }
      , Arg
          { argCName = "end"
          , argType =
              TInterface Name { namespace = "Gsk" , name = "ParseLocation" }
          , argCType = Just "const GskParseLocation*"
          , direction = DirectionIn
          , mayBeNull = False
          , argDoc =
              Documentation
                { rawDocText = Just "end of the error location"
                , sinceVersion = Nothing
                }
          , argScope = ScopeTypeInvalid
          , argClosure = -1
          , argDestroy = -1
          , argCallerAllocates = False
          , argCallbackUserData = False
          , transfer = TransferNothing
          }
      , Arg
          { argCName = "error"
          , argType = TError
          , argCType = Just "const GError*"
          , direction = DirectionIn
          , mayBeNull = False
          , argDoc =
              Documentation
                { rawDocText = Just "the error" , sinceVersion = Nothing }
          , argScope = ScopeTypeInvalid
          , argClosure = -1
          , argDestroy = -1
          , argCallerAllocates = False
          , argCallbackUserData = False
          , transfer = TransferNothing
          }
      , Arg
          { argCName = "user_data"
          , argType = TBasicType TPtr
          , argCType = Just "gpointer"
          , direction = DirectionIn
          , mayBeNull = True
          , argDoc =
              Documentation
                { rawDocText = Just "user data" , sinceVersion = Nothing }
          , argScope = ScopeTypeInvalid
          , argClosure = -1
          , argDestroy = -1
          , argCallerAllocates = False
          , argCallbackUserData = True
          , transfer = TransferNothing
          }
      ]
  , skipReturn = False
  , callableThrows = False
  , callableDeprecated = Nothing
  , callableDocumentation =
      Documentation
        { rawDocText =
            Just
              "Type of callback that is called when an error occurs\nduring node deserialization."
        , sinceVersion = Nothing
        }
  , callableResolvable = Nothing
  }
-}
-- | Type for the callback on the (unwrapped) C side.
type C_ParseErrorFunc =
    Ptr Gsk.ParseLocation.ParseLocation ->
    Ptr Gsk.ParseLocation.ParseLocation ->
    Ptr GError ->
    Ptr () ->
    IO ()

-- Args: [ Arg
--           { argCName = "start"
--           , argType =
--               TInterface Name { namespace = "Gsk" , name = "ParseLocation" }
--           , argCType = Just "const GskParseLocation*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "start of the error location"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "end"
--           , argType =
--               TInterface Name { namespace = "Gsk" , name = "ParseLocation" }
--           , argCType = Just "const GskParseLocation*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "end of the error location"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "error"
--           , argType = TError
--           , argCType = Just "const GError*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the error" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "user_data"
--           , argType = TBasicType TPtr
--           , argCType = Just "gpointer"
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "user data" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = True
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_ParseErrorFunc :: FunPtr C_ParseErrorFunc -> C_ParseErrorFunc

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_ParseErrorFunc ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    FunPtr C_ParseErrorFunc
    -> Gsk.ParseLocation.ParseLocation
    -- ^ /@start@/: start of the error location
    -> Gsk.ParseLocation.ParseLocation
    -- ^ /@end@/: end of the error location
    -> GError
    -- ^ /@error@/: the error
    -> Ptr ()
    -- ^ /@userData@/: user data
    -> m ()
dynamic_ParseErrorFunc :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
FunPtr C_ParseErrorFunc
-> ParseLocation -> ParseLocation -> GError -> Ptr () -> m ()
dynamic_ParseErrorFunc FunPtr C_ParseErrorFunc
__funPtr ParseLocation
start ParseLocation
end GError
error_ Ptr ()
userData = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    start' <- ParseLocation -> IO (Ptr ParseLocation)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr ParseLocation
start
    end' <- unsafeManagedPtrGetPtr end
    error_' <- unsafeManagedPtrGetPtr error_
    (__dynamic_C_ParseErrorFunc __funPtr) start' end' error_' userData
    touchManagedPtr start
    touchManagedPtr end
    touchManagedPtr error_
    return ()

-- | Generate a function pointer callable from C code, from a `C_ParseErrorFunc`.
foreign import ccall "wrapper"
    mk_ParseErrorFunc :: C_ParseErrorFunc -> IO (FunPtr C_ParseErrorFunc)

-- | Type of callback that is called when an error occurs
-- during node deserialization.
type ParseErrorFunc =
    Gsk.ParseLocation.ParseLocation
    -- ^ /@start@/: start of the error location
    -> Gsk.ParseLocation.ParseLocation
    -- ^ /@end@/: end of the error location
    -> GError
    -- ^ /@error@/: the error
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `ParseErrorFunc`@.
noParseErrorFunc :: Maybe ParseErrorFunc
noParseErrorFunc :: Maybe ParseErrorFunc
noParseErrorFunc = Maybe ParseErrorFunc
forall a. Maybe a
Nothing

-- | Type of callback that is called when an error occurs
-- during node deserialization.
type ParseErrorFunc_WithClosures =
    Gsk.ParseLocation.ParseLocation
    -- ^ /@start@/: start of the error location
    -> Gsk.ParseLocation.ParseLocation
    -- ^ /@end@/: end of the error location
    -> GError
    -- ^ /@error@/: the error
    -> Ptr ()
    -- ^ /@userData@/: user data
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `ParseErrorFunc_WithClosures`@.
noParseErrorFunc_WithClosures :: Maybe ParseErrorFunc_WithClosures
noParseErrorFunc_WithClosures :: Maybe ParseErrorFunc_WithClosures
noParseErrorFunc_WithClosures = Maybe ParseErrorFunc_WithClosures
forall a. Maybe a
Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_ParseErrorFunc :: ParseErrorFunc -> ParseErrorFunc_WithClosures
drop_closures_ParseErrorFunc :: ParseErrorFunc -> ParseErrorFunc_WithClosures
drop_closures_ParseErrorFunc ParseErrorFunc
_f ParseLocation
start ParseLocation
end GError
error_ Ptr ()
_ = ParseErrorFunc
_f ParseLocation
start ParseLocation
end GError
error_

-- | Wrap the callback into a `GClosure`.
genClosure_ParseErrorFunc :: MonadIO m => ParseErrorFunc -> m (GClosure C_ParseErrorFunc)
genClosure_ParseErrorFunc :: forall (m :: * -> *).
MonadIO m =>
ParseErrorFunc -> m (GClosure C_ParseErrorFunc)
genClosure_ParseErrorFunc ParseErrorFunc
cb = IO (GClosure C_ParseErrorFunc) -> m (GClosure C_ParseErrorFunc)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (GClosure C_ParseErrorFunc) -> m (GClosure C_ParseErrorFunc))
-> IO (GClosure C_ParseErrorFunc) -> m (GClosure C_ParseErrorFunc)
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: ParseErrorFunc_WithClosures
cb' = ParseErrorFunc -> ParseErrorFunc_WithClosures
drop_closures_ParseErrorFunc ParseErrorFunc
cb
    let cb'' :: C_ParseErrorFunc
cb'' = Maybe (Ptr (FunPtr C_ParseErrorFunc))
-> ParseErrorFunc_WithClosures -> C_ParseErrorFunc
wrap_ParseErrorFunc Maybe (Ptr (FunPtr C_ParseErrorFunc))
forall a. Maybe a
Nothing ParseErrorFunc_WithClosures
cb'
    C_ParseErrorFunc -> IO (FunPtr C_ParseErrorFunc)
mk_ParseErrorFunc C_ParseErrorFunc
cb'' IO (FunPtr C_ParseErrorFunc)
-> (FunPtr C_ParseErrorFunc -> IO (GClosure C_ParseErrorFunc))
-> IO (GClosure C_ParseErrorFunc)
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= FunPtr C_ParseErrorFunc -> IO (GClosure C_ParseErrorFunc)
forall (m :: * -> *) a. MonadIO m => FunPtr a -> m (GClosure a)
B.GClosure.newGClosure


-- | Wrap a `ParseErrorFunc` into a `C_ParseErrorFunc`.
wrap_ParseErrorFunc :: 
    Maybe (Ptr (FunPtr C_ParseErrorFunc)) ->
    ParseErrorFunc_WithClosures ->
    C_ParseErrorFunc
wrap_ParseErrorFunc :: Maybe (Ptr (FunPtr C_ParseErrorFunc))
-> ParseErrorFunc_WithClosures -> C_ParseErrorFunc
wrap_ParseErrorFunc Maybe (Ptr (FunPtr C_ParseErrorFunc))
gi'funptrptr ParseErrorFunc_WithClosures
gi'cb Ptr ParseLocation
start Ptr ParseLocation
end Ptr GError
error_ Ptr ()
userData = do
    start' <- ((ManagedPtr ParseLocation -> ParseLocation)
-> Ptr ParseLocation -> IO ParseLocation
forall a.
(HasCallStack, BoxedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newPtr ManagedPtr ParseLocation -> ParseLocation
Gsk.ParseLocation.ParseLocation) Ptr ParseLocation
start
    end' <- (newPtr Gsk.ParseLocation.ParseLocation) end
    error_' <- (newBoxed GError) error_
    gi'cb  start' end' error_' userData
    maybeReleaseFunPtr gi'funptrptr