]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
girparser: Discover ref/unref methods
authorRico Tzschichholz <ricotz@ubuntu.com>
Fri, 6 Sep 2013 18:29:26 +0000 (20:29 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Fri, 6 Sep 2013 18:29:26 +0000 (20:29 +0200)
Add ability to find ref/unref methods and add corresponding ccode
attributes. Additionally rebuild all gir bindings to pick up the
changes.

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

vala/valagirparser.vala
vapi/gdk-3.0.vapi
vapi/gio-2.0.vapi
vapi/gstreamer-video-1.0.vapi
vapi/json-glib-1.0.vapi
vapi/metadata/Gio-2.0-custom.vala
vapi/metadata/Gio-2.0.metadata
vapi/pango.vapi
vapi/rest-0.7.vapi

index 7a95b7bf6fc0aff070e48c96b9e89ea29be00b1d..8413e9ebc81b1f8b12c147f882207e388567b978 100644 (file)
@@ -3016,14 +3016,14 @@ public class Vala.GirParser : CodeVisitor {
                push_node (element_get_name (name), true);
 
                Class cl;
+               bool require_copy_free = false;
                if (current.new_symbol) {
                        cl = new Class (current.name, current.source_reference);
                        cl.is_compact = true;
                        var typeid = reader.get_attribute ("glib:get-type");
                        if (typeid != null) {
+                               require_copy_free = true;
                                cl.set_attribute_string ("CCode", "type_id", "%s ()".printf (typeid));
-                               cl.set_attribute_string ("CCode", "free_function", "g_boxed_free");
-                               cl.set_attribute_string ("CCode", "copy_function", "g_boxed_copy");
                        }
 
                        current.symbol = cl;
@@ -3041,6 +3041,9 @@ public class Vala.GirParser : CodeVisitor {
 
                cl.comment = parse_symbol_doc ();
 
+               Node? ref_method = null;
+               Node? unref_method = null;
+
                while (current_token == MarkupTokenType.START_ELEMENT) {
                        if (!push_metadata ()) {
                                skip_element ();
@@ -3053,6 +3056,12 @@ public class Vala.GirParser : CodeVisitor {
                                parse_constructor ();
                        } else if (reader.name == "method") {
                                parse_method ("method");
+                               var cname = old_current.get_cname ();
+                               if (cname.has_suffix ("_ref")) {
+                                       ref_method = old_current;
+                               } else if (cname.has_suffix ("_unref")) {
+                                       unref_method = old_current;
+                               }
                        } else if (reader.name == "function") {
                                skip_element ();
                        } else if (reader.name == "union") {
@@ -3066,6 +3075,16 @@ public class Vala.GirParser : CodeVisitor {
                        pop_metadata ();
                }
 
+               // Add ccode-attributes for ref/unref methodes if available
+               // otherwise fallback to default g_boxed_copy/free
+               if (ref_method != null && unref_method != null) {
+                       cl.set_attribute_string ("CCode", "ref_function", ref_method.get_cname ());
+                       cl.set_attribute_string ("CCode", "unref_function", unref_method.get_cname ());
+               } else if (require_copy_free) {
+                       cl.set_attribute_string ("CCode", "copy_function", "g_boxed_copy");
+                       cl.set_attribute_string ("CCode", "free_function", "g_boxed_free");
+               }
+
                pop_node ();
                end_element (element_name);
        }
index dead1dfeebd53cd4fcc3045bcd748e7f0758fb00..f7794f6d49177f58a99be380f74ccd0ce7361c7b 100644 (file)
@@ -4818,7 +4818,7 @@ namespace Gdk {
                public signal void resume_events ();
                public signal void update ();
        }
-       [CCode (cheader_filename = "gdk/gdk.h", copy_function = "g_boxed_copy", free_function = "g_boxed_free", type_id = "gdk_frame_timings_get_type ()")]
+       [CCode (cheader_filename = "gdk/gdk.h", ref_function = "gdk_frame_timings_ref", type_id = "gdk_frame_timings_get_type ()", unref_function = "gdk_frame_timings_unref")]
        [Compact]
        public class FrameTimings {
                public bool get_complete ();
index 0e505f92ab6d43013263dcc35290e7e46cfefe04..414d432d2a2fc4622a4fe094db1f56bfc0b8fb73 100644 (file)
@@ -465,6 +465,8 @@ namespace GLib {
                public string key;
                public int ref_count;
                public string value;
+               public GLib.DBusAnnotationInfo @ref ();
+               public void unref ();
        }
        [CCode (cheader_filename = "gio/gio.h", ref_function = "g_dbus_arg_info_ref", type_id = "g_dbus_arg_info_get_type ()", unref_function = "g_dbus_arg_info_unref")]
        [Compact]
@@ -474,6 +476,8 @@ namespace GLib {
                public string name;
                public int ref_count;
                public string signature;
+               public GLib.DBusArgInfo @ref ();
+               public void unref ();
        }
        [CCode (cheader_filename = "gio/gio.h", type_id = "g_dbus_auth_observer_get_type ()")]
        public class DBusAuthObserver : GLib.Object {
@@ -561,6 +565,8 @@ namespace GLib {
                public unowned GLib.DBusMethodInfo lookup_method (string name);
                public unowned GLib.DBusPropertyInfo lookup_property (string name);
                public unowned GLib.DBusSignalInfo lookup_signal (string name);
+               public GLib.DBusInterfaceInfo @ref ();
+               public void unref ();
        }
        [CCode (cheader_filename = "gio/gio.h", type_id = "g_dbus_interface_skeleton_get_type ()")]
        public abstract class DBusInterfaceSkeleton : GLib.Object, GLib.DBusInterface {
@@ -664,6 +670,8 @@ namespace GLib {
                [CCode (array_length = false, array_null_terminated = true)]
                public GLib.DBusArgInfo[] out_args;
                public int ref_count;
+               public GLib.DBusMethodInfo @ref ();
+               public void unref ();
        }
        [CCode (cheader_filename = "gio/gio.h", type_id = "g_dbus_method_invocation_get_type ()")]
        public class DBusMethodInvocation : GLib.Object {
@@ -703,6 +711,8 @@ namespace GLib {
                public DBusNodeInfo.for_xml (string xml_data) throws GLib.Error;
                public void generate_xml (uint indent, GLib.StringBuilder string_builder);
                public unowned GLib.DBusInterfaceInfo lookup_interface (string name);
+               public GLib.DBusNodeInfo @ref ();
+               public void unref ();
        }
        [CCode (cheader_filename = "gio/gio.h", type_id = "g_dbus_object_manager_client_get_type ()")]
        public class DBusObjectManagerClient : GLib.Object, GLib.AsyncInitable, GLib.DBusObjectManager, GLib.Initable, GLib.AsyncInitable, GLib.DBusObjectManager, GLib.Initable {
@@ -773,7 +783,7 @@ namespace GLib {
                public string g_object_path { owned get; set construct; }
                public virtual signal bool authorize_method (GLib.DBusInterfaceSkeleton interface_, GLib.DBusMethodInvocation invocation);
        }
-       [CCode (cheader_filename = "gio/gio.h", copy_function = "g_boxed_copy", free_function = "g_boxed_free", type_id = "g_dbus_property_info_get_type ()")]
+       [CCode (cheader_filename = "gio/gio.h", ref_function = "g_dbus_property_info_ref", type_id = "g_dbus_property_info_get_type ()", unref_function = "g_dbus_property_info_unref")]
        [Compact]
        public class DBusPropertyInfo {
                [CCode (array_length = false, array_null_terminated = true)]
@@ -782,6 +792,8 @@ namespace GLib {
                public string name;
                public int ref_count;
                public string signature;
+               public GLib.DBusPropertyInfo @ref ();
+               public void unref ();
        }
        [CCode (cheader_filename = "gio/gio.h")]
        public class DBusProxy : GLib.Object, GLib.AsyncInitable, GLib.DBusInterface, GLib.Initable, GLib.AsyncInitable, GLib.DBusInterface, GLib.Initable {
@@ -865,6 +877,8 @@ namespace GLib {
                public GLib.DBusArgInfo[] args;
                public string name;
                public int ref_count;
+               public GLib.DBusSignalInfo @ref ();
+               public void unref ();
        }
        [CCode (cheader_filename = "gio/gio.h")]
        public class DataInputStream : GLib.BufferedInputStream, GLib.Seekable {
@@ -944,6 +958,8 @@ namespace GLib {
                public void add (string name, GLib.FileAttributeType type, GLib.FileAttributeInfoFlags flags);
                public GLib.FileAttributeInfoList dup ();
                public unowned GLib.FileAttributeInfo? lookup (string name);
+               public GLib.FileAttributeInfoList @ref ();
+               public void unref ();
        }
        [CCode (cheader_filename = "gio/gio.h", ref_function = "g_file_attribute_matcher_ref", type_id = "g_file_attribute_matcher_get_type ()", unref_function = "g_file_attribute_matcher_unref")]
        [Compact]
@@ -954,8 +970,10 @@ namespace GLib {
                public unowned string enumerate_next ();
                public bool matches (string attribute);
                public bool matches_only (string attribute);
+               public GLib.FileAttributeMatcher @ref ();
                public GLib.FileAttributeMatcher subtract (GLib.FileAttributeMatcher subtract);
                public string to_string ();
+               public void unref ();
        }
        [CCode (cheader_filename = "gio/gio.h", type_id = "g_file_enumerator_get_type ()")]
        public class FileEnumerator : GLib.Object {
@@ -1203,6 +1221,7 @@ namespace GLib {
                [CCode (has_construct_function = false)]
                public IOModuleScope (GLib.IOModuleScopeFlags flags);
                public void block (string basename);
+               public void free ();
        }
        [CCode (cheader_filename = "gio/gio.h")]
        [Compact]
@@ -1646,6 +1665,8 @@ namespace GLib {
                public static GLib.Resource load (string filename) throws GLib.Error;
                public GLib.Bytes lookup_data (string path, GLib.ResourceLookupFlags lookup_flags) throws GLib.Error;
                public GLib.InputStream open_stream (string path, GLib.ResourceLookupFlags lookup_flags) throws GLib.Error;
+               public GLib.Resource @ref ();
+               public void unref ();
        }
        [CCode (cheader_filename = "gio/gio.h")]
        public class Settings : GLib.Object {
@@ -1729,7 +1750,7 @@ namespace GLib {
                [CCode (has_construct_function = false)]
                protected SettingsBackend ();
        }
-       [CCode (cheader_filename = "gio/gio.h", copy_function = "g_boxed_copy", free_function = "g_boxed_free", type_id = "g_settings_schema_get_type ()")]
+       [CCode (cheader_filename = "gio/gio.h", ref_function = "g_settings_schema_ref", type_id = "g_settings_schema_get_type ()", unref_function = "g_settings_schema_unref")]
        [Compact]
        public class SettingsSchema {
                public unowned string get_id ();
@@ -1737,7 +1758,7 @@ namespace GLib {
                public GLib.SettingsSchema @ref ();
                public void unref ();
        }
-       [CCode (cheader_filename = "gio/gio.h", copy_function = "g_boxed_copy", free_function = "g_boxed_free", type_id = "g_settings_schema_source_get_type ()")]
+       [CCode (cheader_filename = "gio/gio.h", ref_function = "g_settings_schema_source_ref", type_id = "g_settings_schema_source_get_type ()", unref_function = "g_settings_schema_source_unref")]
        [Compact]
        public class SettingsSchemaSource {
                [CCode (has_construct_function = false)]
@@ -2023,6 +2044,7 @@ namespace GLib {
                [CCode (has_construct_function = false)]
                public SrvTarget (string hostname, uint16 port, uint16 priority, uint16 weight);
                public GLib.SrvTarget copy ();
+               public void free ();
                public unowned string get_hostname ();
                public uint16 get_port ();
                public uint16 get_priority ();
index daa716866a1d6feb859810dc02296c433d9aa93b..ed00c3a54b4604485ad628ba0451b34816048801 100644 (file)
@@ -30,7 +30,7 @@ namespace Gst {
                        public void set_user_data<T> (owned T user_data);
                        public void unref ();
                }
-               [CCode (cheader_filename = "gst/video/colorbalance.h,gst/video/colorbalancechannel.h,gst/video/gstvideodecoder.h,gst/video/gstvideoencoder.h,gst/video/gstvideofilter.h,gst/video/gstvideometa.h,gst/video/gstvideopool.h,gst/video/gstvideosink.h,gst/video/gstvideoutils.h,gst/video/navigation.h,gst/video/video-blend.h,gst/video/video-color.h,gst/video/video-enumtypes.h,gst/video/video-event.h,gst/video/video-format.h,gst/video/video-frame.h,gst/video/video-info.h,gst/video/video-overlay-composition.h,gst/video/video.h,gst/video/videoorientation.h,gst/video/videooverlay.h", copy_function = "g_boxed_copy", free_function = "g_boxed_free", type_id = "gst_video_codec_state_get_type ()")]
+               [CCode (cheader_filename = "gst/video/colorbalance.h,gst/video/colorbalancechannel.h,gst/video/gstvideodecoder.h,gst/video/gstvideoencoder.h,gst/video/gstvideofilter.h,gst/video/gstvideometa.h,gst/video/gstvideopool.h,gst/video/gstvideosink.h,gst/video/gstvideoutils.h,gst/video/navigation.h,gst/video/video-blend.h,gst/video/video-color.h,gst/video/video-enumtypes.h,gst/video/video-event.h,gst/video/video-format.h,gst/video/video-frame.h,gst/video/video-info.h,gst/video/video-overlay-composition.h,gst/video/video.h,gst/video/videoorientation.h,gst/video/videooverlay.h", ref_function = "gst_video_codec_state_ref", type_id = "gst_video_codec_state_get_type ()", unref_function = "gst_video_codec_state_unref")]
                [Compact]
                [GIR (name = "VideoCodecState")]
                public class CodecState {
index 9d67ec4bbffd257529f32d9adeed05c76561725b..2688465547130510416227ecac25ece1e6446860 100644 (file)
@@ -2,7 +2,7 @@
 
 [CCode (cprefix = "Json", gir_namespace = "Json", gir_version = "1.0", lower_case_cprefix = "json_")]
 namespace Json {
-       [CCode (cheader_filename = "json-glib/json-glib.h", copy_function = "g_boxed_copy", free_function = "g_boxed_free", type_id = "json_array_get_type ()")]
+       [CCode (cheader_filename = "json-glib/json-glib.h", ref_function = "json_array_ref", type_id = "json_array_get_type ()", unref_function = "json_array_unref")]
        [Compact]
        public class Array {
                [CCode (has_construct_function = false)]
@@ -113,7 +113,7 @@ namespace Json {
                public void take_object (owned Json.Object object);
                public unowned string type_name ();
        }
-       [CCode (cheader_filename = "json-glib/json-glib.h", copy_function = "g_boxed_copy", free_function = "g_boxed_free", type_id = "json_object_get_type ()")]
+       [CCode (cheader_filename = "json-glib/json-glib.h", ref_function = "json_object_ref", type_id = "json_object_get_type ()", unref_function = "json_object_unref")]
        [Compact]
        public class Object {
                [CCode (has_construct_function = false)]
index 012f0a7420104a17246b800c0192c30c910702c5..7a03812d6903f193c0a0a05bf19f4c2d5df84341 100644 (file)
@@ -545,53 +545,6 @@ namespace GLib {
        [CCode (cheader_filename = "gio/gio.h", cname = "g_tls_error_quark")]
        public static GLib.Quark g_tls_error_quark ();
 
-       /*** Bug #: GIR parser doesn't pick up ref/unref functions ***/
-
-       [CCode (cheader_filename = "gio/gio.h", ref_function = "g_dbus_annotation_info_ref", type_id = "g_dbus_annotation_info_get_type ()", unref_function = "g_dbus_annotation_info_unref")]
-       [Compact]
-       public class DBusAnnotationInfo {
-       }
-
-       [CCode (cheader_filename = "gio/gio.h", ref_function = "g_dbus_arg_info_ref", type_id = "g_dbus_arg_info_get_type ()", unref_function = "g_dbus_arg_info_unref")]
-       [Compact]
-       public class DBusArgInfo {
-       }
-
-       [CCode (ref_function = "g_dbus_interface_info_ref", type_id = "g_dbus_interface_info_get_type ()", unref_function = "g_dbus_interface_info_unref")]
-       [Compact]
-       public class DBusInterfaceInfo {
-       }
-
-       [CCode (ref_function = "g_dbus_method_info_ref", type_id = "g_dbus_method_info_get_type ()", unref_function = "g_dbus_method_info_unref")]
-       [Compact]
-       public class DBusMethodInfo {
-       }
-
-       [CCode (ref_function = "g_dbus_node_info_ref", type_id = "g_dbus_node_info_get_type ()", unref_function = "g_dbus_node_info_unref")]
-       [Compact]
-       public class DBusNodeInfo {
-       }
-
-       [CCode (ref_function = "g_dbus_signal_info_ref", type_id = "g_dbus_signal_info_get_type ()", unref_function = "g_dbus_signal_info_unref")]
-       [Compact]
-       public class DBusSignalInfo {
-       }
-
-       [CCode (ref_function = "g_file_attribute_info_list_ref", type_id = "g_file_attribute_info_list_get_type ()", unref_function = "g_file_attribute_info_list_unref")]
-       [Compact]
-       public class FileAttributeInfoList {
-       }
-
-       [CCode (ref_function = "g_file_attribute_matcher_ref", type_id = "g_file_attribute_matcher_get_type ()", unref_function = "g_file_attribute_matcher_unref")]
-       [Compact]
-       public class FileAttributeMatcher {
-       }
-
-       [CCode (ref_function = "g_resource_ref", type_id = "g_resource_get_type ()", unref_function = "g_resource_unref")]
-       [Compact]
-       public class Resource {
-       }
-
        [CCode (cheader_filename = "gio/gio.h", has_target = false, cname = "GSettingsBindGetMapping")]
        public delegate bool SettingsBindGetMappingShared (GLib.Value value, GLib.Variant variant, void* user_data);
        [CCode (cheader_filename = "gio/gio.h", has_target = false, cname = "GSettingsBindSetMapping")]
index f9898a573da81d3f51ac8a672c62d59fad299ecb..29cad7dab649488688d203f1451658d1a1731a58 100644 (file)
@@ -114,8 +114,6 @@ FileInfo
   .list_attributes nullable
 FileEnumerator
   .next_file nullable
-IOModuleScope
-  .free skip
 IOStream
   .close* skip
   .input_stream abstract
@@ -193,8 +191,6 @@ SocketControlMessage
   .serialize.data type="uint8[]"
 SocketListener
   .accept*.source_object#parameter default=null
-SrvTarget
-  .free skip
 srv_target_list_sort type_arguments="GLib.SrvTarget" skip=false
 srv_target_list_sort.targets type_arguments="GLib.SrvTarget" owned
 StaticResource
@@ -268,21 +264,6 @@ proxy_resolver_get_default skip
 simple_async_report_gerror_in_idle parent="GLib.SimpleAsyncResult" name="report_gerror_in_idle"
 tls_* skip
 
-
-// Bug #666796: GIR parser doesn't pick up ref/unref functions
-DBus*Info
-  .ref skip
-  .unref skip
-FileAttributeInfoList
-  .ref skip
-  .unref skip
-FileAttributeMatcher
-  .ref skip
-  .unref skip
-Resource
-  .ref skip
-  .unref skip
-
 // Bug #659886: Async constuctors don't work
 DBusConnection
   .new skip
index 3af047b64f12e74c4777a64c833393c4221913b1..8ae455aeb2443686c1db124d5a8883c106636f23 100644 (file)
@@ -66,7 +66,7 @@ namespace Pango {
                [CCode (has_construct_function = false, type = "PangoAttribute*")]
                public AttrLanguage (Pango.Language language);
        }
-       [CCode (cheader_filename = "pango/pango.h", copy_function = "g_boxed_copy", free_function = "g_boxed_free", type_id = "pango_attr_list_get_type ()")]
+       [CCode (cheader_filename = "pango/pango.h", ref_function = "pango_attr_list_ref", type_id = "pango_attr_list_get_type ()", unref_function = "pango_attr_list_unref")]
        [Compact]
        public class AttrList {
                [CCode (has_construct_function = false)]
@@ -241,7 +241,7 @@ namespace Pango {
                public Pango.Font load_font (Pango.Context context, Pango.FontDescription desc);
                public Pango.Fontset load_fontset (Pango.Context context, Pango.FontDescription desc, Pango.Language language);
        }
-       [CCode (cheader_filename = "pango/pango.h", copy_function = "g_boxed_copy", free_function = "g_boxed_free", type_id = "pango_font_metrics_get_type ()")]
+       [CCode (cheader_filename = "pango/pango.h", ref_function = "pango_font_metrics_ref", type_id = "pango_font_metrics_get_type ()", unref_function = "pango_font_metrics_unref")]
        [Compact]
        public class FontMetrics {
                public int get_approximate_char_width ();
@@ -406,7 +406,7 @@ namespace Pango {
                public bool next_line ();
                public bool next_run ();
        }
-       [CCode (cheader_filename = "pango/pango.h", copy_function = "g_boxed_copy", free_function = "g_boxed_free", type_id = "pango_layout_line_get_type ()")]
+       [CCode (cheader_filename = "pango/pango.h", ref_function = "pango_layout_line_ref", type_id = "pango_layout_line_get_type ()", unref_function = "pango_layout_line_unref")]
        [Compact]
        public class LayoutLine {
                public uint is_paragraph_start;
index c6d9c1187a40117252e3a78241bf9ac230c59a74..ef88f8d52aab8cb0910864e06569e70396b76340 100644 (file)
@@ -56,8 +56,9 @@ namespace Rest {
                [CCode (has_construct_function = false)]
                protected OAuthProxyCall ();
                public void parse_token_reponse ();
+               public void parse_token_response ();
        }
-       [CCode (cheader_filename = "rest/rest-param.h", copy_function = "g_boxed_copy", free_function = "g_boxed_free", type_id = "rest_param_get_type ()")]
+       [CCode (cheader_filename = "rest/rest-param.h", ref_function = "rest_param_ref", type_id = "rest_param_get_type ()", unref_function = "rest_param_unref")]
        [Compact]
        public class Param {
                [CCode (has_construct_function = false)]
@@ -160,7 +161,7 @@ namespace Rest {
                [NoAccessorMethod]
                public Rest.Proxy proxy { owned get; construct; }
        }
-       [CCode (cheader_filename = "rest/rest-xml-node.h", copy_function = "g_boxed_copy", free_function = "g_boxed_free", type_id = "rest_xml_node_get_type ()")]
+       [CCode (cheader_filename = "rest/rest-xml-node.h", ref_function = "rest_xml_node_ref", type_id = "rest_xml_node_get_type ()", unref_function = "rest_xml_node_unref")]
        [Compact]
        public class XmlNode {
                public weak GLib.HashTable<void*,void*> attrs;
@@ -242,7 +243,7 @@ namespace Rest {
                HTTP_HTTP_VERSION_NOT_SUPPORTED;
                public static GLib.Quark quark ();
        }
-       [CCode (cheader_filename = "rest/oauth-proxy.h", cname = "OAuthProxyAuthCallback", instance_pos = 3.9)]
+       [CCode (cheader_filename = "rest/oauth-proxy.h", instance_pos = 3.9)]
        public delegate void OAuthProxyAuthCallback (Rest.OAuthProxy proxy, GLib.Error? error, GLib.Object? weak_object);
        [CCode (cheader_filename = "rest/rest-proxy-call.h", instance_pos = 3.9)]
        public delegate void ProxyCallAsyncCallback (Rest.ProxyCall call, GLib.Error? error, GLib.Object? weak_object);