After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 685231 - [gstreamer] Cannot use Gst.Iterator.find_custom
[gstreamer] Cannot use Gst.Iterator.find_custom
Status: RESOLVED OBSOLETE
Product: vala
Classification: Core
Component: Bindings: GTK+ GStreamer WebKitGTK+
0.20.x
Other Linux
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2012-10-01 17:18 UTC by Sebastian Pölsterl
Modified: 2018-05-22 14:30 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Test case (467 bytes, text/x-vala)
2012-10-01 17:18 UTC, Sebastian Pölsterl
  Details
Unhide user_data of Iterator.find_custom (1.70 KB, patch)
2013-08-04 07:24 UTC, Rico Tzschichholz
none Details | Review
Fix Iterator.find_custom (2.62 KB, patch)
2013-08-14 14:29 UTC, Rico Tzschichholz
none Details | Review

Description Sebastian Pölsterl 2012-10-01 17:18:42 UTC
Created attachment 225514 [details]
Test case

The attached Vala code does not cause errors by valac, however when compiling the generated C code I get:

gsttest.vala.c:94:2: error: too few arguments to function 'gst_iterator_find_custom'
In file included from /opt/gnome3/include/gstreamer-1.0/gst/gstformat.h:30:0,
                 from /opt/gnome3/include/gstreamer-1.0/gst/gstevent.h:175,
                 from /opt/gnome3/include/gstreamer-1.0/gst/gstpadtemplate.h:36,
                 from /opt/gnome3/include/gstreamer-1.0/gst/gstpad.h:68,
                 from /opt/gnome3/include/gstreamer-1.0/gst/gstelement.h:57,
                 from /opt/gnome3/include/gstreamer-1.0/gst/gstbin.h:27,
                 from /opt/gnome3/include/gstreamer-1.0/gst/gst.h:34,
                 from /home/sebp/src/gnome/gnome-dvb-daemon/gsttest.vala.c:7:
/opt/gnome3/include/gstreamer-1.0/gst/gstiterator.h:268:25: note: declared here
error: cc exited with status 256

Looking at the C code it is obvious that the user_data parameter is missing (see http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/gstreamer-GstIterator.html#gst-iterator-find-custom)
Comment 1 Jürg Billeter 2012-11-14 16:47:07 UTC
Gst.Iterator should be converted to a generic class just like it was done for GStreamer 0.10. The `user_data` parameter of gst_iterator_find_custom should be a regular parameter (of generic type) and not be treated as closure. A `user_data` parameter doesn't make any sense with GCompareFunc.
Comment 2 Sebastian Pölsterl 2013-03-16 17:12:55 UTC
Can't we just copy the relevant parts from gstreamer-0.10.metadata to Gst-1.0.metadata?
Comment 3 Sebastian Pölsterl 2013-07-18 17:25:02 UTC
Was there any progress on this issue? AFAICT, the issue still persists with current master.
Comment 4 Rico Tzschichholz 2013-08-04 07:24:06 UTC
Created attachment 250784 [details] [review]
Unhide user_data of Iterator.find_custom
Comment 5 Luca Bruno 2013-08-04 07:27:17 UTC
Is it possible to use CompareDataFunc with a [CCode (type = "GCompareFunc")]?
Comment 6 Rico Tzschichholz 2013-08-04 07:36:59 UTC
No, this API is pretty weird and the GCompareFunc is not used as such. The func is not called inside "Iterator.find_custom", but wrapped inside a FindCustomFoldData struct and passed to "Iterator.fold".

So GCompareFunc is indirectly used as "int func (void* element, void* user_data)"

http://cgit.freedesktop.org/gstreamer/gstreamer/tree/gst/gstiterator.c?h=1.0#n715
Comment 7 Evan Nemerson 2013-08-11 20:58:33 UTC
I'm thinking we should create an alternate binding for GLib.CompareFunc (SearchFunc maybe?) which takes two type parameters, and use that here.  Something along the lines of:


[CCode (cname = "GCompareFunc", has_target = false)]
public delegate int SearchFunc<A,B> (A a, B b);

public class Iterator {
  [CCode (simple_generics = true)]
  public bool find_custom<T> (CompareFunc<GLib.Value?,T> func, out GLib.Value elem, T user_data);
}


I'd have to look at the source, but maybe elem should be unowned?  The documentation isn't really clear.
Comment 8 Maciej (Matthew) Piechotka 2013-08-14 12:10:44 UTC
(In reply to comment #7)
> I'm thinking we should create an alternate binding for GLib.CompareFunc
> (SearchFunc maybe?) which takes two type parameters, and use that here. 
> Something along the lines of:
> 
> 
> [CCode (cname = "GCompareFunc", has_target = false)]
> public delegate int SearchFunc<A,B> (A a, B b);
> 
> public class Iterator {
>   [CCode (simple_generics = true)]
>   public bool find_custom<T> (CompareFunc<GLib.Value?,T> func, out GLib.Value
> elem, T user_data);
> }
> 
> 
> I'd have to look at the source, but maybe elem should be unowned?  The
> documentation isn't really clear.

Wouldn't something like:

[CCode (cname = "GCompareFunc")]
public delegate int SearchFunc<A> (A a);

public class Iterator {
  public bool find_custom ([CCode (target_pos = -1)] SearchFunc<GLib.Value?> func, out GLib.Value elem);
}

Make more sense?
Comment 9 Luca Bruno 2013-08-14 12:44:27 UTC
Yes that's interesting as well as it allows for the use of closures. I'm for it as long as Evan and Rico don't find any problem.
Comment 10 Rico Tzschichholz 2013-08-14 14:29:05 UTC
Created attachment 251616 [details] [review]
Fix Iterator.find_custom
Comment 11 Sebastian Pölsterl 2013-10-12 20:31:14 UTC
I can confirm that the patch in comment 10 fixes this issue. I would highly appreciate if this patch could be committed to master and be part of the next release.
Comment 12 Luca Bruno 2013-12-20 16:36:35 UTC
(In reply to comment #11)
> I can confirm that the patch in comment 10 fixes this issue. I would highly
> appreciate if this patch could be committed to master and be part of the next
> release.

I'm more interested in comment #8, would that work for you?
Comment 13 Michael 'Mickey' Lauer 2018-02-21 10:14:00 UTC
Sebastian, rev 6296d34707d0053919d9496b5cf6c50149fea702 has a hunk with regards to this. Does this already fix the problem or there still something to do?
Comment 14 GNOME Infrastructure Team 2018-05-22 14:30:15 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/vala/issues/321.