{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson and Iñaki García Etxebarria
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- A CSS style sheet which can be injected in loaded pages.
-- 
-- /Since: 2.6/

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

module GI.WebKit2.Structs.UserStyleSheet
    ( 

-- * Exported types
    UserStyleSheet(..)                      ,


 -- * Methods
-- | 
-- 
--  === __Click to display all available methods, including inherited ones__
-- ==== Methods
-- [ref]("GI.WebKit2.Structs.UserStyleSheet#g:method:ref"), [unref]("GI.WebKit2.Structs.UserStyleSheet#g:method:unref").
-- 
-- ==== Getters
-- /None/.
-- 
-- ==== Setters
-- /None/.

#if defined(ENABLE_OVERLOADING)
    ResolveUserStyleSheetMethod             ,
#endif

-- ** new #method:new#

    userStyleSheetNew                       ,


-- ** newForWorld #method:newForWorld#

    userStyleSheetNewForWorld               ,


-- ** ref #method:ref#

#if defined(ENABLE_OVERLOADING)
    UserStyleSheetRefMethodInfo             ,
#endif
    userStyleSheetRef                       ,


-- ** unref #method:unref#

#if defined(ENABLE_OVERLOADING)
    UserStyleSheetUnrefMethodInfo           ,
#endif
    userStyleSheetUnref                     ,




    ) 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 {-# SOURCE #-} qualified GI.WebKit2.Enums as WebKit2.Enums

#else
import {-# SOURCE #-} qualified GI.WebKit2.Enums as WebKit2.Enums

#endif

-- | Memory-managed wrapper type.
newtype UserStyleSheet = UserStyleSheet (SP.ManagedPtr UserStyleSheet)
    deriving (UserStyleSheet -> UserStyleSheet -> Bool
(UserStyleSheet -> UserStyleSheet -> Bool)
-> (UserStyleSheet -> UserStyleSheet -> Bool) -> Eq UserStyleSheet
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: UserStyleSheet -> UserStyleSheet -> Bool
== :: UserStyleSheet -> UserStyleSheet -> Bool
$c/= :: UserStyleSheet -> UserStyleSheet -> Bool
/= :: UserStyleSheet -> UserStyleSheet -> Bool
Eq)

instance SP.ManagedPtrNewtype UserStyleSheet where
    toManagedPtr :: UserStyleSheet -> ManagedPtr UserStyleSheet
toManagedPtr (UserStyleSheet ManagedPtr UserStyleSheet
p) = ManagedPtr UserStyleSheet
p

foreign import ccall "webkit_user_style_sheet_get_type" c_webkit_user_style_sheet_get_type :: 
    IO GType

type instance O.ParentTypes UserStyleSheet = '[]
instance O.HasParentTypes UserStyleSheet

instance B.Types.TypedObject UserStyleSheet where
    glibType :: IO GType
glibType = IO GType
c_webkit_user_style_sheet_get_type

instance B.Types.GBoxed UserStyleSheet

-- | Convert 'UserStyleSheet' to and from 'Data.GI.Base.GValue.GValue'. See 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'.
instance B.GValue.IsGValue (Maybe UserStyleSheet) where
    gvalueGType_ :: IO GType
gvalueGType_ = IO GType
c_webkit_user_style_sheet_get_type
    gvalueSet_ :: Ptr GValue -> Maybe UserStyleSheet -> IO ()
gvalueSet_ Ptr GValue
gv Maybe UserStyleSheet
P.Nothing = Ptr GValue -> Ptr UserStyleSheet -> IO ()
forall a. Ptr GValue -> Ptr a -> IO ()
B.GValue.set_boxed Ptr GValue
gv (Ptr UserStyleSheet
forall a. Ptr a
FP.nullPtr :: FP.Ptr UserStyleSheet)
    gvalueSet_ Ptr GValue
gv (P.Just UserStyleSheet
obj) = UserStyleSheet -> (Ptr UserStyleSheet -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr UserStyleSheet
obj (Ptr GValue -> Ptr UserStyleSheet -> IO ()
forall a. Ptr GValue -> Ptr a -> IO ()
B.GValue.set_boxed Ptr GValue
gv)
    gvalueGet_ :: Ptr GValue -> IO (Maybe UserStyleSheet)
gvalueGet_ Ptr GValue
gv = do
        Ptr UserStyleSheet
ptr <- Ptr GValue -> IO (Ptr UserStyleSheet)
forall b. Ptr GValue -> IO (Ptr b)
B.GValue.get_boxed Ptr GValue
gv :: IO (Ptr UserStyleSheet)
        if Ptr UserStyleSheet
ptr Ptr UserStyleSheet -> Ptr UserStyleSheet -> Bool
forall a. Eq a => a -> a -> Bool
/= Ptr UserStyleSheet
forall a. Ptr a
FP.nullPtr
        then UserStyleSheet -> Maybe UserStyleSheet
forall a. a -> Maybe a
P.Just (UserStyleSheet -> Maybe UserStyleSheet)
-> IO UserStyleSheet -> IO (Maybe UserStyleSheet)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ManagedPtr UserStyleSheet -> UserStyleSheet)
-> Ptr UserStyleSheet -> IO UserStyleSheet
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
B.ManagedPtr.newBoxed ManagedPtr UserStyleSheet -> UserStyleSheet
UserStyleSheet Ptr UserStyleSheet
ptr
        else Maybe UserStyleSheet -> IO (Maybe UserStyleSheet)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe UserStyleSheet
forall a. Maybe a
P.Nothing
        
    


#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList UserStyleSheet
type instance O.AttributeList UserStyleSheet = UserStyleSheetAttributeList
type UserStyleSheetAttributeList = ('[ ] :: [(Symbol, DK.Type)])
#endif

-- method UserStyleSheet::new
-- method type : Constructor
-- Args: [ Arg
--           { argCName = "source"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "Source code of the user style sheet."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "injected_frames"
--           , argType =
--               TInterface
--                 Name { namespace = "WebKit2" , name = "UserContentInjectedFrames" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "A #WebKitUserContentInjectedFrames value"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "level"
--           , argType =
--               TInterface Name { namespace = "WebKit2" , name = "UserStyleLevel" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "A #WebKitUserStyleLevel"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "allow_list"
--           , argType = TCArray True (-1) (-1) (TBasicType TUTF8)
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "An allow_list of URI patterns or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "block_list"
--           , argType = TCArray True (-1) (-1) (TBasicType TUTF8)
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "A block_list of URI patterns or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface
--                  Name { namespace = "WebKit2" , name = "UserStyleSheet" })
-- throws : False
-- Skip return : False

foreign import ccall "webkit_user_style_sheet_new" webkit_user_style_sheet_new :: 
    CString ->                              -- source : TBasicType TUTF8
    CUInt ->                                -- injected_frames : TInterface (Name {namespace = "WebKit2", name = "UserContentInjectedFrames"})
    CUInt ->                                -- level : TInterface (Name {namespace = "WebKit2", name = "UserStyleLevel"})
    Ptr CString ->                          -- allow_list : TCArray True (-1) (-1) (TBasicType TUTF8)
    Ptr CString ->                          -- block_list : TCArray True (-1) (-1) (TBasicType TUTF8)
    IO (Ptr UserStyleSheet)

-- | Creates a new user style sheet.
-- 
-- Style sheets can be applied to some URIs
-- only by passing non-null values for /@allowList@/ or /@blockList@/. Passing a
-- 'P.Nothing' allow_list implies that all URIs are on the allow_list. The style
-- sheet is applied if an URI matches the allow_list and not the block_list.
-- URI patterns must be of the form @[protocol]:\/\/[host]\/[path]@, where the
-- *host* and *path* components can contain the wildcard character (@*@) to
-- represent zero or more other characters.
-- 
-- /Since: 2.6/
userStyleSheetNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@source@/: Source code of the user style sheet.
    -> WebKit2.Enums.UserContentInjectedFrames
    -- ^ /@injectedFrames@/: A t'GI.WebKit2.Enums.UserContentInjectedFrames' value
    -> WebKit2.Enums.UserStyleLevel
    -- ^ /@level@/: A t'GI.WebKit2.Enums.UserStyleLevel'
    -> Maybe ([T.Text])
    -- ^ /@allowList@/: An allow_list of URI patterns or 'P.Nothing'
    -> Maybe ([T.Text])
    -- ^ /@blockList@/: A block_list of URI patterns or 'P.Nothing'
    -> m UserStyleSheet
    -- ^ __Returns:__ A new t'GI.WebKit2.Structs.UserStyleSheet.UserStyleSheet'
userStyleSheetNew :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Text
-> UserContentInjectedFrames
-> UserStyleLevel
-> Maybe [Text]
-> Maybe [Text]
-> m UserStyleSheet
userStyleSheetNew Text
source UserContentInjectedFrames
injectedFrames UserStyleLevel
level Maybe [Text]
allowList Maybe [Text]
blockList = IO UserStyleSheet -> m UserStyleSheet
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO UserStyleSheet -> m UserStyleSheet)
-> IO UserStyleSheet -> m UserStyleSheet
forall a b. (a -> b) -> a -> b
$ do
    CString
source' <- Text -> IO CString
textToCString Text
source
    let injectedFrames' :: CUInt
injectedFrames' = (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CUInt)
-> (UserContentInjectedFrames -> Int)
-> UserContentInjectedFrames
-> CUInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UserContentInjectedFrames -> Int
forall a. Enum a => a -> Int
fromEnum) UserContentInjectedFrames
injectedFrames
    let level' :: CUInt
level' = (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CUInt)
-> (UserStyleLevel -> Int) -> UserStyleLevel -> CUInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UserStyleLevel -> Int
forall a. Enum a => a -> Int
fromEnum) UserStyleLevel
level
    Ptr CString
maybeAllowList <- case Maybe [Text]
allowList of
        Maybe [Text]
Nothing -> Ptr CString -> IO (Ptr CString)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CString
forall a. Ptr a
nullPtr
        Just [Text]
jAllowList -> do
            Ptr CString
jAllowList' <- [Text] -> IO (Ptr CString)
packZeroTerminatedUTF8CArray [Text]
jAllowList
            Ptr CString -> IO (Ptr CString)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CString
jAllowList'
    Ptr CString
maybeBlockList <- case Maybe [Text]
blockList of
        Maybe [Text]
Nothing -> Ptr CString -> IO (Ptr CString)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CString
forall a. Ptr a
nullPtr
        Just [Text]
jBlockList -> do
            Ptr CString
jBlockList' <- [Text] -> IO (Ptr CString)
packZeroTerminatedUTF8CArray [Text]
jBlockList
            Ptr CString -> IO (Ptr CString)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CString
jBlockList'
    Ptr UserStyleSheet
result <- CString
-> CUInt
-> CUInt
-> Ptr CString
-> Ptr CString
-> IO (Ptr UserStyleSheet)
webkit_user_style_sheet_new CString
source' CUInt
injectedFrames' CUInt
level' Ptr CString
maybeAllowList Ptr CString
maybeBlockList
    Text -> Ptr UserStyleSheet -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"userStyleSheetNew" Ptr UserStyleSheet
result
    UserStyleSheet
result' <- ((ManagedPtr UserStyleSheet -> UserStyleSheet)
-> Ptr UserStyleSheet -> IO UserStyleSheet
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr UserStyleSheet -> UserStyleSheet
UserStyleSheet) Ptr UserStyleSheet
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
source'
    (CString -> IO ()) -> Ptr CString -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
maybeAllowList
    Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
maybeAllowList
    (CString -> IO ()) -> Ptr CString -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
maybeBlockList
    Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
maybeBlockList
    UserStyleSheet -> IO UserStyleSheet
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return UserStyleSheet
result'

#if defined(ENABLE_OVERLOADING)
#endif

-- method UserStyleSheet::new_for_world
-- method type : Constructor
-- Args: [ Arg
--           { argCName = "source"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "Source code of the user style sheet."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "injected_frames"
--           , argType =
--               TInterface
--                 Name { namespace = "WebKit2" , name = "UserContentInjectedFrames" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "A #WebKitUserContentInjectedFrames value"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "level"
--           , argType =
--               TInterface Name { namespace = "WebKit2" , name = "UserStyleLevel" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "A #WebKitUserStyleLevel"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "world_name"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the name of a #WebKitScriptWorld"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "allow_list"
--           , argType = TCArray True (-1) (-1) (TBasicType TUTF8)
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "An allow_list of URI patterns or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "block_list"
--           , argType = TCArray True (-1) (-1) (TBasicType TUTF8)
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "A block_list of URI patterns or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface
--                  Name { namespace = "WebKit2" , name = "UserStyleSheet" })
-- throws : False
-- Skip return : False

foreign import ccall "webkit_user_style_sheet_new_for_world" webkit_user_style_sheet_new_for_world :: 
    CString ->                              -- source : TBasicType TUTF8
    CUInt ->                                -- injected_frames : TInterface (Name {namespace = "WebKit2", name = "UserContentInjectedFrames"})
    CUInt ->                                -- level : TInterface (Name {namespace = "WebKit2", name = "UserStyleLevel"})
    CString ->                              -- world_name : TBasicType TUTF8
    Ptr CString ->                          -- allow_list : TCArray True (-1) (-1) (TBasicType TUTF8)
    Ptr CString ->                          -- block_list : TCArray True (-1) (-1) (TBasicType TUTF8)
    IO (Ptr UserStyleSheet)

-- | Creates a new user style sheet for script world.
-- 
-- Creates a new user style sheet for script world with name /@worldName@/.
-- See 'GI.WebKit2.Structs.UserStyleSheet.userStyleSheetNew' for a full description.
-- 
-- /Since: 2.22/
userStyleSheetNewForWorld ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@source@/: Source code of the user style sheet.
    -> WebKit2.Enums.UserContentInjectedFrames
    -- ^ /@injectedFrames@/: A t'GI.WebKit2.Enums.UserContentInjectedFrames' value
    -> WebKit2.Enums.UserStyleLevel
    -- ^ /@level@/: A t'GI.WebKit2.Enums.UserStyleLevel'
    -> T.Text
    -- ^ /@worldName@/: the name of a @/WebKitScriptWorld/@
    -> Maybe ([T.Text])
    -- ^ /@allowList@/: An allow_list of URI patterns or 'P.Nothing'
    -> Maybe ([T.Text])
    -- ^ /@blockList@/: A block_list of URI patterns or 'P.Nothing'
    -> m UserStyleSheet
    -- ^ __Returns:__ A new t'GI.WebKit2.Structs.UserStyleSheet.UserStyleSheet'
userStyleSheetNewForWorld :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Text
-> UserContentInjectedFrames
-> UserStyleLevel
-> Text
-> Maybe [Text]
-> Maybe [Text]
-> m UserStyleSheet
userStyleSheetNewForWorld Text
source UserContentInjectedFrames
injectedFrames UserStyleLevel
level Text
worldName Maybe [Text]
allowList Maybe [Text]
blockList = IO UserStyleSheet -> m UserStyleSheet
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO UserStyleSheet -> m UserStyleSheet)
-> IO UserStyleSheet -> m UserStyleSheet
forall a b. (a -> b) -> a -> b
$ do
    CString
source' <- Text -> IO CString
textToCString Text
source
    let injectedFrames' :: CUInt
injectedFrames' = (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CUInt)
-> (UserContentInjectedFrames -> Int)
-> UserContentInjectedFrames
-> CUInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UserContentInjectedFrames -> Int
forall a. Enum a => a -> Int
fromEnum) UserContentInjectedFrames
injectedFrames
    let level' :: CUInt
level' = (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CUInt)
-> (UserStyleLevel -> Int) -> UserStyleLevel -> CUInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UserStyleLevel -> Int
forall a. Enum a => a -> Int
fromEnum) UserStyleLevel
level
    CString
worldName' <- Text -> IO CString
textToCString Text
worldName
    Ptr CString
maybeAllowList <- case Maybe [Text]
allowList of
        Maybe [Text]
Nothing -> Ptr CString -> IO (Ptr CString)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CString
forall a. Ptr a
nullPtr
        Just [Text]
jAllowList -> do
            Ptr CString
jAllowList' <- [Text] -> IO (Ptr CString)
packZeroTerminatedUTF8CArray [Text]
jAllowList
            Ptr CString -> IO (Ptr CString)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CString
jAllowList'
    Ptr CString
maybeBlockList <- case Maybe [Text]
blockList of
        Maybe [Text]
Nothing -> Ptr CString -> IO (Ptr CString)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CString
forall a. Ptr a
nullPtr
        Just [Text]
jBlockList -> do
            Ptr CString
jBlockList' <- [Text] -> IO (Ptr CString)
packZeroTerminatedUTF8CArray [Text]
jBlockList
            Ptr CString -> IO (Ptr CString)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CString
jBlockList'
    Ptr UserStyleSheet
result <- CString
-> CUInt
-> CUInt
-> CString
-> Ptr CString
-> Ptr CString
-> IO (Ptr UserStyleSheet)
webkit_user_style_sheet_new_for_world CString
source' CUInt
injectedFrames' CUInt
level' CString
worldName' Ptr CString
maybeAllowList Ptr CString
maybeBlockList
    Text -> Ptr UserStyleSheet -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"userStyleSheetNewForWorld" Ptr UserStyleSheet
result
    UserStyleSheet
result' <- ((ManagedPtr UserStyleSheet -> UserStyleSheet)
-> Ptr UserStyleSheet -> IO UserStyleSheet
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr UserStyleSheet -> UserStyleSheet
UserStyleSheet) Ptr UserStyleSheet
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
source'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
worldName'
    (CString -> IO ()) -> Ptr CString -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
maybeAllowList
    Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
maybeAllowList
    (CString -> IO ()) -> Ptr CString -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
maybeBlockList
    Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
maybeBlockList
    UserStyleSheet -> IO UserStyleSheet
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return UserStyleSheet
result'

#if defined(ENABLE_OVERLOADING)
#endif

-- method UserStyleSheet::ref
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "user_style_sheet"
--           , argType =
--               TInterface Name { namespace = "WebKit2" , name = "UserStyleSheet" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #WebKitUserStyleSheet"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface
--                  Name { namespace = "WebKit2" , name = "UserStyleSheet" })
-- throws : False
-- Skip return : False

foreign import ccall "webkit_user_style_sheet_ref" webkit_user_style_sheet_ref :: 
    Ptr UserStyleSheet ->                   -- user_style_sheet : TInterface (Name {namespace = "WebKit2", name = "UserStyleSheet"})
    IO (Ptr UserStyleSheet)

-- | Atomically increments the reference count of /@userStyleSheet@/ by one.
-- 
-- This function is MT-safe and may be called from any thread.
-- 
-- /Since: 2.6/
userStyleSheetRef ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    UserStyleSheet
    -- ^ /@userStyleSheet@/: a t'GI.WebKit2.Structs.UserStyleSheet.UserStyleSheet'
    -> m UserStyleSheet
    -- ^ __Returns:__ The passed t'GI.WebKit2.Structs.UserStyleSheet.UserStyleSheet'
userStyleSheetRef :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
UserStyleSheet -> m UserStyleSheet
userStyleSheetRef UserStyleSheet
userStyleSheet = IO UserStyleSheet -> m UserStyleSheet
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO UserStyleSheet -> m UserStyleSheet)
-> IO UserStyleSheet -> m UserStyleSheet
forall a b. (a -> b) -> a -> b
$ do
    Ptr UserStyleSheet
userStyleSheet' <- UserStyleSheet -> IO (Ptr UserStyleSheet)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr UserStyleSheet
userStyleSheet
    Ptr UserStyleSheet
result <- Ptr UserStyleSheet -> IO (Ptr UserStyleSheet)
webkit_user_style_sheet_ref Ptr UserStyleSheet
userStyleSheet'
    Text -> Ptr UserStyleSheet -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"userStyleSheetRef" Ptr UserStyleSheet
result
    UserStyleSheet
result' <- ((ManagedPtr UserStyleSheet -> UserStyleSheet)
-> Ptr UserStyleSheet -> IO UserStyleSheet
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr UserStyleSheet -> UserStyleSheet
UserStyleSheet) Ptr UserStyleSheet
result
    UserStyleSheet -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr UserStyleSheet
