5
5
The argument-reductions laws of the SWIG bindings something go like
8
- The module prefix can be omitted. o:
10
void *some_C_function = svn_client_foo;
17
However, the following two alternatives also work:
19
# Fully-qualified C name
21
func = svn.client.svn_client_foo
23
# Star-import imports just svn_* names, not bare 'foo' names.
24
from svn.client import *
8
27
- Python functions don't return errors. They throw exceptions.
13
32
pointers with new data (you know, values that are returned to
14
33
the caller, but not as "return values") will return those
15
34
values directly in Python. So:
17
error = foo (object **returned_obj, int blah);
36
object_t *returned_obj;
37
SVN_ERR(svn_client_foo(&returned_obj, blah));
41
returned_obj = svn.client.foo(blah)
45
err = svn_client_foo(&returned_obj, blah);
46
if (err && err->apr_err == SVN_ERR_...)
22
returned_obj = foo (blah)
52
returned_obj = svn.client.foo(blah)
26
56
- Callback function/baton pairs get reduced to just callback
27
57
functions, and the benefit you get from batons is gotten
28
instead through Python default arguments:
30
error = foo (callback_t function, void *baton);
58
instead through defining the callback function locally and
59
passing the 'baton' data in through Python default arguments. So:
61
struct baton_t { userdata1, ... };
63
svn_error_t *cb_func(cb_arg1, ..., void *baton)
66
/* do stuff here with b->userdata1... etc. */
71
baton_t *b = { whatever, ... };
72
error = svn_client_foo(cb_func, b);
35
def function(callback_arg1, ..., userdata1=whatever, ...):
77
def cb_func(cb_arg1, ..., userdata1=whatever, ...):
78
# do stuff here with userdata1 etc.
79
svn.client.foo(cb_func)