{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.WebKit2.Structs.UserScript
(
UserScript(..) ,
#if defined(ENABLE_OVERLOADING)
ResolveUserScriptMethod ,
#endif
userScriptNew ,
userScriptNewForWorld ,
#if defined(ENABLE_OVERLOADING)
UserScriptRefMethodInfo ,
#endif
userScriptRef ,
#if defined(ENABLE_OVERLOADING)
UserScriptUnrefMethodInfo ,
#endif
userScriptUnref ,
) 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.Coerce as Coerce
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 {-# SOURCE #-} qualified GI.WebKit2.Enums as WebKit2.Enums
newtype UserScript = UserScript (SP.ManagedPtr UserScript)
deriving (UserScript -> UserScript -> Bool
(UserScript -> UserScript -> Bool)
-> (UserScript -> UserScript -> Bool) -> Eq UserScript
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UserScript -> UserScript -> Bool
$c/= :: UserScript -> UserScript -> Bool
== :: UserScript -> UserScript -> Bool
$c== :: UserScript -> UserScript -> Bool
Eq)
instance SP.ManagedPtrNewtype UserScript where
toManagedPtr :: UserScript -> ManagedPtr UserScript
toManagedPtr (UserScript ManagedPtr UserScript
p) = ManagedPtr UserScript
p
foreign import ccall "webkit_user_script_get_type" c_webkit_user_script_get_type ::
IO GType
type instance O.ParentTypes UserScript = '[]
instance O.HasParentTypes UserScript
instance B.Types.TypedObject UserScript where
glibType :: IO GType
glibType = IO GType
c_webkit_user_script_get_type
instance B.Types.GBoxed UserScript
instance B.GValue.IsGValue (Maybe UserScript) where
gvalueGType_ :: IO GType
gvalueGType_ = IO GType
c_webkit_user_script_get_type
gvalueSet_ :: Ptr GValue -> Maybe UserScript -> IO ()
gvalueSet_ Ptr GValue
gv Maybe UserScript
P.Nothing = Ptr GValue -> Ptr UserScript -> IO ()
forall a. Ptr GValue -> Ptr a -> IO ()
B.GValue.set_boxed Ptr GValue
gv (Ptr UserScript
forall a. Ptr a
FP.nullPtr :: FP.Ptr UserScript)
gvalueSet_ Ptr GValue
gv (P.Just UserScript
obj) = UserScript -> (Ptr UserScript -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr UserScript
obj (Ptr GValue -> Ptr UserScript -> IO ()
forall a. Ptr GValue -> Ptr a -> IO ()
B.GValue.set_boxed Ptr GValue
gv)
gvalueGet_ :: Ptr GValue -> IO (Maybe UserScript)
gvalueGet_ Ptr GValue
gv = do
Ptr UserScript
ptr <- Ptr GValue -> IO (Ptr UserScript)
forall b. Ptr GValue -> IO (Ptr b)
B.GValue.get_boxed Ptr GValue
gv :: IO (Ptr UserScript)
if Ptr UserScript
ptr Ptr UserScript -> Ptr UserScript -> Bool
forall a. Eq a => a -> a -> Bool
/= Ptr UserScript
forall a. Ptr a
FP.nullPtr
then UserScript -> Maybe UserScript
forall a. a -> Maybe a
P.Just (UserScript -> Maybe UserScript)
-> IO UserScript -> IO (Maybe UserScript)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ManagedPtr UserScript -> UserScript)
-> Ptr UserScript -> IO UserScript
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
B.ManagedPtr.newBoxed ManagedPtr UserScript -> UserScript
UserScript Ptr UserScript
ptr
else Maybe UserScript -> IO (Maybe UserScript)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe UserScript
forall a. Maybe a
P.Nothing
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList UserScript
type instance O.AttributeList UserScript = UserScriptAttributeList
type UserScriptAttributeList = ('[ ] :: [(Symbol, *)])
#endif
foreign import ccall "webkit_user_script_new" webkit_user_script_new ::
CString ->
CUInt ->
CUInt ->
Ptr CString ->
Ptr CString ->
IO (Ptr UserScript)
userScriptNew ::
(B.CallStack.HasCallStack, MonadIO m) =>
T.Text
-> WebKit2.Enums.UserContentInjectedFrames
-> WebKit2.Enums.UserScriptInjectionTime
-> Maybe ([T.Text])
-> Maybe ([T.Text])
-> m UserScript
userScriptNew :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Text
-> UserContentInjectedFrames
-> UserScriptInjectionTime
-> Maybe [Text]
-> Maybe [Text]
-> m UserScript
userScriptNew Text
source UserContentInjectedFrames
injectedFrames UserScriptInjectionTime
injectionTime Maybe [Text]
allowList Maybe [Text]
blockList = IO UserScript -> m UserScript
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO UserScript -> m UserScript) -> IO UserScript -> m UserScript
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 injectionTime' :: CUInt
injectionTime' = (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CUInt)
-> (UserScriptInjectionTime -> Int)
-> UserScriptInjectionTime
-> CUInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UserScriptInjectionTime -> Int
forall a. Enum a => a -> Int
fromEnum) UserScriptInjectionTime
injectionTime
Ptr CString
maybeAllowList <- case Maybe [Text]
allowList of
Maybe [Text]
Nothing -> Ptr CString -> IO (Ptr CString)
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 (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 (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 (m :: * -> *) a. Monad m => a -> m a
return Ptr CString
jBlockList'
Ptr UserScript
result <- CString
-> CUInt
-> CUInt
-> Ptr CString
-> Ptr CString
-> IO (Ptr UserScript)
webkit_user_script_new CString
source' CUInt
injectedFrames' CUInt
injectionTime' Ptr CString
maybeAllowList Ptr CString
maybeBlockList
Text -> Ptr UserScript -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"userScriptNew" Ptr UserScript
result
UserScript
result' <- ((ManagedPtr UserScript -> UserScript)
-> Ptr UserScript -> IO UserScript
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr UserScript -> UserScript
UserScript) Ptr UserScript
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
UserScript -> IO UserScript
forall (m :: * -> *) a. Monad m => a -> m a
return UserScript
result'
#if defined(ENABLE_OVERLOADING)
#endif
foreign import ccall "webkit_user_script_new_for_world" webkit_user_script_new_for_world ::
CString ->
CUInt ->
CUInt ->
CString ->
Ptr CString ->
Ptr CString ->
IO (Ptr UserScript)
userScriptNewForWorld ::
(B.CallStack.HasCallStack, MonadIO m) =>
T.Text
-> WebKit2.Enums.UserContentInjectedFrames
-> WebKit2.Enums.UserScriptInjectionTime
-> T.Text
-> Maybe ([T.Text])
-> Maybe ([T.Text])
-> m UserScript
userScriptNewForWorld :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Text
-> UserContentInjectedFrames
-> UserScriptInjectionTime
-> Text
-> Maybe [Text]
-> Maybe [Text]
-> m UserScript
userScriptNewForWorld Text
source UserContentInjectedFrames
injectedFrames UserScriptInjectionTime
injectionTime Text
worldName Maybe [Text]
allowList Maybe [Text]
blockList = IO UserScript -> m UserScript
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO UserScript -> m UserScript) -> IO UserScript -> m UserScript
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 injectionTime' :: CUInt
injectionTime' = (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CUInt)
-> (UserScriptInjectionTime -> Int)
-> UserScriptInjectionTime
-> CUInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UserScriptInjectionTime -> Int
forall a. Enum a => a -> Int
fromEnum) UserScriptInjectionTime
injectionTime
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 (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 (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 (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 (m :: * -> *) a. Monad m => a -> m a
return Ptr CString
jBlockList'
Ptr UserScript
result <- CString
-> CUInt
-> CUInt
-> CString
-> Ptr CString
-> Ptr CString
-> IO (Ptr UserScript)
webkit_user_script_new_for_world CString
source' CUInt
injectedFrames' CUInt
injectionTime' CString
worldName' Ptr CString
maybeAllowList Ptr CString
maybeBlockList
Text -> Ptr UserScript -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"userScriptNewForWorld" Ptr UserScript
result
UserScript
result' <- ((ManagedPtr UserScript -> UserScript)
-> Ptr UserScript -> IO UserScript
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr UserScript -> UserScript
UserScript) Ptr UserScript
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
UserScript -> IO UserScript
forall (m :: * -> *) a. Monad m => a -> m a
return UserScript
result'
#if defined(ENABLE_OVERLOADING)
#endif
foreign import ccall "webkit_user_script_ref" webkit_user_script_ref ::
Ptr UserScript ->
IO (Ptr UserScript)
userScriptRef ::
(B.CallStack.HasCallStack, MonadIO m) =>
UserScript
-> m UserScript
userScriptRef :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
UserScript -> m UserScript
userScriptRef UserScript
userScript = IO UserScript -> m UserScript
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO UserScript -> m UserScript) -> IO UserScript -> m UserScript
forall a b. (a -> b) -> a -> b
$ do
Ptr UserScript
userScript' <- UserScript -> IO (Ptr UserScript)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr UserScript
userScript
Ptr UserScript
result <- Ptr UserScript -> IO (Ptr UserScript)
webkit_user_script_ref Ptr UserScript
userScript'
Text -> Ptr UserScript -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"userScriptRef" Ptr UserScript
result
UserScript
result' <- ((ManagedPtr UserScript -> UserScript)
-> Ptr UserScript -> IO UserScript
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr UserScript -> UserScript
UserScript) Ptr UserScript
result
UserScript -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr UserScript
userScript
UserScript -> IO UserScript
forall (m :: * -> *) a. Monad m => a -> m a
return UserScript
result'
#if defined(ENABLE_OVERLOADING)
data UserScriptRefMethodInfo
instance (signature ~ (m UserScript), MonadIO m) => O.OverloadedMethod UserScriptRefMethodInfo UserScript signature where
overloadedMethod = userScriptRef
instance O.OverloadedMethodInfo UserScriptRefMethodInfo UserScript where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.WebKit2.Structs.UserScript.userScriptRef",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-webkit2-4.0.28/docs/GI-WebKit2-Structs-UserScript.html#v:userScriptRef"
})
#endif
foreign import ccall "webkit_user_script_unref" webkit_user_script_unref ::
Ptr UserScript ->
IO ()
userScriptUnref ::
(B.CallStack.HasCallStack, MonadIO m) =>
UserScript
-> m ()
userScriptUnref :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
UserScript -> m ()
userScriptUnref UserScript
userScript = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
Ptr UserScript
userScript' <- UserScript -> IO (Ptr UserScript)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr UserScript
userScript
Ptr UserScript -> IO ()
webkit_user_script_unref Ptr UserScript
userScript'
UserScript -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr UserScript
userScript
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data UserScriptUnrefMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.OverloadedMethod UserScriptUnrefMethodInfo UserScript signature where
overloadedMethod = userScriptUnref
instance O.OverloadedMethodInfo UserScriptUnrefMethodInfo UserScript where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.WebKit2.Structs.UserScript.userScriptUnref",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-webkit2-4.0.28/docs/GI-WebKit2-Structs-UserScript.html#v:userScriptUnref"
})
#endif
#if defined(ENABLE_OVERLOADING)
type family ResolveUserScriptMethod (t :: Symbol) (o :: *) :: * where
ResolveUserScriptMethod "ref" o = UserScriptRefMethodInfo
ResolveUserScriptMethod "unref" o = UserScriptUnrefMethodInfo
ResolveUserScriptMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveUserScriptMethod t UserScript, O.OverloadedMethod info UserScript p) => OL.IsLabel t (UserScript -> 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 ~ ResolveUserScriptMethod t UserScript, O.OverloadedMethod info UserScript p, R.HasField t UserScript p) => R.HasField t UserScript p where
getField = O.overloadedMethod @info
#endif
instance (info ~ ResolveUserScriptMethod t UserScript, O.OverloadedMethodInfo info UserScript) => OL.IsLabel t (O.MethodProxy info UserScript) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.MethodProxy
#else
fromLabel _ = O.MethodProxy
#endif
#endif