From: JCWasmx86 Date: Tue, 26 Apr 2022 07:59:44 +0000 (+0200) Subject: dbusgen: Added support for org.gtk.GDBus.Since and partially the org.freedesktop... X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=107b6c426c44917a713565d45ac87c35cf7e1504;p=thirdparty%2Fvala.git dbusgen: Added support for org.gtk.GDBus.Since and partially the org.freedesktop.DBus.Property.EmitsChangedSignal annotation --- diff --git a/dbusgen/tests/test-codegen.xml b/dbusgen/tests/test-codegen.xml index 68116ec14..033cd9c76 100644 --- a/dbusgen/tests/test-codegen.xml +++ b/dbusgen/tests/test-codegen.xml @@ -6,6 +6,7 @@ + diff --git a/dbusgen/tests/test-codegen.xml.vala-expected b/dbusgen/tests/test-codegen.xml.vala-expected index 9b9222243..83c46ea45 100644 --- a/dbusgen/tests/test-codegen.xml.vala-expected +++ b/dbusgen/tests/test-codegen.xml.vala-expected @@ -1,5 +1,6 @@ [DBus (name = "org.project.Bar", timeout = 120000)] public interface OrgProjectBar : GLib.Object { + [Version (since = "0.58")] public abstract void hello_world (string greeting, out string response) throws GLib.DBusError, GLib.IOError; public abstract void test_primitive_types (char val_byte, bool val_boolean, int16 val_int16, uint16 val_uint16, int32 val_int32, uint32 val_uint32, int64 val_int64, uint64 val_uint64, double val_double, string val_string, GLib.ObjectPath val_objpath, string val_signature, string val_bytestring, out char ret_byte, out bool ret_boolean, out int16 ret_int16, out uint16 ret_uint16, out int32 ret_int32, out uint32 ret_uint32, out int64 ret_int64, out uint64 ret_uint64, out double ret_double, out string ret_string, out GLib.ObjectPath ret_objpath, out string ret_signature, out string ret_bytestring) throws GLib.DBusError, GLib.IOError; public abstract void test_non_primitive_types (GLib.HashTable dict_s_to_s, [DBus (signature = "a{s(ii)}")] GLib.Variant dict_s_to_pairs, [DBus (signature = "(iss)")] GLib.Variant a_struct, string[] array_of_strings, out string[] ret_array_of_strings, GLib.ObjectPath[] array_of_objpaths, out GLib.ObjectPath[] ret_array_of_objpaths, string[] array_of_signatures, out string[] ret_array_of_signatures, string[] array_of_bytestrings, out string[] ret_array_of_bytestrings, out string result) throws GLib.DBusError, GLib.IOError; @@ -44,8 +45,10 @@ public interface OrgProjectBar : GLib.Object { public abstract string finally_normal_name { owned get; set; } public abstract string readonly_property { owned get; } public abstract string writeonly_property { set; } + [CCode (notify = false)] [DBus (name = "quiet")] public abstract string quiet { owned get; set; } + [CCode (notify = false)] [DBus (name = "quiet_too")] public abstract string quiet_too { owned get; set; } [DBus (name = "unset_i")] @@ -156,6 +159,7 @@ public interface ChangingInterfaceV2 : GLib.Object { } [DBus (name = "ChangingInterfaceV10", timeout = 120000)] public interface ChangingInterfaceV10 : GLib.Object { + [Version (since = "10.0")] public abstract void added_method_in10 () throws GLib.DBusError, GLib.IOError; public abstract void new_method_in2 () throws GLib.DBusError, GLib.IOError; public abstract void baz_method () throws GLib.DBusError, GLib.IOError; diff --git a/dbusgen/valadbusgen.vala b/dbusgen/valadbusgen.vala index d1f53a704..dfd616ca3 100644 --- a/dbusgen/valadbusgen.vala +++ b/dbusgen/valadbusgen.vala @@ -109,6 +109,7 @@ public class Vala.DBusGen { context.vapi_comments = true; context.add_external_package ("gio-2.0"); + context.add_external_package ("gio-unix-2.0"); if (packages != null) { foreach (string package in packages) { diff --git a/dbusgen/valadbusparser.vala b/dbusgen/valadbusparser.vala index 9b9287aab..5c3a05a0d 100644 --- a/dbusgen/valadbusparser.vala +++ b/dbusgen/valadbusparser.vala @@ -229,7 +229,10 @@ public class Vala.DBusParser : CodeVisitor { // This annotation is intended to be used by code generators to implement client-side caching of property values. // For all properties for which the annotation is set to const, invalidates or true the client may unconditionally // cache the values as the properties don't change or notifications are generated for them if they do. - //TODO + if (val == "false" || val == "const") { + // const is technically wrong, but if you can't change the value, notify will never be triggered + current_node.set_attribute_bool ("CCode", "notify", false); + } break; case "org.freedesktop.DBus.GLib.Async": if (current_node is Method) { @@ -266,12 +269,14 @@ public class Vala.DBusParser : CodeVisitor { case "org.gtk.GDBus.C.UnixFD": // If set to a non-empty string, the generated code will include parameters to exchange file descriptors using the // #GUnixFDList type. This annotation can be used on elements. - //TODO + // Ignore as we don't have to generate any special code break; case "org.gtk.GDBus.Since": // Can be used on any , , and element to specify the version (any free-form // string but compared using a version-aware sort function) the element appeared in. - //TODO + if (val != null) { + current_node.set_attribute_string ("Version", "since", val); + } break; case "org.gtk.GDBus.DocString": // A string with Docbook content for documentation. This annotation can be used on , , ,