Package: glib

Macro glib:with-variant

Lambda List

glib:with-variant ((var vclass value) &body body)

Syntax

(g:with-variant (var vclass value) body) => result

Arguments

var -- a g:variant instance to create and initialize
vclass -- a g:variant-class value
value -- a value corresponding to vclass to set

Details

The g:with-variant macro allocates a new g:variant instance, initializes it with the given value and executes the body that uses var. This macro creates variants with a full reference using the g:variant-ref-sink function.

After execution of the body the g:variant-unref function is called on var. This clears the memory used by the variant.

Notes

This macro can only be used to create and initialise variants for basic types that have a g:variant-class value. The valid basic type strings are "b", "y", "n", "q", "i", "u", "x", "t", "h", "d", "s", "o", and "g".
 

See also

2025-05-26