]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
dbusgen: Added support for org.gtk.GDBus.Since and partially the org.freedesktop...
authorJCWasmx86 <JCWasmx86@t-online.de>
Tue, 26 Apr 2022 07:59:44 +0000 (09:59 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sat, 29 Apr 2023 19:00:17 +0000 (21:00 +0200)
dbusgen/tests/test-codegen.xml
dbusgen/tests/test-codegen.xml.vala-expected
dbusgen/valadbusgen.vala
dbusgen/valadbusparser.vala

index 68116ec146f3b4eb552b26975a020d7aeea39a25..033cd9c76b9088844be1b2f7f1afa4349a7a35c7 100644 (file)
@@ -6,6 +6,7 @@
 
     <method name="HelloWorld">
       <annotation name="org.gtk.GDBus.DocString" value="Method &lt;emphasis&gt;documentation&lt;/emphasis&gt; blablablabla."/>
+      <annotation name="org.gtk.GDBus.Since" value="0.58"/>
       <annotation name="ExistingAnnotation" value="blah"/>
       <annotation name="org.gtk.GDBus.ExistingInternalAnnotation" value="booh"/>
       <arg name="greeting" direction="in" type="s">
index 9b92222430c68a17bc9c77d4e336bd48a82966ee..83c46ea4500174cc9eab7de8b571961a84fdfc04 100644 (file)
@@ -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<string,string> 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;
index d1f53a70429dbf885c339055708cecfebb1d2193..dfd616ca300e2ca0d0435feed5eb95c0eefc3d25 100644 (file)
@@ -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) {
index 9b9287aabc4c12cd2b34b1b34cb6d56cedff0d02..5c3a05a0d77b817a8696d79ec57c4ba6d9540ec7 100644 (file)
@@ -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 <method> elements.
-                               //TODO
+                               // Ignore as we don't have to generate any special code
                                break;
                        case "org.gtk.GDBus.Since":
                                // Can be used on any <interface>, <method>, <signal> and <property> 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 <interface>, <method>, <signal>,