1 /* -*- c-file-style: "ruby" -*- */
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
);
2060 svn_swig_rb_log_entry_receiver(void *baton
,
2061 svn_log_entry_t
*entry
,
2064 svn_error_t
*err
= SVN_NO_ERROR
;
2065 VALUE proc
, rb_pool
;
2067 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
2070 callback_baton_t cbb
;
2072 cbb
.receiver
= proc
;
2073 cbb
.message
= id_call
;
2074 cbb
.args
= rb_ary_new3(1,
2075 c2r_swig_type((void *)entry
,
2076 (void *)"svn_log_entry_t *"));
2077 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
2084 svn_swig_rb_repos_authz_func(svn_boolean_t
*allowed
,
2085 svn_fs_root_t
*root
,
2090 svn_error_t
*err
= SVN_NO_ERROR
;
2091 VALUE proc
, rb_pool
;
2093 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
2098 callback_baton_t cbb
;
2101 cbb
.receiver
= proc
;
2102 cbb
.message
= id_call
;
2103 cbb
.args
= rb_ary_new3(2,
2104 c2r_swig_type((void *)root
,
2105 (void *)"svn_fs_root_t *"),
2107 result
= invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
2109 *allowed
= RTEST(result
);
2115 svn_swig_rb_repos_authz_callback(svn_repos_authz_access_t required
,
2116 svn_boolean_t
*allowed
,
2117 svn_fs_root_t
*root
,
2122 svn_error_t
*err
= SVN_NO_ERROR
;
2123 VALUE proc
, rb_pool
;
2125 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
2130 callback_baton_t cbb
;
2133 cbb
.receiver
= proc
;
2134 cbb
.message
= id_call
;
2135 cbb
.args
= rb_ary_new3(3,
2137 c2r_swig_type((void *)root
,
2138 (void *)"svn_fs_root_t *"),
2140 result
= invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
2142 *allowed
= RTEST(result
);
2148 svn_swig_rb_get_commit_log_func(const char **log_msg
,
2149 const char **tmp_file
,
2150 const apr_array_header_t
*commit_items
,
2154 svn_error_t
*err
= SVN_NO_ERROR
;
2155 VALUE proc
, rb_pool
;
2160 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
2163 callback_baton_t cbb
;
2169 cbb
.receiver
= proc
;
2170 cbb
.message
= id_call
;
2171 cbb
.args
= rb_ary_new3(1, c2r_commit_item3_array(commit_items
));
2172 result
= invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
2175 char error_message
[] =
2176 "log_msg_func should return an array not '%s': "
2177 "[TRUE_IF_IT_IS_MESSAGE, MESSAGE_OR_FILE_AS_STRING]";
2179 if (!RTEST(rb_obj_is_kind_of(result
, rb_cArray
)))
2180 rb_raise(rb_eTypeError
, error_message
, r2c_inspect(result
));
2181 is_message
= rb_ary_entry(result
, 0);
2182 value
= rb_ary_entry(result
, 1);
2184 if (!RTEST(rb_obj_is_kind_of(value
, rb_cString
)))
2185 rb_raise(rb_eTypeError
, error_message
, r2c_inspect(result
));
2186 ret
= (char *)r2c_string(value
, NULL
, pool
);
2187 if (RTEST(is_message
)) {
2199 svn_swig_rb_notify_func2(void *baton
,
2200 const svn_wc_notify_t
*notify
,
2203 VALUE proc
, rb_pool
;
2204 callback_baton_t cbb
;
2206 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
2209 cbb
.receiver
= proc
;
2210 cbb
.message
= id_call
;
2211 cbb
.args
= rb_ary_new3(1, c2r_wc_notify__dup(notify
));
2215 invoke_callback((VALUE
)(&cbb
), rb_pool
);
2219 svn_swig_rb_conflict_resolver_func
2220 (svn_wc_conflict_result_t
**result
,
2221 const svn_wc_conflict_description_t
*description
,
2225 svn_error_t
*err
= SVN_NO_ERROR
;
2226 VALUE proc
, rb_pool
;
2228 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
2231 *result
= svn_wc_create_conflict_result(svn_wc_conflict_choose_postpone
,
2232 description
->merged_file
,
2235 callback_baton_t cbb
;
2238 cbb
.receiver
= proc
;
2239 cbb
.message
= id_call
;
2240 cbb
.args
= rb_ary_new3(
2242 c2r_swig_type((void *)description
,
2243 (void *)"svn_wc_conflict_description_t *") );
2244 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
2245 fret
= invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
2246 *result
= svn_wc_create_conflict_result(NUM2INT(fret
),
2247 description
->merged_file
,
2255 svn_swig_rb_commit_callback(svn_revnum_t new_revision
,
2260 svn_error_t
*err
= SVN_NO_ERROR
;
2261 VALUE proc
, rb_pool
;
2263 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
2266 callback_baton_t cbb
;
2268 cbb
.receiver
= proc
;
2269 cbb
.message
= id_call
;
2270 cbb
.args
= rb_ary_new3(3,
2271 INT2NUM(new_revision
),
2272 c2r_svn_date_string2(date
),
2273 c2r_string2(author
));
2274 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
2281 svn_swig_rb_commit_callback2(const svn_commit_info_t
*commit_info
,
2282 void *baton
, apr_pool_t
*pool
)
2284 svn_error_t
*err
= SVN_NO_ERROR
;
2285 VALUE proc
, rb_pool
;
2287 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
2290 callback_baton_t cbb
;
2292 cbb
.receiver
= proc
;
2293 cbb
.message
= id_call
;
2294 cbb
.args
= rb_ary_new3(1, c2r_commit_info__dup(commit_info
));
2295 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
2302 svn_swig_rb_cancel_func(void *cancel_baton
)
2304 svn_error_t
*err
= SVN_NO_ERROR
;
2305 VALUE proc
, rb_pool
;
2307 svn_swig_rb_from_baton((VALUE
)cancel_baton
, &proc
, &rb_pool
);
2310 callback_baton_t cbb
;
2312 cbb
.receiver
= proc
;
2313 cbb
.message
= id_call
;
2314 cbb
.args
= rb_ary_new3(0);
2315 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
2322 svn_swig_rb_info_receiver(void *baton
,
2324 const svn_info_t
*info
,
2327 svn_error_t
*err
= SVN_NO_ERROR
;
2328 VALUE proc
, rb_pool
;
2330 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
2333 callback_baton_t cbb
;
2335 cbb
.receiver
= proc
;
2336 cbb
.message
= id_call
;
2337 cbb
.args
= rb_ary_new3(2, c2r_string2(path
), c2r_info__dup(info
));
2338 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
2345 svn_swig_rb_config_enumerator(const char *name
,
2350 svn_boolean_t result
= FALSE
;
2351 VALUE proc
, rb_pool
;
2353 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
2356 callback_baton_t cbb
;
2358 cbb
.receiver
= proc
;
2359 cbb
.message
= id_call
;
2360 cbb
.args
= rb_ary_new3(2, c2r_string2(name
), c2r_string2(value
));
2361 result
= RTEST(invoke_callback((VALUE
)(&cbb
), rb_pool
));
2368 svn_swig_rb_config_section_enumerator(const char *name
,
2372 svn_boolean_t result
= FALSE
;
2373 VALUE proc
, rb_pool
;
2375 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
2378 callback_baton_t cbb
;
2380 cbb
.receiver
= proc
;
2381 cbb
.message
= id_call
;
2382 cbb
.args
= rb_ary_new3(1, c2r_string2(name
));
2383 result
= RTEST(invoke_callback((VALUE
)(&cbb
), rb_pool
));
2390 svn_swig_rb_delta_path_driver_cb_func(void **dir_baton
,
2392 void *callback_baton
,
2396 svn_error_t
*err
= SVN_NO_ERROR
;
2397 VALUE proc
, rb_pool
;
2399 svn_swig_rb_from_baton((VALUE
)callback_baton
, &proc
, &rb_pool
);
2402 callback_baton_t cbb
;
2404 item_baton
*ib
= (item_baton
*)parent_baton
;
2406 cbb
.receiver
= proc
;
2407 cbb
.message
= id_call
;
2408 cbb
.args
= rb_ary_new3(2, ib
->baton
, c2r_string2(path
));
2409 result
= invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
2410 *dir_baton
= make_baton(pool
, ib
->editor
, result
);
2417 svn_swig_rb_txdelta_window_handler(svn_txdelta_window_t
*window
,
2420 svn_error_t
*err
= SVN_NO_ERROR
;
2421 VALUE proc
, rb_pool
;
2423 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
2426 callback_baton_t cbb
;
2428 cbb
.receiver
= proc
;
2429 cbb
.message
= id_call
;
2430 cbb
.args
= rb_ary_new3(1, c2r_txdelta_window__dup(window
));
2431 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
2438 svn_swig_rb_fs_warning_callback(void *baton
, svn_error_t
*err
)
2440 VALUE proc
, rb_pool
;
2442 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
2445 callback_baton_t cbb
;
2447 cbb
.receiver
= proc
;
2448 cbb
.message
= id_call
;
2449 cbb
.args
= rb_ary_new3(1, svn_swig_rb_svn_error_to_rb_error(err
));
2450 invoke_callback((VALUE
)(&cbb
), rb_pool
);
2455 cleanup_fs_warning_callback_baton(void *baton
)
2457 rb_holder_pop(rb_svn_fs_warning_callback_baton_holder(), (VALUE
)baton
);
2462 svn_swig_rb_fs_warning_callback_baton_register(VALUE baton
, apr_pool_t
*pool
)
2464 rb_holder_push(rb_svn_fs_warning_callback_baton_holder(), (VALUE
)baton
);
2465 apr_pool_cleanup_register(pool
, (void *)baton
,
2466 cleanup_fs_warning_callback_baton
,
2467 apr_pool_cleanup_null
);
2471 svn_swig_rb_fs_get_locks_callback(void *baton
,
2475 svn_error_t
*err
= SVN_NO_ERROR
;
2476 VALUE proc
, rb_pool
;
2478 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
2481 callback_baton_t cbb
;
2483 cbb
.receiver
= proc
;
2484 cbb
.message
= id_call
;
2485 cbb
.args
= rb_ary_new3(1, c2r_lock__dup(lock
));
2486 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
2493 /* svn_ra_callbacks_t */
2494 static svn_error_t
*
2495 ra_callbacks_open_tmp_file(apr_file_t
**fp
,
2496 void *callback_baton
,
2499 VALUE callbacks
= (VALUE
)callback_baton
;
2500 svn_error_t
*err
= SVN_NO_ERROR
;
2502 if (!NIL_P(callbacks
)) {
2503 callback_baton_t cbb
;
2506 cbb
.receiver
= callbacks
;
2507 cbb
.message
= id_open_tmp_file
;
2508 cbb
.args
= rb_ary_new3(0);
2510 result
= invoke_callback_handle_error((VALUE
)(&cbb
), Qnil
, &err
);
2511 *fp
= svn_swig_rb_make_file(result
, pool
);
2517 static svn_error_t
*
2518 ra_callbacks_get_wc_prop(void *baton
,
2519 const char *relpath
,
2521 const svn_string_t
**value
,
2524 VALUE callbacks
= (VALUE
)baton
;
2525 svn_error_t
*err
= SVN_NO_ERROR
;
2527 if (!NIL_P(callbacks
)) {
2528 callback_baton_t cbb
;
2531 cbb
.receiver
= callbacks
;
2532 cbb
.message
= id_get_wc_prop
;
2533 cbb
.args
= rb_ary_new3(2, c2r_string2(relpath
), c2r_string2(name
));
2534 result
= invoke_callback_handle_error((VALUE
)(&cbb
), Qnil
, &err
);
2535 if (NIL_P(result
)) {
2538 *value
= r2c_svn_string(result
, NULL
, pool
);
2545 static svn_error_t
*
2546 ra_callbacks_set_wc_prop(void *baton
,
2549 const svn_string_t
*value
,
2552 VALUE callbacks
= (VALUE
)baton
;
2553 svn_error_t
*err
= SVN_NO_ERROR
;
2555 if (!NIL_P(callbacks
)) {
2556 callback_baton_t cbb
;
2558 cbb
.receiver
= callbacks
;
2559 cbb
.message
= id_set_wc_prop
;
2560 cbb
.args
= rb_ary_new3(3,
2563 c2r_svn_string((void *)value
, NULL
));
2564 invoke_callback_handle_error((VALUE
)(&cbb
), Qnil
, &err
);
2570 static svn_error_t
*
2571 ra_callbacks_push_wc_prop(void *baton
,
2574 const svn_string_t
*value
,
2577 VALUE callbacks
= (VALUE
)baton
;
2578 svn_error_t
*err
= SVN_NO_ERROR
;
2580 if (!NIL_P(callbacks
)) {
2581 callback_baton_t cbb
;
2583 cbb
.receiver
= callbacks
;
2584 cbb
.message
= id_push_wc_prop
;
2585 cbb
.args
= rb_ary_new3(3,
2588 c2r_svn_string((void *)value
, NULL
));
2589 invoke_callback_handle_error((VALUE
)(&cbb
), Qnil
, &err
);
2595 static svn_error_t
*
2596 ra_callbacks_invalidate_wc_props(void *baton
,
2601 VALUE callbacks
= (VALUE
)baton
;
2602 svn_error_t
*err
= SVN_NO_ERROR
;
2604 if (!NIL_P(callbacks
)) {
2605 callback_baton_t cbb
;
2607 cbb
.receiver
= callbacks
;
2608 cbb
.message
= id_invalidate_wc_props
;
2609 cbb
.args
= rb_ary_new3(2, c2r_string2(path
), c2r_string2(name
));
2610 invoke_callback_handle_error((VALUE
)(&cbb
), Qnil
, &err
);
2618 ra_callbacks_progress_func(apr_off_t progress
,
2623 VALUE callbacks
= (VALUE
)baton
;
2624 if (!NIL_P(callbacks
)) {
2625 callback_baton_t cbb
;
2627 cbb
.receiver
= callbacks
;
2628 cbb
.message
= id_progress_func
;
2629 cbb
.args
= rb_ary_new3(2, AOFF2NUM(progress
), AOFF2NUM(total
));
2630 invoke_callback((VALUE
)(&cbb
), Qnil
);
2635 svn_swig_rb_setup_ra_callbacks(svn_ra_callbacks2_t
**callbacks
,
2640 void *auth_baton
= NULL
;
2642 if (!NIL_P(rb_callbacks
)) {
2643 VALUE rb_auth_baton
= Qnil
;
2644 rb_auth_baton
= rb_funcall(rb_callbacks
, id_auth_baton
, 0);
2645 auth_baton
= r2c_swig_type(rb_auth_baton
,
2646 (void *)"svn_auth_baton_t *",
2650 *callbacks
= apr_pcalloc(pool
, sizeof(**callbacks
));
2651 *baton
= (void *)rb_callbacks
;
2653 (*callbacks
)->open_tmp_file
= ra_callbacks_open_tmp_file
;
2654 (*callbacks
)->auth_baton
= auth_baton
;
2655 (*callbacks
)->get_wc_prop
= ra_callbacks_get_wc_prop
;
2656 (*callbacks
)->set_wc_prop
= ra_callbacks_set_wc_prop
;
2657 (*callbacks
)->push_wc_prop
= ra_callbacks_push_wc_prop
;
2658 (*callbacks
)->invalidate_wc_props
= ra_callbacks_invalidate_wc_props
;
2659 (*callbacks
)->progress_func
= ra_callbacks_progress_func
;
2660 (*callbacks
)->progress_baton
= (void *)rb_callbacks
;
2665 svn_swig_rb_ra_lock_callback(void *baton
,
2667 svn_boolean_t do_lock
,
2668 const svn_lock_t
*lock
,
2669 svn_error_t
*ra_err
,
2672 svn_error_t
*err
= SVN_NO_ERROR
;
2673 VALUE proc
, rb_pool
;
2675 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
2678 callback_baton_t cbb
;
2680 cbb
.receiver
= proc
;
2681 cbb
.message
= id_call
;
2682 cbb
.args
= rb_ary_new3(4,
2684 do_lock
? Qtrue
: Qfalse
,
2685 c2r_lock__dup(lock
),
2687 svn_swig_rb_svn_error_to_rb_error(ra_err
) :
2689 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
2696 svn_swig_rb_just_call(void *baton
)
2698 svn_error_t
*err
= SVN_NO_ERROR
;
2699 VALUE proc
, rb_pool
;
2701 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
2704 callback_baton_t cbb
;
2706 cbb
.receiver
= proc
;
2707 cbb
.message
= id_call
;
2708 cbb
.args
= rb_ary_new3(0);
2709 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
2716 svn_swig_rb_ra_file_rev_handler(void *baton
,
2719 apr_hash_t
*rev_props
,
2720 svn_txdelta_window_handler_t
*delta_handler
,
2722 apr_array_header_t
*prop_diffs
,
2725 svn_error_t
*err
= SVN_NO_ERROR
;
2726 VALUE proc
, rb_pool
;
2728 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
2731 callback_baton_t cbb
;
2733 cbb
.receiver
= proc
;
2734 cbb
.message
= id_call
;
2735 cbb
.args
= rb_ary_new3(4,
2737 c2r_long(&rev
, NULL
),
2738 svn_swig_rb_apr_hash_to_hash_svn_string(rev_props
),
2739 svn_swig_rb_prop_apr_array_to_hash_prop(prop_diffs
));
2740 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
2747 svn_swig_rb_repos_history_func(void *baton
,
2749 svn_revnum_t revision
,
2752 svn_error_t
*err
= SVN_NO_ERROR
;
2753 VALUE proc
, rb_pool
;
2755 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
2758 callback_baton_t cbb
;
2759 VALUE result
= Qnil
;
2761 cbb
.receiver
= proc
;
2762 cbb
.message
= id_call
;
2763 cbb
.args
= rb_ary_new3(2,
2765 c2r_long(&revision
, NULL
));
2766 result
= invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
2768 if (!err
&& SVN_ERR_P(result
)) {
2769 err
= r2c_svn_err(result
, NULL
, NULL
);
2777 svn_swig_rb_repos_file_rev_handler(void *baton
,
2780 apr_hash_t
*rev_props
,
2781 svn_txdelta_window_handler_t
*delta_handler
,
2783 apr_array_header_t
*prop_diffs
,
2786 svn_error_t
*err
= SVN_NO_ERROR
;
2787 VALUE proc
, rb_pool
;
2789 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
2792 callback_baton_t cbb
;
2794 cbb
.receiver
= proc
;
2795 cbb
.message
= id_call
;
2796 cbb
.args
= rb_ary_new3(4,
2798 c2r_long(&rev
, NULL
),
2799 svn_swig_rb_apr_hash_to_hash_svn_string(rev_props
),
2800 svn_swig_rb_prop_apr_array_to_hash_prop(prop_diffs
));
2801 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
2808 svn_swig_rb_wc_relocation_validator3(void *baton
,
2811 const char *root_url
,
2814 svn_error_t
*err
= SVN_NO_ERROR
;
2815 VALUE proc
, rb_pool
;
2817 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
2820 callback_baton_t cbb
;
2822 cbb
.receiver
= proc
;
2823 cbb
.message
= id_call
;
2824 cbb
.args
= rb_ary_new3(3,
2827 c2r_string2(root_url
));
2828 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
2836 /* auth provider callbacks */
2838 svn_swig_rb_auth_simple_prompt_func(svn_auth_cred_simple_t
**cred
,
2841 const char *username
,
2842 svn_boolean_t may_save
,
2845 svn_auth_cred_simple_t
*new_cred
= NULL
;
2846 svn_error_t
*err
= SVN_NO_ERROR
;
2847 VALUE proc
, rb_pool
;
2849 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
2852 callback_baton_t cbb
;
2855 cbb
.receiver
= proc
;
2856 cbb
.message
= id_call
;
2857 cbb
.args
= rb_ary_new3(3,
2859 c2r_string2(username
),
2860 RTEST(may_save
) ? Qtrue
: Qfalse
);
2861 result
= invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
2863 if (!NIL_P(result
)) {
2864 void *result_cred
= NULL
;
2865 svn_auth_cred_simple_t
*tmp_cred
= NULL
;
2867 r2c_swig_type2(result
, "svn_auth_cred_simple_t *", &result_cred
);
2868 tmp_cred
= (svn_auth_cred_simple_t
*)result_cred
;
2869 new_cred
= apr_pcalloc(pool
, sizeof(*new_cred
));
2870 new_cred
->username
= tmp_cred
->username
?
2871 apr_pstrdup(pool
, tmp_cred
->username
) : NULL
;
2872 new_cred
->password
= tmp_cred
->password
?
2873 apr_pstrdup(pool
, tmp_cred
->password
) : NULL
;
2874 new_cred
->may_save
= tmp_cred
->may_save
;
2883 svn_swig_rb_auth_username_prompt_func(svn_auth_cred_username_t
**cred
,
2886 svn_boolean_t may_save
,
2889 svn_auth_cred_username_t
*new_cred
= NULL
;
2890 svn_error_t
*err
= SVN_NO_ERROR
;
2891 VALUE proc
, rb_pool
;
2893 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
2896 callback_baton_t cbb
;
2899 cbb
.receiver
= proc
;
2900 cbb
.message
= id_call
;
2901 cbb
.args
= rb_ary_new3(2,
2903 RTEST(may_save
) ? Qtrue
: Qfalse
);
2904 result
= invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
2906 if (!NIL_P(result
)) {
2907 void *result_cred
= NULL
;
2908 svn_auth_cred_username_t
*tmp_cred
= NULL
;
2910 r2c_swig_type2(result
, "svn_auth_cred_username_t *", &result_cred
);
2911 tmp_cred
= (svn_auth_cred_username_t
*)result_cred
;
2912 new_cred
= apr_pcalloc(pool
, sizeof(*new_cred
));
2913 new_cred
->username
= tmp_cred
->username
?
2914 apr_pstrdup(pool
, tmp_cred
->username
) : NULL
;
2915 new_cred
->may_save
= tmp_cred
->may_save
;
2924 svn_swig_rb_auth_ssl_server_trust_prompt_func(
2925 svn_auth_cred_ssl_server_trust_t
**cred
,
2928 apr_uint32_t failures
,
2929 const svn_auth_ssl_server_cert_info_t
*cert_info
,
2930 svn_boolean_t may_save
,
2933 svn_auth_cred_ssl_server_trust_t
*new_cred
= NULL
;
2934 svn_error_t
*err
= SVN_NO_ERROR
;
2935 VALUE proc
, rb_pool
;
2937 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
2940 callback_baton_t cbb
;
2943 cbb
.receiver
= proc
;
2944 cbb
.message
= id_call
;
2945 cbb
.args
= rb_ary_new3(4,
2948 c2r_auth_ssl_server_cert_info__dup(cert_info
),
2949 RTEST(may_save
) ? Qtrue
: Qfalse
);
2950 result
= invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
2952 if (!NIL_P(result
)) {
2954 svn_auth_cred_ssl_server_trust_t
*tmp_cred
= NULL
;
2956 r2c_swig_type2(result
, "svn_auth_cred_ssl_server_trust_t *",
2958 tmp_cred
= (svn_auth_cred_ssl_server_trust_t
*)result_cred
;
2959 new_cred
= apr_pcalloc(pool
, sizeof(*new_cred
));
2960 *new_cred
= *tmp_cred
;
2969 svn_swig_rb_auth_ssl_client_cert_prompt_func(
2970 svn_auth_cred_ssl_client_cert_t
**cred
,
2973 svn_boolean_t may_save
,
2976 svn_auth_cred_ssl_client_cert_t
*new_cred
= NULL
;
2977 svn_error_t
*err
= SVN_NO_ERROR
;
2978 VALUE proc
, rb_pool
;
2980 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
2983 callback_baton_t cbb
;
2986 cbb
.receiver
= proc
;
2987 cbb
.message
= id_call
;
2988 cbb
.args
= rb_ary_new3(2,
2990 RTEST(may_save
) ? Qtrue
: Qfalse
);
2991 result
= invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
2993 if (!NIL_P(result
)) {
2994 void *result_cred
= NULL
;
2995 svn_auth_cred_ssl_client_cert_t
*tmp_cred
= NULL
;
2997 r2c_swig_type2(result
, "svn_auth_cred_ssl_client_cert_t *",
2999 tmp_cred
= (svn_auth_cred_ssl_client_cert_t
*)result_cred
;
3000 new_cred
= apr_pcalloc(pool
, sizeof(*new_cred
));
3001 new_cred
->cert_file
= tmp_cred
->cert_file
?
3002 apr_pstrdup(pool
, tmp_cred
->cert_file
) : NULL
;
3003 new_cred
->may_save
= tmp_cred
->may_save
;
3012 svn_swig_rb_auth_ssl_client_cert_pw_prompt_func(
3013 svn_auth_cred_ssl_client_cert_pw_t
**cred
,
3016 svn_boolean_t may_save
,
3019 svn_auth_cred_ssl_client_cert_pw_t
*new_cred
= NULL
;
3020 svn_error_t
*err
= SVN_NO_ERROR
;
3021 VALUE proc
, rb_pool
;
3023 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
3026 callback_baton_t cbb
;
3029 cbb
.receiver
= proc
;
3030 cbb
.message
= id_call
;
3031 cbb
.args
= rb_ary_new3(2,
3033 RTEST(may_save
) ? Qtrue
: Qfalse
);
3034 result
= invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
3036 if (!NIL_P(result
)) {
3037 void *result_cred
= NULL
;
3038 svn_auth_cred_ssl_client_cert_pw_t
*tmp_cred
= NULL
;
3040 r2c_swig_type2(result
, "svn_auth_cred_ssl_client_cert_pw_t *",
3042 tmp_cred
= (svn_auth_cred_ssl_client_cert_pw_t
*)result_cred
;
3043 new_cred
= apr_pcalloc(pool
, sizeof(*new_cred
));
3044 new_cred
->password
= tmp_cred
->password
?
3045 apr_pstrdup(pool
, tmp_cred
->password
) : NULL
;
3046 new_cred
->may_save
= tmp_cred
->may_save
;
3056 svn_swig_rb_make_file(VALUE file
, apr_pool_t
*pool
)
3058 apr_file_t
*apr_file
= NULL
;
3060 apr_file_open(&apr_file
, StringValuePtr(file
),
3061 APR_CREATE
| APR_READ
| APR_WRITE
,
3069 static svn_error_t
*
3070 read_handler_rbio(void *baton
, char *buffer
, apr_size_t
*len
)
3073 VALUE io
= (VALUE
)baton
;
3074 svn_error_t
*err
= SVN_NO_ERROR
;
3076 result
= rb_funcall(io
, id_read
, 1, INT2NUM(*len
));
3077 if (NIL_P(result
)) {
3080 memcpy(buffer
, StringValuePtr(result
), RSTRING(result
)->len
);
3081 *len
= RSTRING(result
)->len
;
3087 static svn_error_t
*
3088 write_handler_rbio(void *baton
, const char *data
, apr_size_t
*len
)
3090 VALUE io
= (VALUE
)baton
;
3091 svn_error_t
*err
= SVN_NO_ERROR
;
3093 rb_funcall(io
, id_write
, 1, rb_str_new(data
, *len
));
3099 svn_swig_rb_make_stream(VALUE io
)
3101 svn_stream_t
*stream
;
3103 if (RTEST(rb_funcall(rb_svn_core_stream(), id_eqq
, 1, io
))) {
3104 svn_stream_t
**stream_p
;
3106 r2c_swig_type2(io
, "svn_stream_t *", (void **)stream_p
);
3108 VALUE rb_pool
= rb_pool_new(Qnil
);
3109 apr_pool_wrapper_t
*pool_wrapper
;
3110 apr_pool_wrapper_t
**pool_wrapper_p
;
3112 rb_set_pool(io
, rb_pool
);
3113 pool_wrapper_p
= &pool_wrapper
;
3114 r2c_swig_type2(rb_pool
, "apr_pool_wrapper_t *", (void **)pool_wrapper_p
);
3115 stream
= svn_stream_create((void *)io
, pool_wrapper
->pool
);
3116 svn_stream_set_read(stream
, read_handler_rbio
);
3117 svn_stream_set_write(stream
, write_handler_rbio
);
3124 svn_swig_rb_filename_to_temp_file(const char *file_name
)
3126 return rb_funcall(rb_svn_util(), id_filename_to_temp_file
,
3127 1, rb_str_new2(file_name
));
3131 svn_swig_rb_set_revision(svn_opt_revision_t
*rev
, VALUE value
)
3133 switch (TYPE(value
)) {
3135 rev
->kind
= svn_opt_revision_unspecified
;
3138 rev
->kind
= svn_opt_revision_number
;
3139 rev
->value
.number
= NUM2LONG(value
);
3142 if (RTEST(rb_reg_match(rb_reg_new("^BASE$",
3144 RE_OPTION_IGNORECASE
),
3146 rev
->kind
= svn_opt_revision_base
;
3147 else if (RTEST(rb_reg_match(rb_reg_new("^HEAD$",
3149 RE_OPTION_IGNORECASE
),
3151 rev
->kind
= svn_opt_revision_head
;
3152 else if (RTEST(rb_reg_match(rb_reg_new("^WORKING$",
3153 strlen("^WORKING$"),
3154 RE_OPTION_IGNORECASE
),
3156 rev
->kind
= svn_opt_revision_working
;
3157 else if (RTEST(rb_reg_match(rb_reg_new("^COMMITTED$",
3158 strlen("^COMMITTED$"),
3159 RE_OPTION_IGNORECASE
),
3161 rev
->kind
= svn_opt_revision_committed
;
3162 else if (RTEST(rb_reg_match(rb_reg_new("^PREV$",
3164 RE_OPTION_IGNORECASE
),
3166 rev
->kind
= svn_opt_revision_previous
;
3168 rb_raise(rb_eArgError
,
3169 "invalid value: %s",
3170 StringValuePtr(value
));
3173 if (rb_obj_is_kind_of(value
,
3174 rb_const_get(rb_cObject
, rb_intern("Time")))) {
3175 rev
->kind
= svn_opt_revision_date
;
3176 rev
->value
.date
= NUM2LONG(rb_funcall(value
, rb_intern("to_i"), 0));
3178 rb_raise(rb_eArgError
,
3180 rb_class2name(CLASS_OF(value
)));
3187 svn_swig_rb_adjust_arg_for_client_ctx_and_pool(int *argc
, VALUE
**argv
)
3190 VALUE last_arg
= (*argv
)[*argc
- 1];
3191 if (NIL_P(last_arg
) || POOL_P(last_arg
)) {
3195 if (CONTEXT_P(last_arg
)) {
3207 svn_swig_rb_wc_status_func(void *baton
,
3209 svn_wc_status2_t
*status
)
3211 VALUE proc
, rb_pool
;
3213 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
3216 callback_baton_t cbb
;
3218 cbb
.receiver
= proc
;
3219 cbb
.message
= id_call
;
3220 cbb
.args
= rb_ary_new3(2, c2r_string2(path
), c2r_wc_status2__dup(status
));
3221 invoke_callback((VALUE
)(&cbb
), rb_pool
);
3226 svn_swig_rb_client_blame_receiver_func(void *baton
,
3227 apr_int64_t line_no
,
3228 svn_revnum_t revision
,
3234 svn_error_t
*err
= SVN_NO_ERROR
;
3235 VALUE proc
, rb_pool
;
3237 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
3240 callback_baton_t cbb
;
3242 cbb
.receiver
= proc
;
3243 cbb
.message
= id_call
;
3244 cbb
.args
= rb_ary_new3(5,
3247 c2r_string2(author
),
3248 c2r_svn_date_string2(date
),
3250 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
3258 /* svn_wc_entry_callbacks2_t */
3259 static svn_error_t
*
3260 wc_entry_callbacks2_found_entry(const char *path
,
3261 const svn_wc_entry_t
*entry
,
3265 svn_error_t
*err
= SVN_NO_ERROR
;
3266 VALUE callbacks
, rb_pool
;
3268 svn_swig_rb_from_baton((VALUE
)walk_baton
, &callbacks
, &rb_pool
);;
3270 if (!NIL_P(callbacks
)) {
3271 callback_baton_t cbb
;
3273 cbb
.receiver
= callbacks
;
3274 cbb
.message
= id_found_entry
;
3275 cbb
.args
= rb_ary_new3(2,
3277 c2r_wc_entry__dup(entry
));
3278 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
3284 static svn_error_t
*
3285 wc_entry_callbacks2_handle_error(const char *path
,
3290 VALUE callbacks
, rb_pool
;
3292 svn_swig_rb_from_baton((VALUE
)walk_baton
, &callbacks
, &rb_pool
);;
3294 if (!NIL_P(callbacks
)) {
3295 callback_baton_t cbb
;
3298 message
= id_handle_error
;
3299 if (rb_obj_respond_to(callbacks
, message
, FALSE
)) {
3302 cbb
.receiver
= callbacks
;
3303 cbb
.message
= id_handle_error
;
3304 rb_err
= err
? svn_swig_rb_svn_error_to_rb_error(err
) : Qnil
;
3306 svn_error_clear(err
);
3308 cbb
.args
= rb_ary_new3(2, c2r_string2(path
), rb_err
);
3309 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
3316 svn_wc_entry_callbacks2_t
*
3317 svn_swig_rb_wc_entry_callbacks2(void)
3319 static svn_wc_entry_callbacks2_t wc_entry_callbacks
= {
3320 wc_entry_callbacks2_found_entry
,
3321 wc_entry_callbacks2_handle_error
,
3324 return &wc_entry_callbacks
;
3329 /* svn_wc_diff_callbacks2_t */
3330 static svn_error_t
*
3331 wc_diff_callbacks_file_changed(svn_wc_adm_access_t
*adm_access
,
3332 svn_wc_notify_state_t
*contentstate
,
3333 svn_wc_notify_state_t
*propstate
,
3335 const char *tmpfile1
,
3336 const char *tmpfile2
,
3339 const char *mimetype1
,
3340 const char *mimetype2
,
3341 const apr_array_header_t
*propchanges
,
3342 apr_hash_t
*originalprops
,
3345 VALUE callbacks
, rb_pool
;
3346 svn_error_t
*err
= SVN_NO_ERROR
;
3348 svn_swig_rb_from_baton((VALUE
)diff_baton
, &callbacks
, &rb_pool
);
3349 if (!NIL_P(callbacks
)) {
3350 callback_baton_t cbb
;
3351 VALUE result
= Qnil
;
3353 cbb
.receiver
= callbacks
;
3354 cbb
.message
= id_file_changed
;
3355 cbb
.args
= rb_ary_new3(10,
3356 c2r_swig_type((void *)adm_access
,
3357 (void *)"svn_wc_adm_access_t *"),
3359 c2r_string2(tmpfile1
),
3360 c2r_string2(tmpfile2
),
3363 c2r_string2(mimetype1
),
3364 c2r_string2(mimetype2
),
3365 svn_swig_rb_prop_apr_array_to_hash_prop(propchanges
),
3366 svn_swig_rb_prop_hash_to_hash(originalprops
));
3367 result
= invoke_callback_handle_error((VALUE
)(&cbb
), Qnil
, &err
);
3370 *contentstate
= NUM2INT(rb_ary_entry(result
, 0));
3372 *propstate
= NUM2INT(rb_ary_entry(result
, 1));
3378 static svn_error_t
*
3379 wc_diff_callbacks_file_added(svn_wc_adm_access_t
*adm_access
,
3380 svn_wc_notify_state_t
*contentstate
,
3381 svn_wc_notify_state_t
*propstate
,
3383 const char *tmpfile1
,
3384 const char *tmpfile2
,
3387 const char *mimetype1
,
3388 const char *mimetype2
,
3389 const apr_array_header_t
*propchanges
,
3390 apr_hash_t
*originalprops
,
3393 VALUE callbacks
, rb_pool
;
3394 svn_error_t
*err
= SVN_NO_ERROR
;
3396 svn_swig_rb_from_baton((VALUE
)diff_baton
, &callbacks
, &rb_pool
);
3397 if (!NIL_P(callbacks
)) {
3398 callback_baton_t cbb
;
3399 VALUE result
= Qnil
;
3401 cbb
.receiver
= callbacks
;
3402 cbb
.message
= id_file_added
;
3403 cbb
.args
= rb_ary_new3(10,
3404 c2r_swig_type((void *)adm_access
,
3405 (void *)"svn_wc_adm_access_t *"),
3407 c2r_string2(tmpfile1
),
3408 c2r_string2(tmpfile2
),
3411 c2r_string2(mimetype1
),
3412 c2r_string2(mimetype2
),
3413 svn_swig_rb_prop_apr_array_to_hash_prop(propchanges
),
3414 svn_swig_rb_prop_hash_to_hash(originalprops
));
3415 result
= invoke_callback_handle_error((VALUE
)(&cbb
), Qnil
, &err
);
3418 *contentstate
= NUM2INT(rb_ary_entry(result
, 0));
3420 *propstate
= NUM2INT(rb_ary_entry(result
, 1));
3426 static svn_error_t
*
3427 wc_diff_callbacks_file_deleted(svn_wc_adm_access_t
*adm_access
,
3428 svn_wc_notify_state_t
*state
,
3430 const char *tmpfile1
,
3431 const char *tmpfile2
,
3432 const char *mimetype1
,
3433 const char *mimetype2
,
3434 apr_hash_t
*originalprops
,
3437 VALUE callbacks
, rb_pool
;
3438 svn_error_t
*err
= SVN_NO_ERROR
;
3440 svn_swig_rb_from_baton((VALUE
)diff_baton
, &callbacks
, &rb_pool
);
3441 if (!NIL_P(callbacks
)) {
3442 callback_baton_t cbb
;
3443 VALUE result
= Qnil
;
3445 cbb
.receiver
= callbacks
;
3446 cbb
.message
= id_file_deleted
;
3447 cbb
.args
= rb_ary_new3(7,
3448 c2r_swig_type((void *)adm_access
,
3449 (void *)"svn_wc_adm_access_t *"),
3451 c2r_string2(tmpfile1
),
3452 c2r_string2(tmpfile2
),
3453 c2r_string2(mimetype1
),
3454 c2r_string2(mimetype2
),
3455 svn_swig_rb_prop_hash_to_hash(originalprops
));
3456 result
= invoke_callback_handle_error((VALUE
)(&cbb
), Qnil
, &err
);
3458 *state
= NUM2INT(result
);
3464 static svn_error_t
*
3465 wc_diff_callbacks_dir_added(svn_wc_adm_access_t
*adm_access
,
3466 svn_wc_notify_state_t
*state
,
3471 VALUE callbacks
, rb_pool
;
3472 svn_error_t
*err
= SVN_NO_ERROR
;
3474 svn_swig_rb_from_baton((VALUE
)diff_baton
, &callbacks
, &rb_pool
);
3475 if (!NIL_P(callbacks
)) {
3476 callback_baton_t cbb
;
3477 VALUE result
= Qnil
;
3479 cbb
.receiver
= callbacks
;
3480 cbb
.message
= id_dir_added
;
3481 cbb
.args
= rb_ary_new3(3,
3482 c2r_swig_type((void *)adm_access
,
3483 (void *)"svn_wc_adm_access_t *"),
3486 result
= invoke_callback_handle_error((VALUE
)(&cbb
), Qnil
, &err
);
3488 *state
= NUM2INT(result
);
3494 static svn_error_t
*
3495 wc_diff_callbacks_dir_deleted(svn_wc_adm_access_t
*adm_access
,
3496 svn_wc_notify_state_t
*state
,
3500 VALUE callbacks
, rb_pool
;
3501 svn_error_t
*err
= SVN_NO_ERROR
;
3503 svn_swig_rb_from_baton((VALUE
)diff_baton
, &callbacks
, &rb_pool
);
3504 if (!NIL_P(callbacks
)) {
3505 callback_baton_t cbb
;
3506 VALUE result
= Qnil
;
3508 cbb
.receiver
= callbacks
;
3509 cbb
.message
= id_dir_deleted
;
3510 cbb
.args
= rb_ary_new3(2,
3511 c2r_swig_type((void *)adm_access
,
3512 (void *)"svn_wc_adm_access_t *"),
3514 result
= invoke_callback_handle_error((VALUE
)(&cbb
), Qnil
, &err
);
3516 *state
= NUM2INT(result
);
3522 static svn_error_t
*
3523 wc_diff_callbacks_dir_props_changed(svn_wc_adm_access_t
*adm_access
,
3524 svn_wc_notify_state_t
*state
,
3526 const apr_array_header_t
*propchanges
,
3527 apr_hash_t
*originalprops
,
3530 VALUE callbacks
, rb_pool
;
3531 svn_error_t
*err
= SVN_NO_ERROR
;
3533 svn_swig_rb_from_baton((VALUE
)diff_baton
, &callbacks
, &rb_pool
);
3534 if (!NIL_P(callbacks
)) {
3535 callback_baton_t cbb
;
3536 VALUE result
= Qnil
;
3538 cbb
.receiver
= callbacks
;
3539 cbb
.message
= id_dir_props_changed
;
3540 cbb
.args
= rb_ary_new3(4,
3541 c2r_swig_type((void *)adm_access
,
3542 (void *)"svn_wc_adm_access_t *"),
3544 svn_swig_rb_prop_apr_array_to_hash_prop(propchanges
),
3545 svn_swig_rb_prop_hash_to_hash(originalprops
));
3546 result
= invoke_callback_handle_error((VALUE
)(&cbb
), Qnil
, &err
);
3549 *state
= NUM2INT(result
);
3555 svn_wc_diff_callbacks2_t
*
3556 svn_swig_rb_wc_diff_callbacks2(void)
3558 static svn_wc_diff_callbacks2_t wc_diff_callbacks2
= {
3559 wc_diff_callbacks_file_changed
,
3560 wc_diff_callbacks_file_added
,
3561 wc_diff_callbacks_file_deleted
,
3562 wc_diff_callbacks_dir_added
,
3563 wc_diff_callbacks_dir_deleted
,
3564 wc_diff_callbacks_dir_props_changed
3567 return &wc_diff_callbacks2
;
3572 svn_swig_rb_make_txdelta_window_handler_wrapper(VALUE
*rb_handler_pool
,
3573 apr_pool_t
**handler_pool
,
3574 svn_txdelta_window_handler_t
**handler
,
3575 void ***handler_baton
)
3579 obj
= rb_class_new_instance(0, NULL
, rb_cObject
);
3580 svn_swig_rb_get_pool(0, NULL
, obj
, rb_handler_pool
, handler_pool
);
3581 svn_swig_rb_set_pool_for_no_swig_type(obj
, *rb_handler_pool
);
3582 *handler
= apr_palloc(*handler_pool
, sizeof(svn_txdelta_window_handler_t
));
3583 *handler_baton
= apr_palloc(*handler_pool
, sizeof(void *));
3589 svn_swig_rb_setup_txdelta_window_handler_wrapper(VALUE obj
,
3590 svn_txdelta_window_handler_t handler
,
3591 void *handler_baton
)
3593 rb_ivar_set(obj
, id_handler
,
3594 c2r_swig_type((void *)handler
,
3595 (void *)"svn_txdelta_window_handler_t"));
3596 rb_ivar_set(obj
, id_handler_baton
,
3597 c2r_swig_type(handler_baton
, (void *)"void *"));
3602 svn_swig_rb_invoke_txdelta_window_handler_wrapper(VALUE obj
,
3603 svn_txdelta_window_t
*window
,
3606 svn_txdelta_window_handler_t handler
;
3607 svn_txdelta_window_handler_t
*handler_p
;
3608 void *handler_baton
;
3610 handler_p
= &handler
;
3611 r2c_swig_type2(rb_ivar_get(obj
, id_handler
),
3612 "svn_txdelta_window_handler_t", (void **)handler_p
);
3613 r2c_swig_type2(rb_ivar_get(obj
, id_handler_baton
),
3614 "void *", &handler_baton
);
3616 return handler(window
, handler_baton
);
3621 svn_swig_rb_txdelta_window_t_ops_get(svn_txdelta_window_t
*window
)
3624 const svn_txdelta_op_t
*op
;
3627 ops
= rb_ary_new2(window
->num_ops
);
3629 for (i
= 0; i
< window
->num_ops
; i
++) {
3630 op
= window
->ops
+ i
;
3631 rb_ary_push(ops
, c2r_swig_type((void *)op
, (void *)"svn_txdelta_op_t *"));
3639 svn_swig_rb_client_diff_summarize_func(const svn_client_diff_summarize_t
*diff
,
3643 svn_error_t
*err
= SVN_NO_ERROR
;
3644 VALUE proc
, rb_pool
;
3646 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
3649 callback_baton_t cbb
;
3651 cbb
.receiver
= proc
;
3652 cbb
.message
= id_call
;
3653 cbb
.args
= rb_ary_new3(1, c2r_client_diff_summarize__dup(diff
));
3654 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
3661 svn_swig_rb_client_list_func(void *baton
,
3663 const svn_dirent_t
*dirent
,
3664 const svn_lock_t
*lock
,
3665 const char *abs_path
,
3668 svn_error_t
*err
= SVN_NO_ERROR
;
3669 VALUE proc
, rb_pool
;
3671 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
3674 callback_baton_t cbb
;
3676 cbb
.receiver
= proc
;
3677 cbb
.message
= id_call
;
3678 cbb
.args
= rb_ary_new3(4,
3680 c2r_dirent__dup(dirent
),
3681 c2r_lock__dup(lock
),
3682 c2r_string2(abs_path
));
3683 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
3690 svn_swig_rb_proplist_receiver(void *baton
,
3692 apr_hash_t
*prop_hash
,
3695 svn_error_t
*err
= SVN_NO_ERROR
;
3696 VALUE proc
, rb_pool
;
3698 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
3700 callback_baton_t cbb
;
3702 cbb
.receiver
= proc
;
3703 cbb
.message
= id_call
;
3704 cbb
.args
= rb_ary_new3(2,
3706 svn_swig_rb_prop_hash_to_hash(prop_hash
));
3707 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
3714 svn_swig_rb_changelist_receiver(void *baton
,
3716 const char *changelist
,
3719 svn_error_t
*err
= SVN_NO_ERROR
;
3720 VALUE proc
, rb_pool
;
3722 svn_swig_rb_from_baton((VALUE
)baton
, &proc
, &rb_pool
);
3724 callback_baton_t cbb
;
3726 cbb
.receiver
= proc
;
3727 cbb
.message
= id_call
;
3728 cbb
.args
= rb_ary_new3(2,
3730 c2r_string2(changelist
));
3731 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
3738 /* svn_ra_reporter3_t */
3740 c2r_ra_reporter3(VALUE rb_reporter
, svn_ra_reporter3_t
**reporter
, void **baton
,
3745 r2c_swig_type2(rb_reporter
, "svn_ra_reporter3_t *", (void **)reporter
);
3747 rb_baton
= rb_funcall(rb_reporter
, id_baton
, 0);
3748 r2c_swig_type2(rb_baton
, "void *", baton
);
3751 static svn_error_t
*
3752 svn_swig_rb_ra_reporter_set_path(void *report_baton
, const char *path
,
3753 svn_revnum_t revision
, svn_depth_t depth
,
3754 svn_boolean_t start_empty
,
3755 const char *lock_token
, apr_pool_t
*pool
)
3757 svn_error_t
*err
= SVN_NO_ERROR
;
3758 VALUE reporter
, rb_pool
;
3760 svn_swig_rb_from_baton((VALUE
)report_baton
, &reporter
, &rb_pool
);
3761 if (rb_obj_is_kind_of(reporter
, rb_svn_ra_reporter3())) {
3762 svn_ra_reporter3_t
*svn_reporter
;
3765 c2r_ra_reporter3(reporter
, &svn_reporter
, &baton
, pool
);
3766 err
= svn_reporter
->set_path(baton
, path
, revision
, depth
,
3767 start_empty
, lock_token
, pool
);
3768 } else if (!NIL_P(reporter
)) {
3769 callback_baton_t cbb
;
3771 cbb
.receiver
= reporter
;
3772 cbb
.message
= id_set_path
;
3773 cbb
.args
= rb_ary_new3(4,
3777 c2r_bool2(start_empty
));
3778 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
3784 static svn_error_t
*
3785 svn_swig_rb_ra_reporter_delete_path(void *report_baton
, const char *path
,
3788 svn_error_t
*err
= SVN_NO_ERROR
;
3789 VALUE reporter
, rb_pool
;
3791 svn_swig_rb_from_baton((VALUE
)report_baton
, &reporter
, &rb_pool
);
3792 if (rb_obj_is_kind_of(reporter
, rb_svn_ra_reporter3())) {
3793 svn_ra_reporter3_t
*svn_reporter
;
3796 c2r_ra_reporter3(reporter
, &svn_reporter
, &baton
, pool
);
3797 err
= svn_reporter
->delete_path(baton
, path
, pool
);
3798 } else if (!NIL_P(reporter
)) {
3799 callback_baton_t cbb
;
3801 cbb
.receiver
= reporter
;
3802 cbb
.message
= id_delete_path
;
3803 cbb
.args
= rb_ary_new3(1,
3805 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
3811 static svn_error_t
*
3812 svn_swig_rb_ra_reporter_link_path(void *report_baton
, const char *path
,
3813 const char *url
, svn_revnum_t revision
,
3814 svn_depth_t depth
, svn_boolean_t start_empty
,
3815 const char *lock_token
, apr_pool_t
*pool
)
3817 svn_error_t
*err
= SVN_NO_ERROR
;
3818 VALUE reporter
, rb_pool
;
3820 svn_swig_rb_from_baton((VALUE
)report_baton
, &reporter
, &rb_pool
);
3821 if (rb_obj_is_kind_of(reporter
, rb_svn_ra_reporter3())) {
3822 svn_ra_reporter3_t
*svn_reporter
;
3825 c2r_ra_reporter3(reporter
, &svn_reporter
, &baton
, pool
);
3826 err
= svn_reporter
->link_path(baton
, path
, url
, revision
, depth
,
3827 start_empty
, lock_token
, pool
);
3828 } else if (!NIL_P(reporter
)) {
3829 callback_baton_t cbb
;
3831 cbb
.receiver
= reporter
;
3832 cbb
.message
= id_link_path
;
3833 cbb
.args
= rb_ary_new3(5,
3838 c2r_bool2(start_empty
));
3839 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
3845 static svn_error_t
*
3846 svn_swig_rb_ra_reporter_finish_report(void *report_baton
, apr_pool_t
*pool
)
3848 svn_error_t
*err
= SVN_NO_ERROR
;
3849 VALUE reporter
, rb_pool
;
3851 svn_swig_rb_from_baton((VALUE
)report_baton
, &reporter
, &rb_pool
);
3852 if (rb_obj_is_kind_of(reporter
, rb_svn_ra_reporter3())) {
3853 svn_ra_reporter3_t
*svn_reporter
;
3856 c2r_ra_reporter3(reporter
, &svn_reporter
, &baton
, pool
);
3857 err
= svn_reporter
->finish_report(baton
, pool
);
3858 } else if (!NIL_P(reporter
)) {
3859 callback_baton_t cbb
;
3861 cbb
.receiver
= reporter
;
3862 cbb
.message
= id_finish_report
;
3863 cbb
.args
= rb_ary_new();
3864 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
3870 static svn_error_t
*
3871 svn_swig_rb_ra_reporter_abort_report(void *report_baton
, apr_pool_t
*pool
)
3873 svn_error_t
*err
= SVN_NO_ERROR
;
3874 VALUE reporter
, rb_pool
;
3876 svn_swig_rb_from_baton((VALUE
)report_baton
, &reporter
, &rb_pool
);
3877 if (rb_obj_is_kind_of(reporter
, rb_svn_ra_reporter3())) {
3878 svn_ra_reporter3_t
*svn_reporter
;
3881 c2r_ra_reporter3(reporter
, &svn_reporter
, &baton
, pool
);
3882 err
= svn_reporter
->abort_report(baton
, pool
);
3883 } else if (!NIL_P(reporter
)) {
3884 callback_baton_t cbb
;
3886 cbb
.receiver
= reporter
;
3887 cbb
.message
= id_abort_report
;
3888 cbb
.args
= rb_ary_new();
3889 invoke_callback_handle_error((VALUE
)(&cbb
), rb_pool
, &err
);
3895 static svn_ra_reporter3_t rb_ra_reporter3
= {
3896 svn_swig_rb_ra_reporter_set_path
,
3897 svn_swig_rb_ra_reporter_delete_path
,
3898 svn_swig_rb_ra_reporter_link_path
,
3899 svn_swig_rb_ra_reporter_finish_report
,
3900 svn_swig_rb_ra_reporter_abort_report
3903 svn_ra_reporter3_t
*svn_swig_rb_ra_reporter3
= &rb_ra_reporter3
;