[BangPypers] teach me SWIG

Carl Karsten carl at personnelware.com
Mon Sep 14 21:53:01 CEST 2009

On Mon, Sep 14, 2009 at 1:55 PM, Gora Mohanty <gora at srijan.in> wrote:
> On Tue, 15 Sep 2009 00:04:01 +0530
> bhaskar jain <bhaskar.jain2002 at gmail.com> wrote:
> [...]
>> Problem is that there was a bug and they have changed a few lines
>> in one of the C files. So my question is - will just applying the
>> patch and installing the library again, will i get a fresh good
>> python binding or do i need to regenerate the wrapper_ *.c files
>> using SWIG.
> It depends on what was changed, but it is best to regenerate
> everything. Is this that much of a concern in terms of time,
> etc. It is quite easy to set up a Makefile to do this.
>> Any tips in working with SWIG, using the python bindings will be
>> appreciated. Also is it a frequent problem of segmentation faults
>> using the python bindings of C programs which employ lot of
>> pointers. Sorry, I am new to SWIG.
>> Is it advisable to use SWIG at all?
> [...]
> I would enthusiastically advocate SWIG, but have had arguments with
> people who take a different view, and whose opinions I respect. The
> best counter-arguments I have heard is cleanness of the generated
> code, and efficiency, but at least for a non-pedal-to-the-metal
> coder like me, SWIG definitely does the job. So, I would say that
> if you can take a look at the generated SWIG code, and think that
> you can do better, please do that, and contribute your approach
> back to SWIG.

This is really "do this for me" but the hope is that it is easy and I
will learn how it was done and can later expand on it myself.

I need to read the time stamp from the first and last frame of a .dv
file.   frames are 120000 bytes (or some fixed amount if it is some
other format that has a different frame size), so I can do
frame=open('foo.dv','rb').read(120000) and pass frame somewhere.  or
pass a file object, or whatever binding stuff is easiest to implement.

libdv can do it, here are bindings, but it doesn't include anything to
return the timestamp :

Here is where dvgrab does it - line 836


I don't need any of the "if invalid month, use system date".

Carl K

More information about the BangPypers mailing list