⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 swigutil_py.c

📁 subversion-1.4.3-1.tar.gz 配置svn的源码
💻 C
📖 第 1 页 / 共 4 页
字号:
                             void *parent_baton,                             const char *copyfrom_path,                             svn_revnum_t copyfrom_revision,                             apr_pool_t *file_pool,                             void **file_baton){  item_baton *ib = parent_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 *)"add_file",                                    (char *)"sOslO&", path, ib->baton,                                    copyfrom_path, copyfrom_revision,                                    make_ob_pool, file_pool)) == NULL)    {      err = callback_exception_error();      goto finished;    }  /* make_baton takes our 'result' reference */  *file_baton = make_baton(file_pool, ib->editor, result);  err = SVN_NO_ERROR; finished:  svn_swig_py_release_py_lock();  return err;}static svn_error_t *open_file(const char *path,                              void *parent_baton,                              svn_revnum_t base_revision,                              apr_pool_t *file_pool,                              void **file_baton){  item_baton *ib = parent_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 *)"open_file",                                    (char *)"sOlO&", path, ib->baton,                                    base_revision,                                    make_ob_pool, file_pool)) == NULL)    {      err = callback_exception_error();      goto finished;    }  /* make_baton takes our 'result' reference */  *file_baton = make_baton(file_pool, ib->editor, result);  err = SVN_NO_ERROR; finished:  svn_swig_py_release_py_lock();  return err;}static svn_error_t *window_handler(svn_txdelta_window_t *window,                                   void *baton){  PyObject *handler = baton;  PyObject *result;  svn_error_t *err;  svn_swig_py_acquire_py_lock();  if (window == NULL)    {      /* the last call; it closes the handler */      /* invoke the handler with None for the window */      /* ### python doesn't have 'const' on the format */      result = PyObject_CallFunction(handler, (char *)"O", Py_None);      /* we no longer need to refer to the handler object */      Py_DECREF(handler);    }  else    {      /* invoke the handler with the window */      /* ### python doesn't have 'const' on the format */      result = PyObject_CallFunction(handler, (char *)"O&",         make_ob_txdelta_window, window);    }  if (result == 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 *apply_textdelta(void *file_baton,                                     const char *base_checksum,                                    apr_pool_t *pool,                                    svn_txdelta_window_handler_t *handler,                                    void **h_baton){  item_baton *ib = file_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 *)"(Os)", ib->baton,                                    base_checksum)) == 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;      *h_baton = NULL;    }  else    {      /* return the thunk for invoking the handler. the baton takes our         'result' reference, which is the handler. */      *handler = window_handler;      *h_baton = result;    }  err = SVN_NO_ERROR; finished:  svn_swig_py_release_py_lock();  return err;}static svn_error_t *change_file_prop(void *file_baton,                                     const char *name,                                     const svn_string_t *value,                                     apr_pool_t *pool){  item_baton *ib = file_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 *)"change_file_prop",                                    (char *)"Oss#O&", ib->baton, name,                                    value ? value->data : NULL,                                     value ? value->len : 0,                                    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 *close_file(void *file_baton,                               const char *text_checksum,                               apr_pool_t *pool){  item_baton *ib = file_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 *)"close_file",                                    (char *)"(Os)", ib->baton,                                    text_checksum)) == NULL)    {      err = callback_exception_error();      goto finished;    }  /* there is no return value, so just toss this object (probably Py_None) */  Py_DECREF(result);  /* 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.  */  Py_XDECREF(ib->baton);#ifdef SVN_DEBUG  ib->editor = ib->baton = NULL;#endif  err = SVN_NO_ERROR; finished:  svn_swig_py_release_py_lock();  return err;}static svn_error_t *close_edit(void *edit_baton,                               apr_pool_t *pool){  return close_baton(edit_baton, "close_edit");}static svn_error_t *abort_edit(void *edit_baton,                               apr_pool_t *pool){  return close_baton(edit_baton, "abort_edit");}void svn_swig_py_make_editor(const svn_delta_editor_t **editor,                             void **edit_baton,                             PyObject *py_editor,                             apr_pool_t *pool){  svn_delta_editor_t *thunk_editor = svn_delta_default_editor(pool);    thunk_editor->set_target_revision = set_target_revision;  thunk_editor->open_root = open_root;  thunk_editor->delete_entry = delete_entry;  thunk_editor->add_directory = add_directory;  thunk_editor->open_directory = open_directory;  thunk_editor->change_dir_prop = change_dir_prop;  thunk_editor->close_directory = close_directory;  thunk_editor->add_file = add_file;  thunk_editor->open_file = open_file;  thunk_editor->apply_textdelta = apply_textdelta;  thunk_editor->change_file_prop = change_file_prop;  thunk_editor->close_file = close_file;  thunk_editor->close_edit = close_edit;  thunk_editor->abort_edit = abort_edit;  *editor = thunk_editor;  *edit_baton = make_baton(pool, py_editor, NULL);}/*** Other Wrappers for SVN Functions ***/apr_file_t *svn_swig_py_make_file(PyObject *py_file,                                  apr_pool_t *pool){  apr_file_t *apr_file = NULL;  apr_status_t apr_err;  if (py_file == NULL || py_file == Py_None)    return NULL;  if (PyString_Check(py_file))    {      /* input is a path -- just open an apr_file_t */      char* fname = PyString_AS_STRING(py_file);      apr_err = apr_file_open(&apr_file, fname,                              APR_CREATE | APR_READ | APR_WRITE,                              APR_OS_DEFAULT, pool);      if (apr_err)        {          char buf[256];          apr_strerror(apr_err, buf, sizeof(buf));          PyErr_Format(PyExc_IOError, "apr_file_open failed: %s: '%s'",                       buf, fname);          return NULL;        }    }  else if (PyFile_Check(py_file))    {      FILE *file;      apr_os_file_t osfile;      /* input is a file object -- convert to apr_file_t */      file = PyFile_AsFile(py_file);#ifdef WIN32      osfile = (apr_os_file_t)_get_osfhandle(_fileno(file));#else      osfile = (apr_os_file_t)fileno(file);#endif      apr_err = apr_os_file_put(&apr_file, &osfile, O_CREAT | O_WRONLY, pool);      if (apr_err)        {          char buf[256];          apr_strerror(apr_err, buf, sizeof(buf));          PyErr_Format(PyExc_IOError, "apr_os_file_put failed: %s", buf);          return NULL;        }    }  return apr_file;}static svn_error_t *read_handler_pyio(void *baton, char *buffer, apr_size_t *len){  PyObject *result;  PyObject *py_io = baton;  apr_size_t bytes;  svn_error_t *err = SVN_NO_ERROR;  svn_swig_py_acquire_py_lock();  if ((result = PyObject_CallMethod(py_io, (char *)"read",                                    (char *)"i", *len)) == NULL)    {      err = callback_exception_error();    }  else if (PyString_Check(result))    {      bytes = PyString_GET_SIZE(result);      if (bytes > *len)        {          err = callback_bad_return_error("Too many bytes");        }      else        {          /* Writeback, in case this was a short read, indicating EOF */          *len = bytes;          memcpy(buffer, PyString_AS_STRING(result), *len);        }    }  else    {      err = callback_bad_return_error("Not a string");    }  Py_XDECREF(result);  svn_swig_py_release_py_lock();  return err;}static svn_error_t *write_handler_pyio(void *baton, const char *data, apr_size_t *len){  PyObject *result;  PyObject *py_io = baton;  svn_error_t *err = SVN_NO_ERROR;  if (data != NULL)    {      svn_swig_py_acquire_py_lock();      if ((result = PyObject_CallMethod(py_io, (char *)"write",                                        (char *)"s#", data, *len)) == NULL)        {          err = callback_exception_error();        }      Py_XDECREF(result);      svn_swig_py_release_py_lock();    }  return err;}svn_stream_t *svn_swig_py_make_stream(PyObject *py_io, apr_pool_t *pool){  svn_stream_t *stream;  /* Borrow the caller's reference to py_io - this is safe only because the   * caller must have a reference in order to pass the object into the    * bindings, and we will be finished with the py_io object before we return   * to python. I.e. DO NOT STORE AWAY THE RESULTING svn_stream_t * for use   * over multiple calls into the bindings. */  stream = svn_stream_create(py_io, pool);  svn_stream_set_read(stream, read_handler_pyio);  svn_stream_set_write(stream, write_handler_pyio);  return stream;}void svn_swig_py_notify_func(void *baton,                             const char *path,                             svn_wc_notify_action_t action,                             svn_node_kind_t kind,                             const char *mime_type,                             svn_wc_notify_state_t content_state,                             svn_wc_notify_state_t prop_state,                             svn_revnum_t revision){  PyObject *function = baton;  PyObject *result;  svn_error_t *err = SVN_NO_ERROR;  if (function == NULL || function == Py_None)    return;  svn_swig_py_acquire_py_lock();  if ((result = PyObject_CallFunction(function,                                       (char *)"(siisiii)",                                       path, action, kind,                                      mime_type,                                      content_state, prop_state,                                       revision)) == NULL)    {      err = callback_exception_error();    }  else    {      /* The callback shouldn't be returning anything. */      if (result != Py_None)        err = callback_bad_return_error("Not None");      Py_DECREF(result);    }  /* Our error has no place to go. :-( */  if (err)    svn_error_clear(err);  svn_swig_py_release_py_lock();}void svn_swig_py_status_func(void *baton,                             const char *path,                             svn_wc_status_t *status){  PyObject *function = baton;  PyObject *result;  svn_error_t *err = SVN_NO_ERROR;  if (function == NULL || function == Py_None)    return;  svn_swig_py_acquire_py_lock();  if ((result = PyObject_CallFunction(function, (char *)"sO&", path,                                      make_ob_wc_status, status)) == NULL)    {      err = callback_exception_error();    }  else    {      /* The callback shouldn't be returning anything. */      if (result != Py_None)        err = callback_bad_return_error("Not None");      Py_DECREF(result);    }  /* Our error has no place to go. :-( */  if (err)    svn_error_clear(err);      svn_swig_py_release_py_lock();}svn_error_t *svn_swig_py_cancel_func(void *cancel_baton){  PyObject *function = cancel_baton;  PyObject *result;  svn_error_t *err = SVN_NO_ERROR;  if (function == NULL || function == Py_None)    return SVN_NO_ERROR;  svn_swig_py_acquire_py_lock();  if ((result = PyObject_CallFunction(function, NULL)) == NULL)    {      err = callback_exception_error();    }  else    {      if (PyInt_Check(result))        {          if (PyInt_AsLong(result))            err = svn_error_create(SVN_ERR_CANCELLED, 0, NULL);        }      else if (PyLong_Check(result))        {          if (PyLong_AsLong(result))            err = svn_error_create(SVN_ERR_CANCELLED, 0, NULL);        }      else if (result != Py_None)        {          err = callback_bad_return_error("Not an integer or None");        }      Py_DECREF(result);    }  svn_swig_py_release_py_lock();  return err;}svn_error_t *svn_swig_py_fs_get_locks_func(void *baton,                                            svn_lock_t *lock,                                           apr_pool_t *pool){  PyObject *function = baton;  PyObject *result;  svn_error_t *err = SVN_NO_ERROR;  if (function == NULL || function == Py_None)    return SVN_NO_ERROR;  svn_swig_py_acquire_py_lock();    if ((result = PyObject_CallFunction(function, (char *)"O&O&",                                      make_ob_lock, lock,                                      make_ob_pool, pool)) == NULL)    {      err = callback_exception_error();    }  else    {      /* The callback shouldn't be returning anything. */      if (result != Py_None)        err = callback_bad_return_error("Not None");      Py_DECREF(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,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -