I've wrapped the last two callbacks in the ra callbacks
structure, but the progress wrapper has some problem. If I use
make_ob_pool as for the other ra callbacks, I get a segfault.
According to gdb, pool is NULL, but I verified it is not by
adding a test block that apr_pstrdups and prints a string. I
can't figure out what's wrong.
[[[
Finish wrapping svn_ra_callbacks2_t.
* subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c
(ra_callbacks_progress_func): New callback wrapper.
(ra_callbacks_cancel_func): New callback wrapper using
svn_swig_py_cancel_func.
(svn_swig_py_setup_ra_callbacks): Setup progress and cancel callbacks.
]]]
Index: swigutil_py.c
===================================================================
--- swigutil_py.c (revision 26021)
+++ swigutil_py.c (working copy)
@@ -2860,6 +2860,63 @@
return err;
}
+/* svn_ra_callbacks_t */
+static void
+ra_callbacks_progress_func(apr_off_t progress,
+ apr_off_t total,
+ void *baton,
+ apr_pool_t *pool)
+{
+ PyObject *callbacks = (PyObject *)baton;
+ PyObject *py_callback, *result;
+
+ svn_swig_py_acquire_py_lock();
+
+ py_callback = PyObject_GetAttrString(callbacks,
+ (char *)"progress_func");
+ if (py_callback == NULL)
+ {
+ /* Ouch, no way to pass on exceptions! */
+ /* err = callback_exception_error(); */
+ goto finished;
+ }
+ else if (py_callback == Py_None)
+ {
+ goto finished;
+ }
+
+ if ((result = PyObject_CallFunction(py_callback,
+ (char *)"ll", progress, total)) == NULL)
+/* Why does this segfault? */
+/* (char *)"llO&", progress, total, */
+/* make_ob_pool, pool)) == NULL) */
+ {
+ /* Ouch, no way to pass on exceptions! */
+ /* err = callback_exception_error(); */
+ }
+
+ Py_XDECREF(result);
+finished:
+ Py_XDECREF(py_callback);
+ svn_swig_py_release_py_lock();
+ /* Sure hope nothing went wrong... */
+ /* return err; */
+}
+
+/* svn_ra_callbacks_t */
+static svn_error_t *
+ra_callbacks_cancel_func(void *baton)
+{
+ PyObject *callbacks = (PyObject *)baton;
+ PyObject *py_callback;
+
+ svn_swig_py_acquire_py_lock();
+ py_callback = PyObject_GetAttrString(callbacks,
+ (char *)"cancel_func");
+ svn_swig_py_release_py_lock();
+ return svn_swig_py_cancel_func(py_callback);
+}
+
void
svn_swig_py_setup_ra_callbacks(svn_ra_callbacks2_t **callbacks,
void **baton,
@@ -2895,6 +2952,9 @@
(*callbacks)->set_wc_prop = ra_callbacks_set_wc_prop;
(*callbacks)->push_wc_prop = ra_callbacks_push_wc_prop;
(*callbacks)->invalidate_wc_props = ra_callbacks_invalidate_wc_props;
+ (*callbacks)->progress_func = ra_callbacks_progress_func;
+ (*callbacks)->progress_baton = py_callbacks;
+ (*callbacks)->cancel_func = ra_callbacks_cancel_func;
*baton = py_callbacks;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed Aug 15 20:29:25 2007