Commit Graph

41 Commits

Author SHA1 Message Date
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
David Zeuthen
f819aa5f17 gdbus-codegen: Fix build
See https://bugzilla.gnome.org/show_bug.cgi?id=651998 for details.

Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-06-09 11:53:08 -04:00
Colin Walters
003e052442 gdbus-codegen: Clean config.pyc to make distcheck happy 2011-06-07 14:17:11 -04:00
David Zeuthen
ab18737ead gdbus-codegen: Properly render @param and %TRUE in generated Docbook
Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-05-24 00:27:43 -04:00
David Zeuthen
263ce3042c gdbus-codegen: Handle unexpected XML tags
This was reported in bug 650874. Add tests.

https://bugzilla.gnome.org/show_bug.cgi?id=650874

Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-05-23 23:23:10 -04:00
David Zeuthen
11e01802ab gdbus-codegen: Ensure that generated skeletons are MT-safe
For example, if setting a property on a skeleton from another thread
than where it was constructed, the idle handler responsible for
emitting the PropertiesChanged() signal could run immediately and
clear skeleton->priv->changed_properties_idle_source causing
g_source_unref() to be called with a NULL pointer. This race was
easily be fixed by adding a lock to the skeleton object.

In addition to fixing this race, also move the code for setting up the
idle handler to a class handler for the GObject::notify signal. This
change allows use of g_object_freeze_notify() and g_object_thaw_notify()
to perform atomic property changes from another thread than the one
that the skeleton was created in.

Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-05-15 12:38:24 -04:00
David Zeuthen
ae10eca116 gdbus-codegen: Use (skip) annotation on return values
This was discussed in bug 649657.

https://bugzilla.gnome.org/show_bug.cgi?id=649657

Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-05-13 14:24:22 -04:00
David Zeuthen
ce77614142 gdbus-codegen: Mark members in generated class instance structs as private
Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-05-11 21:16:41 -04:00
Colin Walters
d39731724a gdbus-codegen: Fix annotation parsing
It takes 3 options.
2011-05-11 17:13:57 -04:00
Maarten Bosmans
97cd6fa2e3 gdbus-codegen: Quote substitution variables
Avoids failure if they contain spaces.

Commit message written by Colin Walters <walters@verbum.org>

https://bugzilla.gnome.org/show_bug.cgi?id=649775
2011-05-11 15:47:00 -04:00
Colin Walters
61295f87c9 gdbus-codegen: Drop dependency on argparse
This is only in Python 2.7 or as a separate module.  Use optparse
which exists since 2.3.

https://bugzilla.gnome.org/show_bug.cgi?id=649988
2011-05-11 15:39:34 -04:00
David Zeuthen
f773bd8b76 gdbus-codegen: gracefully handle property get on proxy with no cached property
This can easily happen if the owner of the remote object vanishes. Of
course, when that happens, user code is already notified (by e.g. the
notify::g-name-owner signal) so it can avoid using the proxy but
requiring that is a bit harsh. IOW, before this patch this critical
error was printed

 GLib-GIO-CRITICAL **: g_dbus_gvariant_to_gvalue: assertion `value != NULL' failed

when that happened. With this patch, we just avoid setting the GValue
so the user will get the default value for its type instead. So, for
example, if the user code is getting a GVariant property on such a
defunct proxy, then he gets a NULL back. So unless said user code
checks the return value, criticals will still be printed if the NULL
GVariant is used for anything interesting.

Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-05-06 10:32:42 -04:00
Matthias Clasen
5b4da74bc7 More distcheck fixes 2011-05-04 20:45:46 -04:00
Ray Strode
c062350159 gdbus-codegen: don't assert non-negativity for unsigned values
The code generator sprinkles a few asserts in its output of the form:

g_assert (prop_id - 1 >= 0 && prop_id - 1 < %d);\n

prop_id is unsigned, though, so this generates a compiler warning for
me.

This commit changes the code to merely check for prop_id != 0 instead of
prop_id - 1 >= 0
2011-05-04 12:45:22 -04:00
Alexander Larsson
d97cbc6731 gdbus-codegen: Make sure we pass -Werror
_g_value_equal might not always be used, so mark it G_GNUC_UNUSED
to make sure we're -Werror clean.
2011-05-04 13:54:34 +02:00
Dan Winship
181763438a Update .gitignores 2011-05-02 09:54:15 -04:00
David Zeuthen
0377fe7005 gdbus-codegen: Fix typo in generated docs
Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-04-25 10:42:50 -04:00
David Zeuthen
bbe945183b gdbus-codegen: Generate GDBusObject{,Proxy,Skeleton} subtypes
Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-04-25 09:29:18 -04:00
David Zeuthen
35b6c76244 gdbus-codegen: Document the generated FOO_PEEK_BAR() and FOO_GET_BAR() macros
Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-04-20 09:00:16 -04:00
David Zeuthen
bd5da131a2 gdbus-codegen: Generate gtk-doc section docs
This is nice to have if using gtk-doc on the generated code. We could
also generate -sections.txt and .types files but we don't do that
right now...

Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-04-19 14:40:34 -04:00
David Zeuthen
7a1d420889 gdbus-codegen: Set nick+blurb for properties to shut up gtk-doc
Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-04-19 13:42:28 -04:00
David Zeuthen
271af675eb gdbus-codegen: It's GDBusProxyTypeFunc, not GDBusProxyFunc
Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-04-19 13:39:12 -04:00
David Zeuthen
1ea370a1b1 gdbus-codegen: Document the generated ObjectManagerClient structs
Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-04-19 13:16:10 -04:00
David Zeuthen
3238a6ffe7 gdbus-codegen: Add "Returns:" blurb for generated get_proxy_type()
This was forgotten.

Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-04-19 13:10:25 -04:00
David Zeuthen
68ba1bf074 gdbus-codegen: Generate docs when generating C code
This is handy for both gtk-doc and gobject-introspection.

Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-04-18 14:23:19 -04:00
David Zeuthen
3cef28a2f0 gdbus-codegen: Make generated code introspectable
Specific changes

 - Use get_type(), not get_gtype() for the GType function
   - so we need to use the lower-case name type_ for properties called type
 - Don't return a function pointer, just make the function returned
   available instead
 - Add (type) annotations in constructors so g-ir-scanner detects them as such
 - Add (transfer none) annotations to property getters
 - Add (out) annotations to D-Bus method call functions

Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-04-16 14:08:47 -04:00
David Zeuthen
2e358e12f9 gdbus-codegen: Nuke debug spew
Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-04-15 16:36:54 -04:00
David Zeuthen
a3fa748e54 gdbus-codegen: Never emit empty PropertiesChanged signals
It's not that it's actually a bug to do so per se, strictly speaking,
it's just pointless and wasteful.

Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-04-15 16:11:43 -04:00
David Zeuthen
6bccc46d15 gdbus-codegen: Don't send out PropertiesChanged if value ends up not changing
A fairly typical pattern is to have code that does

 foo_set_bar (object, "");
 if (some_condition)
   {
     foo_set_bar (object, "yes");
   }

where some_condition is often true every time @object is updated.

With this code, bar is essentially always "yes" but because of how
gdbus-codegen works, useless PropertiesChanged events got scheduled
and sent out. With this patch, we avoid that by always keeping the
original value around and comparing it only when we deem it's time to
send out the ::PropertiesChanged signal (typically in an idle but can
be forced by the user via flush()).

Also add a test case for this.

Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-04-15 15:53:28 -04:00
David Zeuthen
cade3cb1da gdbus-codegen: Fix obvious bug in _g_variant_equal0() implementation
Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-04-15 13:51:10 -04:00
David Zeuthen
e19734d6c3 gdbus-codegen: Add support for the org.freedesktop.DBus.Deprecated annotation
Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-04-15 12:56:07 -04:00
David Zeuthen
98e6d4b0a9 gdbus-codegen: Include a blurb about the license of the generated code
More precisely, include this line

 The license of this code is the same as for the source it was derived from.

Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-04-15 08:48:21 -04:00
David Zeuthen
5f31671da0 gdbus-codegen: Use the right program name in introductory comment (again)
Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-04-15 08:44:05 -04:00
David Zeuthen
c76a1f9905 gdbus-codegen: Use the right program name in introductory comment
Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-04-15 08:40:52 -04:00
David Zeuthen
9e9535b45c gdbus-codegen: Add copyright / license headers
Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-04-15 08:33:30 -04:00
David Zeuthen
febfc45fbe GDBus: Support Ugly_Case and use org.gtk.GDBus.C.Name since it's C-only
Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-04-15 08:24:40 -04:00
David Zeuthen
6ccca55752 GDBus: Use Skeleton instead of Stub
After some brainstorming with Simon, see

 https://bugzilla.gnome.org/show_bug.cgi?id=647577#c8

Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-04-13 16:33:51 -04:00
David Zeuthen
34a28f2f06 Add support for org.gtk.GDBus.Since annotation
And use this for a) documentation purposes; and b) to preserve C ABI
when an interface is extended. See

 https://bugzilla.gnome.org/show_bug.cgi?id=647577#c5

for more details. Also add test cases for this.

Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-04-12 16:17:28 -04:00
David Zeuthen
76d3653721 gdbus-codegen: Add --c-generate-object-manager option + doc improvements
Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-04-12 11:50:34 -04:00
David Zeuthen
88ab35f3cb Add a generic libffi based marshaller to libgobject
This code is from https://bugzilla.gnome.org/show_bug.cgi?id=567087
and was adapted by myself to also support the GVariant fundamental
type.

Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-04-08 17:34:44 -04:00
David Zeuthen
0b9229beca Add gdbus-codegen(1) command
It doesn't work yet without the user manually adding ffi bits. That's
the topic of the next commit.

Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-04-08 17:11:38 -04:00