An opaque structure used to hold different types of values.
Before it can be used, a <GValue> has to be
initialized to a specific type by calling value:init on it.
Many types which are stored within a <GValue> need
to allocate data on the heap, so value:unset
must always be called on a <GValue> to free any such
data once you’re finished with the <GValue>, even if
the <GValue> itself is stored on the stack.
The data within the structure has protected scope: it is accessible only
to functions within a <GTypeValueTable> structure, or
implementations of the g_value_*() API. That is, code which
implements new fundamental types.
<GValue> users cannot make any assumptions about how
data is stored within the 2 element data union, and the
g-type member should only be accessed through the
GObject.VALUE_TYPE macro and related macros.
dataCopies the value of self into dest-value.
Get the contents of a G_TYPE_OBJECT derived
<GValue>, increasing its reference count. If the
contents of the <GValue> are #f, then
#f will be returned.
Get a copy the contents of a G_TYPE_STRING
<GValue>.
Get the contents of a variant <GValue>, increasing
its refcount. The returned <GVariant> is
never floating.
Passed: a <GValue>.
a valid <GValue> of type G_TYPE_VARIANT
Returned: a <GVariant>, or #f.
variant contents of self (may be #f); should be unreffed
using variant:unref when no longer
needed
Determines if self will fit inside the size of a pointer value.
This is an internal function introduced mainly for C marshallers.
Get the contents of a G_TYPE_BOOLEAN
<GValue>.
Get the contents of a G_TYPE_BOXED derived
<GValue>.
Do not use this function; it is broken on platforms where the
char type is unsigned, such as ARM and PowerPC. See
value:get-schar.
Get the contents of a G_TYPE_CHAR <GValue>.
Get the contents of a G_TYPE_DOUBLE <GValue>.
Get the contents of a G_TYPE_ENUM <GValue>.
Get the contents of a G_TYPE_FLAGS <GValue>.
Get the contents of a G_TYPE_FLOAT <GValue>.
Get the contents of a G_TYPE_GTYPE <GValue>.
Get the contents of a G_TYPE_INT <GValue>.
Get the contents of a G_TYPE_INT64 <GValue>.
Get the contents of a G_TYPE_LONG <GValue>.
Get the contents of a G_TYPE_OBJECT derived
<GValue>.
Get the contents of a G_TYPE_PARAM <GValue>.
Get the contents of a pointer <GValue>.
Get the contents of a G_TYPE_CHAR <GValue>.
Get the contents of a G_TYPE_STRING <GValue>.
Get the contents of a G_TYPE_UCHAR <GValue>.
Get the contents of a G_TYPE_UINT <GValue>.
Get the contents of a G_TYPE_UINT64 <GValue>.
Get the contents of a G_TYPE_ULONG <GValue>.
Get the contents of a variant <GValue>.
Passed: a <GValue>.
a valid <GValue> of type G_TYPE_VARIANT
Returned: a <GVariant>, or #f.
variant contents of self (may be #f)
Initializes self to store values of the given type, and sets its value to the initial value for type.
This must be called before any other methods on a
<GValue>, so the value knows what type it’s meant to
store.
GValue value = G_VALUE_INIT; g_value_init (&value, SOME_G_TYPE); … g_value_unset (&value);
Returns the value contents as a pointer.
This function asserts that value:fits-pointer? returned true for the passed in
value.
This is an internal function introduced mainly for C marshallers.
Clears the current value in self and resets it to the initial
value (as if the value had just been initialized using value:init).
Set the contents of a G_TYPE_BOOLEAN <GValue>
to v-boolean.
Set the contents of a G_TYPE_BOXED derived
<GValue> to v-boxed.
This is an internal function introduced mainly for C marshallers.
Set the contents of a G_TYPE_CHAR <GValue> to
v-char.
Set the contents of a G_TYPE_DOUBLE <GValue>
to v-double.
Set the contents of a G_TYPE_ENUM <GValue> to
v-enum.
Set the contents of a G_TYPE_FLAGS <GValue>
to v-flags.
Set the contents of a G_TYPE_FLOAT <GValue>
to v-float.
Set the contents of a G_TYPE_GTYPE <GValue>
to v-gtype.
Sets self from an instantiatable type.
This calls the <GTypeValueCollectFunc> function for the type the
<GValue> contains.
Set the contents of a G_TYPE_INT <GValue> to
v-int.
Set the contents of a G_TYPE_INT64 <GValue>
to v-int64.
Set the contents of a G_TYPE_STRING <GValue>
to v-string. The string is assumed to be static and interned
(canonical, for example from
intern-string), and is thus not
duplicated when setting the <GValue>.
Set the contents of a G_TYPE_LONG <GValue> to
v-long.
Set the contents of a G_TYPE_OBJECT derived
<GValue> to v-object.
value:set-object increases the reference
count of v-object (the <GValue> holds a
reference to v-object). If you do not wish to increase the
reference count of the object (i.e. you wish to pass your current
reference to the <GValue> because you no longer need
it), use g_value_take_object() instead.
It is important that your <GValue> holds a reference
to v-object (either its own, or one it has taken) to ensure that
the object won’t be destroyed while the <GValue>
still exists).
Set the contents of a G_TYPE_PARAM <GValue>
to param.
Set the contents of a pointer <GValue> to
v-pointer.
Set the contents of a G_TYPE_CHAR <GValue> to
v-char.
Set the contents of a G_TYPE_BOXED derived
<GValue> to v-boxed.
The boxed value is assumed to be static, and is thus not duplicated when
setting the <GValue>.
Set the contents of a G_TYPE_STRING <GValue>
to v-string. The string is assumed to be static, and is thus not
duplicated when setting the <GValue>.
If the the string is a canonical string, using value:set-interned-string is more appropriate.
Set the contents of a G_TYPE_STRING <GValue>
to a copy of v-string.
This is an internal function introduced mainly for C marshallers.
Set the contents of a G_TYPE_UCHAR <GValue>
to v-uchar.
Set the contents of a G_TYPE_UINT <GValue> to
v-uint.
Set the contents of a G_TYPE_UINT64 <GValue>
to v-uint64.
Set the contents of a G_TYPE_ULONG <GValue>
to v-ulong.
Set the contents of a variant <GValue> to
variant. If the variant is floating, it is consumed.
Passed: a <GValue>.
a valid <GValue> of type G_TYPE_VARIANT
Passed, or left out: a <GVariant>, or
#f.
a <GVariant>, or #f
Steal ownership on contents of a G_TYPE_STRING
<GValue>. As a result of this operation the value’s
contents will be reset to #f.
The purpose of this call is to provide a way to avoid an extra copy when
some object have been serialized into string through
<GValue> API.
NOTE: for safety and compatibility purposes, if
<GValue> contains static string, or an interned one,
this function will return a copy of the string. Otherwise the transfer
notation would be ambiguous.
Passed: a <GValue>.
a valid <GValue> of type G_TYPE_STRING
Returned: a string, or #f.
string content of self; Should be freed with
byte-array:free when no longer needed.
Sets the contents of a G_TYPE_BOXED derived
<GValue> to v-boxed and takes over the
ownership of the caller’s reference to v-boxed; the caller doesn’t
have to unref it any more.
Sets the contents of a G_TYPE_STRING <GValue>
to v-string.
Set the contents of a variant <GValue> to
variant, and takes over the ownership of the caller’s reference to
variant; the caller doesn’t have to unref it any more (i.e. the
reference count of the variant is not increased).
If variant was floating then its floating reference is converted to a hard reference.
If you want the <GValue> to hold its own reference
to variant, use value:set-variant
instead.
This is an internal function introduced mainly for C marshallers.
Passed: a <GValue>.
a valid <GValue> of type G_TYPE_VARIANT
Passed, or left out: a <GVariant>, or
#f.
a <GVariant>, or #f
Tries to cast the contents of self into a type appropriate to store in dest-value.
If a transformation is not possible, dest-value is not modified.
For example, this could transform a G_TYPE_INT value into a
G_TYPE_FLOAT value.
Performing transformations between value types might incur precision loss. Especially transformations into strings might reveal seemingly arbitrary results and the format of particular transformations to strings is not guaranteed over time.
Checks whether a value:copy is able to copy
values of type src-type into values of type dest-type.
Passed: a class, or a GType number.
source type to be copied
Passed: a class, or a GType number.
destination type for copying
Returned: a boolean.
true if the copy is possible; false otherwise
Checks whether value:transform? is able to
transform values of type src-type into values of type
dest-type.
Note that for the types to be transformable, they must be compatible or
a transformation function must be registered using
GObject.Value.register_transform_func.
Passed: a class, or a GType number.
source type
Passed: a class, or a GType number.
target type
Returned: a boolean.
true if the transformation is possible; false otherwise