diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-08-05 16:22:51 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-08-05 16:22:51 +0000 |
commit | cf46733632c7279a9fd0fe6ce26f9185a4ae82a9 (patch) | |
tree | da27775a2161723ef342e91af41a8b51fedef405 /subversion/bindings/swig/python/libsvn_swig_py | |
parent | bb0ef45f7c46b0ae221b26265ef98a768c33f820 (diff) | |
download | subversion-tarball-master.tar.gz |
subversion-1.9.7HEADsubversion-1.9.7master
Diffstat (limited to 'subversion/bindings/swig/python/libsvn_swig_py')
-rw-r--r-- | subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c | 572 | ||||
-rw-r--r-- | subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.h | 105 |
2 files changed, 513 insertions, 164 deletions
diff --git a/subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c b/subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c index 1dbdc1b..af22424 100644 --- a/subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c +++ b/subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c @@ -93,7 +93,7 @@ void svn_swig_py_release_py_lock(void) if (_saved_thread_key == NULL) { /* Obviously, creating a top-level pool for this is pretty stupid. */ - apr_pool_create(&_saved_thread_pool, NULL); + _saved_thread_pool = svn_pool_create(NULL); apr_threadkey_private_create(&_saved_thread_key, NULL, _saved_thread_pool); } @@ -152,7 +152,7 @@ int svn_swig_py_get_pool_arg(PyObject *args, swig_type_info *type, PyObject *input = PyTuple_GET_ITEM(args, argnum); if (input != Py_None && PyObject_HasAttrString(input, markValid)) { - *pool = svn_swig_MustGetPtr(input, type, argnum+1); + *pool = svn_swig_py_must_get_ptr(input, type, argnum+1); if (*pool == NULL) return 1; *py_pool = input; @@ -163,7 +163,7 @@ int svn_swig_py_get_pool_arg(PyObject *args, swig_type_info *type, /* We couldn't find a pool argument, so we'll create a subpool */ *pool = svn_pool_create(application_pool); - *py_pool = svn_swig_NewPointerObj(*pool, type, application_py_pool, + *py_pool = svn_swig_py_new_pointer_obj(*pool, type, application_py_pool, NULL); if (*py_pool == NULL) return 1; @@ -190,7 +190,7 @@ int svn_swig_py_get_parent_pool(PyObject *args, swig_type_info *type, Py_DECREF(*py_pool); - *pool = svn_swig_MustGetPtr(*py_pool, type, 1); + *pool = svn_swig_py_must_get_ptr(*py_pool, type, 1); if (*pool == NULL) return 1; @@ -245,8 +245,8 @@ static int proxy_set_pool(PyObject **proxy, PyObject *pool) #define svn_swig_TypeQuery(x) SWIG_TypeQuery(x) /** Wrapper for SWIG_NewPointerObj */ -PyObject *svn_swig_NewPointerObj(void *obj, swig_type_info *type, - PyObject *pool, PyObject *args) +PyObject *svn_swig_py_new_pointer_obj(void *obj, swig_type_info *type, + PyObject *pool, PyObject *args) { PyObject *proxy = SWIG_NewPointerObj(obj, type, 0); @@ -270,7 +270,7 @@ PyObject *svn_swig_NewPointerObj(void *obj, swig_type_info *type, return proxy; } -/** svn_swig_NewPointerObj, except a string is used to describe the type */ +/** svn_swig_py_new_pointer_obj, except a string is used to describe the type */ static PyObject *svn_swig_NewPointerObjString(void *ptr, const char *type, PyObject *py_pool) { @@ -282,11 +282,11 @@ static PyObject *svn_swig_NewPointerObjString(void *ptr, const char *type, } /* ### cache the swig_type_info at some point? */ - return svn_swig_NewPointerObj(ptr, typeinfo, py_pool, NULL); + return svn_swig_py_new_pointer_obj(ptr, typeinfo, py_pool, NULL); } /** Wrapper for SWIG_ConvertPtr */ -int svn_swig_ConvertPtr(PyObject *input, void **obj, swig_type_info *type) +int svn_swig_py_convert_ptr(PyObject *input, void **obj, swig_type_info *type) { if (PyObject_HasAttrString(input, assertValid)) { @@ -310,11 +310,11 @@ int svn_swig_ConvertPtr(PyObject *input, void **obj, swig_type_info *type) static int svn_swig_ConvertPtrString(PyObject *input, void **obj, const char *type) { - return svn_swig_ConvertPtr(input, obj, svn_swig_TypeQuery(type)); + return svn_swig_py_convert_ptr(input, obj, svn_swig_TypeQuery(type)); } /** Wrapper for SWIG_MustGetPtr */ -void *svn_swig_MustGetPtr(void *input, swig_type_info *type, int argnum) +void *svn_swig_py_must_get_ptr(void *input, swig_type_info *type, int argnum) { if (PyObject_HasAttrString(input, assertValid)) { @@ -443,9 +443,9 @@ static PyObject *make_ob_pool(void *pool) * normally used for anything. It's just here for compatibility * with Subversion 1.2. */ apr_pool_t *new_pool = svn_pool_create(application_pool); - PyObject *new_py_pool = svn_swig_NewPointerObj(new_pool, + PyObject *new_py_pool = svn_swig_py_new_pointer_obj(new_pool, svn_swig_TypeQuery("apr_pool_t *"), application_py_pool, NULL); - (void) pool; /* Silence compiler warnings about unused parameter. */ + SVN_UNUSED(pool); return new_py_pool; } static PyObject *make_ob_fs_root(svn_fs_root_t *ptr, PyObject *py_pool) @@ -459,12 +459,20 @@ static PyObject *make_ob_wc_adm_access(void *adm_access) NULL); } +static PyObject *make_ob_error(svn_error_t *err) +{ + if (err) + return svn_swig_NewPointerObjString(err, "svn_error_t *", NULL); + else + Py_RETURN_NONE; +} + /***/ /* Conversion from Python single objects (not hashes/lists/etc.) to Subversion types. */ -static const char *make_string_from_ob(PyObject *ob, apr_pool_t *pool) +static char *make_string_from_ob(PyObject *ob, apr_pool_t *pool) { if (ob == Py_None) return NULL; @@ -534,7 +542,7 @@ static PyObject *convert_hash(apr_hash_t *hash, static PyObject *convert_to_swigtype(void *value, void *ctx, PyObject *py_pool) { /* ctx is a 'swig_type_info *' */ - return svn_swig_NewPointerObj(value, ctx, py_pool, NULL); + return svn_swig_py_new_pointer_obj(value, ctx, py_pool, NULL); } static PyObject *convert_svn_string_t(void *value, void *ctx, @@ -853,7 +861,7 @@ PyObject *svn_swig_py_convert_hash(apr_hash_t *hash, swig_type_info *type, static PyObject *make_ob_##type(void *value) \ { \ apr_pool_t *new_pool = svn_pool_create(application_pool); \ - PyObject *new_py_pool = svn_swig_NewPointerObj(new_pool, \ + PyObject *new_py_pool = svn_swig_py_new_pointer_obj(new_pool, \ svn_swig_TypeQuery("apr_pool_t *"), application_py_pool, NULL); \ svn_##type##_t *new_value = dup(value, new_pool); \ PyObject *obj = svn_swig_NewPointerObjString(new_value, "svn_" #type "_t *", \ @@ -1224,7 +1232,7 @@ apr_hash_t *svn_swig_py_struct_ptr_hash_from_dict(PyObject *dict, Py_DECREF(keys); return NULL; } - status = svn_swig_ConvertPtr(value, &struct_ptr, type); + status = svn_swig_py_convert_ptr(value, &struct_ptr, type); if (status != 0) { PyErr_SetString(PyExc_TypeError, @@ -1284,7 +1292,7 @@ svn_swig_py_unwrap_struct_ptr(PyObject *source, void **ptr_dest = destination; swig_type_info *type_descriptor = baton; - int status = svn_swig_ConvertPtr(source, ptr_dest, type_descriptor); + int status = svn_swig_py_convert_ptr(source, ptr_dest, type_descriptor); if (status != 0) { @@ -1417,62 +1425,62 @@ commit_item_array_to_list(const apr_array_header_t *array) } - + /*** Errors ***/ /* Convert a given SubversionException to an svn_error_t. On failure returns NULL and sets a Python exception. */ static svn_error_t *exception_to_error(PyObject * exc) { - const char *message, *file = NULL; - apr_status_t apr_err; - long line = 0; - PyObject *apr_err_ob = NULL, *child_ob = NULL, *message_ob = NULL; - PyObject *file_ob = NULL, *line_ob = NULL; + const char *message, *file = NULL; + apr_status_t apr_err; + long line = 0; + PyObject *apr_err_ob = NULL, *child_ob = NULL, *message_ob = NULL; + PyObject *file_ob = NULL, *line_ob = NULL; svn_error_t *rv = NULL, *child = NULL; - if ((apr_err_ob = PyObject_GetAttrString(exc, "apr_err")) == NULL) - goto finished; - apr_err = (apr_status_t) PyInt_AsLong(apr_err_ob); - if (PyErr_Occurred()) goto finished; - - if ((message_ob = PyObject_GetAttrString(exc, "message")) == NULL) - goto finished; - message = PyString_AsString(message_ob); - if (PyErr_Occurred()) goto finished; - - if ((file_ob = PyObject_GetAttrString(exc, "file")) == NULL) - goto finished; - if (file_ob != Py_None) - file = PyString_AsString(file_ob); - if (PyErr_Occurred()) goto finished; - - if ((line_ob = PyObject_GetAttrString(exc, "line")) == NULL) - goto finished; - if (line_ob != Py_None) - line = PyInt_AsLong(line_ob); - if (PyErr_Occurred()) goto finished; - - if ((child_ob = PyObject_GetAttrString(exc, "child")) == NULL) - goto finished; - /* We could check if the child is a Subversion exception too, - but let's just apply duck typing. */ - if (child_ob != Py_None) - child = exception_to_error(child_ob); - if (PyErr_Occurred()) goto finished; - - rv = svn_error_create(apr_err, child, message); - /* Somewhat hacky, but we need to preserve original file/line info. */ - rv->file = file ? apr_pstrdup(rv->pool, file) : NULL; - rv->line = line; + if ((apr_err_ob = PyObject_GetAttrString(exc, "apr_err")) == NULL) + goto finished; + apr_err = (apr_status_t) PyInt_AsLong(apr_err_ob); + if (PyErr_Occurred()) goto finished; + + if ((message_ob = PyObject_GetAttrString(exc, "message")) == NULL) + goto finished; + message = PyString_AsString(message_ob); + if (PyErr_Occurred()) goto finished; + + if ((file_ob = PyObject_GetAttrString(exc, "file")) == NULL) + goto finished; + if (file_ob != Py_None) + file = PyString_AsString(file_ob); + if (PyErr_Occurred()) goto finished; + + if ((line_ob = PyObject_GetAttrString(exc, "line")) == NULL) + goto finished; + if (line_ob != Py_None) + line = PyInt_AsLong(line_ob); + if (PyErr_Occurred()) goto finished; + + if ((child_ob = PyObject_GetAttrString(exc, "child")) == NULL) + goto finished; + /* We could check if the child is a Subversion exception too, + but let's just apply duck typing. */ + if (child_ob != Py_None) + child = exception_to_error(child_ob); + if (PyErr_Occurred()) goto finished; + + rv = svn_error_create(apr_err, child, message); + /* Somewhat hacky, but we need to preserve original file/line info. */ + rv->file = file ? apr_pstrdup(rv->pool, file) : NULL; + rv->line = line; finished: - Py_XDECREF(child_ob); - Py_XDECREF(line_ob); - Py_XDECREF(file_ob); - Py_XDECREF(message_ob); - Py_XDECREF(apr_err_ob); - return rv; + Py_XDECREF(child_ob); + Py_XDECREF(line_ob); + Py_XDECREF(file_ob); + Py_XDECREF(message_ob); + Py_XDECREF(apr_err_ob); + return rv; } /* If the currently set Python exception is a valid SubversionException, @@ -1540,6 +1548,7 @@ static svn_error_t *type_conversion_error(const char *datatype) typedef struct item_baton { PyObject *editor; /* the editor handling the callbacks */ PyObject *baton; /* the dir/file baton (or NULL for edit baton) */ + apr_pool_t *pool; /* top-level pool */ } item_baton; static item_baton *make_baton(apr_pool_t *pool, @@ -1548,13 +1557,11 @@ static item_baton *make_baton(apr_pool_t *pool, { item_baton *newb = apr_palloc(pool, sizeof(*newb)); - /* Note: We steal the caller's reference to 'baton'. Also, to avoid - memory leaks, we borrow the caller's reference to 'editor'. In this - case, borrowing the reference to 'editor' is safe because the contents - of an item_baton struct are only used by functino calls which operate on - the editor itself. */ + /* Note: We steal the caller's reference to 'baton'. */ + Py_INCREF(editor); newb->editor = editor; newb->baton = baton; + newb->pool = pool; return newb; } @@ -1583,6 +1590,9 @@ static svn_error_t *close_baton(void *baton, /* there is no return value, so just toss this object (probably Py_None) */ Py_DECREF(result); + /* Release the editor object */ + Py_DECREF(ib->editor); + /* We're now done with the baton. Since there isn't really a free, all we need to do is note that its objects are no longer referenced by the baton. */ @@ -2044,6 +2054,373 @@ void svn_swig_py_make_editor(const svn_delta_editor_t **editor, *edit_baton = make_baton(pool, py_editor, NULL); } + +/* Wrappers for dump stream parser */ + +static svn_error_t *parse_fn3_magic_header_record(int version, + void *parse_baton, + apr_pool_t *pool) +{ + item_baton *ib = parse_baton; + PyObject *result; + svn_error_t *err; + + svn_swig_py_acquire_py_lock(); + + /* ### python doesn't have 'const' on the method name and format */ + if ((result = PyObject_CallMethod(ib->editor, (char *)"magic_header_record", + (char *)"lO&", version, + make_ob_pool, pool)) == NULL) + { + err = callback_exception_error(); + goto finished; + } + + /* there is no return value, so just toss this object (probably Py_None) */ + Py_DECREF(result); + err = SVN_NO_ERROR; + + finished: + svn_swig_py_release_py_lock(); + return err; +} + + +static svn_error_t *parse_fn3_uuid_record(const char *uuid, + void *parse_baton, + apr_pool_t *pool) +{ + item_baton *ib = parse_baton; + PyObject *result; + svn_error_t *err; + + svn_swig_py_acquire_py_lock(); + + /* ### python doesn't have 'const' on the method name and format */ + if ((result = PyObject_CallMethod(ib->editor, (char *)"uuid_record", + (char *)"sO&", uuid, + make_ob_pool, pool)) == NULL) + { + err = callback_exception_error(); + goto finished; + } + + /* there is no return value, so just toss this object (probably Py_None) */ + Py_DECREF(result); + err = SVN_NO_ERROR; + + finished: + svn_swig_py_release_py_lock(); + return err; +} + + +static svn_error_t *parse_fn3_new_revision_record(void **revision_baton, + apr_hash_t *headers, + void *parse_baton, + apr_pool_t *pool) +{ + item_baton *ib = parse_baton; + PyObject *result; + PyObject *tmp; + svn_error_t *err; + + svn_swig_py_acquire_py_lock(); + + if ((result = PyObject_CallMethod(ib->editor, (char *)"new_revision_record", + (char *)"O&O&", + svn_swig_py_stringhash_to_dict, headers, + make_ob_pool, pool)) == NULL) { + err = callback_exception_error(); + goto finished; + } + + /* make_baton takes our 'result' reference */ + *revision_baton = make_baton(pool, ib->editor, result); + err = SVN_NO_ERROR; + + finished: + svn_swig_py_release_py_lock(); + return err; +} + + +static svn_error_t *parse_fn3_new_node_record(void **node_baton, + apr_hash_t *headers, + void *revision_baton, + apr_pool_t *pool) +{ + item_baton *ib = revision_baton; + PyObject *result; + svn_error_t *err; + + svn_swig_py_acquire_py_lock(); + + if ((result = PyObject_CallMethod(ib->editor, (char *)"new_node_record", + (char *)"O&OO&", + svn_swig_py_stringhash_to_dict, headers, + ib->baton, + make_ob_pool, pool)) == NULL) { + err = callback_exception_error(); + goto finished; + } + + /* make_baton takes our 'result' reference */ + *node_baton = make_baton(pool, ib->editor, result); + err = SVN_NO_ERROR; + + finished: + svn_swig_py_release_py_lock(); + return err; +} + + +static svn_error_t *parse_fn3_set_revision_property(void *revision_baton, + const char *name, + const svn_string_t *value) +{ + item_baton *ib = revision_baton; + PyObject *result; + svn_error_t *err; + + svn_swig_py_acquire_py_lock(); + + /* ### python doesn't have 'const' on the method name and format */ + if ((result = PyObject_CallMethod(ib->editor, (char *)"set_revision_property", + (char *)"Oss#", ib->baton, name, + value ? value->data : NULL, + value ? value->len : 0)) == NULL) + { + err = callback_exception_error(); + goto finished; + } + + /* there is no return value, so just toss this object (probably Py_None) */ + Py_DECREF(result); + err = SVN_NO_ERROR; + + finished: + svn_swig_py_release_py_lock(); + return err; +} + + +static svn_error_t *parse_fn3_set_node_property(void *node_baton, + const char *name, + const svn_string_t *value) +{ + item_baton *ib = node_baton; + PyObject *result; + svn_error_t *err; + + svn_swig_py_acquire_py_lock(); + + /* ### python doesn't have 'const' on the method name and format */ + if ((result = PyObject_CallMethod(ib->editor, (char *)"set_node_property", + (char *)"Oss#", ib->baton, name, + value ? value->data : NULL, + value ? value->len : 0)) == NULL) + { + err = callback_exception_error(); + goto finished; + } + + /* there is no return value, so just toss this object (probably Py_None) */ + Py_DECREF(result); + err = SVN_NO_ERROR; + + finished: + svn_swig_py_release_py_lock(); + return err; +} + + +static svn_error_t *parse_fn3_delete_node_property(void *node_baton, + const char *name) +{ + item_baton *ib = node_baton; + PyObject *result; + svn_error_t *err; + + svn_swig_py_acquire_py_lock(); + + /* ### python doesn't have 'const' on the method name and format */ + if ((result = PyObject_CallMethod(ib->editor, (char *)"delete_node_property", + (char *)"Os", ib->baton, name)) == NULL) + { + err = callback_exception_error(); + goto finished; + } + + /* there is no return value, so just toss this object (probably Py_None) */ + Py_DECREF(result); + err = SVN_NO_ERROR; + + finished: + svn_swig_py_release_py_lock(); + return err; +} + + +static svn_error_t *parse_fn3_remove_node_props(void *node_baton) +{ + item_baton *ib = node_baton; + PyObject *result; + svn_error_t *err; + + svn_swig_py_acquire_py_lock(); + + /* ### python doesn't have 'const' on the method name and format */ + if ((result = PyObject_CallMethod(ib->editor, (char *)"remove_node_props", + (char *)"(O)", ib->baton)) == NULL) + { + err = callback_exception_error(); + goto finished; + } + + /* there is no return value, so just toss this object (probably Py_None) */ + Py_DECREF(result); + err = SVN_NO_ERROR; + + finished: + svn_swig_py_release_py_lock(); + return err; +} + + +static svn_error_t *parse_fn3_set_fulltext(svn_stream_t **stream, + void *node_baton) +{ + item_baton *ib = node_baton; + PyObject *result; + svn_error_t *err; + + svn_swig_py_acquire_py_lock(); + + /* ### python doesn't have 'const' on the method name and format */ + if ((result = PyObject_CallMethod(ib->editor, (char *)"set_fulltext", + (char *)"(O)", ib->baton)) == NULL) + { + err = callback_exception_error(); + goto finished; + } + + /* Interpret None to mean NULL - no text is desired */ + if (result == Py_None) + { + *stream = NULL; + } + else + { + /* create a stream from the IO object. it will increment the + reference on the 'result'. */ + *stream = svn_swig_py_make_stream(result, ib->pool); + } + + /* if the handler returned an IO object, svn_swig_py_make_stream() has + incremented its reference counter. If it was None, it is discarded. */ + Py_DECREF(result); + err = SVN_NO_ERROR; + + finished: + svn_swig_py_release_py_lock(); + return err; +} + + +static svn_error_t *parse_fn3_apply_textdelta(svn_txdelta_window_handler_t *handler, + void **handler_baton, + void *node_baton) +{ + item_baton *ib = node_baton; + PyObject *result; + svn_error_t *err; + + svn_swig_py_acquire_py_lock(); + + /* ### python doesn't have 'const' on the method name and format */ + if ((result = PyObject_CallMethod(ib->editor, (char *)"apply_textdelta", + (char *)"(O)", ib->baton)) == NULL) + { + err = callback_exception_error(); + goto finished; + } + + /* Interpret None to mean svn_delta_noop_window_handler. This is much + easier/faster than making code always have to write a NOOP handler + in Python. */ + if (result == Py_None) + { + Py_DECREF(result); + + *handler = svn_delta_noop_window_handler; + *handler_baton = NULL; + } + else + { + /* return the thunk for invoking the handler. the baton takes our + 'result' reference, which is the handler. */ + *handler = window_handler; + *handler_baton = result; + } + + err = SVN_NO_ERROR; + + finished: + svn_swig_py_release_py_lock(); + return err; +} + + +static svn_error_t *parse_fn3_close_node(void *node_baton) +{ + return close_baton(node_baton, "close_node"); +} + + +static svn_error_t *parse_fn3_close_revision(void *revision_baton) +{ + return close_baton(revision_baton, "close_revision"); +} + + +static const svn_repos_parse_fns3_t thunk_parse_fns3_vtable = + { + parse_fn3_magic_header_record, + parse_fn3_uuid_record, + parse_fn3_new_revision_record, + parse_fn3_new_node_record, + parse_fn3_set_revision_property, + parse_fn3_set_node_property, + parse_fn3_delete_node_property, + parse_fn3_remove_node_props, + parse_fn3_set_fulltext, + parse_fn3_apply_textdelta, + parse_fn3_close_node, + parse_fn3_close_revision + }; + +static apr_status_t +svn_swig_py_parse_fns3_destroy(void *parse_baton) +{ + close_baton(parse_baton, "_close_dumpstream"); + return APR_SUCCESS; +} + +void svn_swig_py_make_parse_fns3(const svn_repos_parse_fns3_t **parse_fns3, + void **parse_baton, + PyObject *py_parse_fns3, + apr_pool_t *pool) +{ + *parse_fns3 = &thunk_parse_fns3_vtable; + *parse_baton = make_baton(pool, py_parse_fns3, NULL); + + /* Dump stream vtable does not provide a method which is called right before + the end of the parsing (similar to close_edit/abort_edit in delta editor). + Thus, register a pool clean-up routine to release this parse baton. */ + apr_pool_cleanup_register(pool, *parse_baton, svn_swig_py_parse_fns3_destroy, + apr_pool_cleanup_null); +} /*** Other Wrappers for SVN Functions ***/ @@ -2200,7 +2577,8 @@ svn_swig_py_make_stream(PyObject *py_io, apr_pool_t *pool) svn_stream_t *stream; stream = svn_stream_create(py_io, pool); - svn_stream_set_read(stream, read_handler_pyio); + svn_stream_set_read2(stream, NULL /* only full read support */, + read_handler_pyio); svn_stream_set_write(stream, write_handler_pyio); svn_stream_set_close(stream, close_handler_pyio); apr_pool_cleanup_register(pool, py_io, svn_swig_py_stream_destroy, @@ -2223,7 +2601,7 @@ svn_swig_py_convert_txdelta_op_c_array(int num_ops, for (i = 0; i < num_ops; ++i) PyList_SET_ITEM(result, i, - svn_swig_NewPointerObj(ops + i, op_type_info, + svn_swig_py_new_pointer_obj(ops + i, op_type_info, parent_pool, NULL)); return result; @@ -2483,6 +2861,42 @@ svn_error_t *svn_swig_py_fs_get_locks_func(void *baton, return err; } +svn_error_t *svn_swig_py_fs_lock_callback( + void *baton, + const char *path, + const svn_lock_t *lock, + svn_error_t *fs_err, + apr_pool_t *pool) +{ + svn_error_t *err = SVN_NO_ERROR; + PyObject *py_callback = baton, *result; + + if (py_callback == NULL || py_callback == Py_None) + return SVN_NO_ERROR; + + svn_swig_py_acquire_py_lock(); + + if ((result = PyObject_CallFunction(py_callback, + (char *)"sO&O&O&", + path, + make_ob_lock, lock, + make_ob_error, fs_err, + make_ob_pool, pool)) == NULL) + { + err = callback_exception_error(); + } + else if (result != Py_None) + { + err = callback_bad_return_error("Not None"); + } + + Py_XDECREF(result); + + svn_swig_py_release_py_lock(); + return err; +} + + svn_error_t *svn_swig_py_get_commit_log_func(const char **log_msg, const char **tmp_file, const apr_array_header_t * @@ -3391,7 +3805,7 @@ ra_callbacks_open_tmp_file(apr_file_t **fp, *fp = svn_swig_py_make_file(result, pool); if (*fp == NULL) { - err = callback_exception_error(); + err = callback_exception_error(); } } @@ -3441,7 +3855,7 @@ ra_callbacks_get_wc_prop(void *baton, Py_ssize_t len; if (PyString_AsStringAndSize(result, &buf, &len) == -1) { - err = callback_exception_error(); + err = callback_exception_error(); } else { @@ -3683,7 +4097,7 @@ ra_callbacks_get_client_string(void *baton, { if ((*name = PyString_AsString(result)) == NULL) { - err = callback_exception_error(); + err = callback_exception_error(); } } @@ -3882,9 +4296,10 @@ svn_error_t *svn_swig_py_ra_lock_callback( svn_swig_py_acquire_py_lock(); if ((result = PyObject_CallFunction(py_callback, - (char *)"sbO&O&", + (char *)"sbO&O&O&", path, do_lock, make_ob_lock, lock, + make_ob_error, ra_err, make_ob_pool, pool)) == NULL) { err = callback_exception_error(); @@ -4068,7 +4483,7 @@ static svn_error_t *reporter_abort_report(void *report_baton, return err; } -const svn_ra_reporter2_t swig_py_ra_reporter2 = { +static const svn_ra_reporter2_t swig_py_ra_reporter2 = { reporter_set_path, reporter_delete_path, reporter_link_path, @@ -4076,6 +4491,11 @@ const svn_ra_reporter2_t swig_py_ra_reporter2 = { reporter_abort_report }; +const svn_ra_reporter2_t *svn_swig_py_get_ra_reporter2() +{ + return &swig_py_ra_reporter2; +} + /* svn_wc_diff_callbacks2_t */ static svn_error_t * wc_diff_callbacks2_file_changed_or_added(const char *callback, diff --git a/subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.h b/subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.h index 60931c2..512da28 100644 --- a/subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.h +++ b/subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.h @@ -40,16 +40,6 @@ #include "svn_repos.h" /* Define DLL export magic on Windows. */ -#ifdef WIN32 -# ifdef SVN_SWIG_SWIGUTIL_PY_C -# define SVN_SWIG_SWIGUTIL_EXPORT __declspec(dllexport) -# else -# define SVN_SWIG_SWIGUTIL_EXPORT __declspec(dllimport) -# endif -#else -# define SVN_SWIG_SWIGUTIL_EXPORT -#endif - #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ @@ -57,27 +47,22 @@ extern "C" { /* Initialize the libsvn_swig_py library. */ -SVN_SWIG_SWIGUTIL_EXPORT apr_status_t svn_swig_py_initialize(void); /* Functions to manage python's global interpreter lock */ -SVN_SWIG_SWIGUTIL_EXPORT void svn_swig_py_release_py_lock(void); -SVN_SWIG_SWIGUTIL_EXPORT void svn_swig_py_acquire_py_lock(void); /*** Automatic Pool Management Functions ***/ /* Set the application pool */ -SVN_SWIG_SWIGUTIL_EXPORT void svn_swig_py_set_application_pool(PyObject *py_pool, apr_pool_t *pool); /* Clear the application pool */ -SVN_SWIG_SWIGUTIL_EXPORT void svn_swig_py_clear_application_pool(void); /* Get the pool argument from the last element of tuple args. @@ -85,7 +70,6 @@ void svn_swig_py_clear_application_pool(void); * subpool. Return 0 if successful. Return 1 if an error * occurs. */ -SVN_SWIG_SWIGUTIL_EXPORT int svn_swig_py_get_pool_arg(PyObject *args, swig_type_info *type, PyObject **py_pool, apr_pool_t **pool); @@ -93,7 +77,6 @@ int svn_swig_py_get_pool_arg(PyObject *args, swig_type_info *type, * argument list. Return 0 if successful. Return 1 if an error * occurs. */ -SVN_SWIG_SWIGUTIL_EXPORT int svn_swig_py_get_parent_pool(PyObject *args, swig_type_info *type, PyObject **py_pool, apr_pool_t **pool); @@ -101,54 +84,45 @@ int svn_swig_py_get_parent_pool(PyObject *args, swig_type_info *type, /*** SWIG Wrappers ***/ /* Wrapper for SWIG_NewPointerObj */ -SVN_SWIG_SWIGUTIL_EXPORT -PyObject *svn_swig_NewPointerObj(void *obj, swig_type_info *type, +PyObject *svn_swig_py_new_pointer_obj(void *obj, swig_type_info *type, PyObject *pool, PyObject *args); /* Wrapper for SWIG_ConvertPtr */ -SVN_SWIG_SWIGUTIL_EXPORT -int svn_swig_ConvertPtr(PyObject *input, void **obj, swig_type_info *type); +int svn_swig_py_convert_ptr(PyObject *input, void **obj, swig_type_info *type); /* Wrapper for SWIG_MustGetPtr */ -SVN_SWIG_SWIGUTIL_EXPORT -void *svn_swig_MustGetPtr(void *input, swig_type_info *type, int argnum); +void *svn_swig_py_must_get_ptr(void *input, swig_type_info *type, int argnum); /*** Functions to expose a custom SubversionException ***/ /* raise a subversion exception, created from a normal subversion error. consume the error. */ -SVN_SWIG_SWIGUTIL_EXPORT void svn_swig_py_svn_exception(svn_error_t *err); /* helper function to convert an apr_hash_t* (char* -> svnstring_t*) to a Python dict */ -SVN_SWIG_SWIGUTIL_EXPORT PyObject *svn_swig_py_prophash_to_dict(apr_hash_t *hash); /* helper function to convert an apr_hash_t* (svn_revnum_t* -> const char *) to a Python dict */ -SVN_SWIG_SWIGUTIL_EXPORT PyObject *svn_swig_py_locationhash_to_dict(apr_hash_t *hash); /* helper function to convert an apr_array_header_t* (of svn_merge_range_t *) to a Python list */ -SVN_SWIG_SWIGUTIL_EXPORT PyObject *svn_swig_py_pointerlist_to_list(apr_array_header_t *list, swig_type_info *type, PyObject *py_pool); /* helper function to convert an apr_hash_t* (const char *->array of svn_merge_range_t *) to a Python dict */ -SVN_SWIG_SWIGUTIL_EXPORT PyObject *svn_swig_py_mergeinfo_to_dict(apr_hash_t *hash, swig_type_info *type, PyObject *py_pool); /* helper function to convert an apr_hash_t* (const char *->hash of mergeinfo hashes) to a Python dict */ -SVN_SWIG_SWIGUTIL_EXPORT PyObject *svn_swig_py_mergeinfo_catalog_to_dict(apr_hash_t *hash, swig_type_info *type, PyObject *py_pool); @@ -156,90 +130,75 @@ PyObject *svn_swig_py_mergeinfo_catalog_to_dict(apr_hash_t *hash, /* helper function to convert an apr_hash_t *(const char *->const char *) to a Python dict */ -SVN_SWIG_SWIGUTIL_EXPORT PyObject *svn_swig_py_stringhash_to_dict(apr_hash_t *hash); /* convert a hash of 'const char *' -> TYPE into a Python dict */ -SVN_SWIG_SWIGUTIL_EXPORT PyObject *svn_swig_py_convert_hash(apr_hash_t *hash, swig_type_info *type, PyObject *py_pool); /* helper function to convert a 'char **' into a Python list of string objects */ -SVN_SWIG_SWIGUTIL_EXPORT PyObject *svn_swig_py_c_strings_to_list(char **strings); /* helper function to convert an array of 'const char *' to a Python list of string objects */ -SVN_SWIG_SWIGUTIL_EXPORT PyObject *svn_swig_py_array_to_list(const apr_array_header_t *strings); /* helper function to convert a hash mapping char * to * svn_log_changed_path_t * to a Python dict mapping str to str. */ -SVN_SWIG_SWIGUTIL_EXPORT PyObject *svn_swig_py_changed_path_hash_to_dict(apr_hash_t *hash); /* helper function to convert a hash mapping char * to * svn_log_changed_path2_t * to a Python dict mapping str to str. */ -SVN_SWIG_SWIGUTIL_EXPORT PyObject *svn_swig_py_changed_path2_hash_to_dict(apr_hash_t *hash); /* helper function to convert an array of 'svn_revnum_t' to a Python list of int objects */ -SVN_SWIG_SWIGUTIL_EXPORT PyObject *svn_swig_py_revarray_to_list(const apr_array_header_t *revs); /* helper function to convert a Python dictionary mapping strings to strings into an apr_hash_t mapping const char *'s to const char *'s, allocated in POOL. */ -SVN_SWIG_SWIGUTIL_EXPORT apr_hash_t *svn_swig_py_stringhash_from_dict(PyObject *dict, apr_pool_t *pool); /* helper function to convert a Python dictionary mapping strings to rangelists into an apr_hash_t mapping const char *'s to rangelists, allocated in POOL. */ -SVN_SWIG_SWIGUTIL_EXPORT apr_hash_t *svn_swig_py_mergeinfo_from_dict(PyObject *dict, apr_pool_t *pool); /* helper function to convert a Python dictionary mapping strings to strings into an 'apr_array_header_t *' of svn_prop_t * allocated in POOL. */ -SVN_SWIG_SWIGUTIL_EXPORT apr_array_header_t *svn_swig_py_proparray_from_dict(PyObject *dict, apr_pool_t *pool); /* helper function to convert a 'apr_array_header_t *' of 'svn_prop_t to a Python dictionary mapping strings to strings. */ -SVN_SWIG_SWIGUTIL_EXPORT PyObject *svn_swig_py_proparray_to_dict(const apr_array_header_t *array); /* helper function to convert a 'apr_array_header_t *' of 'svn_prop_inherited_item_t' to a Python dictionary mapping strings to dictionary. */ -SVN_SWIG_SWIGUTIL_EXPORT PyObject * svn_swig_py_propinheriteditemarray_to_dict(const apr_array_header_t *array); /* helper function to convert a Python dictionary mapping strings to strings into an apr_hash_t mapping const char *'s to svn_string_t's, allocated in POOL. */ -SVN_SWIG_SWIGUTIL_EXPORT apr_hash_t *svn_swig_py_prophash_from_dict(PyObject *dict, apr_pool_t *pool); /* helper function to convert a Python dictionary mapping strings to integers into an apr_hash_t mapping const char *'s to revnums, allocated in POOL. */ -SVN_SWIG_SWIGUTIL_EXPORT apr_hash_t *svn_swig_py_path_revs_hash_from_dict(PyObject *dict, apr_pool_t *pool); /* helper function to convert a Python dictionary mapping strings to SWIG wrappers described by type into an apr_hash_t mapping const char *'s to struct pointers, allocated in POOL. */ -SVN_SWIG_SWIGUTIL_EXPORT apr_hash_t *svn_swig_py_struct_ptr_hash_from_dict(PyObject *dict, swig_type_info *type, apr_pool_t *pool); @@ -259,7 +218,6 @@ typedef int (*svn_swig_py_object_unwrap_t)(PyObject *source, In case of failure, raises a Python exception, presuming that seq was the function argument #argnum. pool is used to allocate the array. */ -SVN_SWIG_SWIGUTIL_EXPORT const apr_array_header_t * svn_swig_py_seq_to_array(PyObject *seq, int element_size, @@ -269,7 +227,6 @@ svn_swig_py_seq_to_array(PyObject *seq, /* An svn_swig_py_object_unwrap_t that extracts a char pointer from a Python string. */ -SVN_SWIG_SWIGUTIL_EXPORT int svn_swig_py_unwrap_string(PyObject *source, void *destination, @@ -277,7 +234,6 @@ svn_swig_py_unwrap_string(PyObject *source, /* An svn_swig_py_object_unwrap_t that extracts an svn_revnum_t from a Python integer. */ -SVN_SWIG_SWIGUTIL_EXPORT int svn_swig_py_unwrap_revnum(PyObject *source, void *destination, @@ -285,30 +241,31 @@ svn_swig_py_unwrap_revnum(PyObject *source, /* An svn_swig_py_object_unwrap_t that extracts a struct pointer from a SWIG wrapper. baton is expected to be a swig_type_info* describing the struct. */ -SVN_SWIG_SWIGUTIL_EXPORT int svn_swig_py_unwrap_struct_ptr(PyObject *source, void *destination, void *baton); /* make an editor that "thunks" from C callbacks up to Python */ -SVN_SWIG_SWIGUTIL_EXPORT void svn_swig_py_make_editor(const svn_delta_editor_t **editor, void **edit_baton, PyObject *py_editor, apr_pool_t *pool); -SVN_SWIG_SWIGUTIL_EXPORT +/* make a parse vtable that "thunks" from C callbacks up to Python */ +void svn_swig_py_make_parse_fns3(const svn_repos_parse_fns3_t **parse_fns3, + void **parse_baton, + PyObject *py_parse_fns3, + apr_pool_t *pool); + apr_file_t *svn_swig_py_make_file(PyObject *py_file, apr_pool_t *pool); -SVN_SWIG_SWIGUTIL_EXPORT svn_stream_t *svn_swig_py_make_stream(PyObject *py_io, apr_pool_t *pool); /* Convert ops, a C array of num_ops elements, to a Python list of SWIG objects with descriptor op_type_info and pool set to parent_pool. */ -SVN_SWIG_SWIGUTIL_EXPORT PyObject * svn_swig_py_convert_txdelta_op_c_array(int num_ops, svn_txdelta_op_t *ops, @@ -317,7 +274,6 @@ svn_swig_py_convert_txdelta_op_c_array(int num_ops, /* a notify function that executes a Python function that is passed in via the baton argument */ -SVN_SWIG_SWIGUTIL_EXPORT void svn_swig_py_notify_func(void *baton, const char *path, svn_wc_notify_action_t action, @@ -327,21 +283,18 @@ void svn_swig_py_notify_func(void *baton, svn_wc_notify_state_t prop_state, svn_revnum_t revision); -SVN_SWIG_SWIGUTIL_EXPORT void svn_swig_py_notify_func2(void *baton, const svn_wc_notify_t *notify, apr_pool_t *pool); /* a status function that executes a Python function that is passed in via the baton argument */ -SVN_SWIG_SWIGUTIL_EXPORT void svn_swig_py_status_func(void *baton, const char *path, svn_wc_status_t *status); /* a svn_delta_path_driver callback that executes a Python function that is passed in via the baton argument */ -SVN_SWIG_SWIGUTIL_EXPORT svn_error_t *svn_swig_py_delta_path_driver_cb_func(void **dir_baton, void *parent_baton, void *callback_baton, @@ -350,24 +303,27 @@ svn_error_t *svn_swig_py_delta_path_driver_cb_func(void **dir_baton, /* a status function that executes a Python function that is passed in via the baton argument */ -SVN_SWIG_SWIGUTIL_EXPORT void svn_swig_py_status_func2(void *baton, const char *path, svn_wc_status2_t *status); /* a cancel function that executes a Python function passed in via the cancel_baton argument. */ -SVN_SWIG_SWIGUTIL_EXPORT svn_error_t *svn_swig_py_cancel_func(void *cancel_baton); /* thunked fs get_locks function */ -SVN_SWIG_SWIGUTIL_EXPORT svn_error_t *svn_swig_py_fs_get_locks_func(void *baton, svn_lock_t *lock, apr_pool_t *pool); +svn_error_t *svn_swig_py_fs_lock_callback( + void *baton, + const char *path, + const svn_lock_t *lock, + svn_error_t *ra_err, + apr_pool_t *pool); + /* thunked commit log fetcher */ -SVN_SWIG_SWIGUTIL_EXPORT svn_error_t *svn_swig_py_get_commit_log_func(const char **log_msg, const char **tmp_file, const apr_array_header_t * @@ -376,7 +332,6 @@ svn_error_t *svn_swig_py_get_commit_log_func(const char **log_msg, apr_pool_t *pool); /* thunked repos authz callback function */ -SVN_SWIG_SWIGUTIL_EXPORT svn_error_t *svn_swig_py_repos_authz_func(svn_boolean_t *allowed, svn_fs_root_t *root, const char *path, @@ -384,14 +339,12 @@ svn_error_t *svn_swig_py_repos_authz_func(svn_boolean_t *allowed, apr_pool_t *pool); /* thunked history callback function */ -SVN_SWIG_SWIGUTIL_EXPORT svn_error_t *svn_swig_py_repos_history_func(void *baton, const char *path, svn_revnum_t revision, apr_pool_t *pool); /* thunked log receiver function */ -SVN_SWIG_SWIGUTIL_EXPORT svn_error_t *svn_swig_py_log_receiver(void *py_receiver, apr_hash_t *changed_paths, svn_revnum_t rev, @@ -401,23 +354,19 @@ svn_error_t *svn_swig_py_log_receiver(void *py_receiver, apr_pool_t *pool); /* thunked log receiver2 function */ -SVN_SWIG_SWIGUTIL_EXPORT svn_error_t *svn_swig_py_log_entry_receiver(void *baton, svn_log_entry_t *log_entry, apr_pool_t *pool); /* thunked repos freeze function */ -SVN_SWIG_SWIGUTIL_EXPORT svn_error_t *svn_swig_py_repos_freeze_func(void *baton, apr_pool_t *pool); /* thunked fs freeze function */ -SVN_SWIG_SWIGUTIL_EXPORT svn_error_t *svn_swig_py_fs_freeze_func(void *baton, apr_pool_t *pool); /* thunked proplist receiver2 function */ -SVN_SWIG_SWIGUTIL_EXPORT svn_error_t *svn_swig_py_proplist_receiver2(void *baton, const char *path, apr_hash_t *prop_hash, @@ -425,21 +374,18 @@ svn_error_t *svn_swig_py_proplist_receiver2(void *baton, apr_pool_t *pool); /* thunked info receiver function */ -SVN_SWIG_SWIGUTIL_EXPORT svn_error_t *svn_swig_py_info_receiver_func(void *py_receiver, const char *path, const svn_info_t *info, apr_pool_t *pool); /* thunked location segments receiver function */ -SVN_SWIG_SWIGUTIL_EXPORT svn_error_t * svn_swig_py_location_segment_receiver_func(svn_location_segment_t *segment, void *baton, apr_pool_t *pool); /* thunked blame receiver function */ -SVN_SWIG_SWIGUTIL_EXPORT svn_error_t *svn_swig_py_client_blame_receiver_func(void *baton, apr_int64_t line_no, svn_revnum_t revision, @@ -449,21 +395,18 @@ svn_error_t *svn_swig_py_client_blame_receiver_func(void *baton, apr_pool_t *pool); /* thunked changelist receiver function */ -SVN_SWIG_SWIGUTIL_EXPORT svn_error_t *svn_swig_py_changelist_receiver_func(void *baton, const char *path, const char *changelist, apr_pool_t *pool); /* auth provider callbacks */ -SVN_SWIG_SWIGUTIL_EXPORT svn_error_t * svn_swig_py_auth_gnome_keyring_unlock_prompt_func( char **keyring_passwd, const char *keyring_name, void *baton, apr_pool_t *pool); -SVN_SWIG_SWIGUTIL_EXPORT svn_error_t *svn_swig_py_auth_simple_prompt_func( svn_auth_cred_simple_t **cred, void *baton, @@ -472,7 +415,6 @@ svn_error_t *svn_swig_py_auth_simple_prompt_func( svn_boolean_t may_save, apr_pool_t *pool); -SVN_SWIG_SWIGUTIL_EXPORT svn_error_t *svn_swig_py_auth_username_prompt_func( svn_auth_cred_username_t **cred, void *baton, @@ -480,7 +422,6 @@ svn_error_t *svn_swig_py_auth_username_prompt_func( svn_boolean_t may_save, apr_pool_t *pool); -SVN_SWIG_SWIGUTIL_EXPORT svn_error_t *svn_swig_py_auth_ssl_server_trust_prompt_func( svn_auth_cred_ssl_server_trust_t **cred, void *baton, @@ -490,7 +431,6 @@ svn_error_t *svn_swig_py_auth_ssl_server_trust_prompt_func( svn_boolean_t may_save, apr_pool_t *pool); -SVN_SWIG_SWIGUTIL_EXPORT svn_error_t *svn_swig_py_auth_ssl_client_cert_prompt_func( svn_auth_cred_ssl_client_cert_t **cred, void *baton, @@ -498,7 +438,6 @@ svn_error_t *svn_swig_py_auth_ssl_client_cert_prompt_func( svn_boolean_t may_save, apr_pool_t *pool); -SVN_SWIG_SWIGUTIL_EXPORT svn_error_t *svn_swig_py_auth_ssl_client_cert_pw_prompt_func( svn_auth_cred_ssl_client_cert_pw_t **cred, void *baton, @@ -507,7 +446,6 @@ svn_error_t *svn_swig_py_auth_ssl_client_cert_pw_prompt_func( apr_pool_t *pool); /* auth cleanup callback */ -SVN_SWIG_SWIGUTIL_EXPORT svn_error_t *svn_swig_py_config_auth_walk_func(svn_boolean_t *delete_cred, void *walk_baton, const char *cred_kind, @@ -515,32 +453,27 @@ svn_error_t *svn_swig_py_config_auth_walk_func(svn_boolean_t *delete_cred, apr_hash_t *hash, apr_pool_t *scratch_pool); -SVN_SWIG_SWIGUTIL_EXPORT void svn_swig_py_setup_ra_callbacks(svn_ra_callbacks2_t **callbacks, void **baton, PyObject *py_callbacks, apr_pool_t *pool); -SVN_SWIG_SWIGUTIL_EXPORT svn_wc_diff_callbacks2_t * svn_swig_py_setup_wc_diff_callbacks2(void **baton, PyObject *py_callbacks, apr_pool_t *pool); -SVN_SWIG_SWIGUTIL_EXPORT svn_error_t *svn_swig_py_commit_callback2(const svn_commit_info_t *commit_info, void *baton, apr_pool_t *pool); -SVN_SWIG_SWIGUTIL_EXPORT svn_error_t *svn_swig_py_commit_callback(svn_revnum_t new_revision, const char *date, const char *author, void *baton); -SVN_SWIG_SWIGUTIL_EXPORT svn_error_t *svn_swig_py_ra_file_rev_handler_func( void *baton, const char *path, @@ -551,7 +484,6 @@ svn_error_t *svn_swig_py_ra_file_rev_handler_func( apr_array_header_t *prop_diffs, apr_pool_t *pool); -SVN_SWIG_SWIGUTIL_EXPORT svn_error_t *svn_swig_py_ra_lock_callback( void *baton, const char *path, @@ -560,17 +492,14 @@ svn_error_t *svn_swig_py_ra_lock_callback( svn_error_t *ra_err, apr_pool_t *pool); -SVN_SWIG_SWIGUTIL_EXPORT -extern const svn_ra_reporter2_t swig_py_ra_reporter2; +const svn_ra_reporter2_t *svn_swig_py_get_ra_reporter2(void); -SVN_SWIG_SWIGUTIL_EXPORT svn_boolean_t svn_swig_py_config_enumerator2(const char *name, const char *value, void *baton, apr_pool_t *pool); -SVN_SWIG_SWIGUTIL_EXPORT svn_boolean_t svn_swig_py_config_section_enumerator2(const char *name, void *baton, |