[gst-devel] event system

David I. Lehn dlehn at vt.edu
Wed Jun 20 19:12:58 CEST 2001


* Thomas Nyberg <thomas at codefactory.se> [20010615 02:22]:
> On Thu, Jun 14, 2001 at 05:31:41PM -0400, David I. Lehn wrote:
> > > A little example of a possible API to send events:
> > > 
> > >   GstEvent *ev = gst_event_new (GST_EVENT_SEEK);
> > >   GST_EVENT_SEEK_TYPE (ev) = GST_EVENT_SEEK_OFFSET; 
> > >   GST_EVENT_SEEK_POSITION (ev) = 1000; 
> > > 
> > 
> > Is there some reason for this ugly spelling?  GstBuffer has it too and I
> > still don't know why.  It's more uniform and exactly the same to write
> > it functional like everything else:
> > 
> > gst_event_set_seek_type(ev, GST_EVENT_SEEK_OFFSET);
> > gst_event_set_seek_position(ev, 1000);
> > 
> > and associated:
> > 
> > aType = gst_event_seek_type(ev);
> > aPostion = gst_event_seek_position(ev);
> > 
> > I think all the GST_BUFFER_* macros should change to look like this too.
> > Any reason not to do this?
> >
> 
> Since they are macros, i.e. #define MY_MACRO - it is common to denote
> them by capital letters. Then it is easier to tell them apart from real
> functions. Changing all of these would be really bad, IMO.
> 

Users should be concerned with the interface not the implementation.

Why do you want to tell them apart?  What if we decide we need to change
one of these macros to a function?  (ie to add parameter checking or
whatever)  In my opinion the interface should be uniform, not some mix
of struct macro accessorish hacks and real functions.  Certainly there
are places to use MACRO_SYNTAX() but this isn't it IMHO.  glib.h style
would seem to agree for the most part.  There are many function-looking
macros in there.  I'm sure someone could come up with a more technical
discussion about how evaluating FOO(bar) shouldn't return an lvalue that
you assign to.  non-intuitive compared to most code.  I've also never
seen this style used before... confused me first time I saw it.

I'm sure sed-master-omega could switch the whole source tree in 1 line
or less. ;)

-dave
-- 
David I. Lehn <dlehn at vt.edu>  | http://www.lehn.org/~dlehn/
Computer Engineering Graduate @ Virginia Tech in sunny Blacksburg, VA




More information about the gstreamer-devel mailing list