{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.Gtk.Objects.CClosureExpression
(
CClosureExpression(..) ,
IsCClosureExpression ,
toCClosureExpression ,
#if defined(ENABLE_OVERLOADING)
ResolveCClosureExpressionMethod ,
#endif
cClosureExpressionNew ,
) 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.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.Text as T
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 GI.GObject.Callbacks as GObject.Callbacks
import {-# SOURCE #-} qualified GI.Gtk.Objects.Expression as Gtk.Expression
newtype CClosureExpression = CClosureExpression (SP.ManagedPtr CClosureExpression)
deriving (CClosureExpression -> CClosureExpression -> Bool
(CClosureExpression -> CClosureExpression -> Bool)
-> (CClosureExpression -> CClosureExpression -> Bool)
-> Eq CClosureExpression
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CClosureExpression -> CClosureExpression -> Bool
$c/= :: CClosureExpression -> CClosureExpression -> Bool
== :: CClosureExpression -> CClosureExpression -> Bool
$c== :: CClosureExpression -> CClosureExpression -> Bool
Eq)
instance SP.ManagedPtrNewtype CClosureExpression where
toManagedPtr :: CClosureExpression -> ManagedPtr CClosureExpression
toManagedPtr (CClosureExpression ManagedPtr CClosureExpression
p) = ManagedPtr CClosureExpression
p
foreign import ccall "gtk_cclosure_expression_get_type"
c_gtk_cclosure_expression_get_type :: IO B.Types.GType
instance B.Types.TypedObject CClosureExpression where
glibType :: IO GType
glibType = IO GType
c_gtk_cclosure_expression_get_type
class (SP.BoxedPtr o, SP.TypedObject o, O.IsDescendantOf CClosureExpression o) => IsCClosureExpression o
instance (SP.BoxedPtr o, SP.TypedObject o, O.IsDescendantOf CClosureExpression o) => IsCClosureExpression o
instance O.HasParentTypes CClosureExpression
type instance O.ParentTypes CClosureExpression = '[Gtk.Expression.Expression]
toCClosureExpression :: (MIO.MonadIO m, IsCClosureExpression o) => o -> m CClosureExpression
toCClosureExpression :: forall (m :: * -> *) o.
(MonadIO m, IsCClosureExpression o) =>
o -> m CClosureExpression
toCClosureExpression = IO CClosureExpression -> m CClosureExpression
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO CClosureExpression -> m CClosureExpression)
-> (o -> IO CClosureExpression) -> o -> m CClosureExpression
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr CClosureExpression -> CClosureExpression)
-> o -> IO CClosureExpression
forall o o'.
(HasCallStack, ManagedPtrNewtype o, TypedObject o,
ManagedPtrNewtype o', TypedObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
B.ManagedPtr.unsafeCastTo ManagedPtr CClosureExpression -> CClosureExpression
CClosureExpression
#if defined(ENABLE_OVERLOADING)
type family ResolveCClosureExpressionMethod (t :: Symbol) (o :: *) :: * where
ResolveCClosureExpressionMethod "bind" o = Gtk.Expression.ExpressionBindMethodInfo
ResolveCClosureExpressionMethod "evaluate" o = Gtk.Expression.ExpressionEvaluateMethodInfo
ResolveCClosureExpressionMethod "isStatic" o = Gtk.Expression.ExpressionIsStaticMethodInfo
ResolveCClosureExpressionMethod "ref" o = Gtk.Expression.ExpressionRefMethodInfo
ResolveCClosureExpressionMethod "unref" o = Gtk.Expression.ExpressionUnrefMethodInfo
ResolveCClosureExpressionMethod "watch" o = Gtk.Expression.ExpressionWatchMethodInfo
ResolveCClosureExpressionMethod "getValueType" o = Gtk.Expression.ExpressionGetValueTypeMethodInfo
ResolveCClosureExpressionMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveCClosureExpressionMethod t CClosureExpression, O.OverloadedMethod info CClosureExpression p) => OL.IsLabel t (CClosureExpression -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod @info
#else
fromLabel _ = O.overloadedMethod @info
#endif
#if MIN_VERSION_base(4,13,0)
instance (info ~ ResolveCClosureExpressionMethod t CClosureExpression, O.OverloadedMethod info CClosureExpression p, R.HasField t CClosureExpression p) => R.HasField t CClosureExpression p where
getField = O.overloadedMethod @info
#endif
instance (info ~ ResolveCClosureExpressionMethod t CClosureExpression, O.OverloadedMethodInfo info CClosureExpression) => OL.IsLabel t (O.MethodProxy info CClosureExpression) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.MethodProxy
#else
fromLabel _ = O.MethodProxy
#endif
#endif
instance BoxedPtr CClosureExpression where
boxedPtrCopy :: CClosureExpression -> IO CClosureExpression
boxedPtrCopy = CClosureExpression -> IO CClosureExpression
forall (m :: * -> *) a. Monad m => a -> m a
return
boxedPtrFree :: CClosureExpression -> IO ()
boxedPtrFree = \CClosureExpression
_x -> () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
foreign import ccall "gtk_cclosure_expression_new" gtk_cclosure_expression_new ::
CGType ->
FunPtr GObject.Callbacks.C_ClosureMarshal ->
Word32 ->
Ptr (Ptr Gtk.Expression.Expression) ->
FunPtr GObject.Callbacks.C_Callback ->
Ptr () ->
FunPtr GObject.Callbacks.C_ClosureNotify ->
IO (Ptr Gtk.Expression.Expression)
cClosureExpressionNew ::
(B.CallStack.HasCallStack, MonadIO m) =>
GType
-> Maybe (GObject.Callbacks.ClosureMarshal)
-> [Gtk.Expression.Expression]
-> GObject.Callbacks.Callback
-> m Gtk.Expression.Expression
cClosureExpressionNew :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
GType
-> Maybe ClosureMarshal -> [Expression] -> IO () -> m Expression
cClosureExpressionNew GType
valueType Maybe ClosureMarshal
marshal [Expression]
params IO ()
callbackFunc = IO Expression -> m Expression
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Expression -> m Expression) -> IO Expression -> m Expression
forall a b. (a -> b) -> a -> b
$ do
let nParams :: Word32
nParams = Int -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Word32) -> Int -> Word32
forall a b. (a -> b) -> a -> b
$ [Expression] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
P.length [Expression]
params
let valueType' :: CGType
valueType' = GType -> CGType
gtypeToCGType GType
valueType
FunPtr C_ClosureMarshal
maybeMarshal <- case Maybe ClosureMarshal
marshal of
Maybe ClosureMarshal
Nothing -> FunPtr C_ClosureMarshal -> IO (FunPtr C_ClosureMarshal)
forall (m :: * -> *) a. Monad m => a -> m a
return (Ptr Any -> FunPtr C_ClosureMarshal
forall a b. Ptr a -> FunPtr b
castPtrToFunPtr Ptr Any
forall a. Ptr a
nullPtr)
Just ClosureMarshal
jMarshal -> do
FunPtr C_ClosureMarshal
jMarshal' <- C_ClosureMarshal -> IO (FunPtr C_ClosureMarshal)
GObject.Callbacks.mk_ClosureMarshal (Maybe (Ptr (FunPtr C_ClosureMarshal))
-> ClosureMarshal -> C_ClosureMarshal
GObject.Callbacks.wrap_ClosureMarshal Maybe (Ptr (FunPtr C_ClosureMarshal))
forall a. Maybe a
Nothing ClosureMarshal
jMarshal)
FunPtr C_ClosureMarshal -> IO (FunPtr C_ClosureMarshal)
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_ClosureMarshal
jMarshal'
[Ptr Expression]
params' <- (Expression -> IO (Ptr Expression))
-> [Expression] -> IO [Ptr Expression]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Expression -> IO (Ptr Expression)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
B.ManagedPtr.disownManagedPtr [Expression]
params
Ptr (Ptr Expression)
params'' <- [Ptr Expression] -> IO (Ptr (Ptr Expression))
forall a. [Ptr a] -> IO (Ptr (Ptr a))
packPtrArray [Ptr Expression]
params'
FunPtr (IO ())
callbackFunc' <- IO () -> IO (FunPtr (IO ()))
GObject.Callbacks.mk_Callback (Maybe (Ptr (FunPtr (IO ()))) -> IO () -> IO ()
GObject.Callbacks.wrap_Callback Maybe (Ptr (FunPtr (IO ())))
forall a. Maybe a
Nothing IO ()
callbackFunc)
let userData :: Ptr ()
userData = FunPtr (IO ()) -> Ptr ()
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr FunPtr (IO ())
callbackFunc'
let userDestroy :: FunPtr (Ptr a -> Ptr b -> IO ())
userDestroy = FunPtr (Ptr a -> Ptr b -> IO ())
forall a b. FunPtr (Ptr a -> Ptr b -> IO ())
SP.safeFreeFunPtrPtr'
Ptr Expression
result <- CGType
-> FunPtr C_ClosureMarshal
-> Word32
-> Ptr (Ptr Expression)
-> FunPtr (IO ())
-> Ptr ()
-> FunPtr C_ClosureNotify
-> IO (Ptr Expression)
gtk_cclosure_expression_new CGType
valueType' FunPtr C_ClosureMarshal
maybeMarshal Word32
nParams Ptr (Ptr Expression)
params'' FunPtr (IO ())
callbackFunc' Ptr ()
userData FunPtr C_ClosureNotify
forall a b. FunPtr (Ptr a -> Ptr b -> IO ())
userDestroy
Text -> Ptr Expression -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"cClosureExpressionNew" Ptr Expression
result
Expression
result' <- ((ManagedPtr Expression -> Expression)
-> Ptr Expression -> IO Expression
forall a.
(HasCallStack, BoxedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapPtr ManagedPtr Expression -> Expression
Gtk.Expression.Expression) Ptr Expression
result
Ptr Any -> IO ()
forall a. Ptr a -> IO ()
safeFreeFunPtr (Ptr Any -> IO ()) -> Ptr Any -> IO ()
forall a b. (a -> b) -> a -> b
$ FunPtr C_ClosureMarshal -> Ptr Any
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr FunPtr C_ClosureMarshal
maybeMarshal
(Expression -> IO ()) -> [Expression] -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ Expression -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr [Expression]
params
Expression -> IO Expression
forall (m :: * -> *) a. Monad m => a -> m a
return Expression
result'
#if defined(ENABLE_OVERLOADING)
#endif