~svn/ubuntu/oneiric/subversion/ppa

« back to all changes in this revision

Viewing changes to subversion/bindings/swig/python/README

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-12-05 01:26:14 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051205012614-qom4xfypgtsqc2xq
Tags: 1.2.3dfsg1-3ubuntu1
Merge with the final Debian release of 1.2.3dfsg1-3, bringing in
fixes to the clean target, better documentation of the libdb4.3
upgrade and build fixes to work with swig1.3_1.3.27.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
                                -*- text -*-
 
2
 
 
3
TRANSLATING PARAMETER LISTS
 
4
 
 
5
   The argument-reductions laws of the SWIG bindings something go like
 
6
   this:
 
7
   
 
8
     - Python functions don't return errors.  They throw exceptions.
 
9
       Which means that...
 
10
   
 
11
     - ...Python functions will return the "other" stuff that the C
 
12
       functions "return" instead.  C functions which populate
 
13
       pointers with new data (you know, values that are returned to
 
14
       the caller, but not as "return values") will return those
 
15
       values directly in Python.  So:
 
16
   
 
17
          error = foo (object **returned_obj, int blah);
 
18
   
 
19
       becomes:
 
20
   
 
21
          try:
 
22
              returned_obj = foo (blah)
 
23
          except:
 
24
              # handle it
 
25
   
 
26
     - Callback function/baton pairs get reduced to just callback
 
27
       functions, and the benefit you get from batons is gotten
 
28
       instead through Python default arguments:
 
29
   
 
30
          error = foo (callback_t function, void *baton);
 
31
   
 
32
       becomes:
 
33
   
 
34
          try:
 
35
              def function(callback_arg1, ..., userdata1=whatever, ...):
 
36
                  # do stuff here
 
37
              foo(function)
 
38
          except:
 
39
              # handle it