gi-gio-2.0.20: GI/Gio/Structs/StaticResource.hs
{- |
Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License : LGPL-2.1
Maintainer : Iñaki García Etxebarria (inaki@blueleaf.cc)
'GI.Gio.Structs.StaticResource.StaticResource' is an opaque data structure and can only be accessed
using the following functions.
-}
#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
&& !defined(__HADDOCK_VERSION__))
module GI.Gio.Structs.StaticResource
(
-- * Exported types
StaticResource(..) ,
newZeroStaticResource ,
noStaticResource ,
-- * Methods
-- ** fini #method:fini#
#if ENABLE_OVERLOADING
StaticResourceFiniMethodInfo ,
#endif
staticResourceFini ,
-- ** getResource #method:getResource#
#if ENABLE_OVERLOADING
StaticResourceGetResourceMethodInfo ,
#endif
staticResourceGetResource ,
-- ** init #method:init#
#if ENABLE_OVERLOADING
StaticResourceInitMethodInfo ,
#endif
staticResourceInit ,
) 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.ManagedPtr as B.ManagedPtr
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.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 {-# SOURCE #-} qualified GI.Gio.Structs.Resource as Gio.Resource
-- | Memory-managed wrapper type.
newtype StaticResource = StaticResource (ManagedPtr StaticResource)
instance WrappedPtr StaticResource where
wrappedPtrCalloc = callocBytes 40
wrappedPtrCopy = \p -> withManagedPtr p (copyBytes 40 >=> wrapPtr StaticResource)
wrappedPtrFree = Just ptr_to_g_free
-- | Construct a `StaticResource` struct initialized to zero.
newZeroStaticResource :: MonadIO m => m StaticResource
newZeroStaticResource = liftIO $ wrappedPtrCalloc >>= wrapPtr StaticResource
instance tag ~ 'AttrSet => Constructible StaticResource tag where
new _ attrs = do
o <- newZeroStaticResource
GI.Attributes.set o attrs
return o
-- | A convenience alias for `Nothing` :: `Maybe` `StaticResource`.
noStaticResource :: Maybe StaticResource
noStaticResource = Nothing
#if ENABLE_OVERLOADING
instance O.HasAttributeList StaticResource
type instance O.AttributeList StaticResource = StaticResourceAttributeList
type StaticResourceAttributeList = ('[ ] :: [(Symbol, *)])
#endif
-- method StaticResource::fini
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "static_resource", argType = TInterface (Name {namespace = "Gio", name = "StaticResource"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "pointer to a static #GStaticResource", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False
foreign import ccall "g_static_resource_fini" g_static_resource_fini ::
Ptr StaticResource -> -- static_resource : TInterface (Name {namespace = "Gio", name = "StaticResource"})
IO ()
{- |
Finalized a GResource initialized by 'GI.Gio.Structs.StaticResource.staticResourceInit'.
This is normally used by code generated by
[glib-compile-resources][glib-compile-resources]
and is not typically used by other code.
/Since: 2.32/
-}
staticResourceFini ::
(B.CallStack.HasCallStack, MonadIO m) =>
StaticResource
{- ^ /@staticResource@/: pointer to a static 'GI.Gio.Structs.StaticResource.StaticResource' -}
-> m ()
staticResourceFini staticResource = liftIO $ do
staticResource' <- unsafeManagedPtrGetPtr staticResource
g_static_resource_fini staticResource'
touchManagedPtr staticResource
return ()
#if ENABLE_OVERLOADING
data StaticResourceFiniMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo StaticResourceFiniMethodInfo StaticResource signature where
overloadedMethod _ = staticResourceFini
#endif
-- method StaticResource::get_resource
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "static_resource", argType = TInterface (Name {namespace = "Gio", name = "StaticResource"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "pointer to a static #GStaticResource", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "Resource"}))
-- throws : False
-- Skip return : False
foreign import ccall "g_static_resource_get_resource" g_static_resource_get_resource ::
Ptr StaticResource -> -- static_resource : TInterface (Name {namespace = "Gio", name = "StaticResource"})
IO (Ptr Gio.Resource.Resource)
{- |
Gets the GResource that was registered by a call to 'GI.Gio.Structs.StaticResource.staticResourceInit'.
This is normally used by code generated by
[glib-compile-resources][glib-compile-resources]
and is not typically used by other code.
/Since: 2.32/
-}
staticResourceGetResource ::
(B.CallStack.HasCallStack, MonadIO m) =>
StaticResource
{- ^ /@staticResource@/: pointer to a static 'GI.Gio.Structs.StaticResource.StaticResource' -}
-> m Gio.Resource.Resource
{- ^ __Returns:__ a 'GI.Gio.Structs.Resource.Resource' -}
staticResourceGetResource staticResource = liftIO $ do
staticResource' <- unsafeManagedPtrGetPtr staticResource
result <- g_static_resource_get_resource staticResource'
checkUnexpectedReturnNULL "staticResourceGetResource" result
result' <- (newBoxed Gio.Resource.Resource) result
touchManagedPtr staticResource
return result'
#if ENABLE_OVERLOADING
data StaticResourceGetResourceMethodInfo
instance (signature ~ (m Gio.Resource.Resource), MonadIO m) => O.MethodInfo StaticResourceGetResourceMethodInfo StaticResource signature where
overloadedMethod _ = staticResourceGetResource
#endif
-- method StaticResource::init
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "static_resource", argType = TInterface (Name {namespace = "Gio", name = "StaticResource"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "pointer to a static #GStaticResource", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False
foreign import ccall "g_static_resource_init" g_static_resource_init ::
Ptr StaticResource -> -- static_resource : TInterface (Name {namespace = "Gio", name = "StaticResource"})
IO ()
{- |
Initializes a GResource from static data using a
GStaticResource.
This is normally used by code generated by
[glib-compile-resources][glib-compile-resources]
and is not typically used by other code.
/Since: 2.32/
-}
staticResourceInit ::
(B.CallStack.HasCallStack, MonadIO m) =>
StaticResource
{- ^ /@staticResource@/: pointer to a static 'GI.Gio.Structs.StaticResource.StaticResource' -}
-> m ()
staticResourceInit staticResource = liftIO $ do
staticResource' <- unsafeManagedPtrGetPtr staticResource
g_static_resource_init staticResource'
touchManagedPtr staticResource
return ()
#if ENABLE_OVERLOADING
data StaticResourceInitMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo StaticResourceInitMethodInfo StaticResource signature where
overloadedMethod _ = staticResourceInit
#endif
#if ENABLE_OVERLOADING
type family ResolveStaticResourceMethod (t :: Symbol) (o :: *) :: * where
ResolveStaticResourceMethod "fini" o = StaticResourceFiniMethodInfo
ResolveStaticResourceMethod "init" o = StaticResourceInitMethodInfo
ResolveStaticResourceMethod "getResource" o = StaticResourceGetResourceMethodInfo
ResolveStaticResourceMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveStaticResourceMethod t StaticResource, O.MethodInfo info StaticResource p) => OL.IsLabel t (StaticResource -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#else
fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif
#endif