Commit Graph

25 Commits

Author SHA1 Message Date
Colin Walters
4fb2d737ac gvariant: Make g_variant_new_from_bytes() public
Now that GBytes has been made public, we should make
g_variant_new_from_bytes() public too.

Add g_variant_get_data_as_bytes() to match.

https://bugzilla.gnome.org/show_bug.cgi?id=677062
2012-10-23 16:25:49 +02:00
Stef Walter
14fb10d14b GBytes: add a size argument to g_bytes_get_data
* An out size argument so that this is more easily bindable
   by gobject-introspection.

https://bugzilla.gnome.org/show_bug.cgi?id=665879
2011-12-15 07:22:37 +01:00
Philip Withnall
22da18fa70 GVariant: add preconditions to ref. counting functions
These prevent GVariants from accidentally being brought back to life after
being freed, and should make it easier to track down ref. counting issues.

Closes: bgo#665184
2011-12-02 10:23:14 +00:00
Stef Walter
fcc69fd318 GBytes: A new type for an immutable set of bytes.
* Represents an immutable reference counted block of memory.
 * This is basically the internal glib GBuffer structure exposed,
   renamed, and with some additional capabilities.
 * The GBytes name comes from python3's immutable 'bytes' type
 * GBytes can be safely used as keys in hash tables, and have
   functions for doing so: g_bytes_hash, g_bytes_equal
 * GByteArray is a mutable form of GBytes, and vice versa. There
   are functions for converting from one to the other efficiently:
   g_bytes_unref_to_array() and g_byte_array_free_to_bytes()
 * Adds g_byte_array_new_take() to support above functions

https://bugzilla.gnome.org/show_bug.cgi?id=663291
2011-11-24 08:58:38 +01:00
Ryan Lortie
0e0554bd62 GVariant: drop use of @returns 2011-11-21 11:33:21 -05:00
Ryan Lortie
4d5fe27048 GVariant: add a clarification to the docs
Add a note to the doc for g_viarnat_get_child_value() that the return
value is non-floating and must be freed with g_variant_unref().

https://bugzilla.gnome.org/show_bug.cgi?id=654412
2011-10-04 17:32:53 -04:00
Simon McVittie
ebb544f549 g_variant_get_data: mention what you need to know to deserialise
Also include a shorter version in the docs for g_variant_store, with a
pointer to g_variant_get_data.

Bug: https://bugzilla.gnome.org/show_bug.cgi?id=632049
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Reviewed-by: Ryan Lortie <desrt@desrt.ca>
2011-10-04 12:39:22 +01:00
Pavel Holejsovsky
85d12096e4 Add missing GVariant annotations
https://bugzilla.gnome.org/show_bug.cgi?id=656031
2011-08-06 11:32:18 +02:00
Ryan Lortie
58c247e51b GVariant: add g_variant_take_ref()
This function implements the following logic:

  if (g_variant_is_floating (value))
    g_variant_ref_sink (value);

which is used for consuming the return value of callbacks that may or
may not return floating references.

This patch also replaces a few instances of the above code with the new
function (GSettings, GDBus) and lifts a long-standing restriction on the
use of floating values as the return value for signal handlers by
improving g_value_take_variant().

https://bugzilla.gnome.org/show_bug.cgi?id=627974
2011-07-12 19:44:21 +02:00
Colin Walters
a6f09e104c GBuffer: Suffix header with private.h
This makes it clearer it's not public API yet.

https://bugzilla.gnome.org/show_bug.cgi?id=651745
2011-06-06 09:58:21 -04:00
Giovanni Campagna
39ba9c8e49 g_variant_get_child_value: Add a precondition on length
Ensure callers get a warning if they pass a bad length.

Split into a separate commit and changed to order index before
n_children by Colin Walters <walters@verbum.org>
2011-05-27 16:05:56 -04:00
Giovanni Campagna
e61fa51fd5 GVariant: fix introspection annotations
Add transfer annotations for most functions, as well as some (array)
and (skip) for functions that use varargs.

https://bugzilla.gnome.org/show_bug.cgi?id=646635
2011-05-27 15:56:50 -04:00
Ryan Lortie
d4209c1c41 GVariant: clear memory before releasing it
Bug #640807 makes a reasonable case for why it's better to have your
program crash outright in the case of memory errors.  With this
modification, GVariant is far more likely to do that in the case that a
GVariant pointer is used shortly after being freed.
2011-01-28 08:25:05 -05:00
Javier Jardón
a583405f66 docs: gvariant-core: g_variant_normalise -> g_variant_get_normal_form() 2011-01-14 17:54:04 +00:00
Javier Jardón
6c0491841e gvariant-core: Fix typo
g_variant_create_from_data -> g_variant_new_from_data
2011-01-14 17:25:07 +00:00
Ryan Lortie
181982c47c GVariant: avoid locking in a common case
Avoid acquiring the lock on the instance on the case of deserialising a
child.  We know that it is safe to do this unlocked because a serialised
child will never become unserialised.

Closes #626320
2010-10-26 11:49:32 -04:00
Ryan Lortie
11f06115a4 Bug 629709 - Empty variants
Fix some GVariant bugs uncovered by calling g_variant_new_from_data with
invalid data (which it should be immune to).
2010-09-15 11:21:44 -04:00
Ryan Lortie
2e53e50244 glib/: fully remove galias hacks 2010-07-07 19:34:35 -04:00
Christian Persch
052ef2614a Add g_variant_is_floating 2010-06-19 19:07:36 +02:00
Tor Lillqvist
2ab76c5b36 Make the GVariant code compile with a non-gcc compiler
In particular, tested with Microsoft Visual C 2008.
2010-03-21 11:22:06 +02:00
Ryan Lortie
9dea0253a3 GVariant: add loading, byteswapping, normalisation 2010-03-14 15:56:18 -04:00
Ryan Lortie
ed3c914cdb Merge the main public API of GVariant 2010-02-19 10:52:03 -05:00
Ryan Lortie
b899bfc741 GVariant: create child instance from its own data
also: white-space fix in the serialiser
2010-02-15 19:38:00 -05:00
Ryan Lortie
e66d66c555 GVariant: lock before freeing, to avoid assert 2010-02-11 16:53:56 -05:00
Ryan Lortie
1e655eb02c merge GVariant 2010-02-10 11:35:01 -05:00