📄 swigutil_rb.c
字号:
voidsvn_swig_rb_handle_svn_error(svn_error_t *error){ VALUE rb_error = svn_swig_rb_svn_error_to_rb_error(error); svn_error_clear(error); rb_exc_raise(rb_error);}static VALUE inited = Qnil;/* C -> Ruby */VALUEsvn_swig_rb_from_swig_type(void *value, void *ctx){ swig_type_info *info; if (NIL_P(inited)) { SWIG_InitRuntime(); inited = Qtrue; } info = SWIG_TypeQuery((char *)ctx); if (info) { return SWIG_NewPointerObj(value, info, 0); } else { rb_raise(rb_eArgError, "invalid SWIG type: %s", (char *)ctx); }}#define c2r_swig_type svn_swig_rb_from_swig_typestatic VALUEc2r_string(void *value, void *ctx){ if (value) { return rb_str_new2((const char *)value); } else { return Qnil; }}static VALUEc2r_string2(const char *cstr){ return c2r_string((void *)cstr, NULL);}static VALUEc2r_long(void *value, void *ctx){ return INT2NUM(*(long *)value);}static VALUEc2r_svn_string(void *value, void *ctx){ const svn_string_t *s = (svn_string_t *)value; return c2r_string2(s->data);}/* C -> Ruby (dup) */#define DEFINE_DUP_BASE(type, dup_func, type_prefix) \static VALUE \c2r_ ## type ## _dup(void *type, void *ctx) \{ \ apr_pool_t *type ## _pool; \ VALUE rb_ ## type ## _pool; \ svn_ ## type ## _t *copied_ ## type; \ VALUE rb_copied_ ## type; \ \ if (!type) \ return Qnil; \ \ svn_swig_rb_get_pool(0, (VALUE *)0, 0, \ &rb_ ## type ## _pool, &type ## _pool); \ copied_ ## type = svn_ ## dup_func((type_prefix svn_ ## type ## _t *)type, \ type ## _pool); \ rb_copied_ ## type = c2r_swig_type((void *)copied_ ## type, \ (void *)"svn_" # type "_t *"); \ rb_set_pool(rb_copied_ ## type, rb_ ## type ##_pool); \ \ return rb_copied_ ## type; \} \#define DEFINE_DUP_BASE_WITH_CONVENIENCE(type, dup_func, type_prefix) \DEFINE_DUP_BASE(type, dup_func, type_prefix) \static VALUE \c2r_ ## type ## __dup(type_prefix svn_ ## type ## _t *type) \{ \ return c2r_ ## type ## _dup((void *)type, NULL); \}#define DEFINE_DUP(type, dup_func) \ DEFINE_DUP_BASE_WITH_CONVENIENCE(type, dup_func, const)#define DEFINE_DUP2(type) \ DEFINE_DUP(type, type ## _dup)#define DEFINE_DUP_NO_CONVENIENCE(type, dup_func) \ DEFINE_DUP_BASE(type, dup_func, const)#define DEFINE_DUP_NO_CONVENIENCE2(type) \ DEFINE_DUP_NO_CONVENIENCE(type, type ## _dup)#define DEFINE_DUP_NO_CONST(type, dup_func) \ DEFINE_DUP_BASE_WITH_CONVENIENCE(type, dup_func,)#define DEFINE_DUP_NO_CONST2(type) \ DEFINE_DUP_NO_CONST(type, type ## _dup)DEFINE_DUP(wc_notify, wc_dup_notify)DEFINE_DUP2(txdelta_window)DEFINE_DUP2(info)DEFINE_DUP2(commit_info)DEFINE_DUP2(lock)DEFINE_DUP2(auth_ssl_server_cert_info)DEFINE_DUP2(wc_entry)DEFINE_DUP2(client_diff_summarize)DEFINE_DUP2(dirent)DEFINE_DUP_NO_CONVENIENCE2(prop)DEFINE_DUP_NO_CONVENIENCE2(client_commit_item2)DEFINE_DUP_NO_CONVENIENCE2(client_proplist_item)DEFINE_DUP_NO_CONVENIENCE2(wc_external_item)DEFINE_DUP_NO_CONVENIENCE2(log_changed_path)DEFINE_DUP_NO_CONST(wc_status2, wc_dup_status2)/* Ruby -> C */static void *r2c_string(VALUE value, void *ctx, apr_pool_t *pool){ return (void *)apr_pstrdup(pool, StringValuePtr(value));}static void *r2c_svn_string(VALUE value, void *ctx, apr_pool_t *pool){ return (void *)svn_string_create(StringValuePtr(value), pool);}void *svn_swig_rb_to_swig_type(VALUE value, void *ctx, apr_pool_t *pool){ void **result = NULL; result = apr_palloc(pool, sizeof(void *)); r2c_swig_type2(value, (const char *)ctx, result); return *result;}#define r2c_swig_type svn_swig_rb_to_swig_typestatic voidr2c_swig_type2(VALUE value, const char *type_name, void **result){ int res; res = SWIG_ConvertPtr(value, result, SWIG_TypeQuery(type_name), SWIG_POINTER_EXCEPTION);#ifdef SWIG_IsOK if (!SWIG_IsOK(res)) { VALUE message = rb_funcall(value, rb_intern("inspect"), 0); rb_str_cat2(message, "must be "); rb_str_cat2(message, type_name); SWIG_Error(SWIG_ArgError(res), StringValuePtr(message)); }#endif}static void *r2c_long(VALUE value, void *ctx, apr_pool_t *pool){ return (void *)NUM2LONG(value);}static void *r2c_svn_err(VALUE rb_svn_err, void *ctx, apr_pool_t *pool){ VALUE message; svn_error_t *err; message = rb_funcall(rb_svn_err, rb_id_message(), 0); err = svn_error_create(NUM2INT(rb_funcall(rb_svn_err, rb_id_code(), 0)), NULL, StringValuePtr(message)); return (void *)err;}/* apr_array_t -> Ruby Array */#define DEFINE_APR_ARRAY_TO_ARRAY(return_type, name, conv, amp, type, ctx) \return_type \name(const apr_array_header_t *apr_ary) \{ \ VALUE ary = rb_ary_new(); \ int i; \ \ for (i = 0; i < apr_ary->nelts; i++) { \ rb_ary_push(ary, conv((void *)amp(APR_ARRAY_IDX(apr_ary, i, type)), \ ctx)); \ } \ \ return ary; \}DEFINE_APR_ARRAY_TO_ARRAY(VALUE, svn_swig_rb_apr_array_to_array_string, c2r_string, , const char *, NULL)DEFINE_APR_ARRAY_TO_ARRAY(VALUE, svn_swig_rb_apr_array_to_array_svn_string, c2r_svn_string, &, svn_string_t, NULL)DEFINE_APR_ARRAY_TO_ARRAY(static VALUE, c2r_commit_item2_array, c2r_client_commit_item2_dup, , svn_client_commit_item2_t *, NULL)DEFINE_APR_ARRAY_TO_ARRAY(VALUE, svn_swig_rb_apr_array_to_array_prop, c2r_prop_dup, &, svn_prop_t, NULL)DEFINE_APR_ARRAY_TO_ARRAY(VALUE, svn_swig_rb_apr_array_to_array_svn_rev, c2r_long, &, svn_revnum_t, NULL)DEFINE_APR_ARRAY_TO_ARRAY(VALUE, svn_swig_rb_apr_array_to_array_proplist_item, c2r_client_proplist_item_dup, , svn_client_proplist_item_t *, NULL)DEFINE_APR_ARRAY_TO_ARRAY(VALUE, svn_swig_rb_apr_array_to_array_external_item, c2r_wc_external_item_dup, , svn_wc_external_item_t *, NULL)/* Ruby Array -> apr_array_t */#define DEFINE_ARRAY_TO_APR_ARRAY(type, name, converter, context) \apr_array_header_t * \name(VALUE array, apr_pool_t *pool) \{ \ int i, len; \ apr_array_header_t *apr_ary; \ \ Check_Type(array, T_ARRAY); \ len = RARRAY(array)->len; \ apr_ary = apr_array_make(pool, len, sizeof(type)); \ apr_ary->nelts = len; \ for (i = 0; i < len; i++) { \ VALUE value; \ type val; \ value = rb_ary_entry(array, i); \ val = (type)converter(value, context, pool); \ APR_ARRAY_IDX(apr_ary, i, type) = val; \ } \ return apr_ary; \}DEFINE_ARRAY_TO_APR_ARRAY(const char *, svn_swig_rb_strings_to_apr_array, r2c_string, NULL)DEFINE_ARRAY_TO_APR_ARRAY(svn_auth_provider_object_t *, svn_swig_rb_array_to_auth_provider_object_apr_array, r2c_swig_type, (void *)"svn_auth_provider_object_t *")DEFINE_ARRAY_TO_APR_ARRAY(svn_prop_t *, svn_swig_rb_array_to_apr_array_prop, r2c_swig_type, (void *)"svn_prop_t *")DEFINE_ARRAY_TO_APR_ARRAY(svn_revnum_t, svn_swig_rb_array_to_apr_array_revnum, r2c_long, NULL)/* apr_hash_t -> Ruby Hash */static VALUEc2r_hash_with_key_convert(apr_hash_t *hash, c2r_func key_conv, void *key_ctx, c2r_func value_conv, void *value_ctx){ apr_hash_index_t *hi; VALUE r_hash = rb_hash_new(); for (hi = apr_hash_first(NULL, hash); hi; hi = apr_hash_next(hi)) { const void *key; void *val; VALUE v = Qnil; apr_hash_this(hi, &key, NULL, &val); if (val) { v = (*value_conv)(val, value_ctx); } rb_hash_aset(r_hash, (*key_conv)((void *)key, key_ctx), v); } return r_hash;}VALUEc2r_hash(apr_hash_t *hash, c2r_func value_conv, void *ctx){ return c2r_hash_with_key_convert(hash, c2r_string, NULL, value_conv, ctx);}VALUEsvn_swig_rb_apr_hash_to_hash_string(apr_hash_t *hash){ return c2r_hash(hash, c2r_string, NULL);}VALUEsvn_swig_rb_apr_hash_to_hash_svn_string(apr_hash_t *hash){ return c2r_hash(hash, c2r_svn_string, NULL);}VALUEsvn_swig_rb_apr_hash_to_hash_swig_type(apr_hash_t *hash, const char *type_name){ return c2r_hash(hash, c2r_swig_type, (void *)type_name);}VALUEsvn_swig_rb_prop_hash_to_hash(apr_hash_t *prop_hash){ return svn_swig_rb_apr_hash_to_hash_svn_string(prop_hash);}VALUEc2r_revnum(void *value, void *ctx){ svn_revnum_t *num = value; return INT2NUM(*num);}VALUEsvn_swig_rb_apr_revnum_key_hash_to_hash_string(apr_hash_t *hash){ return c2r_hash_with_key_convert(hash, c2r_revnum, NULL, c2r_string, NULL);}/* Ruby Hash -> apr_hash_t */static intr2c_hash_i(VALUE key, VALUE value, hash_to_apr_hash_data_t *data){ if (key != Qundef) { void *val = data->func(value, data->ctx, data->pool); apr_hash_set(data->apr_hash, apr_pstrdup(data->pool, StringValuePtr(key)), APR_HASH_KEY_STRING, val); } return ST_CONTINUE;}static apr_hash_t *r2c_hash(VALUE hash, r2c_func func, void *ctx, apr_pool_t *pool){ if (NIL_P(hash)) { return NULL; } else { apr_hash_t *apr_hash; hash_to_apr_hash_data_t data = { NULL, func, ctx, pool }; apr_hash = apr_hash_make(pool); data.apr_hash = apr_hash; rb_hash_foreach(hash, r2c_hash_i, (VALUE)&data); return apr_hash; }}apr_hash_t *svn_swig_rb_hash_to_apr_hash_string(VALUE hash, apr_pool_t *pool){ return r2c_hash(hash, r2c_string, NULL, pool);}apr_hash_t *svn_swig_rb_hash_to_apr_hash_svn_string(VALUE hash, apr_pool_t *pool){ return r2c_hash(hash, r2c_svn_string, NULL, pool);}apr_hash_t *svn_swig_rb_hash_to_apr_hash_swig_type(VALUE hash, const char *typename, apr_pool_t *pool){ return r2c_hash(hash, r2c_swig_type, (void *)typename, pool);}static intr2c_hash_i_for_revnum(VALUE key, VALUE value, hash_to_apr_hash_data_t *data){ if (key != Qundef) { svn_revnum_t *revnum = apr_palloc(data->pool, sizeof(svn_revnum_t)); *revnum = NUM2INT(value); apr_hash_set(data->apr_hash, apr_pstrdup(data->pool, StringValuePtr(key)), APR_HASH_KEY_STRING, (void *)revnum); } return ST_CONTINUE;}apr_hash_t *svn_swig_rb_hash_to_apr_hash_revnum(VALUE hash, apr_pool_t *pool){ if (NIL_P(hash)) { return NULL; } else { apr_hash_t *apr_hash; hash_to_apr_hash_data_t data = { NULL, NULL, NULL, pool }; apr_hash = apr_hash_make(pool); data.apr_hash = apr_hash; rb_hash_foreach(hash, r2c_hash_i_for_revnum, (VALUE)&data); return apr_hash; }}/* callback */typedef struct { svn_error_t **err; VALUE pool;} callback_rescue_baton_t;typedef struct { VALUE args; callback_rescue_baton_t *rescue_baton;} callback_handle_error_baton_t;static VALUEcallback(VALUE info){ VALUE pool, result; pool = rb_ary_entry(info, 0); result = rb_apply(rb_ary_entry(info, 1), (ID)rb_ary_entry(info, 2), rb_ary_aref1(info, rb_range_new(INT2NUM(3), INT2NUM(-1), FALSE))); svn_swig_rb_push_pool(pool); return result;}static VALUEcallback_rescue(VALUE baton){ callback_rescue_baton_t *rescue_baton = (callback_rescue_baton_t*)baton; *(rescue_baton->err) = r2c_svn_err(ruby_errinfo, NULL, NULL); svn_swig_rb_push_pool(rescue_baton->pool); return Qnil;}static VALUEcallback_ensure(VALUE pool){ svn_swig_rb_pop_pool(pool); return Qnil;}static VALUEinvoke_callback(VALUE args, VALUE pool){ VALUE new_args = rb_ary_dup(args); rb_ary_unshift(new_args, pool); return rb_ensure(callback, new_args, callback_ensure, pool);}static VALUEcallback_handle_error(VALUE baton){ callback_handle_error_baton_t *handle_error_baton; handle_error_baton = (callback_handle_error_baton_t *)baton; return rb_rescue2(callback, handle_error_baton->args,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -