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>
This commit is contained in:
David Zeuthen
2011-04-12 16:17:28 -04:00
parent 76d3653721
commit 34a28f2f06
9 changed files with 193 additions and 13 deletions

View File

@@ -1,11 +1,13 @@
<node>
<!-- org.gtk.GDBus.Example.ObjectManager.Animal:
@short_description: Example docs generated by gdbus-codegen
@since: 2.30
This D-Bus interface is used to describe a simple animal.
-->
<interface name="org.gtk.GDBus.Example.ObjectManager.Animal">
<!-- Mood: The mood of the animal.
@since: 2.30
Known values for this property include
<literal>Happy</literal> and <literal>Sad</literal>. Use the
@@ -23,6 +25,7 @@
Poke:
@make_sad: Whether to make the animal sad.
@make_happy: Whether to make the animal happy.
@since: 2.30
Method used to changing the mood of the animal. See also the
#org.gtk.GDBus.Example.ObjectManager.Animal:Mood property.
@@ -35,6 +38,7 @@
<!--
Jumped:
@height: Height, in meters, that the animal jumped.
@since: 2.30
Emitted when the animal decides to jump.
-->

View File

@@ -2144,6 +2144,27 @@ gpointer name_forcing_4 = foo_rocket123_get_speed_xyz;
/* ---------------------------------------------------------------------------------------------------- */
/* See https://bugzilla.gnome.org/show_bug.cgi?id=647577#c5 for details */
#define CHECK_FIELD(name, v1, v2) g_assert_cmpint (G_STRUCT_OFFSET (FooChangingInterface##v1##Iface, name), ==, G_STRUCT_OFFSET (FooChangingInterface##v2##Iface, name));
static void
test_interface_stability (void)
{
CHECK_FIELD(handle_foo_method, V1, V2);
CHECK_FIELD(handle_bar_method, V1, V2);
CHECK_FIELD(handle_baz_method, V1, V2);
CHECK_FIELD(foo_signal, V1, V2);
CHECK_FIELD(bar_signal, V1, V2);
CHECK_FIELD(baz_signal, V1, V2);
CHECK_FIELD(handle_new_method_in2, V2, V10);
CHECK_FIELD(new_signal_in2, V2, V10);
}
#undef CHECK_FIELD
/* ---------------------------------------------------------------------------------------------------- */
int
main (int argc,
char *argv[])
@@ -2167,6 +2188,7 @@ main (int argc,
usleep (500 * 1000);
g_test_add_func ("/gdbus/codegen/annotations", test_annotations);
g_test_add_func ("/gdbus/codegen/interface_stability", test_interface_stability);
g_test_add_func ("/gdbus/codegen/object-manager", test_object_manager);
ret = g_test_run();

View File

@@ -338,4 +338,64 @@
<property name="FancyProperty" type="s" access="read"/>
</interface>
<interface name="ChangingInterfaceV1">
<method name="FooMethod"/>
<method name="BarMethod"/>
<method name="BazMethod"/>
<signal name="FooSignal"/>
<signal name="BarSignal"/>
<signal name="BazSignal"/>
</interface>
<interface name="ChangingInterfaceV2">
<!--
NewSignalIn2:
@since: 2.0
-->
<signal name="NewSignalIn2"/>
<!--
NewMethodIn2:
@since: 2.0
-->
<method name="NewMethodIn2"/>
<!-- reverse order -->
<signal name="BazSignal"/>
<signal name="BarSignal"/>
<signal name="FooSignal"/>
<method name="BazMethod"/>
<method name="BarMethod"/>
<method name="FooMethod"/>
</interface>
<interface name="ChangingInterfaceV10">
<!--
AddedSignalIn10:
@since: 10.0
-->
<signal name="AddedSignalIn10"/>
<method name="AddedMethodIn10">
<annotation name="org.gtk.GDBus.Since" value="10.0"/>
</method>
<!--
NewSignalIn2:
@since: 2.0
-->
<signal name="NewSignalIn2"/>
<!--
NewMethodIn2:
@since: 2.0
-->
<method name="NewMethodIn2"/>
<!-- reverse order -->
<signal name="BazSignal"/>
<signal name="BarSignal"/>
<signal name="FooSignal"/>
<method name="BazMethod"/>
<method name="BarMethod"/>
<method name="FooMethod"/>
</interface>
</node>