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

📄 swigutil_rb.c

📁 subversion-1.4.3-1.tar.gz 配置svn的源码
💻 C
📖 第 1 页 / 共 5 页
字号:
#include "rubyhead.swg"#include "swig_ruby_external_runtime.swg"#include "swigutil_rb.h"#include <st.h>#include "svn_nls.h"#define POOL_P(obj) (RTEST(rb_obj_is_kind_of(obj, rb_svn_core_pool())))#define CONTEXT_P(obj) (RTEST(rb_obj_is_kind_of(obj, rb_svn_client_context())))#define SVN_ERR_P(obj) (RTEST(rb_obj_is_kind_of(obj, rb_svn_error())))static VALUE mSvn = Qnil;static VALUE mSvnClient = Qnil;static VALUE cSvnClientContext = Qnil;static VALUE mSvnCore = Qnil;static VALUE cSvnCorePool = Qnil;static VALUE cSvnCoreStream = Qnil;static VALUE cSvnDelta = Qnil;static VALUE cSvnDeltaEditor = Qnil;static VALUE cSvnDeltaTextDeltaWindowHandler = Qnil;static VALUE cSvnError = Qnil;static VALUE cSvnFs = Qnil;static VALUE cSvnFsFileSystem = Qnil;#define DEFINE_ID(key, name)                    \static ID id_ ## key = 0;                       \static ID                                       \rb_id_ ## key(void)                             \{                                               \  if (!id_ ## key) {                            \    id_ ## key = rb_intern(name);               \  }                                             \  return id_ ## key;                            \}DEFINE_ID(code, "code")DEFINE_ID(message, "message")DEFINE_ID(call, "call")DEFINE_ID(read, "read")DEFINE_ID(write, "write")DEFINE_ID(eqq, "===")DEFINE_ID(baton, "baton")DEFINE_ID(new, "new")DEFINE_ID(new_corresponding_error, "new_corresponding_error")DEFINE_ID(set_target_revision, "set_target_revision")DEFINE_ID(open_root, "open_root")DEFINE_ID(delete_entry, "delete_entry")DEFINE_ID(add_directory, "add_directory")DEFINE_ID(open_directory, "open_directory")DEFINE_ID(change_dir_prop, "change_dir_prop")DEFINE_ID(close_directory, "close_directory")DEFINE_ID(absent_directory, "absent_directory")DEFINE_ID(add_file, "add_file")DEFINE_ID(open_file, "open_file")DEFINE_ID(apply_textdelta, "apply_textdelta")DEFINE_ID(change_file_prop, "change_file_prop")DEFINE_ID(absent_file, "absent_file")DEFINE_ID(close_file, "close_file")DEFINE_ID(close_edit, "close_edit")DEFINE_ID(abort_edit, "abort_edit")DEFINE_ID(__pool__, "__pool__")DEFINE_ID(__pools__, "__pools__")DEFINE_ID(name, "name")DEFINE_ID(swig_type_regex, "swig_type_regex")DEFINE_ID(open_tmp_file, "open_tmp_file")DEFINE_ID(get_wc_prop, "get_wc_prop")DEFINE_ID(set_wc_prop, "set_wc_prop")DEFINE_ID(push_wc_prop, "push_wc_prop")DEFINE_ID(invalidate_wc_props, "invalidate_wc_props")DEFINE_ID(progress_func, "progress_func")DEFINE_ID(auth_baton, "auth_baton")DEFINE_ID(found_entry, "found_entry")DEFINE_ID(file_changed, "file_changed")DEFINE_ID(file_added, "file_added")DEFINE_ID(file_deleted, "file_deleted")DEFINE_ID(dir_added, "dir_added")DEFINE_ID(dir_deleted, "dir_deleted")DEFINE_ID(dir_props_changed, "dir_props_changed")DEFINE_ID(handler, "handler")DEFINE_ID(handler_baton, "handler_baton")DEFINE_ID(__batons__, "__batons__")typedef void *(*r2c_func)(VALUE value, void *ctx, apr_pool_t *pool);typedef VALUE (*c2r_func)(void *value, void *ctx);typedef struct hash_to_apr_hash_data_t{  apr_hash_t *apr_hash;  r2c_func func;  void *ctx;  apr_pool_t *pool;} hash_to_apr_hash_data_t;static void r2c_swig_type2(VALUE value, const char *type_name, void **result);static VALUErb_ary_aref1(VALUE ary, VALUE arg){  VALUE args[1] = {arg};  return rb_ary_aref(1, args, ary);}/* initialize */voidsvn_swig_rb_initialize(void){  apr_initialize();  atexit(apr_terminate);  svn_nls_init();}/* constant getter */static VALUErb_svn(void){  if (NIL_P(mSvn)) {    mSvn = rb_const_get(rb_cObject, rb_intern("Svn"));  }  return mSvn;}static VALUErb_svn_client(void){  if (NIL_P(mSvnClient)) {    mSvnClient = rb_const_get(rb_svn(), rb_intern("Client"));  }  return mSvnClient;}static VALUErb_svn_client_context(void){  if (NIL_P(cSvnClientContext)) {    cSvnClientContext = rb_const_get(rb_svn_client(), rb_intern("Context"));  }  return cSvnClientContext;}static VALUErb_svn_core(void){  if (NIL_P(mSvnCore)) {    mSvnCore = rb_const_get(rb_svn(), rb_intern("Core"));  }  return mSvnCore;}static VALUErb_svn_core_pool(void){  if (NIL_P(cSvnCorePool)) {    cSvnCorePool = rb_const_get(rb_svn_core(), rb_intern("Pool"));    rb_ivar_set(cSvnCorePool, rb_id___pools__(), rb_hash_new());  }  return cSvnCorePool;}static VALUErb_svn_core_stream(void){  if (NIL_P(cSvnCoreStream)) {    cSvnCoreStream = rb_const_get(rb_svn_core(), rb_intern("Stream"));  }  return cSvnCoreStream;}static VALUErb_svn_delta(void){  if (NIL_P(cSvnDelta)) {    cSvnDelta = rb_const_get(rb_svn(), rb_intern("Delta"));  }  return cSvnDelta;}VALUEsvn_swig_rb_svn_delta_editor(void){  if (NIL_P(cSvnDeltaEditor)) {    cSvnDeltaEditor =      rb_const_get(rb_svn_delta(), rb_intern("Editor"));  }  return cSvnDeltaEditor;}VALUEsvn_swig_rb_svn_delta_text_delta_window_handler(void){  if (NIL_P(cSvnDeltaTextDeltaWindowHandler)) {    cSvnDeltaTextDeltaWindowHandler =      rb_const_get(rb_svn_delta(), rb_intern("TextDeltaWindowHandler"));  }  return cSvnDeltaTextDeltaWindowHandler;}static VALUErb_svn_error(void){  if (NIL_P(cSvnError)) {    cSvnError = rb_const_get(rb_svn(), rb_intern("Error"));  }  return cSvnError;}static VALUErb_svn_fs(void){  if (NIL_P(cSvnFs)) {    cSvnFs = rb_const_get(rb_svn(), rb_intern("Fs"));  }  return cSvnFs;}static VALUErb_svn_fs_file_system(void){  if (NIL_P(cSvnFsFileSystem)) {    cSvnFsFileSystem = rb_const_get(rb_svn_fs(), rb_intern("FileSystem"));    rb_ivar_set(cSvnFsFileSystem, rb_id___batons__(), rb_hash_new());  }  return cSvnFsFileSystem;}/* pool holder */static VALUErb_svn_pool_holder(void){  return rb_ivar_get(rb_svn_core_pool(), rb_id___pools__());}static VALUErb_svn_fs_warning_callback_baton_holder(void){  return rb_ivar_get(rb_svn_fs_file_system(), rb_id___batons__());}static VALUErb_holder_push(VALUE holder, VALUE obj){  VALUE key, objs;  key = rb_obj_id(obj);  objs = rb_hash_aref(holder, key);  if (NIL_P(objs)) {    objs = rb_ary_new();    rb_hash_aset(holder, key, objs);  }  rb_ary_push(objs, obj);  return Qnil;}static VALUErb_holder_pop(VALUE holder, VALUE obj){  VALUE key, objs;  VALUE result = Qnil;  key = rb_obj_id(obj);  objs = rb_hash_aref(holder, key);  if (!NIL_P(objs)) {    result = rb_ary_pop(objs);    if (RARRAY(objs)->len == 0) {      rb_hash_delete(holder, key);    }  }  return result;}/* pool */static VALUErb_get_pool(VALUE self){  return rb_ivar_get(self, rb_id___pool__());}static VALUErb_pools(VALUE self){  VALUE pools = rb_ivar_get(self, rb_id___pools__());  if (NIL_P(pools)) {    pools = rb_hash_new();    rb_ivar_set(self, rb_id___pools__(), pools);  }    return pools;}static VALUErb_set_pool(VALUE self, VALUE pool){  if (NIL_P(pool)) {    VALUE old_pool = rb_ivar_get(self, rb_id___pool__());    rb_hash_aset(rb_pools(self), rb_obj_id(old_pool), old_pool);    rb_ivar_set(self, rb_id___pool__(), Qnil);  } else {    if (NIL_P(rb_ivar_get(self, rb_id___pool__()))) {      rb_ivar_set(self, rb_id___pool__(), pool);    } else {      rb_hash_aset(rb_pools(self), rb_obj_id(pool), pool);    }  }  return Qnil;}static VALUErb_pool_new(VALUE parent){  return rb_funcall(rb_svn_core_pool(), rb_id_new(), 1, parent);}static VALUE swig_type_re = Qnil;static VALUEswig_type_regex(void){  if (NIL_P(swig_type_re)) {    char reg_str[] = "\\A(?:SWIG|Svn::Ext)::";    swig_type_re = rb_reg_new(reg_str, strlen(reg_str), 0);    rb_ivar_set(rb_svn(), rb_id_swig_type_regex(), swig_type_re);  }  return swig_type_re;}static VALUEfind_swig_type_object(int num, VALUE *objects){  VALUE re = swig_type_regex();  int i;  for (i = 0; i < num; i++) {    if (RTEST(rb_reg_match(re,                           rb_funcall(rb_obj_class(objects[i]),                                      rb_id_name(),                                      0)))) {      return objects[i];    }  }    return Qnil;}voidsvn_swig_rb_get_pool(int argc, VALUE *argv, VALUE self,                     VALUE *rb_pool, apr_pool_t **pool){  VALUE target;  apr_pool_wrapper_t *pool_wrapper;  apr_pool_wrapper_t **pool_wrapper_p;    *rb_pool = Qnil;    if (argc > 0) {    if (POOL_P(argv[argc - 1])) {      *rb_pool = rb_pool_new(argv[argc - 1]);      argc -= 1;    }  }  target = find_swig_type_object(argc, argv);    if (!NIL_P(self)) {    *rb_pool = rb_get_pool(self);    if (POOL_P(*rb_pool)) {      *rb_pool = rb_pool_new(*rb_pool);    } else {      *rb_pool = Qnil;    }  }  if (NIL_P(*rb_pool)) {    *rb_pool = rb_pool_new(rb_get_pool(target));  }  pool_wrapper_p = &pool_wrapper;  r2c_swig_type2(*rb_pool, "apr_pool_wrapper_t *", (void **)pool_wrapper_p);  *pool = pool_wrapper->pool;}static VALUErb_set_pool_if_swig_type_object(VALUE target, VALUE pool){  VALUE targets[1] = {target};    if (!NIL_P(find_swig_type_object(1, targets))) {    rb_set_pool(target, pool);  }  return Qnil;}voidsvn_swig_rb_set_pool(VALUE target, VALUE pool){  if (NIL_P(target)) {    return;  }      if (!RTEST(rb_obj_is_kind_of(target, rb_cArray))) {    target = rb_ary_new3(1, target);  }  rb_iterate(rb_each, target, rb_set_pool_if_swig_type_object, pool);}voidsvn_swig_rb_set_pool_for_no_swig_type(VALUE target, VALUE pool){  if (NIL_P(target)) {    return;  }      if (!RTEST(rb_obj_is_kind_of(target, rb_cArray))) {    target = rb_ary_new3(1, target);  }  rb_iterate(rb_each, target, rb_set_pool, pool);}voidsvn_swig_rb_push_pool(VALUE pool){  if (!NIL_P(pool)) {    rb_holder_push(rb_svn_pool_holder(), pool);  }}voidsvn_swig_rb_pop_pool(VALUE pool){  if (!NIL_P(pool)) {    rb_holder_pop(rb_svn_pool_holder(), pool);  }}/* error */VALUEsvn_swig_rb_svn_error_new(VALUE code, VALUE message, VALUE file, VALUE line){  return rb_funcall(rb_svn_error(),                    rb_id_new_corresponding_error(),                    4, code, message, file, line);}static VALUEsvn_swig_rb_svn_error_to_rb_error(svn_error_t *error){  VALUE error_code = INT2NUM(error->apr_err);  VALUE message;  VALUE file = Qnil;  VALUE line = Qnil;  if (error->file)    file = rb_str_new2(error->file);  if (error->line)    line = LONG2NUM(error->line);    message = rb_str_new2(error->message ? error->message : "");    while (error->child) {    error = error->child;    if (error->message) {      rb_str_concat(message, rb_str_new2("\n"));      rb_str_concat(message, rb_str_new2(error->message));    }  }  return svn_swig_rb_svn_error_new(error_code, message, file, line);}

⌨️ 快捷键说明

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