diff options
Diffstat (limited to 'subversion/bindings/swig/svn_delta.i')
-rw-r--r-- | subversion/bindings/swig/svn_delta.i | 80 |
1 files changed, 33 insertions, 47 deletions
diff --git a/subversion/bindings/swig/svn_delta.i b/subversion/bindings/swig/svn_delta.i index 6e9d306..ddcd714 100644 --- a/subversion/bindings/swig/svn_delta.i +++ b/subversion/bindings/swig/svn_delta.i @@ -174,61 +174,47 @@ svn_txdelta_window_t_ops_get(svn_txdelta_window_t *window) #ifdef SWIGPYTHON %ignore svn_txdelta_window_t::ops; -%inline %{ -static PyObject * -svn_txdelta_window_t_ops_get(PyObject *window_ob) +%extend svn_txdelta_window_t { + +void _ops_get(int *num_ops, svn_txdelta_op_t **ops) { - void *window; - PyObject *ops_list, *window_pool; - int status; - - /* Kludge alert! - Normally, these kinds of conversions would belong in a typemap. - However, typemaps won't allow us to change the result type to an array, - so we have to make this custom accessor function. - A cleaner approach would be to use something like: - - %extend svn_txdelta_window_t { void get_ops(apr_array_header_t ** ops); } - - But that means unnecessary copying, plus more hacks to get the pool for the - array and for wrapping the individual op objects. So we just don't bother. - */ + *num_ops = self->num_ops; + *ops = self->ops; +} + +%pythoncode { + ops = property(_ops_get) +} +} + +%typemap(argout) (int *num_ops, svn_txdelta_op_t **ops) { + apr_pool_t *parent_pool; + PyObject *parent_py_pool; + PyObject *ops_list; - /* Note: the standard svn-python typemap releases the GIL while calling the - wrapped function, but this function does Python stuff, so we have to - reacquire it again. */ - svn_swig_py_acquire_py_lock(); - status = svn_swig_ConvertPtr(window_ob, &window, - SWIG_TypeQuery("svn_txdelta_window_t *")); - - if (status != 0) - { - PyErr_SetString(PyExc_TypeError, - "expected an svn_txdelta_window_t* proxy"); - svn_swig_py_release_py_lock(); - return NULL; - } - - window_pool = PyObject_GetAttrString(window_ob, "_parent_pool"); - - if (window_pool == NULL) - { - svn_swig_py_release_py_lock(); - return NULL; - } - - ops_list = svn_swig_py_txdelta_window_t_ops_get(window, - SWIG_TypeQuery("svn_txdelta_op_t *"), window_pool); - - svn_swig_py_release_py_lock(); + if (svn_swig_py_get_parent_pool(args, $descriptor(apr_pool_t *), + &parent_py_pool, &parent_pool)) + SWIG_fail; - return ops_list; + ops_list = svn_swig_py_convert_txdelta_op_c_array(*$1, *$2, + $descriptor(svn_txdelta_op_t *), parent_py_pool); + + if (!ops_list) SWIG_fail; + + %append_output(ops_list); } -%} #endif %include svn_delta_h.swg +#ifdef SWIGPYTHON +%pythoncode { +# This function is for backwards compatibility only. +# Use svn_txdelta_window_t.ops instead. +svn_txdelta_window_t_ops_get = svn_txdelta_window_t._ops_get +} +#endif + #ifdef SWIGRUBY %inline %{ static VALUE |