]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
gstreamer-1.0: fix functions which return floating references
authorEvan Nemerson <evan@coeus-group.com>
Sat, 12 Oct 2013 05:00:11 +0000 (22:00 -0700)
committerEvan Nemerson <evan@coeus-group.com>
Sat, 12 Oct 2013 05:00:11 +0000 (22:00 -0700)
GStreamer uses the (transfer floating) annotation for these, which
g-i recognizes as an alias for (transfer none), therefore there is
no way to pick them up in vapigen.

vala/valagirparser.vala
vapi/gstreamer-1.0.vapi
vapi/metadata/Gst-1.0.metadata

index 4fb2e9a4bca6466922b26a2702d1317cce60badb..5fab592a8de34f6fd221dc074045085b4d1e1d25 100644 (file)
@@ -2863,6 +2863,10 @@ public class Vala.GirParser : CodeVisitor {
                        } else if (symbol_type == "function") {
                                m.binding = MemberBinding.STATIC;
                        }
+                       if (metadata.has_argument (ArgumentType.FLOATING)) {
+                               m.returns_floating_reference = metadata.get_bool (ArgumentType.FLOATING);
+                               m.return_type.value_owned = true;
+                       }
                }
 
                if (s is Method && !(s is CreationMethod)) {
@@ -2878,9 +2882,6 @@ public class Vala.GirParser : CodeVisitor {
                                method.set_attribute_string ("CCode", "vfunc_name", metadata.get_string (ArgumentType.VFUNC_NAME));
                                method.is_virtual = true;
                        }
-                       if (metadata.has_argument (ArgumentType.FLOATING)) {
-                               method.returns_floating_reference = metadata.get_bool (ArgumentType.FLOATING);
-                       }
                }
 
                if (!(metadata.get_expression (ArgumentType.THROWS) is NullLiteral)) {
index bc30e2ba1ae88cea4752c5f801b2ba3a64d3e943..ea5c6698a78c8bc544dfe4a0d89c6f4952f0fc5d 100644 (file)
@@ -509,7 +509,7 @@ namespace Gst {
                public bool polling;
                public Gst.Clock provided_clock;
                public bool state_dirty;
-               [CCode (has_construct_function = false, type = "GstElement*")]
+               [CCode (has_construct_function = false, returns_floating_reference = true, type = "GstElement*")]
                public Bin (string name);
                public bool add (owned Gst.Element element);
                [NoWrapper]
@@ -892,7 +892,8 @@ namespace Gst {
                public bool link_pads (string? srcpadname, Gst.Element dest, string? destpadname, Gst.PadLinkCheck flags = Gst.PadLinkCheck.DEFAULT);
                public bool link_pads_filtered (string? srcpadname, Gst.Element dest, string? destpadname, Gst.Caps? filter);
                public void lost_state ();
-               public static unowned Gst.Element make_from_uri (Gst.URIType type, string uri, string? elementname) throws GLib.Error;
+               [CCode (returns_floating_reference = true)]
+               public static Gst.Element make_from_uri (Gst.URIType type, string uri, string? elementname) throws GLib.Error;
                public void message_full (Gst.MessageType type, GLib.Quark domain, int code, owned string? text, owned string? debug, string file, string function, int line);
                public virtual bool post_message (owned Gst.Message message);
                public virtual Gst.Clock provide_clock ();
@@ -939,7 +940,8 @@ namespace Gst {
                public bool can_sink_any_caps (Gst.Caps caps);
                public bool can_src_all_caps (Gst.Caps caps);
                public bool can_src_any_caps (Gst.Caps caps);
-               public unowned Gst.Element create (string? name);
+               [CCode (returns_floating_reference = true)]
+               public Gst.Element create (string? name);
                public static Gst.ElementFactory find (string name);
                public GLib.Type get_element_type ();
                public unowned string get_metadata (string key);
@@ -954,7 +956,8 @@ namespace Gst {
                public static GLib.List<Gst.ElementFactory> list_filter (GLib.List<Gst.ElementFactory> list, Gst.Caps caps, Gst.PadDirection direction, bool subsetonly);
                public static GLib.List<Gst.ElementFactory> list_get_elements (Gst.ElementFactoryListType type, Gst.Rank minrank);
                public bool list_is_type (Gst.ElementFactoryListType type);
-               public static unowned Gst.Element make (string factoryname, string? name);
+               [CCode (returns_floating_reference = true)]
+               public static Gst.Element make (string factoryname, string? name);
        }
        [CCode (cheader_filename = "gst/gst.h", ref_function = "gst_event_ref", type_id = "gst_event_get_type ()", unref_function = "gst_event_unref")]
        [Compact]
@@ -1036,7 +1039,7 @@ namespace Gst {
        }
        [CCode (cheader_filename = "gst/gst.h", type_id = "gst_ghost_pad_get_type ()")]
        public class GhostPad : Gst.ProxyPad {
-               [CCode (has_construct_function = false, type = "GstPad*")]
+               [CCode (has_construct_function = false, returns_floating_reference = true, type = "GstPad*")]
                public GhostPad (string? name, Gst.Pad target);
                public static bool activate_mode_default (Gst.Pad pad, Gst.Object? parent, Gst.PadMode mode, bool active);
                public bool @construct ();
@@ -1266,7 +1269,7 @@ namespace Gst {
        public class Pad : Gst.Object {
                public void* element_private;
                public weak Gst.PadTemplate padtemplate;
-               [CCode (has_construct_function = false)]
+               [CCode (has_construct_function = false, returns_floating_reference = true)]
                public Pad (string name, Gst.PadDirection direction);
                public bool activate_mode (Gst.PadMode mode, bool active);
                public ulong add_probe (Gst.PadProbeType mask, owned Gst.PadProbeCallback callback);
@@ -1363,7 +1366,7 @@ namespace Gst {
        }
        [CCode (cheader_filename = "gst/gst.h", type_id = "gst_pad_template_get_type ()")]
        public class PadTemplate : Gst.Object {
-               [CCode (has_construct_function = false)]
+               [CCode (has_construct_function = false, returns_floating_reference = true)]
                public PadTemplate (string name_template, Gst.PadDirection direction, Gst.PadPresence presence, Gst.Caps caps);
                public Gst.Caps get_caps ();
                public Gst.Caps caps { owned get; construct; }
@@ -1394,7 +1397,7 @@ namespace Gst {
        public class Pipeline : Gst.Bin, Gst.ChildProxy {
                public weak Gst.Clock fixed_clock;
                public Gst.ClockTime stream_time;
-               [CCode (has_construct_function = false, type = "GstElement*")]
+               [CCode (has_construct_function = false, returns_floating_reference = true, type = "GstElement*")]
                public Pipeline (string? name);
                public void auto_clock ();
                public bool get_auto_flush_bus ();
@@ -2995,9 +2998,9 @@ namespace Gst {
        public static bool is_initialized ();
        [CCode (cheader_filename = "gst/gst.h")]
        public static GLib.ParamSpec param_spec_fraction (string name, string nick, string blurb, int min_num, int min_denom, int max_num, int max_denom, int default_num, int default_denom, GLib.ParamFlags flags);
-       [CCode (cheader_filename = "gst/gst.h", cname = "gst_parse_bin_from_description_full")]
+       [CCode (cheader_filename = "gst/gst.h", cname = "gst_parse_bin_from_description_full", returns_floating_reference = true)]
        public static Gst.Bin parse_bin_from_description (string bin_description, bool ghost_unlinked_pads, Gst.ParseContext? context = null, Gst.ParseFlags flags = Gst.ParseFlags.NONE) throws GLib.Error;
-       [CCode (cheader_filename = "gst/gst.h", cname = "gst_parse_launch_full")]
+       [CCode (cheader_filename = "gst/gst.h", cname = "gst_parse_launch_full", returns_floating_reference = true)]
        public static Gst.Element parse_launch (string pipeline_description, Gst.ParseContext? context = null, Gst.ParseFlags flags = Gst.ParseFlags.NONE) throws GLib.Error;
        [CCode (cheader_filename = "gst/gst.h", cname = "gst_parse_launchv_full")]
        public static Gst.Element parse_launchv ([CCode (array_length = false, array_null_terminated = true)] string[] argv, Gst.ParseContext? context = null, Gst.ParseFlags flags = Gst.ParseFlags.NONE) throws GLib.Error;
index cdf212d8dde9001461f42cfc8ac08cf896374cc2..04306f153bd66220bfab890d09a8f8b0bacd273f 100644 (file)
@@ -79,6 +79,19 @@ parse_launch_full name="parse_launch"
 parse_launchv skip
 parse_launchv_full name="parse_launchv"
 
+// Floating references (bug #657202)
+parse_bin_from_description_full floating
+PadTemplate.new floating
+Element.make_from_uri floating
+GhostPad.new floating
+Pipeline.new floating
+Pad.new floating
+ElementFactory
+  .create floating
+  .make floating
+Bin.new floating
+parse_launch_full floating
+
 // Default values
 Bus
   .add_signal_watch_full.priority default=GLib.Priority.DEFAULT