userStyleSheet
    UserStyleSheet -> IO UserStyleSheet
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return UserStyleSheet
result'

#if defined(ENABLE_OVERLOADING)
data UserStyleSheetRefMethodInfo
instance (signature ~ (m UserStyleSheet), MonadIO m) => O.OverloadedMethod UserStyleSheetRefMethodInfo UserStyleSheet signature where
    overloadedMethod = userStyleSheetRef

instance O.OverloadedMethodInfo UserStyleSheetRefMethodInfo UserStyleSheet where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.WebKit2.Structs.UserStyleSheet.userStyleSheetRef",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-webkit2-4.0.31/docs/GI-WebKit2-Structs-UserStyleSheet.html#v:userStyleSheetRef"
        })


#endif

-- method UserStyleSheet::unref
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "user_style_sheet"
--           , argType =
--               TInterface Name { namespace = "WebKit2" , name = "UserStyleSheet" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #WebKitUserStyleSheet"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "webkit_user_style_sheet_unref" webkit_user_style_sheet_unref :: 
    Ptr UserStyleSheet ->                   -- user_style_sheet : TInterface (Name {namespace = "WebKit2", name = "UserStyleSheet"})
    IO ()

-- | Atomically decrements the reference count of /@userStyleSheet@/ by one.
-- 
-- If the reference count drops to 0, all memory allocated by
-- t'GI.WebKit2.Structs.UserStyleSheet.UserStyleSheet' is released. This function is MT-safe and may be
-- called from any thread.
-- 
-- /Since: 2.6/
userStyleSheetUnref ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    UserStyleSheet
    -- ^ /@userStyleSheet@/: a t'GI.WebKit2.Structs.UserStyleSheet.UserStyleSheet'
    -> m ()
userStyleSheetUnref :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
UserStyleSheet -> m ()
userStyleSheetUnref UserStyleSheet
userStyleSheet = 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
    Ptr UserStyleSheet
userStyleSheet' <- UserStyleSheet -> IO (Ptr UserStyleSheet)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr UserStyleSheet
userStyleSheet
    Ptr UserStyleSheet -> IO ()
webkit_user_style_sheet_unref Ptr UserStyleSheet
userStyleSheet'
    UserStyleSheet -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr UserStyleSheet
userStyleSheet
    () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data UserStyleSheetUnrefMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.OverloadedMethod UserStyleSheetUnrefMethodInfo UserStyleSheet signature where
    overloadedMethod = userStyleSheetUnref

instance O.OverloadedMethodInfo UserStyleSheetUnrefMethodInfo UserStyleSheet where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.WebKit2.Structs.UserStyleSheet.userStyleSheetUnref",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-webkit2-4.0.31/docs/GI-WebKit2-Structs-UserStyleSheet.html#v:userStyleSheetUnref"
        })


#endif

#if defined(ENABLE_OVERLOADING)
type family ResolveUserStyleSheetMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
    ResolveUserStyleSheetMethod "ref" o = UserStyleSheetRefMethodInfo
    ResolveUserStyleSheetMethod "unref" o = UserStyleSheetUnrefMethodInfo
    ResolveUserStyleSheetMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveUserStyleSheetMethod t UserStyleSheet, O.OverloadedMethod info UserStyleSheet p) => OL.IsLabel t (UserStyleSheet -> 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 ~ ResolveUserStyleSheetMethod t UserStyleSheet, O.OverloadedMethod info UserStyleSheet p, R.HasField t UserStyleSheet p) => R.HasField t UserStyleSheet p where
    getField = O.overloadedMethod @info

#endif

instance (info ~ ResolveUserStyleSheetMethod t UserStyleSheet, O.OverloadedMethodInfo info UserStyleSheet) => OL.IsLabel t (O.MethodProxy info UserStyleSheet) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.MethodProxy
#else
    fromLabel _ = O.MethodProxy
#endif

#endif