2 /* Tell swigutil_rb.h that we're inside the implementation */
3 #define SVN_SWIG_SWIGUTIL_RB_C
5 #include "swig_ruby_external_runtime.swg"
6 #include "swigutil_rb.h"
9 #undef PACKAGE_BUGREPORT
12 #undef PACKAGE_TARNAME
13 #undef PACKAGE_VERSION
16 #include "svn_private_config.h"
18 #ifndef RE_OPTION_IGNORECASE
19 # ifdef ONIG_OPTION_IGNORECASE
20 # define RE_OPTION_IGNORECASE ONIG_OPTION_IGNORECASE
25 # define RSTRING_LEN(str) (RSTRING(str)->len)
29 # define RSTRING_PTR(str) (RSTRING(str)->ptr)
35 #include "svn_pools.h"
40 #if APR_HAS_LARGE_FILES
41 # define AOFF2NUM(num) LL2NUM(num)
43 # define AOFF2NUM(num) LONG2NUM(num)
46 #if SIZEOF_LONG_LONG == 8
47 # define AI642NUM(num) LL2NUM(num)
49 # define AI642NUM(num) LONG2NUM(num)
52 #define EMPTY_CPP_ARGUMENT
54 #define POOL_P(obj) (RTEST(rb_obj_is_kind_of(obj, rb_svn_core_pool())))
55 #define CONTEXT_P(obj) (RTEST(rb_obj_is_kind_of(obj, rb_svn_client_context())))
56 #define SVN_ERR_P(obj) (RTEST(rb_obj_is_kind_of(obj, rb_svn_error())))
58 static VALUE mSvn
= Qnil
;
59 static VALUE mSvnClient
= Qnil
;
60 static VALUE mSvnUtil
= Qnil
;
61 static VALUE cSvnClientContext
= Qnil
;
62 static VALUE mSvnCore
= Qnil
;
63 static VALUE cSvnCorePool
= Qnil
;
64 static VALUE cSvnCoreStream
= Qnil
;
65 static VALUE cSvnDelta
= Qnil
;
66 static VALUE cSvnDeltaEditor
= Qnil
;
67 static VALUE cSvnDeltaTextDeltaWindowHandler
= Qnil
;
68 static VALUE cSvnError
= Qnil
;
69 static VALUE cSvnErrorSvnError
= Qnil
;
70 static VALUE cSvnFs
= Qnil
;
71 static VALUE cSvnFsFileSystem
= Qnil
;
72 static VALUE cSvnRa
= Qnil
;
73 static VALUE cSvnRaReporter3
= Qnil
;
75 #define DECLARE_ID(key) static ID id_ ## key
76 #define DEFINE_ID(key) DEFINE_ID_WITH_NAME(key, #key)
77 #define DEFINE_ID_WITH_NAME(key, name) id_ ## key = rb_intern(name)
87 DECLARE_ID(new_corresponding_error
);
88 DECLARE_ID(set_target_revision
);
89 DECLARE_ID(open_root
);
90 DECLARE_ID(delete_entry
);
91 DECLARE_ID(add_directory
);
92 DECLARE_ID(open_directory
);
93 DECLARE_ID(change_dir_prop
);
94 DECLARE_ID(close_directory
);
95 DECLARE_ID(absent_directory
);
97 DECLARE_ID(open_file
);
98 DECLARE_ID(apply_textdelta
);
99 DECLARE_ID(change_file_prop
);
100 DECLARE_ID(absent_file
);
101 DECLARE_ID(close_file
);
102 DECLARE_ID(close_edit
);
103 DECLARE_ID(abort_edit
);
104 DECLARE_ID(__pool__
);
105 DECLARE_ID(__pools__
);
108 DECLARE_ID(swig_type_regex
);
109 DECLARE_ID(open_tmp_file
);
110 DECLARE_ID(get_wc_prop
);
111 DECLARE_ID(set_wc_prop
);
112 DECLARE_ID(push_wc_prop
);
113 DECLARE_ID(invalidate_wc_props
);
114 DECLARE_ID(progress_func
);
115 DECLARE_ID(auth_baton
);
116 DECLARE_ID(found_entry
);
117 DECLARE_ID(file_changed
);
118 DECLARE_ID(file_added
);
119 DECLARE_ID(file_deleted
);
120 DECLARE_ID(dir_added
);
121 DECLARE_ID(dir_deleted
);
122 DECLARE_ID(dir_props_changed
);
124 DECLARE_ID(handler_baton
);
125 DECLARE_ID(__batons__
);
127 DECLARE_ID(filename_to_temp_file
);
129 DECLARE_ID(handle_error
);
130 DECLARE_ID(set_path
);
131 DECLARE_ID(delete_path
);
132 DECLARE_ID(link_path
);
133 DECLARE_ID(finish_report
);
134 DECLARE_ID(abort_report
);
139 typedef void *(*r2c_func
)(VALUE value
, void *ctx
, apr_pool_t
*pool
);
140 typedef VALUE (*c2r_func
)(void *value
, void *ctx
);
141 typedef struct hash_to_apr_hash_data_t
143 apr_hash_t
*apr_hash
;
147 } hash_to_apr_hash_data_t
;
149 static void r2c_swig_type2(VALUE value
, const char *type_name
, void **result
);
150 static const char *r2c_inspect(VALUE object
);
154 /* constant getter */
159 mSvn
= rb_const_get(rb_cObject
, rb_intern("Svn"));
167 if (NIL_P(mSvnUtil
)) {
168 mSvnUtil
= rb_const_get(rb_svn(), rb_intern("Util"));
176 if (NIL_P(mSvnClient
)) {
177 mSvnClient
= rb_const_get(rb_svn(), rb_intern("Client"));
183 rb_svn_client_context(void)
185 if (NIL_P(cSvnClientContext
)) {
186 cSvnClientContext
= rb_const_get(rb_svn_client(), rb_intern("Context"));
188 return cSvnClientContext
;
194 if (NIL_P(mSvnCore
)) {
195 mSvnCore
= rb_const_get(rb_svn(), rb_intern("Core"));
201 rb_svn_core_pool(void)
203 if (NIL_P(cSvnCorePool
)) {
204 cSvnCorePool
= rb_const_get(rb_svn_core(), rb_intern("Pool"));
205 rb_ivar_set(cSvnCorePool
, id___pools__
, rb_hash_new());
211 rb_svn_core_stream(void)
213 if (NIL_P(cSvnCoreStream
)) {
214 cSvnCoreStream
= rb_const_get(rb_svn_core(), rb_intern("Stream"));
216 return cSvnCoreStream
;
222 if (NIL_P(cSvnDelta
)) {
223 cSvnDelta
= rb_const_get(rb_svn(), rb_intern("Delta"));
229 svn_swig_rb_svn_delta_editor(void)
231 if (NIL_P(cSvnDeltaEditor
)) {
233 rb_const_get(rb_svn_delta(), rb_intern("Editor"));
235 return cSvnDeltaEditor
;
239 svn_swig_rb_svn_delta_text_delta_window_handler(void)
241 if (NIL_P(cSvnDeltaTextDeltaWindowHandler
)) {
242 cSvnDeltaTextDeltaWindowHandler
=
243 rb_const_get(rb_svn_delta(), rb_intern("TextDeltaWindowHandler"));
245 return cSvnDeltaTextDeltaWindowHandler
;
251 if (NIL_P(cSvnError
)) {
252 cSvnError
= rb_const_get(rb_svn(), rb_intern("Error"));
258 rb_svn_error_svn_error(void)
260 if (NIL_P(cSvnErrorSvnError
)) {
261 cSvnErrorSvnError
= rb_const_get(rb_svn_error(), rb_intern("SvnError"));
263 return cSvnErrorSvnError
;
270 cSvnFs
= rb_const_get(rb_svn(), rb_intern("Fs"));
276 rb_svn_fs_file_system(void)
278 if (NIL_P(cSvnFsFileSystem
)) {
279 cSvnFsFileSystem
= rb_const_get(rb_svn_fs(), rb_intern("FileSystem"));
280 rb_ivar_set(cSvnFsFileSystem
, id___batons__
, rb_hash_new());
282 return cSvnFsFileSystem
;
289 cSvnRa
= rb_const_get(rb_svn(), rb_intern("Ra"));
295 rb_svn_ra_reporter3(void)
297 if (NIL_P(cSvnRaReporter3
)) {
298 cSvnRaReporter3
= rb_const_get(rb_svn_ra(), rb_intern("Reporter3"));
300 return cSvnRaReporter3
;
304 /* constant resolver */
306 resolve_constant(VALUE parent
, const char *prefix
, VALUE name
)
310 const_name
= rb_str_new2(prefix
);
311 rb_str_concat(const_name
,
312 rb_funcall(rb_funcall(name
, id_to_s
, 0),
314 return rb_const_get(parent
, rb_intern(StringValuePtr(const_name
)));
320 svn_swig_rb_converter_to_locale_encoding(VALUE self
, VALUE str
)
327 pool
= svn_pool_create(NULL
);
328 err
= svn_utf_cstring_from_utf8(&dest
, StringValueCStr(str
), pool
);
330 svn_pool_destroy(pool
);
331 svn_swig_rb_handle_svn_error(err
);
334 result
= rb_str_new2(dest
);
335 svn_pool_destroy(pool
);
340 svn_swig_rb_locale_set(int argc
, VALUE
*argv
, VALUE self
)
345 VALUE rb_category
, rb_locale
;
347 rb_scan_args(argc
, argv
, "02", &rb_category
, &rb_locale
);
349 if (NIL_P(rb_category
))
352 category
= NUM2INT(rb_category
);
354 if (NIL_P(rb_locale
))
357 locale
= StringValueCStr(rb_locale
);
359 result
= setlocale(category
, locale
);
361 return result
? rb_str_new2(result
) : Qnil
;
365 svn_swig_rb_gettext_bindtextdomain(VALUE self
, VALUE path
)
368 bindtextdomain(PACKAGE_NAME
, StringValueCStr(path
));
374 svn_swig_rb_gettext__(VALUE self
, VALUE message
)
377 return rb_str_new2(_(StringValueCStr(message
)));
384 svn_swig_rb_initialize_ids(void)
391 DEFINE_ID_WITH_NAME(eqq
, "===");
394 DEFINE_ID(new_corresponding_error
);
395 DEFINE_ID(set_target_revision
);
396 DEFINE_ID(open_root
);
397 DEFINE_ID(delete_entry
);
398 DEFINE_ID(add_directory
);
399 DEFINE_ID(open_directory
);
400 DEFINE_ID(change_dir_prop
);
401 DEFINE_ID(close_directory
);
402 DEFINE_ID(absent_directory
);
404 DEFINE_ID(open_file
);
405 DEFINE_ID(apply_textdelta
);
406 DEFINE_ID(change_file_prop
);
407 DEFINE_ID(absent_file
);
408 DEFINE_ID(close_file
);
409 DEFINE_ID(close_edit
);
410 DEFINE_ID(abort_edit
);
412 DEFINE_ID(__pools__
);
415 DEFINE_ID(swig_type_regex
);
416 DEFINE_ID(open_tmp_file
);
417 DEFINE_ID(get_wc_prop
);
418 DEFINE_ID(set_wc_prop
);
419 DEFINE_ID(push_wc_prop
);
420 DEFINE_ID(invalidate_wc_props
);
421 DEFINE_ID(progress_func
);
422 DEFINE_ID(auth_baton
);
423 DEFINE_ID(found_entry
);
424 DEFINE_ID(file_changed
);
425 DEFINE_ID(file_added
);
426 DEFINE_ID(file_deleted
);
427 DEFINE_ID(dir_added
);
428 DEFINE_ID(dir_deleted
);
429 DEFINE_ID(dir_props_changed
);
431 DEFINE_ID(handler_baton
);
432 DEFINE_ID(__batons__
);
434 DEFINE_ID(filename_to_temp_file
);
436 DEFINE_ID(handle_error
);
438 DEFINE_ID(delete_path
);
439 DEFINE_ID(link_path
);
440 DEFINE_ID(finish_report
);
441 DEFINE_ID(abort_report
);
447 svn_swig_rb_initialize(void)
451 VALUE mSvnConverter
, mSvnLocale
, mSvnGetText
;
453 status
= apr_initialize();
456 apr_strerror(status
, buf
, sizeof(buf
) - 1);
457 rb_raise(rb_eLoadError
, "cannot initialize APR: %s", buf
);
460 if (atexit(apr_terminate
)) {
461 rb_raise(rb_eLoadError
, "atexit registration failed");
464 pool
= svn_pool_create(NULL
);
465 svn_utf_initialize(pool
);
467 svn_swig_rb_initialize_ids();
469 mSvnConverter
= rb_define_module_under(rb_svn(), "Converter");
470 rb_define_module_function(mSvnConverter
, "to_locale_encoding",
471 svn_swig_rb_converter_to_locale_encoding
, 1);
473 mSvnLocale
= rb_define_module_under(rb_svn(), "Locale");
474 rb_define_const(mSvnLocale
, "ALL", INT2NUM(LC_ALL
));
475 rb_define_const(mSvnLocale
, "COLLATE", INT2NUM(LC_COLLATE
));
476 rb_define_const(mSvnLocale
, "CTYPE", INT2NUM(LC_CTYPE
));
478 rb_define_const(mSvnLocale
, "MESSAGES", INT2NUM(LC_MESSAGES
));
480 rb_define_const(mSvnLocale
, "MONETARY", INT2NUM(LC_MONETARY
));
481 rb_define_const(mSvnLocale
, "NUMERIC", INT2NUM(LC_NUMERIC
));
482 rb_define_const(mSvnLocale
, "TIME", INT2NUM(LC_TIME
));
483 rb_define_module_function(mSvnLocale
, "set", svn_swig_rb_locale_set
, -1);
485 mSvnGetText
= rb_define_module_under(rb_svn(), "GetText");
486 rb_define_module_function(mSvnGetText
, "bindtextdomain",
487 svn_swig_rb_gettext_bindtextdomain
, 1);
488 rb_define_module_function(mSvnGetText
, "_",
489 svn_swig_rb_gettext__
, 1);
495 rb_svn_pool_holder(void)
497 return rb_ivar_get(rb_svn_core_pool(), id___pools__
);
501 rb_svn_fs_warning_callback_baton_holder(void)
503 return rb_ivar_get(rb_svn_fs_file_system(), id___batons__
);
507 rb_holder_push(VALUE holder
, VALUE obj
)
511 key
= rb_obj_id(obj
);
512 objs
= rb_hash_aref(holder
, key
);
516 rb_hash_aset(holder
, key
, objs
);
519 rb_ary_push(objs
, obj
);
525 rb_holder_pop(VALUE holder
, VALUE obj
)
530 key
= rb_obj_id(obj
);
531 objs
= rb_hash_aref(holder
, key
);
534 result
= rb_ary_pop(objs
);
535 if (RARRAY(objs
)->len
== 0) {
536 rb_hash_delete(holder
, key
);
546 rb_get_pool(VALUE self
)
548 return rb_ivar_get(self
, id___pool__
);
554 VALUE pools
= rb_ivar_get(self
, id___pools__
);
557 pools
= rb_hash_new();
558 rb_ivar_set(self
, id___pools__
, pools
);
565 rb_set_pool(VALUE self
, VALUE pool
)
568 VALUE old_pool
= rb_ivar_get(self
, id___pool__
);
569 rb_hash_aset(rb_pools(self
), rb_obj_id(old_pool
), old_pool
);
570 rb_ivar_set(self
, id___pool__
, Qnil
);
572 if (NIL_P(rb_ivar_get(self
, id___pool__
))) {
573 rb_ivar_set(self
, id___pool__
, pool
);
575 rb_hash_aset(rb_pools(self
), rb_obj_id(pool
), pool
);
583 rb_pool_new(VALUE parent
)
585 return rb_funcall(rb_svn_core_pool(), id_new
, 1, parent
);
588 static VALUE swig_type_re
= Qnil
;
591 swig_type_regex(void)
593 if (NIL_P(swig_type_re
)) {
594 char reg_str
[] = "\\A(?:SWIG|Svn::Ext)::";
595 swig_type_re
= rb_reg_new(reg_str
, strlen(reg_str
), 0);
596 rb_ivar_set(rb_svn(), id_swig_type_regex
, swig_type_re
);
602 find_swig_type_object(int num
, VALUE
*objects
)
604 VALUE re
= swig_type_regex();
607 for (i
= 0; i
< num
; i
++) {
608 if (RTEST(rb_reg_match(re
,
609 rb_funcall(rb_obj_class(objects
[i
]),
620 svn_swig_rb_get_pool(int argc
, VALUE
*argv
, VALUE self
,
621 VALUE
*rb_pool
, apr_pool_t
**pool
)
626 if (POOL_P(argv
[argc
- 1])) {
627 *rb_pool
= rb_pool_new(argv
[argc
- 1]);
632 if (NIL_P(*rb_pool
) && !NIL_P(self
)) {
633 *rb_pool
= rb_get_pool(self
);
634 if (POOL_P(*rb_pool
)) {
635 *rb_pool
= rb_pool_new(*rb_pool
);
641 if (NIL_P(*rb_pool
)) {
643 target
= find_swig_type_object(argc
, argv
);
644 *rb_pool
= rb_pool_new(rb_get_pool(target
));
648 apr_pool_wrapper_t
*pool_wrapper
;
649 apr_pool_wrapper_t
**pool_wrapper_p
;
651 pool_wrapper_p
= &pool_wrapper
;
652 r2c_swig_type2(*rb_pool
, "apr_pool_wrapper_t *", (void **)pool_wrapper_p
);
653 *pool
= pool_wrapper
->pool
;
658 rb_set_pool_if_swig_type_object(VALUE target
, VALUE pool
)
660 VALUE targets
[1] = {target
};
662 if (!NIL_P(find_swig_type_object(1, targets
))) {
663 rb_set_pool(target
, pool
);
670 struct rb_set_pool_for_hash_arg
{
676 rb_set_pool_for_hash_callback(VALUE key
, VALUE value
,
677 struct rb_set_pool_for_hash_arg
*arg
)
679 if (svn_swig_rb_set_pool(value
, arg
->pool
))
685 svn_swig_rb_set_pool(VALUE target
, VALUE pool
)
691 if (RTEST(rb_obj_is_kind_of(target
, rb_cArray
))) {
693 svn_boolean_t set
= FALSE
;
695 for (i
= 0; i
< RARRAY(target
)->len
; i
++) {
696 if (svn_swig_rb_set_pool(RARRAY(target
)->ptr
[i
], pool
))
700 } else if (RTEST(rb_obj_is_kind_of(target
, rb_cHash
))) {
701 struct rb_set_pool_for_hash_arg arg
;
704 rb_hash_foreach(target
, rb_set_pool_for_hash_callback
, (VALUE
)&arg
);
707 return rb_set_pool_if_swig_type_object(target
, pool
);
712 svn_swig_rb_set_pool_for_no_swig_type(VALUE target
, VALUE pool
)
718 if (!RTEST(rb_obj_is_kind_of(target
, rb_cArray
))) {
719 target
= rb_ary_new3(1, target
);
722 rb_iterate(rb_each
, target
, rb_set_pool
, pool
);
726 svn_swig_rb_push_pool(VALUE pool
)
729 rb_holder_push(rb_svn_pool_holder(), pool
);
734 svn_swig_rb_pop_pool(VALUE pool
)
737 rb_holder_pop(rb_svn_pool_holder(), pool
);
742 svn_swig_rb_destroy_pool(VALUE pool
)
745 rb_funcall(pool
, id_destroy
, 0);
750 svn_swig_rb_destroy_internal_pool(VALUE object
)
752 svn_swig_rb_destroy_pool(rb_get_pool(object
));
758 svn_swig_rb_raise_svn_fs_already_close(void)
760 static VALUE rb_svn_error_fs_already_close
= 0;
762 if (!rb_svn_error_fs_already_close
) {
763 rb_svn_error_fs_already_close
=
764 rb_const_get(rb_svn_error(), rb_intern("FsAlreadyClose"));
767 rb_raise(rb_svn_error_fs_already_close
, "closed file system");
771 svn_swig_rb_raise_svn_repos_already_close(void)
773 static VALUE rb_svn_error_repos_already_close
= 0;
775 if (!rb_svn_error_repos_already_close
) {
776 rb_svn_error_repos_already_close
=
777 rb_const_get(rb_svn_error(), rb_intern("ReposAlreadyClose"));
780 rb_raise(rb_svn_error_repos_already_close
, "closed repository");
784 svn_swig_rb_svn_error_new(VALUE code
, VALUE message
, VALUE file
, VALUE line
)
786 return rb_funcall(rb_svn_error_svn_error(),
787 id_new_corresponding_error
,
788 4, code
, message
, file
, line
);
792 svn_swig_rb_svn_error_to_rb_error(svn_error_t
*error
)
794 VALUE error_code
= INT2NUM(error
->apr_err
);
800 file
= rb_str_new2(error
->file
);
802 line
= LONG2NUM(error
->line
);
804 message
= rb_str_new2(error
->message
? error
->message
: "");
806 while (error
->child
) {
807 error
= error
->child
;
808 if (error
->message
) {
809 rb_str_concat(message
, rb_str_new2("\n"));
810 rb_str_concat(message
, rb_str_new2(error
->message
));
814 return svn_swig_rb_svn_error_new(error_code
, message
, file
, line
);
818 svn_swig_rb_handle_svn_error(svn_error_t
*error
)
820 VALUE rb_error
= svn_swig_rb_svn_error_to_rb_error(error
);
821 svn_error_clear(error
);
822 rb_exc_raise(rb_error
);
826 static VALUE inited
= Qnil
;
829 svn_swig_rb_from_swig_type(void *value
, void *ctx
)
831 swig_type_info
*info
;
838 info
= SWIG_TypeQuery((char *)ctx
);
840 return SWIG_NewPointerObj(value
, info
, 0);
842 rb_raise(rb_eArgError
, "invalid SWIG type: %s", (char *)ctx
);
845 #define c2r_swig_type svn_swig_rb_from_swig_type
848 svn_swig_rb_to_depth(VALUE value
)
851 return svn_depth_infinity
;
852 } else if (value
== Qtrue
) {
853 return SVN_DEPTH_INFINITY_OR_FILES(TRUE
);
854 } else if (value
== Qfalse
) {
855 return SVN_DEPTH_INFINITY_OR_FILES(FALSE
);
856 } else if (RTEST(rb_obj_is_kind_of(value
, rb_cString
)) ||
857 RTEST(rb_obj_is_kind_of(value
, rb_cSymbol
))) {
858 value
= rb_funcall(value
, id_to_s
, 0);
859 return svn_depth_from_word(StringValueCStr(value
));
860 } else if (RTEST(rb_obj_is_kind_of(value
, rb_cInteger
))) {
861 return NUM2INT(value
);
863 rb_raise(rb_eArgError
,
864 "'%s' must be DEPTH_STRING (e.g. \"infinity\" or :infinity) "
865 "or Svn::Core::DEPTH_*",
870 svn_mergeinfo_inheritance_t
871 svn_swig_rb_to_mergeinfo_inheritance(VALUE value
)
874 return svn_mergeinfo_inherited
;
875 } else if (RTEST(rb_obj_is_kind_of(value
, rb_cString
)) ||
876 RTEST(rb_obj_is_kind_of(value
, rb_cSymbol
))) {
877 value
= rb_funcall(value
, id_to_s
, 0);
878 return svn_inheritance_from_word(StringValueCStr(value
));
879 } else if (RTEST(rb_obj_is_kind_of(value
, rb_cInteger
))) {
880 return NUM2INT(value
);
882 rb_raise(rb_eArgError
,
883 "'%s' must be MERGEINFO_STRING (e.g. \"explicit\" or :explicit) "
884 "or Svn::Core::MERGEINFO_*",
890 c2r_string(void *value
, void *ctx
)
893 return rb_str_new2((const char *)value
);
900 c2r_string2(const char *cstr
)
902 return c2r_string((void *)cstr
, NULL
);
905 #define c2r_bool2(bool) (bool ? Qtrue : Qfalse)
908 svn_swig_rb_svn_date_string_to_time(const char *date
)
915 pool
= svn_pool_create(NULL
);
916 error
= svn_time_from_cstring(&tm
, date
, pool
);
917 svn_pool_destroy(pool
);
919 svn_swig_rb_handle_svn_error(error
);
920 return rb_time_new((time_t)apr_time_sec(tm
), (time_t)apr_time_usec(tm
));
925 #define c2r_svn_date_string2 svn_swig_rb_svn_date_string_to_time
928 c2r_long(void *value
, void *ctx
)
930 return INT2NUM(*(long *)value
);
934 c2r_svn_string(void *value
, void *ctx
)
936 const svn_string_t
*s
= (svn_string_t
*)value
;
938 return c2r_string2(s
->data
);
942 apr_array_header_t
*array
;
944 } prop_hash_each_arg_t
;
947 svn_swig_rb_to_apr_array_row_prop_callback(VALUE key
, VALUE value
,
948 prop_hash_each_arg_t
*arg
)
952 prop
= apr_array_push(arg
->array
);
953 prop
->name
= apr_pstrdup(arg
->pool
, StringValueCStr(key
));
954 prop
->value
= svn_string_ncreate(RSTRING_PTR(value
), RSTRING_LEN(value
),
960 svn_swig_rb_to_apr_array_row_prop(VALUE array_or_hash
, apr_pool_t
*pool
)
962 if (RTEST(rb_obj_is_kind_of(array_or_hash
, rb_cArray
))) {
964 apr_array_header_t
*result
;
966 len
= RARRAY(array_or_hash
)->len
;
967 result
= apr_array_make(pool
, len
, sizeof(svn_prop_t
));
969 for (i
= 0; i
< len
; i
++) {
970 VALUE name
, value
, item
;
973 item
= rb_ary_entry(array_or_hash
, i
);
974 name
= rb_funcall(item
, id_name
, 0);
975 value
= rb_funcall(item
, id_value
, 0);
976 prop
= &APR_ARRAY_IDX(result
, i
, svn_prop_t
);
977 prop
->name
= apr_pstrdup(pool
, StringValueCStr(name
));
978 prop
->value
= svn_string_ncreate(RSTRING_PTR(value
), RSTRING_LEN(value
),
982 } else if (RTEST(rb_obj_is_kind_of(array_or_hash
, rb_cHash
))) {
983 apr_array_header_t
*result
;
984 prop_hash_each_arg_t arg
;
986 result
= apr_array_make(pool
, 0, sizeof(svn_prop_t
));
989 rb_hash_foreach(array_or_hash
, svn_swig_rb_to_apr_array_row_prop_callback
,
993 rb_raise(rb_eArgError
,
994 "'%s' must be [Svn::Core::Prop, ...] or {'name' => 'value', ...}",
995 r2c_inspect(array_or_hash
));
1000 svn_swig_rb_to_apr_array_prop_callback(VALUE key
, VALUE value
,
1001 prop_hash_each_arg_t
*arg
)
1005 prop
= apr_palloc(arg
->pool
, sizeof(svn_prop_t
));
1006 prop
->name
= apr_pstrdup(arg
->pool
, StringValueCStr(key
));
1007 prop
->value
= svn_string_ncreate(RSTRING_PTR(value
), RSTRING_LEN(value
),
1009 APR_ARRAY_PUSH(arg
->array
, svn_prop_t
*) = prop
;
1013 apr_array_header_t
*
1014 svn_swig_rb_to_apr_array_prop(VALUE array_or_hash
, apr_pool_t
*pool
)
1016 if (RTEST(rb_obj_is_kind_of(array_or_hash
, rb_cArray
))) {
1018 apr_array_header_t
*result
;
1020 len
= RARRAY(array_or_hash
)->len
;
1021 result
= apr_array_make(pool
, len
, sizeof(svn_prop_t
*));
1022 result
->nelts
= len
;
1023 for (i
= 0; i
< len
; i
++) {
1024 VALUE name
, value
, item
;
1027 item
= rb_ary_entry(array_or_hash
, i
);
1028 name
= rb_funcall(item
, id_name
, 0);
1029 value
= rb_funcall(item
, id_value
, 0);
1030 prop
= apr_palloc(pool
, sizeof(svn_prop_t
));
1031 prop
->name
= apr_pstrdup(pool
, StringValueCStr(name
));
1032 prop
->value
= svn_string_ncreate(RSTRING_PTR(value
), RSTRING_LEN(value
),
1034 APR_ARRAY_IDX(result
, i
, svn_prop_t
*) = prop
;
1037 } else if (RTEST(rb_obj_is_kind_of(array_or_hash
, rb_cHash
))) {
1038 apr_array_header_t
*result
;
1039 prop_hash_each_arg_t arg
;
1041 result
= apr_array_make(pool
, 0, sizeof(svn_prop_t
*));
1044 rb_hash_foreach(array_or_hash
, svn_swig_rb_to_apr_array_prop_callback
,
1048 rb_raise(rb_eArgError
,
1049 "'%s' must be [Svn::Core::Prop, ...] or {'name' => 'value', ...}",
1050 r2c_inspect(array_or_hash
));
1055 /* C -> Ruby (dup) */
1056 #define DEFINE_DUP_BASE(type, dup_func, type_prefix) \
1058 c2r_ ## type ## _dup(void *type, void *ctx) \
1062 svn_ ## type ## _t *copied_item; \
1063 VALUE rb_copied_item; \
1068 svn_swig_rb_get_pool(0, (VALUE *)0, 0, &rb_pool, &pool); \
1069 copied_item = svn_ ## dup_func((type_prefix svn_ ## type ## _t *)type, \
1071 rb_copied_item = c2r_swig_type((void *)copied_item, \
1072 (void *)"svn_" # type "_t *"); \
1073 rb_set_pool(rb_copied_item, rb_pool); \
1075 return rb_copied_item; \
1078 #define DEFINE_DUP_BASE_WITH_CONVENIENCE(type, dup_func, type_prefix) \
1079 DEFINE_DUP_BASE(type, dup_func, type_prefix) \
1081 c2r_ ## type ## __dup(type_prefix svn_ ## type ## _t *type) \
1084 void_type = (void *)type; \
1085 return c2r_ ## type ## _dup(void_type, NULL); \
1088 #define DEFINE_DUP_WITH_FUNCTION_NAME(type, dup_func) \
1089 DEFINE_DUP_BASE_WITH_CONVENIENCE(type, dup_func, const)
1090 #define DEFINE_DUP(type) \
1091 DEFINE_DUP_WITH_FUNCTION_NAME(type, type ## _dup)
1093 #define DEFINE_DUP_NO_CONVENIENCE_WITH_FUNCTION_NAME(type, dup_func) \
1094 DEFINE_DUP_BASE(type, dup_func, const)
1095 #define DEFINE_DUP_NO_CONVENIENCE(type) \
1096 DEFINE_DUP_NO_CONVENIENCE_WITH_FUNCTION_NAME(type, type ## _dup)
1098 #define DEFINE_DUP_NO_CONST_WITH_FUNCTION_NAME(type, dup_func) \
1099 DEFINE_DUP_BASE_WITH_CONVENIENCE(type, dup_func,)
1100 #define DEFINE_DUP_NO_CONST(type) \
1101 DEFINE_DUP_NO_CONST_WITH_FUNCTION_NAME(type, type ## _dup)
1103 #define DEFINE_DUP_NO_CONST_NO_CONVENIENCE_WITH_FUNCTION_NAME(type, dup_func) \
1104 DEFINE_DUP_BASE(type, dup_func,)
1105 #define DEFINE_DUP_NO_CONST_NO_CONVENIENCE(type) \
1106 DEFINE_DUP_NO_CONST_NO_CONVENIENCE_WITH_FUNCTION_NAME(type, type ## _dup)
1109 DEFINE_DUP_WITH_FUNCTION_NAME(wc_notify
, wc_dup_notify
)
1110 DEFINE_DUP(txdelta_window
)
1112 DEFINE_DUP(commit_info
)
1114 DEFINE_DUP(auth_ssl_server_cert_info
)
1115 DEFINE_DUP(wc_entry
)
1116 DEFINE_DUP(client_diff_summarize
)
1118 DEFINE_DUP_NO_CONVENIENCE(client_commit_item3
)
1119 DEFINE_DUP_NO_CONVENIENCE(client_proplist_item
)
1120 DEFINE_DUP_NO_CONVENIENCE(wc_external_item2
)
1121 DEFINE_DUP_NO_CONVENIENCE(log_changed_path
)
1122 DEFINE_DUP_NO_CONST_WITH_FUNCTION_NAME(wc_status2
, wc_dup_status2
)
1123 DEFINE_DUP_NO_CONST_NO_CONVENIENCE(merge_range
)
1128 r2c_inspect(VALUE object
)
1131 inspected
= rb_funcall(object
, id_inspect
, 0);
1132 return StringValueCStr(inspected
);
1136 r2c_string(VALUE value
, void *ctx
, apr_pool_t
*pool
)
1138 return (void *)apr_pstrdup(pool
, StringValuePtr(value
));
1142 r2c_svn_string(VALUE value
, void *ctx
, apr_pool_t
*pool
)
1144 return (void *)svn_string_create(StringValuePtr(value
), pool
);
1148 svn_swig_rb_to_swig_type(VALUE value
, void *ctx
, apr_pool_t
*pool
)
1150 void **result
= NULL
;
1151 result
= apr_palloc(pool
, sizeof(void *));
1152 r2c_swig_type2(value
, (const char *)ctx
, result
);
1155 #define r2c_swig_type svn_swig_rb_to_swig_type
1158 r2c_swig_type2(VALUE value
, const char *type_name
, void **result
)
1161 res
= SWIG_ConvertPtr(value
, result
, SWIG_TypeQuery(type_name
),
1162 SWIG_POINTER_EXCEPTION
);
1164 if (!SWIG_IsOK(res
)) {
1165 VALUE message
= rb_funcall(value
, rb_intern("inspect"), 0);
1166 rb_str_cat2(message
, "must be ");
1167 rb_str_cat2(message
, type_name
);
1168 SWIG_Error(SWIG_ArgError(res
), StringValuePtr(message
));
1174 r2c_long(VALUE value
, void *ctx
, apr_pool_t
*pool
)
1176 return (void *)NUM2LONG(value
);
1180 r2c_svn_err(VALUE rb_svn_err
, void *ctx
, apr_pool_t
*pool
)
1185 message
= rb_funcall(rb_svn_err
, id_message
, 0);
1186 err
= svn_error_create(NUM2INT(rb_funcall(rb_svn_err
, id_code
, 0)),
1188 StringValuePtr(message
));
1193 r2c_revnum(VALUE value
, void *ctx
, apr_pool_t
*pool
)
1195 svn_revnum_t
*revnum
;
1196 revnum
= apr_palloc(pool
, sizeof(svn_revnum_t
));
1197 *revnum
= NUM2INT(value
);
1202 r2c_merge_range(VALUE value
, void *ctx
, apr_pool_t
*pool
)
1204 return svn_swig_rb_array_to_apr_array_merge_range(value
, pool
);
1208 /* apr_array_t -> Ruby Array */
1209 #define DEFINE_APR_ARRAY_TO_ARRAY(return_type, name, conv, amp, type, ctx) \
1211 name(const apr_array_header_t *apr_ary) \
1213 VALUE ary = rb_ary_new(); \
1216 for (i = 0; i < apr_ary->nelts; i++) { \
1217 rb_ary_push(ary, conv((void *)amp(APR_ARRAY_IDX(apr_ary, i, type)), \
1224 DEFINE_APR_ARRAY_TO_ARRAY(VALUE
, svn_swig_rb_apr_array_to_array_string
,
1225 c2r_string
, EMPTY_CPP_ARGUMENT
, const char *, NULL
)
1226 DEFINE_APR_ARRAY_TO_ARRAY(VALUE
, svn_swig_rb_apr_array_to_array_svn_string
,
1227 c2r_svn_string
, &, svn_string_t
, NULL
)
1228 DEFINE_APR_ARRAY_TO_ARRAY(static VALUE
, c2r_commit_item3_array
,
1229 c2r_client_commit_item3_dup
, EMPTY_CPP_ARGUMENT
,
1230 svn_client_commit_item3_t
*, NULL
)
1231 DEFINE_APR_ARRAY_TO_ARRAY(VALUE
, svn_swig_rb_apr_array_to_array_svn_rev
,
1232 c2r_long
, &, svn_revnum_t
, NULL
)
1233 DEFINE_APR_ARRAY_TO_ARRAY(VALUE
, svn_swig_rb_apr_array_to_array_proplist_item
,
1234 c2r_client_proplist_item_dup
, EMPTY_CPP_ARGUMENT
,
1235 svn_client_proplist_item_t
*, NULL
)
1236 DEFINE_APR_ARRAY_TO_ARRAY(VALUE
, svn_swig_rb_apr_array_to_array_external_item2
,
1237 c2r_wc_external_item2_dup
, EMPTY_CPP_ARGUMENT
,
1238 svn_wc_external_item2_t
*, NULL
)
1239 DEFINE_APR_ARRAY_TO_ARRAY(VALUE
, svn_swig_rb_apr_array_to_array_merge_range
,
1240 c2r_merge_range_dup
, EMPTY_CPP_ARGUMENT
,
1241 svn_merge_range_t
*, NULL
)
1244 c2r_merge_range_array(void *value
, void *ctx
)
1246 return svn_swig_rb_apr_array_to_array_merge_range(value
);
1250 svn_swig_rb_prop_apr_array_to_hash_prop(const apr_array_header_t
*apr_ary
)
1255 hash
= rb_hash_new();
1256 for (i
= 0; i
< apr_ary
->nelts
; i
++) {
1258 prop
= APR_ARRAY_IDX(apr_ary
, i
, svn_prop_t
);
1260 prop
.name
? rb_str_new2(prop
.name
) : Qnil
,
1261 prop
.value
&& prop
.value
->data
?
1262 rb_str_new2(prop
.value
->data
) : Qnil
);
1268 apr_array_header_t
*
1269 svn_swig_rb_array_to_apr_array_revision_range(VALUE array
, apr_pool_t
*pool
)
1272 apr_array_header_t
*apr_ary
;
1274 Check_Type(array
, T_ARRAY
);
1275 len
= RARRAY(array
)->len
;
1276 apr_ary
= apr_array_make(pool
, len
, sizeof(svn_opt_revision_range_t
*));
1277 apr_ary
->nelts
= len
;
1278 for (i
= 0; i
< len
; i
++) {
1280 svn_opt_revision_range_t
*range
;
1282 value
= rb_ary_entry(array
, i
);
1283 if (RTEST(rb_obj_is_kind_of(value
, rb_cArray
))) {
1284 if (RARRAY(value
)->len
!= 2)
1285 rb_raise(rb_eArgError
,
1286 "revision range should be [start, end]: %s",
1287 r2c_inspect(value
));
1288 range
= apr_palloc(pool
, sizeof(*range
));
1289 svn_swig_rb_set_revision(&range
->start
, rb_ary_entry(value
, 0));
1290 svn_swig_rb_set_revision(&range
->end
, rb_ary_entry(value
, 1));
1292 range
= r2c_swig_type(value
, (void *)"svn_opt_revision_range_t *", pool
);
1294 APR_ARRAY_IDX(apr_ary
, i
, svn_opt_revision_range_t
*) = range
;
1301 /* Ruby Array -> apr_array_t */
1302 #define DEFINE_ARRAY_TO_APR_ARRAY(type, name, converter, context) \
1303 apr_array_header_t * \
1304 name(VALUE array, apr_pool_t *pool) \
1307 apr_array_header_t *apr_ary; \
1309 Check_Type(array, T_ARRAY); \
1310 len = RARRAY(array)->len; \
1311 apr_ary = apr_array_make(pool, len, sizeof(type)); \
1312 apr_ary->nelts = len; \
1313 for (i = 0; i < len; i++) { \
1316 value = rb_ary_entry(array, i); \
1317 val = (type)converter(value, context, pool); \
1318 APR_ARRAY_IDX(apr_ary, i, type) = val; \
1323 DEFINE_ARRAY_TO_APR_ARRAY(const char *, svn_swig_rb_strings_to_apr_array
,
1325 DEFINE_ARRAY_TO_APR_ARRAY(svn_auth_provider_object_t
*,
1326 svn_swig_rb_array_to_auth_provider_object_apr_array
,
1327 r2c_swig_type
, (void *)"svn_auth_provider_object_t *")
1328 DEFINE_ARRAY_TO_APR_ARRAY(svn_revnum_t
,
1329 svn_swig_rb_array_to_apr_array_revnum
,
1331 DEFINE_ARRAY_TO_APR_ARRAY(svn_merge_range_t
*,
1332 svn_swig_rb_array_to_apr_array_merge_range
,
1333 r2c_swig_type
, (void *)"svn_merge_range_t *")
1334 DEFINE_ARRAY_TO_APR_ARRAY(svn_client_copy_source_t
*,
1335 svn_swig_rb_array_to_apr_array_copy_source
,
1336 r2c_swig_type
, (void *)"svn_client_copy_source_t *")
1339 /* apr_hash_t -> Ruby Hash */
1341 c2r_hash_with_key_convert(apr_hash_t
*hash
,
1344 c2r_func value_conv
,
1347 apr_hash_index_t
*hi
;
1353 r_hash
= rb_hash_new();
1355 for (hi
= apr_hash_first(NULL
, hash
); hi
; hi
= apr_hash_next(hi
)) {
1360 apr_hash_this(hi
, &key
, NULL
, &val
);
1362 v
= (*value_conv
)(val
, value_ctx
);
1364 rb_hash_aset(r_hash
, (*key_conv
)((void *)key
, key_ctx
), v
);
1371 c2r_hash(apr_hash_t
*hash
,
1372 c2r_func value_conv
,
1375 return c2r_hash_with_key_convert(hash
, c2r_string
, NULL
, value_conv
, ctx
);
1379 svn_swig_rb_apr_hash_to_hash_string(apr_hash_t
*hash
)
1381 return c2r_hash(hash
, c2r_string
, NULL
);
1385 svn_swig_rb_apr_hash_to_hash_svn_string(apr_hash_t
*hash
)
1387 return c2r_hash(hash
, c2r_svn_string
, NULL
);
1391 svn_swig_rb_apr_hash_to_hash_swig_type(apr_hash_t
*hash
, const char *type_name
)
1393 return c2r_hash(hash
, c2r_swig_type
, (void *)type_name
);
1397 svn_swig_rb_apr_hash_to_hash_merge_range(apr_hash_t
*hash
)
1399 return c2r_hash(hash
, c2r_merge_range_array
, NULL
);
1403 c2r_merge_range_hash(void *value
, void *ctx
)
1405 apr_hash_t
*hash
= value
;
1407 return svn_swig_rb_apr_hash_to_hash_merge_range(hash
);
1411 svn_swig_rb_apr_hash_to_hash_merge_range_hash(apr_hash_t
*hash
)
1413 return c2r_hash(hash
, c2r_merge_range_hash
, NULL
);
1417 svn_swig_rb_prop_hash_to_hash(apr_hash_t
*prop_hash
)
1419 return svn_swig_rb_apr_hash_to_hash_svn_string(prop_hash
);
1423 c2r_revnum(void *value
, void *ctx
)
1425 svn_revnum_t
*num
= value
;
1426 return INT2NUM(*num
);
1430 svn_swig_rb_apr_revnum_key_hash_to_hash_string(apr_hash_t
*hash
)
1432 return c2r_hash_with_key_convert(hash
, c2r_revnum
, NULL
, c2r_string
, NULL
);
1436 /* Ruby Hash -> apr_hash_t */
1438 r2c_hash_i(VALUE key
, VALUE value
, hash_to_apr_hash_data_t
*data
)
1440 if (key
!= Qundef
) {
1441 void *val
= data
->func(value
, data
->ctx
, data
->pool
);
1442 apr_hash_set(data
->apr_hash
,
1443 apr_pstrdup(data
->pool
, StringValuePtr(key
)),
1444 APR_HASH_KEY_STRING
,
1451 r2c_hash(VALUE hash
, r2c_func func
, void *ctx
, apr_pool_t
*pool
)
1456 apr_hash_t
*apr_hash
;
1457 hash_to_apr_hash_data_t data
= {
1464 apr_hash
= apr_hash_make(pool
);
1465 data
.apr_hash
= apr_hash
;
1466 rb_hash_foreach(hash
, r2c_hash_i
, (VALUE
)&data
);
1474 svn_swig_rb_hash_to_apr_hash_string(VALUE hash
, apr_pool_t
*pool
)
1476 return r2c_hash(hash
, r2c_string
, NULL
, pool
);
1480 svn_swig_rb_hash_to_apr_hash_svn_string(VALUE hash
, apr_pool_t
*pool
)
1482 return r2c_hash(hash
, r2c_svn_string
, NULL
, pool
);
1486 svn_swig_rb_hash_to_apr_hash_swig_type(VALUE hash
, const char *typename
, apr_pool_t
*pool
)
1488 return r2c_hash(hash
, r2c_swig_type
, (void *)typename
, pool
);
1492 svn_swig_rb_hash_to_apr_hash_revnum(VALUE hash
, apr_pool_t
*pool
)
1494 return r2c_hash(hash
, r2c_revnum
, NULL
, pool
);
1498 svn_swig_rb_hash_to_apr_hash_merge_range(VALUE hash
, apr_pool_t
*pool
)
1500 return r2c_hash(hash
, r2c_merge_range
, NULL
, pool
);
1515 } callback_rescue_baton_t
;
1518 callback_baton_t
*callback_baton
;
1519 callback_rescue_baton_t
*rescue_baton
;
1520 } callback_handle_error_baton_t
;
1523 callback(VALUE baton
)
1525 callback_baton_t
*cbb
= (callback_baton_t
*)baton
;
1528 result
= rb_apply(cbb
->receiver
, cbb
->message
, cbb
->args
);
1529 svn_swig_rb_push_pool(cbb
->pool
);
1535 callback_rescue(VALUE baton
)
1537 callback_rescue_baton_t
*rescue_baton
= (callback_rescue_baton_t
*)baton
;
1539 *(rescue_baton
->err
) = r2c_svn_err(ruby_errinfo
, NULL
, NULL
);
1540 svn_swig_rb_push_pool(rescue_baton
->pool
);
1546 callback_ensure(VALUE pool
)
1548 svn_swig_rb_pop_pool(pool
);
1554 invoke_callback(VALUE baton
, VALUE pool
)
1556 callback_baton_t
*cbb
= (callback_baton_t
*)baton
;
1558 VALUE argv
[] = {pool
};
1560 svn_swig_rb_get_pool(1, argv
, Qnil
, &sub_pool
, NULL
);
1561 cbb
->pool
= sub_pool
;
1562 return rb_ensure(callback
, baton
, callback_ensure
, sub_pool
);
1566 callback_handle_error(VALUE baton
)
1568 callback_handle_error_baton_t
*handle_error_baton
;
1569 handle_error_baton
= (callback_handle_error_baton_t
*)baton
;
1571 return rb_rescue2(callback
,
1572 (VALUE
)(handle_error_baton
->callback_baton
),
1574 (VALUE
)(handle_error_baton
->rescue_baton
),
1580 invoke_callback_handle_error(VALUE baton
, VALUE pool
, svn_error_t
**err
)
1582 callback_baton_t
*cbb
= (callback_baton_t
*)baton
;
1583 callback_handle_error_baton_t handle_error_baton
;
1584 callback_rescue_baton_t rescue_baton
;
1586 rescue_baton
.err
= err
;
1587 rescue_baton
.pool
= pool
;
1589 handle_error_baton
.callback_baton
= cbb
;
1590 handle_error_baton
.rescue_baton
= &rescue_baton
;
1592 return rb_ensure(callback_handle_error
, (VALUE
)&handle_error_baton
,
1593 callback_ensure
, pool
);
1597 /* svn_delta_editor_t */
1604 add_baton(VALUE editor
, VALUE baton
)
1606 if (NIL_P((rb_ivar_get(editor
, id_baton
)))) {
1607 rb_ivar_set(editor
, id_baton
, rb_ary_new());
1610 rb_ary_push(rb_ivar_get(editor
, id_baton
), baton
);
1614 make_baton(apr_pool_t
*pool
, VALUE editor
, VALUE baton
)
1616 item_baton
*newb
= apr_palloc(pool
, sizeof(*newb
));
1618 newb
->editor
= editor
;
1619 newb
->baton
= baton
;
1620 add_baton(editor
, baton
);
1626 add_baton_if_delta_editor(VALUE target
, VALUE baton
)
1628 if (RTEST(rb_obj_is_kind_of(target
, svn_swig_rb_svn_delta_editor()))) {
1629 add_baton(target
, baton
);
1636 svn_swig_rb_set_baton(VALUE target
, VALUE baton
)
1642 if (!RTEST(rb_obj_is_kind_of(target
, rb_cArray
))) {
1643 target
= rb_ary_new3(1, target
);
1646 rb_iterate(rb_each
, target
, add_baton_if_delta_editor
, baton
);
1650 static svn_error_t
*
1651 delta_editor_set_target_revision(void *edit_baton
,
1652 svn_revnum_t target_revision
,
1655 item_baton
*ib
= edit_baton
;
1656 svn_error_t
*err
= SVN_NO_ERROR
;
1657 callback_baton_t cbb
;
1659 cbb
.receiver
= ib
->editor
;
1660 cbb
.message
= id_set_target_revision
;
1661 cbb
.args
= rb_ary_new3(1, INT2NUM(target_revision
));
1662 invoke_callback_handle_error((VALUE
)(&cbb
), Qnil
, &err
);
1666 static svn_error_t
*
1667 delta_editor_open_root(void *edit_baton
,
1668 svn_revnum_t base_revision
,
1669 apr_pool_t
*dir_pool
,
1672 item_baton
*ib
= edit_baton
;
1673 svn_error_t
*err
= SVN_NO_ERROR
;
1674 callback_baton_t cbb
;
1677 cbb
.receiver
= ib
->editor
;
1678 cbb
.message
= id_open_root
;
1679 cbb
.args
= rb_ary_new3(1, INT2NUM(base_revision
));
1680 result
= invoke_callback_handle_error((VALUE
)(&cbb
), Qnil
, &err
);
1681 *root_baton
= make_baton(dir_pool
, ib
->editor
, result
);
1685 static svn_error_t
*
1686 delta_editor_delete_entry(const char *path
,
1687 svn_revnum_t revision
,
1691 item_baton
*ib
= parent_baton
;
1692 svn_error_t
*err
= SVN_NO_ERROR
;
1693 callback_baton_t cbb
;
1695 cbb
.receiver
= ib
->editor
;
1696 cbb
.message
= id_delete_entry
;
1697 cbb
.args
= rb_ary_new3(3, c2r_string2(path
), INT2NUM(revision
), ib
->baton
);
1698 invoke_callback_handle_error((VALUE
)(&cbb
), Qnil
, &err
);
1702 static svn_error_t
*
1703 delta_editor_add_directory(const char *path
,
1705 const char *copyfrom_path
,
1706 svn_revnum_t copyfrom_revision
,
1707 apr_pool_t
*dir_pool
,
1710 item_baton
*ib
= parent_baton
;
1711 svn_error_t
*err
= SVN_NO_ERROR
;
1712 callback_baton_t cbb
;
1715 cbb
.receiver
= ib
->editor
;
1716 cbb
.message
= id_add_directory
;
1717 cbb
.args
= rb_ary_new3(4,
1720 c2r_string2(copyfrom_path
),
1721 INT2NUM(copyfrom_revision
));
1722 result
= invoke_callback_handle_error((VALUE
)(&cbb
), Qnil
, &err
);
1723 *child_baton
= make_baton(dir_pool
, ib
->editor
, result
);
1727 static svn_error_t
*
1728 delta_editor_open_directory(const char *path
,
1730 svn_revnum_t base_revision
,
1731 apr_pool_t
*dir_pool
,
1734 item_baton
*ib
= parent_baton
;
1735 svn_error_t
*err
= SVN_NO_ERROR
;
1736 callback_baton_t cbb
;
1739 cbb
.receiver
= ib
->editor
;
1740 cbb
.message
= id_open_directory
;
1741 cbb
.args
= rb_ary_new3(3,
1744 INT2NUM(base_revision
));
1745 result
= invoke_callback_handle_error((VALUE
)(&cbb
), Qnil
, &err
);
1746 *child_baton
= make_baton(dir_pool
, ib
->editor
, result
);
1750 static svn_error_t
*
1751 delta_editor_change_dir_prop(void *dir_baton
,
1753 const svn_string_t
*value
,
1756 item_baton
*ib
= dir_baton
;
1757 svn_error_t
*err
= SVN_NO_ERROR
;
1758 callback_baton_t cbb
;
1760 cbb
.receiver
= ib
->editor
;
1761 cbb
.message
= id_change_dir_prop
;
1762 cbb
.args
= rb_ary_new3(3,
1765 value
? rb_str_new(value
->data
, value
->len
) : Qnil
);
1766 invoke_callback_handle_error((VALUE
)(&cbb
), Qnil
, &err
);
1770 static svn_error_t
*
1771 delta_editor_close_baton(void *baton
, ID method_id
)
1773 item_baton
*ib
= baton
;
1774 svn_error_t
*err
= SVN_NO_ERROR
;
1775 callback_baton_t cbb
;
1777 cbb
.receiver
= ib
->editor
;
1778 cbb
.message
= method_id
;
1779 cbb
.args
= rb_ary_new3(1, ib
->baton
);
1780 invoke_callback_handle_error((VALUE
)(&cbb
), Qnil
, &err
);
1784 static svn_error_t
*
1785 delta_editor_close_directory(void *dir_baton
, apr_pool_t
*pool
)
1787 return delta_editor_close_baton(dir_baton
, id_close_directory
);
1790 static svn_error_t
*
1791 delta_editor_absent_directory(const char *path
,
1795 item_baton
*ib
= parent_baton
;
1796 svn_error_t
*err
= SVN_NO_ERROR
;
1797 callback_baton_t cbb
;
1799 cbb
.receiver
= ib
->editor
;
1800 cbb
.message
= id_absent_directory
;
1801 cbb
.args
= rb_ary_new3(2, c2r_string2(path
), ib
->baton
);
1802 invoke_callback_handle_error((VALUE
)(&cbb
), Qnil
, &err
);
1806 static svn_error_t
*
1807 delta_editor_add_file(const char *path
,
1809 const char *copyfrom_path
,
1810 svn_revnum_t copyfrom_revision
,
1811 apr_pool_t
*file_pool
,
1814 item_baton
*ib
= parent_baton
;
1815 svn_error_t
*err
= SVN_NO_ERROR
;
1816 callback_baton_t cbb
;
1819 cbb
.receiver
= ib
->editor
;
1820 cbb
.message
= id_add_file
;
1821 cbb
.args
= rb_ary_new3(4,
1824 c2r_string2(copyfrom_path
),
1825 INT2NUM(copyfrom_revision
));
1826 result
= invoke_callback_handle_error((VALUE
)(&cbb
), Qnil
, &err
);
1827 *file_baton
= make_baton(file_pool
, ib
->editor
, result
);
1831 static svn_error_t
*
1832 delta_editor_open_file(const char *path
,
1834 svn_revnum_t base_revision
,
1835 apr_pool_t
*file_pool
,
1838 item_baton
*ib
= parent_baton
;
1839 svn_error_t
*err
= SVN_NO_ERROR
;
1840 callback_baton_t cbb
;
1843 cbb
.receiver
= ib
->editor
;
1844 cbb
.message
= id_open_file
;
1845 cbb
.args
= rb_ary_new3(3,
1848 INT2NUM(base_revision
));
1849 result
= invoke_callback_handle_error((VALUE
)(&cbb
), Qnil
, &err
);
1850 *file_baton
= make_baton(file_pool
, ib
->editor
, result
);
1854 static svn_error_t
*
1855 delta_editor_window_handler(svn_txdelta_window_t
*window
, void *baton
)
1857 VALUE handler
= (VALUE
)baton
;
1858 callback_baton_t cbb
;
1860 svn_error_t
*err
= SVN_NO_ERROR
;
1862 cbb
.receiver
= handler
;
1863 cbb
.message
= id_call
;
1864 cbb
.args
= rb_ary_new3(1, c2r_txdelta_window__dup(window
));
1865 result
= invoke_callback_handle_error((VALUE
)(&cbb
), Qnil
, &err
);
1869 static svn_error_t
*
1870 delta_editor_apply_textdelta(void *file_baton
,
1871 const char *base_checksum
,
1873 svn_txdelta_window_handler_t
*handler
,
1876 item_baton
*ib
= file_baton
;
1877 svn_error_t
*err
= SVN_NO_ERROR
;
1878 callback_baton_t cbb
;
1881 cbb
.receiver
= ib
->editor
;
1882 cbb
.message
= id_apply_textdelta
;
1883 cbb
.args
= rb_ary_new3(2, ib
->baton
, c2r_string2(base_checksum
));
1884 result
= invoke_callback_handle_error((VALUE
)(&cbb
), Qnil
, &err
);
1885 if (NIL_P(result
)) {
1886 *handler
= svn_delta_noop_window_handler
;
1889 *handler
= delta_editor_window_handler
;
1890 *h_baton
= (void *)result
;
1896 static svn_error_t
*
1897 delta_editor_change_file_prop(void *file_baton
,
1899 const svn_string_t
*value
,
1902 item_baton
*ib
= file_baton
;
1903 svn_error_t
*err
= SVN_NO_ERROR
;
1904 callback_baton_t cbb
;
1906 cbb
.receiver
= ib
->editor
;
1907 cbb
.message
= id_change_file_prop
;
1908 cbb
.args
= rb_ary_new3(3,
1911 value
? rb_str_new(value
->data
, value
->len
) : Qnil
);
1912 invoke_callback_handle_error((VALUE
)(&cbb
), Qnil
, &err
);
1917 static svn_error_t
*
1918 delta_editor_close_file(void *file_baton
,
1919 const char *text_checksum
,
1922 item_baton
*ib
= file_baton
;
1923 svn_error_t
*err
= SVN_NO_ERROR
;
1924 callback_baton_t cbb
;
1926 cbb
.receiver
= ib
->editor
;
1927 cbb
.message
= id_close_file
;
1928 cbb
.args
= rb_ary_new3(2, ib
->baton
, c2r_string2(text_checksum
));
1929 invoke_callback_handle_error((VALUE
)(&cbb
), Qnil
, &err
);
1934 static svn_error_t
*
1935 delta_editor_absent_file(const char *path
,
1939 item_baton
*ib
= parent_baton
;
1940 svn_error_t
*err
= SVN_NO_ERROR
;
1941 callback_baton_t cbb
;
1943 cbb
.receiver
= ib
->editor
;
1944 cbb
.message
= id_absent_file
;
1945 cbb
.args
= rb_ary_new3(2, c2r_string2(path
), ib
->baton
);
1946 invoke_callback_handle_error((VALUE
)(&cbb
), Qnil
, &err
);
1951 static svn_error_t
*
1952 delta_editor_close_edit(void *edit_baton
, apr_pool_t
*pool
)
1954 item_baton
*ib
= edit_baton
;
1955 svn_error_t
*err
= delta_editor_close_baton(edit_baton
, id_close_edit
);
1956 rb_ary_clear(rb_ivar_get(ib
->editor
, id_baton
));
1960 static svn_error_t
*
1961 delta_editor_abort_edit(void *edit_baton
, apr_pool_t
*pool
)
1963 item_baton
*ib
= edit_baton
;
1964 svn_error_t
*err
= delta_editor_close_baton(edit_baton
, id_abort_edit
);
1965 rb_ary_clear(rb_ivar_get(ib
->editor
, id_baton
));
1970 svn_swig_rb_make_delta_editor(svn_delta_editor_t
**editor
,
1975 svn_delta_editor_t
*thunk_editor
= svn_delta_default_editor(pool
);
1977 thunk_editor
->set_target_revision
= delta_editor_set_target_revision
;
1978 thunk_editor
->open_root
= delta_editor_open_root
;
1979 thunk_editor
->delete_entry
= delta_editor_delete_entry
;
1980 thunk_editor
->add_directory
= delta_editor_add_directory
;
1981 thunk_editor
->open_directory
= delta_editor_open_directory
;
1982 thunk_editor
->change_dir_prop
= delta_editor_change_dir_prop
;
1983 thunk_editor
->close_directory
= delta_editor_close_directory
;
1984 thunk_editor
->absent_directory
= delta_editor_absent_directory
;
1985 thunk_editor
->add_file
= delta_editor_add_file
;
1986 thunk_editor
->open_file
= delta_editor_open_file
;
1987 thunk_editor
->apply_textdelta
= delta_editor_apply_textdelta
;
1988 thunk_editor
->change_file_prop
= delta_editor_change_file_prop
;
1989 thunk_editor
->close_file
= delta_editor_close_file
;
1990 thunk_editor
->absent_file
= delta_editor_absent_file
;
1991 thunk_editor
->close_edit
= delta_editor_close_edit
;
1992 thunk_editor
->abort_edit
= delta_editor_abort_edit
;
1994 *editor
= thunk_editor
;
1995 rb_ivar_set(rb_editor
, id_baton
, rb_ary_new());
1996 *edit_baton
= make_baton(pool
, rb_editor
, Qnil
);
2001 svn_swig_rb_make_baton(VALUE proc
, VALUE pool
)
2006 return rb_ary_new3(2, proc
, pool
);
2011 svn_swig_rb_from_baton(VALUE baton
, VALUE
*proc
, VALUE
*pool
)
2017 *proc
= rb_ary_entry(baton
, 0);
2018 *pool
= rb_ary_entry(baton
, 1);
2023 svn_swig_rb_log_receiver(void *baton
,
2024 apr_hash_t
*changed_paths
,
2025 svn_revnum_t revision
,
2028 const char *message
,
2031 svn_error_t
*err
= SVN_NO_ERROR
;
2032 VALUE proc
, rb_pool
;
2034 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
2037 callback_baton_t cbb
;
2038 VALUE rb_changed_paths
= Qnil
;
2040 if (changed_paths
) {
2041 rb_changed_paths
= c2r_hash(changed_paths
,
2042 c2r_log_changed_path_dup
,
2046 cbb
.receiver
= proc
;
2047 cbb
.message
= id_call
;
2048 cbb
.args
= rb_ary_new3(5,
2050 c2r_long(&revision
, NULL
),
2051 c2r_string2(author
),
2052 c2r_svn_date_string2(date
),
2053 c2r_string2(message
));
2054 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
2061 svn_swig_rb_repos_authz_func(svn_boolean_t
*allowed
,
2062 svn_fs_root_t
*root
,
2067 svn_error_t
*err
= SVN_NO_ERROR
;
2068 VALUE proc
, rb_pool
;
2070 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
2075 callback_baton_t cbb
;
2078 cbb
.receiver
= proc
;
2079 cbb
.message
= id_call
;
2080 cbb
.args
= rb_ary_new3(2,
2081 c2r_swig_type((void *)root
,
2082 (void *)"svn_fs_root_t *"),
2084 result
= invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
2086 *allowed
= RTEST(result
);
2092 svn_swig_rb_repos_authz_callback(svn_repos_authz_access_t required
,
2093 svn_boolean_t
*allowed
,
2094 svn_fs_root_t
*root
,
2099 svn_error_t
*err
= SVN_NO_ERROR
;
2100 VALUE proc
, rb_pool
;
2102 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
2107 callback_baton_t cbb
;
2110 cbb
.receiver
= proc
;
2111 cbb
.message
= id_call
;
2112 cbb
.args
= rb_ary_new3(3,
2114 c2r_swig_type((void *)root
,
2115 (void *)"svn_fs_root_t *"),
2117 result
= invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
2119 *allowed
= RTEST(result
);
2125 svn_swig_rb_get_commit_log_func(const char **log_msg
,
2126 const char **tmp_file
,
2127 const apr_array_header_t
*commit_items
,
2131 svn_error_t
*err
= SVN_NO_ERROR
;
2132 VALUE proc
, rb_pool
;
2137 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
2140 callback_baton_t cbb
;
2146 cbb
.receiver
= proc
;
2147 cbb
.message
= id_call
;
2148 cbb
.args
= rb_ary_new3(1, c2r_commit_item3_array(commit_items
));
2149 result
= invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
2152 char error_message
[] =
2153 "log_msg_func should return an array not '%s': "
2154 "[TRUE_IF_IT_IS_MESSAGE, MESSAGE_OR_FILE_AS_STRING]";
2156 if (!RTEST(rb_obj_is_kind_of(result
, rb_cArray
)))
2157 rb_raise(rb_eTypeError
, error_message
, r2c_inspect(result
));
2158 is_message
= rb_ary_entry(result
, 0);
2159 value
= rb_ary_entry(result
, 1);
2161 if (!RTEST(rb_obj_is_kind_of(value
, rb_cString
)))
2162 rb_raise(rb_eTypeError
, error_message
, r2c_inspect(result
));
2163 ret
= (char *)r2c_string(value
, NULL
, pool
);
2164 if (RTEST(is_message
)) {
2176 svn_swig_rb_notify_func2(void *baton
,
2177 const svn_wc_notify_t
*notify
,
2180 VALUE proc
, rb_pool
;
2181 callback_baton_t cbb
;
2183 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
2186 cbb
.receiver
= proc
;
2187 cbb
.message
= id_call
;
2188 cbb
.args
= rb_ary_new3(1, c2r_wc_notify__dup(notify
));
2192 svn_error_clear(notify
->err
);
2195 invoke_callback((VALUE
)(&cbb
), rb_pool
);
2199 svn_swig_rb_conflict_resolver_func
2200 (svn_wc_conflict_result_t
**result
,
2201 const svn_wc_conflict_description_t
*description
,
2205 svn_error_t
*err
= SVN_NO_ERROR
;
2206 VALUE proc
, rb_pool
;
2208 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
2211 *result
= svn_wc_create_conflict_result(svn_wc_conflict_choose_postpone
,
2212 description
->merged_file
,
2215 callback_baton_t cbb
;
2218 cbb
.receiver
= proc
;
2219 cbb
.message
= id_call
;
2220 cbb
.args
= rb_ary_new3(
2222 c2r_swig_type((void *)description
,
2223 (void *)"svn_wc_conflict_description_t *") );
2224 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
2225 fret
= invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
2226 *result
= svn_wc_create_conflict_result(NUM2INT(fret
),
2227 description
->merged_file
,
2235 svn_swig_rb_commit_callback(svn_revnum_t new_revision
,
2240 svn_error_t
*err
= SVN_NO_ERROR
;
2241 VALUE proc
, rb_pool
;
2243 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
2246 callback_baton_t cbb
;
2248 cbb
.receiver
= proc
;
2249 cbb
.message
= id_call
;
2250 cbb
.args
= rb_ary_new3(3,
2251 INT2NUM(new_revision
),
2252 c2r_svn_date_string2(date
),
2253 c2r_string2(author
));
2254 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
2261 svn_swig_rb_commit_callback2(const svn_commit_info_t
*commit_info
,
2262 void *baton
, apr_pool_t
*pool
)
2264 svn_error_t
*err
= SVN_NO_ERROR
;
2265 VALUE proc
, rb_pool
;
2267 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
2270 callback_baton_t cbb
;
2272 cbb
.receiver
= proc
;
2273 cbb
.message
= id_call
;
2274 cbb
.args
= rb_ary_new3(1, c2r_commit_info__dup(commit_info
));
2275 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
2282 svn_swig_rb_cancel_func(void *cancel_baton
)
2284 svn_error_t
*err
= SVN_NO_ERROR
;
2285 VALUE proc
, rb_pool
;
2287 svn_swig_rb_from_baton((VALUE
)cancel_baton
, &proc
, &rb_pool
);
2290 callback_baton_t cbb
;
2292 cbb
.receiver
= proc
;
2293 cbb
.message
= id_call
;
2294 cbb
.args
= rb_ary_new3(0);
2295 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
2302 svn_swig_rb_info_receiver(void *baton
,
2304 const svn_info_t
*info
,
2307 svn_error_t
*err
= SVN_NO_ERROR
;
2308 VALUE proc
, rb_pool
;
2310 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
2313 callback_baton_t cbb
;
2315 cbb
.receiver
= proc
;
2316 cbb
.message
= id_call
;
2317 cbb
.args
= rb_ary_new3(2, c2r_string2(path
), c2r_info__dup(info
));
2318 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
2325 svn_swig_rb_config_enumerator(const char *name
,
2330 svn_boolean_t result
= FALSE
;
2331 VALUE proc
, rb_pool
;
2333 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
2336 callback_baton_t cbb
;
2338 cbb
.receiver
= proc
;
2339 cbb
.message
= id_call
;
2340 cbb
.args
= rb_ary_new3(2, c2r_string2(name
), c2r_string2(value
));
2341 result
= RTEST(invoke_callback((VALUE
)(&cbb
), rb_pool
));
2348 svn_swig_rb_config_section_enumerator(const char *name
,
2352 svn_boolean_t result
= FALSE
;
2353 VALUE proc
, rb_pool
;
2355 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
2358 callback_baton_t cbb
;
2360 cbb
.receiver
= proc
;
2361 cbb
.message
= id_call
;
2362 cbb
.args
= rb_ary_new3(1, c2r_string2(name
));
2363 result
= RTEST(invoke_callback((VALUE
)(&cbb
), rb_pool
));
2370 svn_swig_rb_delta_path_driver_cb_func(void **dir_baton
,
2372 void *callback_baton
,
2376 svn_error_t
*err
= SVN_NO_ERROR
;
2377 VALUE proc
, rb_pool
;
2379 svn_swig_rb_from_baton((VALUE
)callback_baton
, &proc
, &rb_pool
);
2382 callback_baton_t cbb
;
2384 item_baton
*ib
= (item_baton
*)parent_baton
;
2386 cbb
.receiver
= proc
;
2387 cbb
.message
= id_call
;
2388 cbb
.args
= rb_ary_new3(2, ib
->baton
, c2r_string2(path
));
2389 result
= invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
2390 *dir_baton
= make_baton(pool
, ib
->editor
, result
);
2397 svn_swig_rb_txdelta_window_handler(svn_txdelta_window_t
*window
,
2400 svn_error_t
*err
= SVN_NO_ERROR
;
2401 VALUE proc
, rb_pool
;
2403 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
2406 callback_baton_t cbb
;
2408 cbb
.receiver
= proc
;
2409 cbb
.message
= id_call
;
2410 cbb
.args
= rb_ary_new3(1, c2r_txdelta_window__dup(window
));
2411 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
2418 svn_swig_rb_fs_warning_callback(void *baton
, svn_error_t
*err
)
2420 VALUE proc
, rb_pool
;
2422 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
2425 callback_baton_t cbb
;
2427 cbb
.receiver
= proc
;
2428 cbb
.message
= id_call
;
2429 cbb
.args
= rb_ary_new3(1, svn_swig_rb_svn_error_to_rb_error(err
));
2430 invoke_callback((VALUE
)(&cbb
), rb_pool
);
2435 cleanup_fs_warning_callback_baton(void *baton
)
2437 rb_holder_pop(rb_svn_fs_warning_callback_baton_holder(), (VALUE
)baton
);
2442 svn_swig_rb_fs_warning_callback_baton_register(VALUE baton
, apr_pool_t
*pool
)
2444 rb_holder_push(rb_svn_fs_warning_callback_baton_holder(), (VALUE
)baton
);
2445 apr_pool_cleanup_register(pool
, (void *)baton
,
2446 cleanup_fs_warning_callback_baton
,
2447 apr_pool_cleanup_null
);
2451 svn_swig_rb_fs_get_locks_callback(void *baton
,
2455 svn_error_t
*err
= SVN_NO_ERROR
;
2456 VALUE proc
, rb_pool
;
2458 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
2461 callback_baton_t cbb
;
2463 cbb
.receiver
= proc
;
2464 cbb
.message
= id_call
;
2465 cbb
.args
= rb_ary_new3(1, c2r_lock__dup(lock
));
2466 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
2473 /* svn_ra_callbacks_t */
2474 static svn_error_t
*
2475 ra_callbacks_open_tmp_file(apr_file_t
**fp
,
2476 void *callback_baton
,
2479 VALUE callbacks
= (VALUE
)callback_baton
;
2480 svn_error_t
*err
= SVN_NO_ERROR
;
2482 if (!NIL_P(callbacks
)) {
2483 callback_baton_t cbb
;
2486 cbb
.receiver
= callbacks
;
2487 cbb
.message
= id_open_tmp_file
;
2488 cbb
.args
= rb_ary_new3(0);
2490 result
= invoke_callback_handle_error((VALUE
)(&cbb
), Qnil
, &err
);
2491 *fp
= svn_swig_rb_make_file(result
, pool
);
2497 static svn_error_t
*
2498 ra_callbacks_get_wc_prop(void *baton
,
2499 const char *relpath
,
2501 const svn_string_t
**value
,
2504 VALUE callbacks
= (VALUE
)baton
;
2505 svn_error_t
*err
= SVN_NO_ERROR
;
2507 if (!NIL_P(callbacks
)) {
2508 callback_baton_t cbb
;
2511 cbb
.receiver
= callbacks
;
2512 cbb
.message
= id_get_wc_prop
;
2513 cbb
.args
= rb_ary_new3(2, c2r_string2(relpath
), c2r_string2(name
));
2514 result
= invoke_callback_handle_error((VALUE
)(&cbb
), Qnil
, &err
);
2515 if (NIL_P(result
)) {
2518 *value
= r2c_svn_string(result
, NULL
, pool
);
2525 static svn_error_t
*
2526 ra_callbacks_set_wc_prop(void *baton
,
2529 const svn_string_t
*value
,
2532 VALUE callbacks
= (VALUE
)baton
;
2533 svn_error_t
*err
= SVN_NO_ERROR
;
2535 if (!NIL_P(callbacks
)) {
2536 callback_baton_t cbb
;
2538 cbb
.receiver
= callbacks
;
2539 cbb
.message
= id_set_wc_prop
;
2540 cbb
.args
= rb_ary_new3(3,
2543 c2r_svn_string((void *)value
, NULL
));
2544 invoke_callback_handle_error((VALUE
)(&cbb
), Qnil
, &err
);
2550 static svn_error_t
*
2551 ra_callbacks_push_wc_prop(void *baton
,
2554 const svn_string_t
*value
,
2557 VALUE callbacks
= (VALUE
)baton
;
2558 svn_error_t
*err
= SVN_NO_ERROR
;
2560 if (!NIL_P(callbacks
)) {
2561 callback_baton_t cbb
;
2563 cbb
.receiver
= callbacks
;
2564 cbb
.message
= id_push_wc_prop
;
2565 cbb
.args
= rb_ary_new3(3,
2568 c2r_svn_string((void *)value
, NULL
));
2569 invoke_callback_handle_error((VALUE
)(&cbb
), Qnil
, &err
);
2575 static svn_error_t
*
2576 ra_callbacks_invalidate_wc_props(void *baton
,
2581 VALUE callbacks
= (VALUE
)baton
;
2582 svn_error_t
*err
= SVN_NO_ERROR
;
2584 if (!NIL_P(callbacks
)) {
2585 callback_baton_t cbb
;
2587 cbb
.receiver
= callbacks
;
2588 cbb
.message
= id_invalidate_wc_props
;
2589 cbb
.args
= rb_ary_new3(2, c2r_string2(path
), c2r_string2(name
));
2590 invoke_callback_handle_error((VALUE
)(&cbb
), Qnil
, &err
);
2598 ra_callbacks_progress_func(apr_off_t progress
,
2603 VALUE callbacks
= (VALUE
)baton
;
2604 if (!NIL_P(callbacks
)) {
2605 callback_baton_t cbb
;
2607 cbb
.receiver
= callbacks
;
2608 cbb
.message
= id_progress_func
;
2609 cbb
.args
= rb_ary_new3(2, AOFF2NUM(progress
), AOFF2NUM(total
));
2610 invoke_callback((VALUE
)(&cbb
), Qnil
);
2615 svn_swig_rb_setup_ra_callbacks(svn_ra_callbacks2_t
**callbacks
,
2620 void *auth_baton
= NULL
;
2622 if (!NIL_P(rb_callbacks
)) {
2623 VALUE rb_auth_baton
= Qnil
;
2624 rb_auth_baton
= rb_funcall(rb_callbacks
, id_auth_baton
, 0);
2625 auth_baton
= r2c_swig_type(rb_auth_baton
,
2626 (void *)"svn_auth_baton_t *",
2630 *callbacks
= apr_pcalloc(pool
, sizeof(**callbacks
));
2632 (*callbacks
)->open_tmp_file
= ra_callbacks_open_tmp_file
;
2633 (*callbacks
)->auth_baton
= auth_baton
;
2634 (*callbacks
)->get_wc_prop
= ra_callbacks_get_wc_prop
;
2635 (*callbacks
)->set_wc_prop
= ra_callbacks_set_wc_prop
;
2636 (*callbacks
)->push_wc_prop
= ra_callbacks_push_wc_prop
;
2637 (*callbacks
)->invalidate_wc_props
= ra_callbacks_invalidate_wc_props
;
2638 (*callbacks
)->progress_func
= ra_callbacks_progress_func
;
2639 (*callbacks
)->progress_baton
= (void *)rb_callbacks
;
2644 svn_swig_rb_ra_lock_callback(void *baton
,
2646 svn_boolean_t do_lock
,
2647 const svn_lock_t
*lock
,
2648 svn_error_t
*ra_err
,
2651 svn_error_t
*err
= SVN_NO_ERROR
;
2652 VALUE proc
, rb_pool
;
2654 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
2657 callback_baton_t cbb
;
2659 cbb
.receiver
= proc
;
2660 cbb
.message
= id_call
;
2661 cbb
.args
= rb_ary_new3(4,
2663 do_lock
? Qtrue
: Qfalse
,
2664 c2r_lock__dup(lock
),
2666 svn_swig_rb_svn_error_to_rb_error(ra_err
) :
2668 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
2675 svn_swig_rb_just_call(void *baton
)
2677 svn_error_t
*err
= SVN_NO_ERROR
;
2678 VALUE proc
, rb_pool
;
2680 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
2683 callback_baton_t cbb
;
2685 cbb
.receiver
= proc
;
2686 cbb
.message
= id_call
;
2687 cbb
.args
= rb_ary_new3(0);
2688 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
2695 svn_swig_rb_ra_file_rev_handler(void *baton
,
2698 apr_hash_t
*rev_props
,
2699 svn_txdelta_window_handler_t
*delta_handler
,
2701 apr_array_header_t
*prop_diffs
,
2704 svn_error_t
*err
= SVN_NO_ERROR
;
2705 VALUE proc
, rb_pool
;
2707 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
2710 callback_baton_t cbb
;
2712 cbb
.receiver
= proc
;
2713 cbb
.message
= id_call
;
2714 cbb
.args
= rb_ary_new3(4,
2716 c2r_long(&rev
, NULL
),
2717 svn_swig_rb_apr_hash_to_hash_svn_string(rev_props
),
2718 svn_swig_rb_prop_apr_array_to_hash_prop(prop_diffs
));
2719 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
2726 svn_swig_rb_repos_history_func(void *baton
,
2728 svn_revnum_t revision
,
2731 svn_error_t
*err
= SVN_NO_ERROR
;
2732 VALUE proc
, rb_pool
;
2734 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
2737 callback_baton_t cbb
;
2738 VALUE result
= Qnil
;
2740 cbb
.receiver
= proc
;
2741 cbb
.message
= id_call
;
2742 cbb
.args
= rb_ary_new3(2,
2744 c2r_long(&revision
, NULL
));
2745 result
= invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
2747 if (!err
&& SVN_ERR_P(result
)) {
2748 err
= r2c_svn_err(result
, NULL
, NULL
);
2756 svn_swig_rb_repos_file_rev_handler(void *baton
,
2759 apr_hash_t
*rev_props
,
2760 svn_txdelta_window_handler_t
*delta_handler
,
2762 apr_array_header_t
*prop_diffs
,
2765 svn_error_t
*err
= SVN_NO_ERROR
;
2766 VALUE proc
, rb_pool
;
2768 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
2771 callback_baton_t cbb
;
2773 cbb
.receiver
= proc
;
2774 cbb
.message
= id_call
;
2775 cbb
.args
= rb_ary_new3(4,
2777 c2r_long(&rev
, NULL
),
2778 svn_swig_rb_apr_hash_to_hash_svn_string(rev_props
),
2779 svn_swig_rb_prop_apr_array_to_hash_prop(prop_diffs
));
2780 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
2787 svn_swig_rb_wc_relocation_validator3(void *baton
,
2790 const char *root_url
,
2793 svn_error_t
*err
= SVN_NO_ERROR
;
2794 VALUE proc
, rb_pool
;
2796 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
2799 callback_baton_t cbb
;
2801 cbb
.receiver
= proc
;
2802 cbb
.message
= id_call
;
2803 cbb
.args
= rb_ary_new3(3,
2806 c2r_string2(root_url
));
2807 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
2815 /* auth provider callbacks */
2817 svn_swig_rb_auth_simple_prompt_func(svn_auth_cred_simple_t
**cred
,
2820 const char *username
,
2821 svn_boolean_t may_save
,
2824 svn_auth_cred_simple_t
*new_cred
= NULL
;
2825 svn_error_t
*err
= SVN_NO_ERROR
;
2826 VALUE proc
, rb_pool
;
2828 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
2831 callback_baton_t cbb
;
2834 cbb
.receiver
= proc
;
2835 cbb
.message
= id_call
;
2836 cbb
.args
= rb_ary_new3(3,
2838 c2r_string2(username
),
2839 RTEST(may_save
) ? Qtrue
: Qfalse
);
2840 result
= invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
2842 if (!NIL_P(result
)) {
2843 void *result_cred
= NULL
;
2844 svn_auth_cred_simple_t
*tmp_cred
= NULL
;
2846 r2c_swig_type2(result
, "svn_auth_cred_simple_t *", &result_cred
);
2847 tmp_cred
= (svn_auth_cred_simple_t
*)result_cred
;
2848 new_cred
= apr_pcalloc(pool
, sizeof(*new_cred
));
2849 new_cred
->username
= tmp_cred
->username
?
2850 apr_pstrdup(pool
, tmp_cred
->username
) : NULL
;
2851 new_cred
->password
= tmp_cred
->password
?
2852 apr_pstrdup(pool
, tmp_cred
->password
) : NULL
;
2853 new_cred
->may_save
= tmp_cred
->may_save
;
2862 svn_swig_rb_auth_username_prompt_func(svn_auth_cred_username_t
**cred
,
2865 svn_boolean_t may_save
,
2868 svn_auth_cred_username_t
*new_cred
= NULL
;
2869 svn_error_t
*err
= SVN_NO_ERROR
;
2870 VALUE proc
, rb_pool
;
2872 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
2875 callback_baton_t cbb
;
2878 cbb
.receiver
= proc
;
2879 cbb
.message
= id_call
;
2880 cbb
.args
= rb_ary_new3(2,
2882 RTEST(may_save
) ? Qtrue
: Qfalse
);
2883 result
= invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
2885 if (!NIL_P(result
)) {
2886 void *result_cred
= NULL
;
2887 svn_auth_cred_username_t
*tmp_cred
= NULL
;
2889 r2c_swig_type2(result
, "svn_auth_cred_username_t *", &result_cred
);
2890 tmp_cred
= (svn_auth_cred_username_t
*)result_cred
;
2891 new_cred
= apr_pcalloc(pool
, sizeof(*new_cred
));
2892 new_cred
->username
= tmp_cred
->username
?
2893 apr_pstrdup(pool
, tmp_cred
->username
) : NULL
;
2894 new_cred
->may_save
= tmp_cred
->may_save
;
2903 svn_swig_rb_auth_ssl_server_trust_prompt_func(
2904 svn_auth_cred_ssl_server_trust_t
**cred
,
2907 apr_uint32_t failures
,
2908 const svn_auth_ssl_server_cert_info_t
*cert_info
,
2909 svn_boolean_t may_save
,
2912 svn_auth_cred_ssl_server_trust_t
*new_cred
= NULL
;
2913 svn_error_t
*err
= SVN_NO_ERROR
;
2914 VALUE proc
, rb_pool
;
2916 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
2919 callback_baton_t cbb
;
2922 cbb
.receiver
= proc
;
2923 cbb
.message
= id_call
;
2924 cbb
.args
= rb_ary_new3(4,
2927 c2r_auth_ssl_server_cert_info__dup(cert_info
),
2928 RTEST(may_save
) ? Qtrue
: Qfalse
);
2929 result
= invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
2931 if (!NIL_P(result
)) {
2933 svn_auth_cred_ssl_server_trust_t
*tmp_cred
= NULL
;
2935 r2c_swig_type2(result
, "svn_auth_cred_ssl_server_trust_t *",
2937 tmp_cred
= (svn_auth_cred_ssl_server_trust_t
*)result_cred
;
2938 new_cred
= apr_pcalloc(pool
, sizeof(*new_cred
));
2939 *new_cred
= *tmp_cred
;
2948 svn_swig_rb_auth_ssl_client_cert_prompt_func(
2949 svn_auth_cred_ssl_client_cert_t
**cred
,
2952 svn_boolean_t may_save
,
2955 svn_auth_cred_ssl_client_cert_t
*new_cred
= NULL
;
2956 svn_error_t
*err
= SVN_NO_ERROR
;
2957 VALUE proc
, rb_pool
;
2959 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
2962 callback_baton_t cbb
;
2965 cbb
.receiver
= proc
;
2966 cbb
.message
= id_call
;
2967 cbb
.args
= rb_ary_new3(2,
2969 RTEST(may_save
) ? Qtrue
: Qfalse
);
2970 result
= invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
2972 if (!NIL_P(result
)) {
2973 void *result_cred
= NULL
;
2974 svn_auth_cred_ssl_client_cert_t
*tmp_cred
= NULL
;
2976 r2c_swig_type2(result
, "svn_auth_cred_ssl_client_cert_t *",
2978 tmp_cred
= (svn_auth_cred_ssl_client_cert_t
*)result_cred
;
2979 new_cred
= apr_pcalloc(pool
, sizeof(*new_cred
));
2980 new_cred
->cert_file
= tmp_cred
->cert_file
?
2981 apr_pstrdup(pool
, tmp_cred
->cert_file
) : NULL
;
2982 new_cred
->may_save
= tmp_cred
->may_save
;
2991 svn_swig_rb_auth_ssl_client_cert_pw_prompt_func(
2992 svn_auth_cred_ssl_client_cert_pw_t
**cred
,
2995 svn_boolean_t may_save
,
2998 svn_auth_cred_ssl_client_cert_pw_t
*new_cred
= NULL
;
2999 svn_error_t
*err
= SVN_NO_ERROR
;
3000 VALUE proc
, rb_pool
;
3002 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
3005 callback_baton_t cbb
;
3008 cbb
.receiver
= proc
;
3009 cbb
.message
= id_call
;
3010 cbb
.args
= rb_ary_new3(2,
3012 RTEST(may_save
) ? Qtrue
: Qfalse
);
3013 result
= invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
3015 if (!NIL_P(result
)) {
3016 void *result_cred
= NULL
;
3017 svn_auth_cred_ssl_client_cert_pw_t
*tmp_cred
= NULL
;
3019 r2c_swig_type2(result
, "svn_auth_cred_ssl_client_cert_pw_t *",
3021 tmp_cred
= (svn_auth_cred_ssl_client_cert_pw_t
*)result_cred
;
3022 new_cred
= apr_pcalloc(pool
, sizeof(*new_cred
));
3023 new_cred
->password
= tmp_cred
->password
?
3024 apr_pstrdup(pool
, tmp_cred
->password
) : NULL
;
3025 new_cred
->may_save
= tmp_cred
->may_save
;
3035 svn_swig_rb_make_file(VALUE file
, apr_pool_t
*pool
)
3037 apr_file_t
*apr_file
= NULL
;
3039 apr_file_open(&apr_file
, StringValuePtr(file
),
3040 APR_CREATE
| APR_READ
| APR_WRITE
,
3048 static svn_error_t
*
3049 read_handler_rbio(void *baton
, char *buffer
, apr_size_t
*len
)
3052 VALUE io
= (VALUE
)baton
;
3053 svn_error_t
*err
= SVN_NO_ERROR
;
3055 result
= rb_funcall(io
, id_read
, 1, INT2NUM(*len
));
3056 if (NIL_P(result
)) {
3059 memcpy(buffer
, StringValuePtr(result
), RSTRING(result
)->len
);
3060 *len
= RSTRING(result
)->len
;
3066 static svn_error_t
*
3067 write_handler_rbio(void *baton
, const char *data
, apr_size_t
*len
)
3069 VALUE io
= (VALUE
)baton
;
3070 svn_error_t
*err
= SVN_NO_ERROR
;
3072 rb_funcall(io
, id_write
, 1, rb_str_new(data
, *len
));
3078 svn_swig_rb_make_stream(VALUE io
)
3080 svn_stream_t
*stream
;
3082 if (RTEST(rb_funcall(rb_svn_core_stream(), id_eqq
, 1, io
))) {
3083 svn_stream_t
**stream_p
;
3085 r2c_swig_type2(io
, "svn_stream_t *", (void **)stream_p
);
3087 VALUE rb_pool
= rb_pool_new(Qnil
);
3088 apr_pool_wrapper_t
*pool_wrapper
;
3089 apr_pool_wrapper_t
**pool_wrapper_p
;
3091 rb_set_pool(io
, rb_pool
);
3092 pool_wrapper_p
= &pool_wrapper
;
3093 r2c_swig_type2(rb_pool
, "apr_pool_wrapper_t *", (void **)pool_wrapper_p
);
3094 stream
= svn_stream_create((void *)io
, pool_wrapper
->pool
);
3095 svn_stream_set_read(stream
, read_handler_rbio
);
3096 svn_stream_set_write(stream
, write_handler_rbio
);
3103 svn_swig_rb_filename_to_temp_file(const char *file_name
)
3105 return rb_funcall(rb_svn_util(), id_filename_to_temp_file
,
3106 1, rb_str_new2(file_name
));
3110 svn_swig_rb_set_revision(svn_opt_revision_t
*rev
, VALUE value
)
3112 switch (TYPE(value
)) {
3114 rev
->kind
= svn_opt_revision_unspecified
;
3117 rev
->kind
= svn_opt_revision_number
;
3118 rev
->value
.number
= NUM2LONG(value
);
3121 if (RTEST(rb_reg_match(rb_reg_new("^BASE$",
3123 RE_OPTION_IGNORECASE
),
3125 rev
->kind
= svn_opt_revision_base
;
3126 else if (RTEST(rb_reg_match(rb_reg_new("^HEAD$",
3128 RE_OPTION_IGNORECASE
),
3130 rev
->kind
= svn_opt_revision_head
;
3131 else if (RTEST(rb_reg_match(rb_reg_new("^WORKING$",
3132 strlen("^WORKING$"),
3133 RE_OPTION_IGNORECASE
),
3135 rev
->kind
= svn_opt_revision_working
;
3136 else if (RTEST(rb_reg_match(rb_reg_new("^COMMITTED$",
3137 strlen("^COMMITTED$"),
3138 RE_OPTION_IGNORECASE
),
3140 rev
->kind
= svn_opt_revision_committed
;
3141 else if (RTEST(rb_reg_match(rb_reg_new("^PREV$",
3143 RE_OPTION_IGNORECASE
),
3145 rev
->kind
= svn_opt_revision_previous
;
3147 rb_raise(rb_eArgError
,
3148 "invalid value: %s",
3149 StringValuePtr(value
));
3152 if (rb_obj_is_kind_of(value
,
3153 rb_const_get(rb_cObject
, rb_intern("Time")))) {
3154 rev
->kind
= svn_opt_revision_date
;
3155 rev
->value
.date
= NUM2LONG(rb_funcall(value
, rb_intern("to_i"), 0));
3157 rb_raise(rb_eArgError
,
3159 rb_class2name(CLASS_OF(value
)));
3166 svn_swig_rb_adjust_arg_for_client_ctx_and_pool(int *argc
, VALUE
**argv
)
3169 VALUE last_arg
= (*argv
)[*argc
- 1];
3170 if (NIL_P(last_arg
) || POOL_P(last_arg
)) {
3174 if (CONTEXT_P(last_arg
)) {
3186 svn_swig_rb_wc_status_func(void *baton
,
3188 svn_wc_status2_t
*status
)
3190 VALUE proc
, rb_pool
;
3192 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
3195 callback_baton_t cbb
;
3197 cbb
.receiver
= proc
;
3198 cbb
.message
= id_call
;
3199 cbb
.args
= rb_ary_new3(2, c2r_string2(path
), c2r_wc_status2__dup(status
));
3200 invoke_callback((VALUE
)(&cbb
), rb_pool
);
3205 svn_swig_rb_client_blame_receiver_func(void *baton
,
3206 apr_int64_t line_no
,
3207 svn_revnum_t revision
,
3213 svn_error_t
*err
= SVN_NO_ERROR
;
3214 VALUE proc
, rb_pool
;
3216 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
3219 callback_baton_t cbb
;
3221 cbb
.receiver
= proc
;
3222 cbb
.message
= id_call
;
3223 cbb
.args
= rb_ary_new3(5,
3226 c2r_string2(author
),
3227 c2r_svn_date_string2(date
),
3229 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
3237 /* svn_wc_entry_callbacks2_t */
3238 static svn_error_t
*
3239 wc_entry_callbacks2_found_entry(const char *path
,
3240 const svn_wc_entry_t
*entry
,
3244 svn_error_t
*err
= SVN_NO_ERROR
;
3245 VALUE callbacks
, rb_pool
;
3247 svn_swig_rb_from_baton((VALUE
)walk_baton
, &callbacks
, &rb_pool
);;
3249 if (!NIL_P(callbacks
)) {
3250 callback_baton_t cbb
;
3252 cbb
.receiver
= callbacks
;
3253 cbb
.message
= id_found_entry
;
3254 cbb
.args
= rb_ary_new3(2,
3256 c2r_wc_entry__dup(entry
));
3257 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
3263 static svn_error_t
*
3264 wc_entry_callbacks2_handle_error(const char *path
,
3269 VALUE callbacks
, rb_pool
;
3271 svn_swig_rb_from_baton((VALUE
)walk_baton
, &callbacks
, &rb_pool
);;
3273 if (!NIL_P(callbacks
)) {
3274 callback_baton_t cbb
;
3277 message
= id_handle_error
;
3278 if (rb_obj_respond_to(callbacks
, message
, FALSE
)) {
3281 cbb
.receiver
= callbacks
;
3282 cbb
.message
= id_handle_error
;
3283 rb_err
= err
? svn_swig_rb_svn_error_to_rb_error(err
) : Qnil
;
3285 svn_error_clear(err
);
3287 cbb
.args
= rb_ary_new3(2, c2r_string2(path
), rb_err
);
3288 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
3295 svn_wc_entry_callbacks2_t
*
3296 svn_swig_rb_wc_entry_callbacks2(void)
3298 static svn_wc_entry_callbacks2_t wc_entry_callbacks
= {
3299 wc_entry_callbacks2_found_entry
,
3300 wc_entry_callbacks2_handle_error
,
3303 return &wc_entry_callbacks
;
3308 /* svn_wc_diff_callbacks2_t */
3309 static svn_error_t
*
3310 wc_diff_callbacks_file_changed(svn_wc_adm_access_t
*adm_access
,
3311 svn_wc_notify_state_t
*contentstate
,
3312 svn_wc_notify_state_t
*propstate
,
3314 const char *tmpfile1
,
3315 const char *tmpfile2
,
3318 const char *mimetype1
,
3319 const char *mimetype2
,
3320 const apr_array_header_t
*propchanges
,
3321 apr_hash_t
*originalprops
,
3324 VALUE callbacks
, rb_pool
;
3325 svn_error_t
*err
= SVN_NO_ERROR
;
3327 svn_swig_rb_from_baton((VALUE
)diff_baton
, &callbacks
, &rb_pool
);
3328 if (!NIL_P(callbacks
)) {
3329 callback_baton_t cbb
;
3330 VALUE result
= Qnil
;
3332 cbb
.receiver
= callbacks
;
3333 cbb
.message
= id_file_changed
;
3334 cbb
.args
= rb_ary_new3(10,
3335 c2r_swig_type((void *)adm_access
,
3336 (void *)"svn_wc_adm_access_t *"),
3338 c2r_string2(tmpfile1
),
3339 c2r_string2(tmpfile2
),
3342 c2r_string2(mimetype1
),
3343 c2r_string2(mimetype2
),
3344 svn_swig_rb_prop_apr_array_to_hash_prop(propchanges
),
3345 svn_swig_rb_prop_hash_to_hash(originalprops
));
3346 result
= invoke_callback_handle_error((VALUE
)(&cbb
), Qnil
, &err
);
3349 *contentstate
= NUM2INT(rb_ary_entry(result
, 0));
3351 *propstate
= NUM2INT(rb_ary_entry(result
, 1));
3357 static svn_error_t
*
3358 wc_diff_callbacks_file_added(svn_wc_adm_access_t
*adm_access
,
3359 svn_wc_notify_state_t
*contentstate
,
3360 svn_wc_notify_state_t
*propstate
,
3362 const char *tmpfile1
,
3363 const char *tmpfile2
,
3366 const char *mimetype1
,
3367 const char *mimetype2
,
3368 const apr_array_header_t
*propchanges
,
3369 apr_hash_t
*originalprops
,
3372 VALUE callbacks
, rb_pool
;
3373 svn_error_t
*err
= SVN_NO_ERROR
;
3375 svn_swig_rb_from_baton((VALUE
)diff_baton
, &callbacks
, &rb_pool
);
3376 if (!NIL_P(callbacks
)) {
3377 callback_baton_t cbb
;
3378 VALUE result
= Qnil
;
3380 cbb
.receiver
= callbacks
;
3381 cbb
.message
= id_file_added
;
3382 cbb
.args
= rb_ary_new3(10,
3383 c2r_swig_type((void *)adm_access
,
3384 (void *)"svn_wc_adm_access_t *"),
3386 c2r_string2(tmpfile1
),
3387 c2r_string2(tmpfile2
),
3390 c2r_string2(mimetype1
),
3391 c2r_string2(mimetype2
),
3392 svn_swig_rb_prop_apr_array_to_hash_prop(propchanges
),
3393 svn_swig_rb_prop_hash_to_hash(originalprops
));
3394 result
= invoke_callback_handle_error((VALUE
)(&cbb
), Qnil
, &err
);
3397 *contentstate
= NUM2INT(rb_ary_entry(result
, 0));
3399 *propstate
= NUM2INT(rb_ary_entry(result
, 1));
3405 static svn_error_t
*
3406 wc_diff_callbacks_file_deleted(svn_wc_adm_access_t
*adm_access
,
3407 svn_wc_notify_state_t
*state
,
3409 const char *tmpfile1
,
3410 const char *tmpfile2
,
3411 const char *mimetype1
,
3412 const char *mimetype2
,
3413 apr_hash_t
*originalprops
,
3416 VALUE callbacks
, rb_pool
;
3417 svn_error_t
*err
= SVN_NO_ERROR
;
3419 svn_swig_rb_from_baton((VALUE
)diff_baton
, &callbacks
, &rb_pool
);
3420 if (!NIL_P(callbacks
)) {
3421 callback_baton_t cbb
;
3422 VALUE result
= Qnil
;
3424 cbb
.receiver
= callbacks
;
3425 cbb
.message
= id_file_deleted
;
3426 cbb
.args
= rb_ary_new3(7,
3427 c2r_swig_type((void *)adm_access
,
3428 (void *)"svn_wc_adm_access_t *"),
3430 c2r_string2(tmpfile1
),
3431 c2r_string2(tmpfile2
),
3432 c2r_string2(mimetype1
),
3433 c2r_string2(mimetype2
),
3434 svn_swig_rb_prop_hash_to_hash(originalprops
));
3435 result
= invoke_callback_handle_error((VALUE
)(&cbb
), Qnil
, &err
);
3437 *state
= NUM2INT(result
);
3443 static svn_error_t
*
3444 wc_diff_callbacks_dir_added(svn_wc_adm_access_t
*adm_access
,
3445 svn_wc_notify_state_t
*state
,
3450 VALUE callbacks
, rb_pool
;
3451 svn_error_t
*err
= SVN_NO_ERROR
;
3453 svn_swig_rb_from_baton((VALUE
)diff_baton
, &callbacks
, &rb_pool
);
3454 if (!NIL_P(callbacks
)) {
3455 callback_baton_t cbb
;
3456 VALUE result
= Qnil
;
3458 cbb
.receiver
= callbacks
;
3459 cbb
.message
= id_dir_added
;
3460 cbb
.args
= rb_ary_new3(3,
3461 c2r_swig_type((void *)adm_access
,
3462 (void *)"svn_wc_adm_access_t *"),
3465 result
= invoke_callback_handle_error((VALUE
)(&cbb
), Qnil
, &err
);
3467 *state
= NUM2INT(result
);
3473 static svn_error_t
*
3474 wc_diff_callbacks_dir_deleted(svn_wc_adm_access_t
*adm_access
,
3475 svn_wc_notify_state_t
*state
,
3479 VALUE callbacks
, rb_pool
;
3480 svn_error_t
*err
= SVN_NO_ERROR
;
3482 svn_swig_rb_from_baton((VALUE
)diff_baton
, &callbacks
, &rb_pool
);
3483 if (!NIL_P(callbacks
)) {
3484 callback_baton_t cbb
;
3485 VALUE result
= Qnil
;
3487 cbb
.receiver
= callbacks
;
3488 cbb
.message
= id_dir_deleted
;
3489 cbb
.args
= rb_ary_new3(2,
3490 c2r_swig_type((void *)adm_access
,
3491 (void *)"svn_wc_adm_access_t *"),
3493 result
= invoke_callback_handle_error((VALUE
)(&cbb
), Qnil
, &err
);
3495 *state
= NUM2INT(result
);
3501 static svn_error_t
*
3502 wc_diff_callbacks_dir_props_changed(svn_wc_adm_access_t
*adm_access
,
3503 svn_wc_notify_state_t
*state
,
3505 const apr_array_header_t
*propchanges
,
3506 apr_hash_t
*originalprops
,
3509 VALUE callbacks
, rb_pool
;
3510 svn_error_t
*err
= SVN_NO_ERROR
;
3512 svn_swig_rb_from_baton((VALUE
)diff_baton
, &callbacks
, &rb_pool
);
3513 if (!NIL_P(callbacks
)) {
3514 callback_baton_t cbb
;
3515 VALUE result
= Qnil
;
3517 cbb
.receiver
= callbacks
;
3518 cbb
.message
= id_dir_props_changed
;
3519 cbb
.args
= rb_ary_new3(4,
3520 c2r_swig_type((void *)adm_access
,
3521 (void *)"svn_wc_adm_access_t *"),
3523 svn_swig_rb_prop_apr_array_to_hash_prop(propchanges
),
3524 svn_swig_rb_prop_hash_to_hash(originalprops
));
3525 result
= invoke_callback_handle_error((VALUE
)(&cbb
), Qnil
, &err
);
3528 *state
= NUM2INT(result
);
3534 svn_wc_diff_callbacks2_t
*
3535 svn_swig_rb_wc_diff_callbacks2(void)
3537 static svn_wc_diff_callbacks2_t wc_diff_callbacks2
= {
3538 wc_diff_callbacks_file_changed
,
3539 wc_diff_callbacks_file_added
,
3540 wc_diff_callbacks_file_deleted
,
3541 wc_diff_callbacks_dir_added
,
3542 wc_diff_callbacks_dir_deleted
,
3543 wc_diff_callbacks_dir_props_changed
3546 return &wc_diff_callbacks2
;
3551 svn_swig_rb_make_txdelta_window_handler_wrapper(VALUE
*rb_handler_pool
,
3552 apr_pool_t
**handler_pool
,
3553 svn_txdelta_window_handler_t
**handler
,
3554 void ***handler_baton
)
3558 obj
= rb_class_new_instance(0, NULL
, rb_cObject
);
3559 svn_swig_rb_get_pool(0, NULL
, obj
, rb_handler_pool
, handler_pool
);
3560 svn_swig_rb_set_pool_for_no_swig_type(obj
, *rb_handler_pool
);
3561 *handler
= apr_palloc(*handler_pool
, sizeof(svn_txdelta_window_handler_t
));
3562 *handler_baton
= apr_palloc(*handler_pool
, sizeof(void *));
3568 svn_swig_rb_setup_txdelta_window_handler_wrapper(VALUE obj
,
3569 svn_txdelta_window_handler_t handler
,
3570 void *handler_baton
)
3572 rb_ivar_set(obj
, id_handler
,
3573 c2r_swig_type((void *)handler
,
3574 (void *)"svn_txdelta_window_handler_t"));
3575 rb_ivar_set(obj
, id_handler_baton
,
3576 c2r_swig_type(handler_baton
, (void *)"void *"));
3581 svn_swig_rb_invoke_txdelta_window_handler_wrapper(VALUE obj
,
3582 svn_txdelta_window_t
*window
,
3585 svn_txdelta_window_handler_t handler
;
3586 svn_txdelta_window_handler_t
*handler_p
;
3587 void *handler_baton
;
3589 handler_p
= &handler
;
3590 r2c_swig_type2(rb_ivar_get(obj
, id_handler
),
3591 "svn_txdelta_window_handler_t", (void **)handler_p
);
3592 r2c_swig_type2(rb_ivar_get(obj
, id_handler_baton
),
3593 "void *", &handler_baton
);
3595 return handler(window
, handler_baton
);
3600 svn_swig_rb_txdelta_window_t_ops_get(svn_txdelta_window_t
*window
)
3603 const svn_txdelta_op_t
*op
;
3606 ops
= rb_ary_new2(window
->num_ops
);
3608 for (i
= 0; i
< window
->num_ops
; i
++) {
3609 op
= window
->ops
+ i
;
3610 rb_ary_push(ops
, c2r_swig_type((void *)op
, (void *)"svn_txdelta_op_t *"));
3618 svn_swig_rb_client_diff_summarize_func(const svn_client_diff_summarize_t
*diff
,
3622 svn_error_t
*err
= SVN_NO_ERROR
;
3623 VALUE proc
, rb_pool
;
3625 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
3628 callback_baton_t cbb
;
3630 cbb
.receiver
= proc
;
3631 cbb
.message
= id_call
;
3632 cbb
.args
= rb_ary_new3(1, c2r_client_diff_summarize__dup(diff
));
3633 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
3640 svn_swig_rb_client_list_func(void *baton
,
3642 const svn_dirent_t
*dirent
,
3643 const svn_lock_t
*lock
,
3644 const char *abs_path
,
3647 svn_error_t
*err
= SVN_NO_ERROR
;
3648 VALUE proc
, rb_pool
;
3650 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
3653 callback_baton_t cbb
;
3655 cbb
.receiver
= proc
;
3656 cbb
.message
= id_call
;
3657 cbb
.args
= rb_ary_new3(4,
3659 c2r_dirent__dup(dirent
),
3660 c2r_lock__dup(lock
),
3661 c2r_string2(abs_path
));
3662 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
3669 svn_swig_rb_proplist_receiver(void *baton
,
3671 apr_hash_t
*prop_hash
,
3674 svn_error_t
*err
= SVN_NO_ERROR
;
3675 VALUE proc
, rb_pool
;
3677 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
3679 callback_baton_t cbb
;
3681 cbb
.receiver
= proc
;
3682 cbb
.message
= id_call
;
3683 cbb
.args
= rb_ary_new3(2,
3685 svn_swig_rb_prop_hash_to_hash(prop_hash
));
3686 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
3693 svn_swig_rb_changelist_receiver(void *baton
,
3695 const char *changelist
,
3698 svn_error_t
*err
= SVN_NO_ERROR
;
3699 VALUE proc
, rb_pool
;
3701 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
3703 callback_baton_t cbb
;
3705 cbb
.receiver
= proc
;
3706 cbb
.message
= id_call
;
3707 cbb
.args
= rb_ary_new3(2,
3709 c2r_string2(changelist
));
3710 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
3717 /* svn_ra_reporter3_t */
3719 c2r_ra_reporter3(VALUE rb_reporter
, svn_ra_reporter3_t
**reporter
, void **baton
,
3724 r2c_swig_type2(rb_reporter
, "svn_ra_reporter3_t *", (void **)reporter
);
3726 rb_baton
= rb_funcall(rb_reporter
, id_baton
, 0);
3727 r2c_swig_type2(rb_baton
, "void *", baton
);
3730 static svn_error_t
*
3731 svn_swig_rb_ra_reporter_set_path(void *report_baton
, const char *path
,
3732 svn_revnum_t revision
, svn_depth_t depth
,
3733 svn_boolean_t start_empty
,
3734 const char *lock_token
, apr_pool_t
*pool
)
3736 svn_error_t
*err
= SVN_NO_ERROR
;
3737 VALUE reporter
, rb_pool
;
3739 svn_swig_rb_from_baton((VALUE
)report_baton
, &reporter
, &rb_pool
);
3740 if (rb_obj_is_kind_of(reporter
, rb_svn_ra_reporter3())) {
3741 svn_ra_reporter3_t
*svn_reporter
;
3744 c2r_ra_reporter3(reporter
, &svn_reporter
, &baton
, pool
);
3745 err
= svn_reporter
->set_path(baton
, path
, revision
, depth
,
3746 start_empty
, lock_token
, pool
);
3747 } else if (!NIL_P(reporter
)) {
3748 callback_baton_t cbb
;
3750 cbb
.receiver
= reporter
;
3751 cbb
.message
= id_set_path
;
3752 cbb
.args
= rb_ary_new3(4,
3756 c2r_bool2(start_empty
));
3757 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
3763 static svn_error_t
*
3764 svn_swig_rb_ra_reporter_delete_path(void *report_baton
, const char *path
,
3767 svn_error_t
*err
= SVN_NO_ERROR
;
3768 VALUE reporter
, rb_pool
;
3770 svn_swig_rb_from_baton((VALUE
)report_baton
, &reporter
, &rb_pool
);
3771 if (rb_obj_is_kind_of(reporter
, rb_svn_ra_reporter3())) {
3772 svn_ra_reporter3_t
*svn_reporter
;
3775 c2r_ra_reporter3(reporter
, &svn_reporter
, &baton
, pool
);
3776 err
= svn_reporter
->delete_path(baton
, path
, pool
);
3777 } else if (!NIL_P(reporter
)) {
3778 callback_baton_t cbb
;
3780 cbb
.receiver
= reporter
;
3781 cbb
.message
= id_delete_path
;
3782 cbb
.args
= rb_ary_new3(1,
3784 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
3790 static svn_error_t
*
3791 svn_swig_rb_ra_reporter_link_path(void *report_baton
, const char *path
,
3792 const char *url
, svn_revnum_t revision
,
3793 svn_depth_t depth
, svn_boolean_t start_empty
,
3794 const char *lock_token
, apr_pool_t
*pool
)
3796 svn_error_t
*err
= SVN_NO_ERROR
;
3797 VALUE reporter
, rb_pool
;
3799 svn_swig_rb_from_baton((VALUE
)report_baton
, &reporter
, &rb_pool
);
3800 if (rb_obj_is_kind_of(reporter
, rb_svn_ra_reporter3())) {
3801 svn_ra_reporter3_t
*svn_reporter
;
3804 c2r_ra_reporter3(reporter
, &svn_reporter
, &baton
, pool
);
3805 err
= svn_reporter
->link_path(baton
, path
, url
, revision
, depth
,
3806 start_empty
, lock_token
, pool
);
3807 } else if (!NIL_P(reporter
)) {
3808 callback_baton_t cbb
;
3810 cbb
.receiver
= reporter
;
3811 cbb
.message
= id_link_path
;
3812 cbb
.args
= rb_ary_new3(5,
3817 c2r_bool2(start_empty
));
3818 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
3824 static svn_error_t
*
3825 svn_swig_rb_ra_reporter_finish_report(void *report_baton
, apr_pool_t
*pool
)
3827 svn_error_t
*err
= SVN_NO_ERROR
;
3828 VALUE reporter
, rb_pool
;
3830 svn_swig_rb_from_baton((VALUE
)report_baton
, &reporter
, &rb_pool
);
3831 if (rb_obj_is_kind_of(reporter
, rb_svn_ra_reporter3())) {
3832 svn_ra_reporter3_t
*svn_reporter
;
3835 c2r_ra_reporter3(reporter
, &svn_reporter
, &baton
, pool
);
3836 err
= svn_reporter
->finish_report(baton
, pool
);
3837 } else if (!NIL_P(reporter
)) {
3838 callback_baton_t cbb
;
3840 cbb
.receiver
= reporter
;
3841 cbb
.message
= id_finish_report
;
3842 cbb
.args
= rb_ary_new();
3843 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
3849 static svn_error_t
*
3850 svn_swig_rb_ra_reporter_abort_report(void *report_baton
, apr_pool_t
*pool
)
3852 svn_error_t
*err
= SVN_NO_ERROR
;
3853 VALUE reporter
, rb_pool
;
3855 svn_swig_rb_from_baton((VALUE
)report_baton
, &reporter
, &rb_pool
);
3856 if (rb_obj_is_kind_of(reporter
, rb_svn_ra_reporter3())) {
3857 svn_ra_reporter3_t
*svn_reporter
;
3860 c2r_ra_reporter3(reporter
, &svn_reporter
, &baton
, pool
);
3861 err
= svn_reporter
->abort_report(baton
, pool
);
3862 } else if (!NIL_P(reporter
)) {
3863 callback_baton_t cbb
;
3865 cbb
.receiver
= reporter
;
3866 cbb
.message
= id_abort_report
;
3867 cbb
.args
= rb_ary_new();
3868 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
3874 static svn_ra_reporter3_t rb_ra_reporter3
= {
3875 svn_swig_rb_ra_reporter_set_path
,
3876 svn_swig_rb_ra_reporter_delete_path
,
3877 svn_swig_rb_ra_reporter_link_path
,
3878 svn_swig_rb_ra_reporter_finish_report
,
3879 svn_swig_rb_ra_reporter_abort_report
3882 svn_ra_reporter3_t
*svn_swig_rb_ra_reporter3
= &rb_ra_reporter3
;