{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.Handy.Objects.ValueObject
(
ValueObject(..) ,
IsValueObject ,
toValueObject ,
noValueObject ,
#if defined(ENABLE_OVERLOADING)
ResolveValueObjectMethod ,
#endif
#if defined(ENABLE_OVERLOADING)
ValueObjectCopyValueMethodInfo ,
#endif
valueObjectCopyValue ,
#if defined(ENABLE_OVERLOADING)
ValueObjectDupStringMethodInfo ,
#endif
valueObjectDupString ,
#if defined(ENABLE_OVERLOADING)
ValueObjectGetStringMethodInfo ,
#endif
valueObjectGetString ,
#if defined(ENABLE_OVERLOADING)
ValueObjectGetValueMethodInfo ,
#endif
valueObjectGetValue ,
valueObjectNew ,
#if defined(ENABLE_OVERLOADING)
ValueObjectValuePropertyInfo ,
#endif
constructValueObjectValue ,
getValueObjectValue ,
#if defined(ENABLE_OVERLOADING)
valueObjectValue ,
#endif
) 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.GI.Base.Signals as B.Signals
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 GI.GObject.Objects.Object as GObject.Object
newtype ValueObject = ValueObject (ManagedPtr ValueObject)
deriving (ValueObject -> ValueObject -> Bool
(ValueObject -> ValueObject -> Bool)
-> (ValueObject -> ValueObject -> Bool) -> Eq ValueObject
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ValueObject -> ValueObject -> Bool
$c/= :: ValueObject -> ValueObject -> Bool
== :: ValueObject -> ValueObject -> Bool
$c== :: ValueObject -> ValueObject -> Bool
Eq)
foreign import ccall "hdy_value_object_get_type"
c_hdy_value_object_get_type :: IO GType
instance GObject ValueObject where
gobjectType :: IO GType
gobjectType = IO GType
c_hdy_value_object_get_type
instance B.GValue.IsGValue ValueObject where
toGValue :: ValueObject -> IO GValue
toGValue o :: ValueObject
o = do
GType
gtype <- IO GType
c_hdy_value_object_get_type
ValueObject -> (Ptr ValueObject -> IO GValue) -> IO GValue
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr ValueObject
o (GType
-> (GValue -> Ptr ValueObject -> IO ())
-> Ptr ValueObject
-> IO GValue
forall a. GType -> (GValue -> a -> IO ()) -> a -> IO GValue
B.GValue.buildGValue GType
gtype GValue -> Ptr ValueObject -> IO ()
forall a. GObject a => GValue -> Ptr a -> IO ()
B.GValue.set_object)
fromGValue :: GValue -> IO ValueObject
fromGValue gv :: GValue
gv = do
Ptr ValueObject
ptr <- GValue -> IO (Ptr ValueObject)
forall b. GObject b => GValue -> IO (Ptr b)
B.GValue.get_object GValue
gv :: IO (Ptr ValueObject)
(ManagedPtr ValueObject -> ValueObject)
-> Ptr ValueObject -> IO ValueObject
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
B.ManagedPtr.newObject ManagedPtr ValueObject -> ValueObject
ValueObject Ptr ValueObject
ptr
class (GObject o, O.IsDescendantOf ValueObject o) => IsValueObject o
instance (GObject o, O.IsDescendantOf ValueObject o) => IsValueObject o
instance O.HasParentTypes ValueObject
type instance O.ParentTypes ValueObject = '[GObject.Object.Object]
toValueObject :: (MonadIO m, IsValueObject o) => o -> m ValueObject
toValueObject :: o -> m ValueObject
toValueObject = IO ValueObject -> m ValueObject
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ValueObject -> m ValueObject)
-> (o -> IO ValueObject) -> o -> m ValueObject
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr ValueObject -> ValueObject) -> o -> IO ValueObject
forall o o'.
(HasCallStack, GObject o, GObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
unsafeCastTo ManagedPtr ValueObject -> ValueObject
ValueObject
noValueObject :: Maybe ValueObject
noValueObject :: Maybe ValueObject
noValueObject = Maybe ValueObject
forall a. Maybe a
Nothing
#if defined(ENABLE_OVERLOADING)
type family ResolveValueObjectMethod (t :: Symbol) (o :: *) :: * where
ResolveValueObjectMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
ResolveValueObjectMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
ResolveValueObjectMethod "copyValue" o = ValueObjectCopyValueMethodInfo
ResolveValueObjectMethod "dupString" o = ValueObjectDupStringMethodInfo
ResolveValueObjectMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
ResolveValueObjectMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
ResolveValueObjectMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
ResolveValueObjectMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
ResolveValueObjectMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
ResolveValueObjectMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
ResolveValueObjectMethod "ref" o = GObject.Object.ObjectRefMethodInfo
ResolveValueObjectMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
ResolveValueObjectMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
ResolveValueObjectMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
ResolveValueObjectMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
ResolveValueObjectMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
ResolveValueObjectMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
ResolveValueObjectMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
ResolveValueObjectMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
ResolveValueObjectMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
ResolveValueObjectMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
ResolveValueObjectMethod "getString" o = ValueObjectGetStringMethodInfo
ResolveValueObjectMethod "getValue" o = ValueObjectGetValueMethodInfo
ResolveValueObjectMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
ResolveValueObjectMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
ResolveValueObjectMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
ResolveValueObjectMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveValueObjectMethod t ValueObject, O.MethodInfo info ValueObject p) => OL.IsLabel t (ValueObject -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod @info
#else
fromLabel _ = O.overloadedMethod @info
#endif
#endif
getValueObjectValue :: (MonadIO m, IsValueObject o) => o -> m GValue
getValueObjectValue :: o -> m GValue
getValueObjectValue obj :: o
obj = IO GValue -> m GValue
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO GValue -> m GValue) -> IO GValue -> m GValue
forall a b. (a -> b) -> a -> b
$ Text -> IO (Maybe GValue) -> IO GValue
forall a. HasCallStack => Text -> IO (Maybe a) -> IO a
checkUnexpectedNothing "getValueObjectValue" (IO (Maybe GValue) -> IO GValue) -> IO (Maybe GValue) -> IO GValue
forall a b. (a -> b) -> a -> b
$ o -> String -> (ManagedPtr GValue -> GValue) -> IO (Maybe GValue)
forall a b.
(GObject a, BoxedObject b) =>
a -> String -> (ManagedPtr b -> b) -> IO (Maybe b)
B.Properties.getObjectPropertyBoxed o
obj "value" ManagedPtr GValue -> GValue
GValue
constructValueObjectValue :: (IsValueObject o) => GValue -> IO (GValueConstruct o)
constructValueObjectValue :: GValue -> IO (GValueConstruct o)
constructValueObjectValue val :: GValue
val = String -> Maybe GValue -> IO (GValueConstruct o)
forall a o.
BoxedObject a =>
String -> Maybe a -> IO (GValueConstruct o)
B.Properties.constructObjectPropertyBoxed "value" (GValue -> Maybe GValue
forall a. a -> Maybe a
Just GValue
val)
#if defined(ENABLE_OVERLOADING)
data ValueObjectValuePropertyInfo
instance AttrInfo ValueObjectValuePropertyInfo where
type AttrAllowedOps ValueObjectValuePropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
type AttrBaseTypeConstraint ValueObjectValuePropertyInfo = IsValueObject
type AttrSetTypeConstraint ValueObjectValuePropertyInfo = (~) GValue
type AttrTransferTypeConstraint ValueObjectValuePropertyInfo = (~) GValue
type AttrTransferType ValueObjectValuePropertyInfo = GValue
type AttrGetType ValueObjectValuePropertyInfo = GValue
type AttrLabel ValueObjectValuePropertyInfo = "value"
type AttrOrigin ValueObjectValuePropertyInfo = ValueObject
attrGet = getValueObjectValue
attrSet = undefined
attrTransfer _ v = do
return v
attrConstruct = constructValueObjectValue
attrClear = undefined
#endif
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList ValueObject
type instance O.AttributeList ValueObject = ValueObjectAttributeList
type ValueObjectAttributeList = ('[ '("value", ValueObjectValuePropertyInfo)] :: [(Symbol, *)])
#endif
#if defined(ENABLE_OVERLOADING)
valueObjectValue :: AttrLabelProxy "value"
valueObjectValue = AttrLabelProxy
#endif
#if defined(ENABLE_OVERLOADING)
type instance O.SignalList ValueObject = ValueObjectSignalList
type ValueObjectSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])
#endif
foreign import ccall "hdy_value_object_new" hdy_value_object_new ::
Ptr GValue ->
IO (Ptr ValueObject)
valueObjectNew ::
(B.CallStack.HasCallStack, MonadIO m) =>
GValue
-> m ValueObject
valueObjectNew :: GValue -> m ValueObject
valueObjectNew value :: GValue
value = IO ValueObject -> m ValueObject
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ValueObject -> m ValueObject)
-> IO ValueObject -> m ValueObject
forall a b. (a -> b) -> a -> b
$ do
Ptr GValue
value' <- GValue -> IO (Ptr GValue)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr GValue
value
Ptr ValueObject
result <- Ptr GValue -> IO (Ptr ValueObject)
hdy_value_object_new Ptr GValue
value'
Text -> Ptr ValueObject -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "valueObjectNew" Ptr ValueObject
result
ValueObject
result' <- ((ManagedPtr ValueObject -> ValueObject)
-> Ptr ValueObject -> IO ValueObject
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr ValueObject -> ValueObject
ValueObject) Ptr ValueObject
result
GValue -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr GValue
value
ValueObject -> IO ValueObject
forall (m :: * -> *) a. Monad m => a -> m a
return ValueObject
result'
#if defined(ENABLE_OVERLOADING)
#endif
foreign import ccall "hdy_value_object_copy_value" hdy_value_object_copy_value ::
Ptr ValueObject ->
Ptr GValue ->
IO ()
valueObjectCopyValue ::
(B.CallStack.HasCallStack, MonadIO m, IsValueObject a) =>
a
-> GValue
-> m ()
valueObjectCopyValue :: a -> GValue -> m ()
valueObjectCopyValue value :: a
value dest :: GValue
dest = 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 ValueObject
value' <- a -> IO (Ptr ValueObject)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
value
Ptr GValue
dest' <- GValue -> IO (Ptr GValue)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr GValue
dest
Ptr ValueObject -> Ptr GValue -> IO ()
hdy_value_object_copy_value Ptr ValueObject
value' Ptr GValue
dest'
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
value
GValue -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr GValue
dest
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data ValueObjectCopyValueMethodInfo
instance (signature ~ (GValue -> m ()), MonadIO m, IsValueObject a) => O.MethodInfo ValueObjectCopyValueMethodInfo a signature where
overloadedMethod = valueObjectCopyValue
#endif
foreign import ccall "hdy_value_object_dup_string" hdy_value_object_dup_string ::
Ptr ValueObject ->
IO CString
valueObjectDupString ::
(B.CallStack.HasCallStack, MonadIO m, IsValueObject a) =>
a
-> m T.Text
valueObjectDupString :: a -> m Text
valueObjectDupString value :: a
value = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
Ptr ValueObject
value' <- a -> IO (Ptr ValueObject)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
value
CString
result <- Ptr ValueObject -> IO CString
hdy_value_object_dup_string Ptr ValueObject
value'
Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "valueObjectDupString" CString
result
Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
value
Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'
#if defined(ENABLE_OVERLOADING)
data ValueObjectDupStringMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsValueObject a) => O.MethodInfo ValueObjectDupStringMethodInfo a signature where
overloadedMethod = valueObjectDupString
#endif
foreign import ccall "hdy_value_object_get_string" hdy_value_object_get_string ::
Ptr ValueObject ->
IO CString
valueObjectGetString ::
(B.CallStack.HasCallStack, MonadIO m, IsValueObject a) =>
a
-> m T.Text
valueObjectGetString :: a -> m Text
valueObjectGetString value :: a
value = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
Ptr ValueObject
value' <- a -> IO (Ptr ValueObject)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
value
CString
result <- Ptr ValueObject -> IO CString
hdy_value_object_get_string Ptr ValueObject
value'
Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "valueObjectGetString" CString
result
Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
value
Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'
#if defined(ENABLE_OVERLOADING)
data ValueObjectGetStringMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsValueObject a) => O.MethodInfo ValueObjectGetStringMethodInfo a signature where
overloadedMethod = valueObjectGetString
#endif
foreign import ccall "hdy_value_object_get_value" hdy_value_object_get_value ::
Ptr ValueObject ->
IO (Ptr GValue)
valueObjectGetValue ::
(B.CallStack.HasCallStack, MonadIO m, IsValueObject a) =>
a
-> m GValue
valueObjectGetValue :: a -> m GValue
valueObjectGetValue value :: a
value = IO GValue -> m GValue
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO GValue -> m GValue) -> IO GValue -> m GValue
forall a b. (a -> b) -> a -> b
$ do
Ptr ValueObject
value' <- a -> IO (Ptr ValueObject)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
value
Ptr GValue
result <- Ptr ValueObject -> IO (Ptr GValue)
hdy_value_object_get_value Ptr ValueObject
value'
Text -> Ptr GValue -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "valueObjectGetValue" Ptr GValue
result
GValue
result' <- ((ManagedPtr GValue -> GValue) -> Ptr GValue -> IO GValue
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr GValue -> GValue
GValue) Ptr GValue
result
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
value
GValue -> IO GValue
forall (m :: * -> *) a. Monad m => a -> m a
return GValue
result'
#if defined(ENABLE_OVERLOADING)
data ValueObjectGetValueMethodInfo
instance (signature ~ (m GValue), MonadIO m, IsValueObject a) => O.MethodInfo ValueObjectGetValueMethodInfo a signature where
overloadedMethod = valueObjectGetValue
#endif