]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
gidlparser: Support error types for delegates 1df2c050ba29c84026a14e7ee23fa6bcd00b1044
authorMichal Hruby <michal.mhr@gmail.com>
Tue, 5 Apr 2011 20:38:56 +0000 (22:38 +0200)
committerLuca Bruno <lucabru@src.gnome.org>
Tue, 5 Apr 2011 20:41:33 +0000 (22:41 +0200)
Fixes bug 644420.

vapi/gio-2.0.vapi
vapi/gtk+-2.0.vapi
vapi/libgda-4.0.vapi
vapigen/valagidlparser.vala

index a9da0a17a3e3f1b2b6ad939699070cf284310d00..3f719a713e0243887119be7f949a297610b8961c 100644 (file)
@@ -2476,11 +2476,11 @@ namespace GLib {
        [CCode (cheader_filename = "gio/gio.h")]
        public delegate bool CancellableSourceFunc (GLib.Cancellable cancellable);
        [CCode (cheader_filename = "gio/gio.h")]
-       public delegate unowned GLib.Variant DBusInterfaceGetPropertyFunc (GLib.DBusConnection connection, string sender, string object_path, string interface_name, string property_name, GLib.Error error);
+       public delegate unowned GLib.Variant DBusInterfaceGetPropertyFunc (GLib.DBusConnection connection, string sender, string object_path, string interface_name, string property_name) throws GLib.Error;
        [CCode (cheader_filename = "gio/gio.h")]
        public delegate void DBusInterfaceMethodCallFunc (GLib.DBusConnection connection, string sender, string object_path, string interface_name, string method_name, GLib.Variant parameters, GLib.DBusMethodInvocation invocation);
        [CCode (cheader_filename = "gio/gio.h")]
-       public delegate bool DBusInterfaceSetPropertyFunc (GLib.DBusConnection connection, string sender, string object_path, string interface_name, string property_name, GLib.Variant value, GLib.Error error);
+       public delegate bool DBusInterfaceSetPropertyFunc (GLib.DBusConnection connection, string sender, string object_path, string interface_name, string property_name, GLib.Variant value) throws GLib.Error;
        [CCode (cheader_filename = "gio/gio.h")]
        public delegate unowned GLib.DBusMessage DBusMessageFilterFunction (GLib.DBusConnection connection, GLib.DBusMessage message, bool incoming);
        [CCode (cheader_filename = "gio/gio.h")]
index 7d27503aaff50f46da3f7227019709c9efa4e278..889232b787c48f5964abcabffc3cdd161fdb2a2f 100644 (file)
@@ -7474,7 +7474,7 @@ namespace Gtk {
        [CCode (cheader_filename = "gtk/gtk.h")]
        public delegate int RecentSortFunc (Gtk.RecentInfo a, Gtk.RecentInfo b);
        [CCode (cheader_filename = "gtk/gtk.h", instance_pos = 5.9)]
-       public delegate bool TextBufferDeserializeFunc (Gtk.TextBuffer register_buffer, Gtk.TextBuffer content_buffer, Gtk.TextIter iter, [CCode (array_length_type = "gsize")] uint8[] data, bool create_tags, GLib.Error error);
+       public delegate bool TextBufferDeserializeFunc (Gtk.TextBuffer register_buffer, Gtk.TextBuffer content_buffer, Gtk.TextIter iter, [CCode (array_length_type = "gsize")] uint8[] data, bool create_tags) throws GLib.Error;
        [CCode (cheader_filename = "gtk/gtk.h")]
        public delegate uchar TextBufferSerializeFunc (Gtk.TextBuffer register_buffer, Gtk.TextBuffer content_buffer, Gtk.TextIter start, Gtk.TextIter end, size_t length);
        [CCode (cheader_filename = "gtk/gtk.h")]
index e0068d2388b23efabdd337a921522e041a4ca102..e60392a93a477c188a9d665bfdb1ed6b5e2178d8 100644 (file)
@@ -2056,21 +2056,21 @@ namespace Gda {
        [CCode (cheader_filename = "libgda/libgda.h")]
        public delegate void ServerProviderExecCallback (Gda.ServerProvider provider, Gda.Connection cnc, uint task_id, GLib.Object result_obj, GLib.Error error);
        [CCode (cheader_filename = "libgda/libgda.h", has_target = false)]
-       public delegate bool SqlForeachFunc (Gda.SqlAnyPart p1, void* p2, GLib.Error p3);
+       public delegate bool SqlForeachFunc (Gda.SqlAnyPart p1, void* p2) throws GLib.Error;
        [CCode (cheader_filename = "libgda/libgda.h", has_target = false)]
-       public delegate unowned string SqlRenderingExpr (Gda.SqlExpr expr, Gda.SqlRenderingContext context, bool is_default, bool is_null, GLib.Error error);
+       public delegate unowned string SqlRenderingExpr (Gda.SqlExpr expr, Gda.SqlRenderingContext context, bool is_default, bool is_null) throws GLib.Error;
        [CCode (cheader_filename = "libgda/libgda.h", has_target = false)]
-       public delegate unowned string SqlRenderingFunc (Gda.SqlAnyPart node, Gda.SqlRenderingContext context, GLib.Error error);
+       public delegate unowned string SqlRenderingFunc (Gda.SqlAnyPart node, Gda.SqlRenderingContext context) throws GLib.Error;
        [CCode (cheader_filename = "libgda/libgda.h", has_target = false)]
-       public delegate unowned string SqlRenderingPSpecFunc (Gda.SqlParamSpec pspec, Gda.SqlExpr expr, Gda.SqlRenderingContext context, bool is_default, bool is_null, GLib.Error error);
+       public delegate unowned string SqlRenderingPSpecFunc (Gda.SqlParamSpec pspec, Gda.SqlExpr expr, Gda.SqlRenderingContext context, bool is_default, bool is_null) throws GLib.Error;
        [CCode (cheader_filename = "libgda/libgda.h", has_target = false)]
-       public delegate unowned string SqlRenderingValue (GLib.Value value, Gda.SqlRenderingContext context, GLib.Error error);
+       public delegate unowned string SqlRenderingValue (GLib.Value value, Gda.SqlRenderingContext context) throws GLib.Error;
        [CCode (cheader_filename = "libgda/libgda.h", has_target = false)]
        public delegate bool SqlReservedKeywordsFunc (string word);
        [CCode (cheader_filename = "libgda/libgda.h")]
        public delegate void VConnectionHubFunc (Gda.Connection cnc, string ns);
        [CCode (cheader_filename = "libgda/libgda.h", has_target = false)]
-       public delegate unowned GLib.List VconnectionDataModelCreateColumnsFunc (Gda.VconnectionDataModelSpec p1, GLib.Error p2);
+       public delegate unowned GLib.List VconnectionDataModelCreateColumnsFunc (Gda.VconnectionDataModelSpec p1) throws GLib.Error;
        [CCode (cheader_filename = "libgda/libgda.h", has_target = false)]
        public delegate unowned Gda.DataModel VconnectionDataModelCreateModelFunc (Gda.VconnectionDataModelSpec p1);
        [CCode (cheader_filename = "libgda/libgda.h", has_target = false)]
index 740fb0bc51e54eabdf61ff6e813184dd4baa7a9f..a0b775deff341ac888699294f25fd878435025b5 100644 (file)
@@ -452,6 +452,8 @@ public class Vala.GIdlParser : CodeVisitor {
                cb.access = SymbolAccessibility.PUBLIC;
 
                bool check_has_target = true;
+               bool suppress_throws = false;
+               string? error_types = null;
 
                var attributes = get_attributes (node.name);
                if (attributes != null) {
@@ -478,6 +480,12 @@ public class Vala.GIdlParser : CodeVisitor {
                                                return_type = new ArrayType (return_type, 1, return_type.source_reference);
                                                cb.return_type = return_type;
                                        }
+                               } else if (nv[0] == "throws") {
+                                       if (eval (nv[1]) == "0") {
+                                               suppress_throws = true;
+                                       }
+                               } else if (nv[0] == "error_types") {
+                                       error_types = eval (nv[1]);
                                } else if (nv[0] == "array_length_type") {
                                        cb.array_length_type = eval (nv[1]);
                                } else if (nv[0] == "type_name") {
@@ -514,6 +522,14 @@ public class Vala.GIdlParser : CodeVisitor {
                                // hide user_data parameter for instance delegates
                                cb.has_target = true;
                        } else {
+                               // check for GError parameter
+                               if (suppress_throws == false && param_is_exception (param)) {
+                                       if (error_types == null)
+                                               cb.add_error_type (parse_type (param.type));
+                                       remaining_params--;
+                                       continue;
+                               }
+
                                string param_name = param_node.name;
                                if (param_name == "string") {
                                        // avoid conflict with string type
@@ -604,7 +620,14 @@ public class Vala.GIdlParser : CodeVisitor {
 
                        remaining_params--;
                }
-               
+
+               if (suppress_throws == false && error_types != null) {
+                       var type_args = eval (error_types).split (",");
+                       foreach (string type_arg in type_args) {
+                               cb.add_error_type (parse_type_from_string (type_arg, true));
+                       }
+               }
+
                return cb;
        }
 
@@ -2156,6 +2179,7 @@ public class Vala.GIdlParser : CodeVisitor {
                                continue;
                        }
 
+                       // check for GError parameter
                        if (suppress_throws == false && param_is_exception (param)) {
                                if (error_types == null)
                                        m.add_error_type (parse_type (param.type));