[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Python/swig bindings.

From: C. Michael Pilato <cmpilato_at_collab.net>
Date: 2004-10-01 18:21:55 CEST

Douglas Waer <douglas.m.waer@boeing.com> writes:

> I'm trying to create some Python scripts, and I'm having some trouble
> figuring out what the parameter lists to the calls should be. For example,
> in svn_client.h, svn_client_status shows 11 parameters, but the python call
> only requires 9. Is there some resource, header file, or document that I'm
> just overlooking to figure out the parameters?

The argument-reductions laws of the SWIG bindings go like this:

   1. Python functions don't return errors. They throw exceptions.
       Which means that...

   2. ...Python functions will return the "other" stuff that the C
       functions "return" instead. C functions which populate
       pointers with new data (you know, values that are returned to
       the caller, but not as "return values") will return those
       values directly in Python. So:

          error = foo (object **returned_obj, int blah);

       becomes:

          try:
              returned_obj = foo (blah)
          except:
              # handle it

   3. Callback function/baton pairs get reduced to just callback
       functions, and the benefit you get from batons is gotten
       instead through Python default arguments:

          error = foo (callback_t function, void *baton);

       becomes:

          try:
              def function(callback_arg1, ..., userdata1=whatever, ...):
                  # do stuff here
              foo(function)
          except:
              # handle it

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri Oct 1 18:24:01 2004

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.