Fix compiler warning due to missing function prototype.
[svn.git] / subversion / bindings / swig / core.i
blobc97f448cb3c58e587a9f9e903808912af0f54d7d
1 /*
2 * ====================================================================
3 * Copyright (c) 2000-2007 CollabNet. All rights reserved.
5 * This software is licensed as described in the file COPYING, which
6 * you should have received as part of this distribution. The terms
7 * are also available at http://subversion.tigris.org/license-1.html.
8 * If newer versions of this license are posted there, you may use a
9 * newer version instead, at your option.
11 * This software consists of voluntary contributions made by many
12 * individuals. For exact contribution history, see the revision
13 * history and logs, available at http://subversion.tigris.org/.
14 * ====================================================================
16 * core.i: SWIG module interface file for libsvn_subr, a few pieces of
17 * APR functionality, and anything else that does not fit into any
18 * of the more specific module files.
21 #if defined(SWIGPYTHON)
22 %module(package="libsvn") core
23 #elif defined(SWIGPERL)
24 %module "SVN::_Core"
25 #elif defined(SWIGRUBY)
26 %module "svn::ext::core"
27 #endif
29 %include svn_global.swg
32 #include <apr.h>
33 #include <apr_general.h>
35 #include "svn_md5.h"
36 #include "svn_diff.h"
39 #ifdef SWIGRUBY
41 #include <apu.h>
42 #include <apr_xlate.h>
44 #endif
46 /* ### for now, let's ignore this thing. */
47 %ignore svn_prop_t;
49 /* -----------------------------------------------------------------------
50 The following struct members have to be read-only because otherwise
51 strings assigned to then would never be freed, resulting in memory
52 leaks. This prevents the swig warning "Warning(451): Setting const
53 char * member may leak memory."
55 %immutable svn_log_changed_path_t::copyfrom_path;
56 %immutable svn_dirent_t::last_author;
57 %immutable svn_error_t::message;
58 %immutable svn_error_t::file;
60 /* -----------------------------------------------------------------------
61 completely ignore a number of functions. the presumption is that the
62 scripting language already has facilities for these things (or they
63 are relatively trivial).
66 /* svn_io.h: We cherry-pick certain functions from this file. To aid in this,
67 * EVERY function in the file is listed in the order it appears, and is either
68 * %ignore-d, or present as a comment, explicitly documenting that we wrap it.
71 %ignore svn_io_check_path;
72 %ignore svn_io_check_special_path;
73 %ignore svn_io_check_resolved_path;
74 /* This is useful for implementing svn_ra_callbacks_t->open_tmp_file */
75 // svn_io_open_unique_file2
76 // svn_io_open_unique_file
77 %ignore svn_io_create_unique_link;
78 %ignore svn_io_read_link;
79 %ignore svn_io_temp_dir;
80 %ignore svn_io_copy_file;
81 %ignore svn_io_copy_link;
82 %ignore svn_io_copy_dir_recursively;
83 %ignore svn_io_make_dir_recursively;
84 %ignore svn_io_dir_empty;
85 %ignore svn_io_append_file;
86 %ignore svn_io_set_file_read_only;
87 %ignore svn_io_set_file_read_write;
88 %ignore svn_io_set_file_read_write_carefully;
89 %ignore svn_io_set_file_executable;
90 %ignore svn_io_is_file_executable;
91 %ignore svn_io_read_length_line;
92 %ignore svn_io_file_affected_time;
93 %ignore svn_io_set_file_affected_time;
94 %ignore svn_io_filesizes_different_p;
95 // svn_io_file_checksum
96 // svn_io_files_contents_same_p
97 %ignore svn_io_file_create;
98 %ignore svn_io_file_lock;
99 %ignore svn_io_file_lock2;
100 %ignore svn_io_file_flush_to_disk;
101 %ignore svn_io_dir_file_copy;
103 /* Not useful from scripting languages. Custom streams should be achieved
104 * by passing a scripting language native stream into a svn_stream_t *
105 * parameter, and letting a typemap using svn_swig_xx_make_stream() take
106 * care of the details. */
107 %ignore svn_stream_create;
108 %ignore svn_stream_set_baton;
109 %ignore svn_stream_set_read;
110 %ignore svn_stream_set_write;
111 %ignore svn_stream_set_close;
113 /* The permitted svn_stream and svn_stringbuf functions could possibly
114 * be used by a script, in conjunction with other APIs which return or
115 * accept streams. This requires that the relevant language's custom
116 * svn_stream_t wrapping code does not obstruct this usage. */
117 // svn_stream_empty
118 // svn_stream_disown
119 // svn_stream_from_aprfile2
120 // svn_stream_from_aprfile
121 // svn_stream_for_stdout
122 // svn_stream_from_stringbuf
123 // svn_stream_compressed
124 /* svn_stream_checksummed would require special attention to wrap, because
125 * of the read_digest and write_digest parameters. */
126 %ignore svn_stream_checksummed;
127 // svn_stream_read
128 // svn_stream_write
129 // svn_stream_close
131 /* Scripts can do the printf, then write to a stream.
132 * We can't really handle the variadic, so ignore it. */
133 %ignore svn_stream_printf;
134 %ignore svn_stream_printf_from_utf8;
136 // svn_stream_readline
137 // svn_stream_copy
138 // svn_stream_contents_same
139 // svn_stringbuf_from_file
140 // svn_stringbuf_from_aprfile
142 #ifndef SWIGPYTHON
143 /* These functions are useful in Python, because they allow you to
144 * easily delete files which are marked as read-only on Windows. */
145 %ignore svn_io_remove_file;
146 %ignore svn_io_remove_dir;
147 #endif
148 %ignore svn_io_get_dir_filenames;
149 %ignore svn_io_get_dirents2;
150 %ignore svn_io_get_dirents;
151 %ignore svn_io_dir_walk;
152 %ignore svn_io_start_cmd;
153 %ignore svn_io_wait_for_cmd;
154 %ignore svn_io_run_cmd;
155 %ignore svn_io_run_diff;
156 %ignore svn_io_run_diff3_2;
157 %ignore svn_io_run_diff3;
158 // svn_io_detect_mimetype
159 %ignore svn_io_file_open;
160 %ignore svn_io_file_close;
161 %ignore svn_io_file_getc;
162 %ignore svn_io_file_info_get;
163 %ignore svn_io_file_read;
164 %ignore svn_io_file_read_full;
165 %ignore svn_io_file_seek;
166 %ignore svn_io_file_write;
167 %ignore svn_io_file_write_full;
168 %ignore svn_io_stat;
169 %ignore svn_io_file_rename;
170 %ignore svn_io_file_move;
171 %ignore svn_io_dir_make;
172 %ignore svn_io_dir_make_hidden;
173 %ignore svn_io_dir_make_sgid;
174 %ignore svn_io_dir_open;
175 %ignore svn_io_dir_remove_nonrecursive;
176 %ignore svn_io_dir_read;
177 %ignore svn_io_read_version_file;
178 %ignore svn_io_write_version_file;
180 /* svn_path.h: We cherry-pick certain functions from this file. To aid in this,
181 * EVERY function in the file is listed in the order it appears, and is either
182 * %ignore-d, or present as a comment, explicitly documenting that we wrap it.
184 // svn_path_internal_style;
185 // svn_path_local_style;
186 %ignore svn_path_join;
187 %ignore svn_path_join_many;
188 %ignore svn_path_basename;
189 %ignore svn_path_dirname;
190 %ignore svn_path_component_count;
191 %ignore svn_path_add_component;
192 %ignore svn_path_remove_component;
193 %ignore svn_path_remove_components;
194 %ignore svn_path_split;
195 // svn_path_is_empty;
196 // svn_path_canonicalize;
197 // svn_path_compare_paths;
198 // svn_path_get_longest_ancestor;
199 %ignore svn_path_get_absolute;
200 %ignore svn_path_split_if_file;
201 %ignore svn_path_condense_targets;
202 %ignore svn_path_remove_redundancies;
203 %ignore svn_path_decompose;
204 %ignore svn_path_compose;
205 %ignore svn_path_is_single_path_component;
206 %ignore svn_path_is_backpath_present;
207 %ignore svn_path_is_child;
208 %ignore svn_path_is_ancestor;
209 %ignore svn_path_check_valid;
210 %ignore svn_path_is_url;
211 // svn_path_is_uri_safe;
212 %ignore svn_path_uri_encode;
213 %ignore svn_path_uri_decode;
214 %ignore svn_path_url_add_component;
215 %ignore svn_path_uri_from_iri;
216 %ignore svn_path_uri_autoescape;
217 %ignore svn_path_cstring_from_utf8;
218 %ignore svn_path_cstring_to_utf8;
220 /* Other files */
221 /* bad pool convention */
222 %ignore svn_opt_print_generic_help;
224 %ignore svn_opt_args_to_target_array;
226 /* Ugliness because the constants are typedefed and SWIG ignores them
227 as a result. */
228 %constant svn_revnum_t SWIG_SVN_INVALID_REVNUM = -1;
229 %constant svn_revnum_t SWIG_SVN_IGNORED_REVNUM = -1;
231 /* -----------------------------------------------------------------------
232 input rangelist
234 %apply apr_array_header_t *RANGELIST {
235 apr_array_header_t *rangeinput,
236 const apr_array_header_t *rangelist,
237 apr_array_header_t *from,
238 apr_array_header_t *to,
239 apr_array_header_t *changes,
240 apr_array_header_t *eraser,
241 apr_array_header_t *whiteboard,
242 apr_array_header_t *rangelist1,
243 apr_array_header_t *rangelist2
246 /* -----------------------------------------------------------------------
247 output rangelist
249 %apply apr_array_header_t **RANGELIST {
250 apr_array_header_t **rangelist,
251 apr_array_header_t **inheritable_rangelist,
252 apr_array_header_t **deleted,
253 apr_array_header_t **added,
254 apr_array_header_t **output
257 /* -----------------------------------------------------------------------
258 input and output rangelist
260 %apply apr_array_header_t **RANGELIST_INOUT {
261 apr_array_header_t **rangelist_inout
264 /* -----------------------------------------------------------------------
265 input mergeinfo hash
267 %apply apr_hash_t *MERGEINFO {
268 apr_hash_t *mergefrom,
269 apr_hash_t *mergeto,
270 apr_hash_t *mergein1,
271 apr_hash_t *mergein2,
272 apr_hash_t *mergeinfo,
273 apr_hash_t *mergeinput,
274 apr_hash_t *eraser,
275 apr_hash_t *whiteboard,
276 apr_hash_t *changes
279 /* -----------------------------------------------------------------------
280 output mergeinfo
283 #if defined(SWIGPYTHON) || defined(SWIGRUBY)
284 %apply apr_hash_t **MERGEINFO_INOUT {
285 apr_hash_t **mergeinfo_inout
288 %apply apr_hash_t **MERGEINFO {
289 apr_hash_t **mergeinfo,
290 apr_hash_t **inheritable_mergeinfo,
291 apr_hash_t **deleted,
292 apr_hash_t **added
294 #endif
296 /* -----------------------------------------------------------------------
297 output mergeinfo hash
300 #if defined(SWIGRUBY) || defined(SWIGPYTHON)
301 %apply apr_hash_t **MERGEINFO_CATALOG {
302 apr_hash_t **catalog
304 #endif
307 /* -----------------------------------------------------------------------
308 handle the default value of svn_config_get().and the
309 config directory of svn_config_read_auth_data() and
310 svn_config_write_auth_data().
312 %apply const char *MAY_BE_NULL {
313 const char *default_value,
314 const char *config_dir,
315 const char *conflict_original,
316 const char *conflict_modified,
317 const char *conflict_latest,
318 const char *conflict_separator
321 /* -----------------------------------------------------------------------
322 fix up the svn_stream_read() ptr/len arguments
324 #ifdef SWIGPYTHON
325 %typemap(in) (char *buffer, apr_size_t *len) ($*2_type temp) {
326 if (!PyInt_Check($input)) {
327 PyErr_SetString(PyExc_TypeError,
328 "expecting an integer for the buffer size");
329 SWIG_fail;
331 temp = PyInt_AsLong($input);
332 if (temp < 0) {
333 PyErr_SetString(PyExc_ValueError,
334 "buffer size must be a positive integer");
335 SWIG_fail;
337 $1 = malloc(temp);
338 $2 = ($2_ltype)&temp;
340 #endif
341 #ifdef SWIGPERL
342 %typemap(in) (char *buffer, apr_size_t *len) ($*2_type temp) {
343 temp = SvIV($input);
344 $1 = malloc(temp);
345 $2 = ($2_ltype)&temp;
347 #endif
348 #ifdef SWIGRUBY
349 %typemap(in) (char *buffer, apr_size_t *len) ($*2_type temp) {
350 temp = NUM2LONG($input);
351 $1 = malloc(temp);
352 $2 = ($2_ltype)&temp;
354 #endif
356 /* ### need to use freearg or somesuch to ensure the string is freed.
357 ### watch out for 'return' anywhere in the binding code. */
359 #ifdef SWIGPYTHON
360 %typemap(argout) (char *buffer, apr_size_t *len) {
361 %append_output(PyString_FromStringAndSize($1, *$2));
362 free($1);
364 #endif
365 #ifdef SWIGPERL
366 %typemap(argout) (char *buffer, apr_size_t *len) {
367 %append_output(sv_2mortal(newSVpvn($1, *$2)));
368 free($1);
370 #endif
371 #ifdef SWIGRUBY
372 %typemap(argout) (char *buffer, apr_size_t *len) {
373 %append_output(*$2 == 0 ? Qnil : rb_str_new($1, *$2));
374 free($1);
376 #endif
378 /* -----------------------------------------------------------------------
379 fix up the svn_stream_write() ptr/len arguments
381 #ifdef SWIGPYTHON
382 %typemap(in) (const char *data, apr_size_t *len) ($*2_type temp) {
383 if (!PyString_Check($input)) {
384 PyErr_SetString(PyExc_TypeError,
385 "expecting a string for the buffer");
386 SWIG_fail;
388 $1 = PyString_AS_STRING($input);
389 temp = PyString_GET_SIZE($input);
390 $2 = ($2_ltype)&temp;
392 #endif
393 #ifdef SWIGPERL
394 %typemap(in) (const char *data, apr_size_t *len) ($*2_type temp) {
395 $1 = SvPV($input, temp);
396 $2 = ($2_ltype)&temp;
398 #endif
399 #ifdef SWIGRUBY
400 %typemap(in) (const char *data, apr_size_t *len) ($*2_type temp)
402 $1 = StringValuePtr($input);
403 temp = RSTRING($input)->len;
404 $2 = ($2_ltype)&temp;
406 #endif
408 #ifdef SWIGPYTHON
409 %typemap(argout) (const char *data, apr_size_t *len) {
410 %append_output(PyInt_FromLong(*$2));
412 #endif
414 #ifdef SWIGPERL
415 %typemap(argout) (const char *data, apr_size_t *len) {
416 %append_output(sv_2mortal(newSViv(*$2)));
418 #endif
420 #ifdef SWIGRUBY
421 %typemap(argout) (const char *data, apr_size_t *len) {
422 %append_output(LONG2NUM(*$2));
424 #endif
426 /* -----------------------------------------------------------------------
427 auth parameter set/get
430 /* set */
431 #ifdef SWIGPYTHON
432 %typemap(in) const void *value
433 (apr_pool_t *_global_pool = NULL, PyObject *_global_py_pool = NULL)
435 if (_global_pool == NULL)
437 if (svn_swig_py_get_parent_pool(args, $descriptor(apr_pool_t *),
438 &_global_py_pool, &_global_pool))
439 SWIG_fail;
442 if (PyString_Check($input)) {
443 char *value = PyString_AS_STRING($input);
444 $1 = apr_pstrdup(_global_pool, value);
446 else if (PyLong_Check($input)) {
447 $1 = apr_palloc(_global_pool, sizeof(apr_uint32_t));
448 *((apr_uint32_t *)$1) = PyLong_AsLong($input);
450 else if (PyInt_Check($input)) {
451 $1 = apr_palloc(_global_pool, sizeof(apr_uint32_t));
452 *((apr_uint32_t *)$1) = PyInt_AsLong($input);
454 else if ($input == Py_None) {
455 $1 = NULL;
457 else if (svn_swig_ConvertPtr($input, (void **)&$1, $descriptor(svn_auth_ssl_server_cert_info_t *)) == 0) {
459 else {
460 PyErr_SetString(PyExc_TypeError, "not a known type");
461 SWIG_fail;
464 #endif
467 - all values are converted to char*
468 - assume the first argument is Ruby object for svn_auth_baton_t*
470 #ifdef SWIGRUBY
471 %typemap(in) const void *value
473 if (NIL_P($input)) {
474 $1 = (void *)NULL;
475 } else {
476 VALUE _rb_pool;
477 apr_pool_t *_global_pool;
478 char *value = StringValuePtr($input);
480 svn_swig_rb_get_pool(1, argv, Qnil, &_rb_pool, &_global_pool);
481 $1 = (void *)apr_pstrdup(_global_pool, value);
484 #endif
486 /* get */
487 /* assume the value is char* */
488 #ifdef SWIGRUBY
489 %typemap(out) const void *
491 char *value = $1;
492 if (value) {
493 $result = rb_str_new2(value);
494 } else {
495 $result = Qnil;
498 #endif
500 #ifndef SWIGRUBY
501 %ignore svn_auth_get_parameter;
502 #endif
504 /* -----------------------------------------------------------------------
505 svn_io_parse_mimetypes_file()
508 #ifdef SWIGRUBY
509 %apply apr_hash_t **HASH_CSTRING {
510 apr_hash_t **type_map
512 #endif
514 /* -----------------------------------------------------------------------
515 svn_io_detect_mimetype2()
518 %apply apr_hash_t *HASH_CSTRING {
519 apr_hash_t *mimetype_map
522 /* -----------------------------------------------------------------------
523 describe how to pass a FILE* as a parameter (svn_stream_from_stdio)
525 #ifdef SWIGPYTHON
526 %typemap(in) FILE * {
527 $1 = PyFile_AsFile($input);
528 if ($1 == NULL) {
529 PyErr_SetString(PyExc_ValueError, "Must pass in a valid file object");
530 SWIG_fail;
533 #endif
534 #ifdef SWIGPERL
535 %typemap(in) FILE * {
536 $1 = PerlIO_exportFILE (IoIFP (sv_2io ($input)), NULL);
538 #endif
540 /* -----------------------------------------------------------------------
541 wrap some specific APR functionality
544 apr_status_t apr_initialize(void);
545 void apr_terminate(void);
547 apr_status_t apr_time_ansi_put(apr_time_t *result, time_t input);
549 void apr_pool_destroy(apr_pool_t *p);
550 void apr_pool_clear(apr_pool_t *p);
552 apr_status_t apr_file_open_stdout (apr_file_t **out, apr_pool_t *pool);
553 apr_status_t apr_file_open_stderr (apr_file_t **out, apr_pool_t *pool);
555 /* Allow parsing of apr_errno.h without parsing apr.h. */
556 #define APR_DECLARE(x) x
557 /* Not wrapped, use svn_strerror instead. */
558 %ignore apr_strerror;
559 /* Wrap the APR status and error codes. */
560 /* Sigh, or not. This would mean actually having access to apr_errno.h at
561 wrapper generation time, which, when rolling tarballs, the include paths
562 are not currently set up to give us. FIXME. So, instead, we replicate
563 one important typedef here instead.
564 %include apr_errno.h
566 typedef int apr_status_t;
568 /* -----------------------------------------------------------------------
569 pool functions renaming since swig doesn't take care of the #define's
571 %rename (svn_pool_create) svn_pool_create_ex;
572 %ignore svn_pool_create_ex_debug;
573 %typemap(default) apr_allocator_t *allocator {
574 $1 = NULL;
577 /* -----------------------------------------------------------------------
578 Default pool handling for perl.
580 #ifdef SWIGPERL
581 apr_pool_t *current_pool;
583 #if SWIG_VERSION <= 0x010324
585 #define SVN_SWIGEXPORT(t) SWIGEXPORT(t)
587 #else
589 #define SVN_SWIGEXPORT(t) SWIGEXPORT t
591 #endif
595 static apr_pool_t *current_pool = 0;
597 SVN_SWIGEXPORT(apr_pool_t *)
598 svn_swig_pl_get_current_pool (void)
600 return current_pool;
603 SVN_SWIGEXPORT(void)
604 svn_swig_pl_set_current_pool (apr_pool_t *pool)
606 current_pool = pool;
611 #endif
613 /* -----------------------------------------------------------------------
614 wrap config functions
617 #ifdef SWIGPERL
618 %callback_typemap(svn_config_enumerator_t callback, void *baton,
620 svn_swig_pl_thunk_config_enumerator,
622 #endif
624 #ifdef SWIGRUBY
625 %callback_typemap(svn_config_enumerator2_t callback, void *baton,
628 svn_swig_rb_config_enumerator)
630 %callback_typemap(svn_config_section_enumerator2_t callback, void *baton,
633 svn_swig_rb_config_section_enumerator)
634 #endif
636 /* Allow None to be passed as config_dir argument */
637 #ifdef SWIGPYTHON
638 %typemap(in,parse="z") const char *config_dir "";
639 #endif
641 /* -----------------------------------------------------------------------
642 thunk the various authentication prompt functions.
643 PERL NOTE: store the inputed SV in _global_callback for use in the
644 later argout typemap
646 #ifdef SWIGPERL
647 %define %authprompt_callback_typemap(AuthType)
648 %typemap(in) (svn_auth_ ## AuthType ## _prompt_func_t prompt_func,
649 void *prompt_baton) {
650 $1 = svn_swig_pl_thunk_ ## AuthType ## _prompt;
651 $2 = $input;
652 _global_callback = $input;
654 %enddef
655 #else
656 %define %authprompt_callback_typemap(AuthType)
657 %callback_typemap(svn_auth_ ## AuthType ## _prompt_func_t prompt_func,
658 void *prompt_baton,
659 svn_swig_py_auth_ ## AuthType ## _prompt_func,,
660 svn_swig_rb_auth_ ## AuthType ## _prompt_func)
661 %enddef
662 #endif
664 %authprompt_callback_typemap(simple)
665 %authprompt_callback_typemap(username)
666 %authprompt_callback_typemap(ssl_server_trust)
667 %authprompt_callback_typemap(ssl_client_cert)
668 %authprompt_callback_typemap(ssl_client_cert_pw)
670 /* -----------------------------------------------------------------------
671 * For all the various functions that set a callback baton create a reference
672 * for the baton (which in this case is an SV pointing to the callback)
673 * and make that a return from the function. The perl side should
674 * then store the return in the object the baton is attached to.
675 * If the function already returns a value then this value is follows that
676 * function. In the case of the prompt functions auth_open_helper in Core.pm
677 * is used to split up these values.
679 #ifdef SWIGPERL
680 %typemap(argout) void *CALLBACK_BATON (SV * _global_callback) {
681 /* callback baton */
682 %append_output(sv_2mortal(newRV_inc(_global_callback)));
685 %typemap(in) void *CALLBACK_BATON (SV * _global_callback) {
686 _global_callback = $input;
687 $1 = (void *) _global_callback;
690 %apply void *CALLBACK_BATON {
691 void *prompt_baton
693 #endif
696 /* -----------------------------------------------------------------------
697 These APIs take an "inout" parameter that necessitates more careful
698 definition.
700 %ignore svn_mergeinfo_merge;
701 %ignore svn_mergeinfo_sort;
702 %ignore svn_rangelist_merge;
703 %ignore svn_rangelist_reverse;
705 #ifdef SWIGRUBY
706 %ignore svn_auth_open;
707 %ignore svn_diff_file_options_create;
708 %ignore svn_create_commit_info;
709 %ignore svn_commit_info_dup;
711 %ignore svn_opt_args_to_target_array2;
712 %ignore svn_opt_args_to_target_array3;
713 %ignore svn_opt_parse_num_args;
714 %ignore svn_opt_parse_all_args;
715 #endif
717 /* ----------------------------------------------------------------------- */
719 %include svn_error_codes_h.swg
720 %include svn_time_h.swg
721 %include svn_types_h.swg
722 %include svn_pools_h.swg
723 %include svn_version_h.swg
725 /* The constant SVN_PROP_REVISION_ALL_PROPS is a C fragment, not a single
726 data value, so the SWIG parser will raise a 305 warning if we don't
727 suppress it. */
728 #pragma SWIG nowarn=305
729 %include svn_props_h.swg
730 #pragma SWIG nowarn=+305
732 %include svn_opt_h.swg
733 %include svn_auth_h.swg
734 %include svn_config_h.swg
735 %include svn_utf_h.swg
736 %include svn_nls_h.swg
737 %include svn_path_h.swg
738 %include svn_mergeinfo_h.swg
739 %include svn_io_h.swg
741 #ifdef SWIGPERL
742 %include svn_md5_h.swg
743 %include svn_diff_h.swg
744 %include svn_error_h.swg
747 #include "svn_private_config.h"
749 %init %{
750 #if defined(SVN_AVOID_CIRCULAR_LINKAGE_AT_ALL_COSTS_HACK)
751 svn_swig_pl_bind_current_pool_fns (&svn_swig_pl_get_current_pool,
752 &svn_swig_pl_set_current_pool);
753 #endif
755 #endif
757 #ifdef SWIGPYTHON
759 void svn_swig_py_set_application_pool(PyObject *py_pool, apr_pool_t *pool);
760 void svn_swig_py_clear_application_pool();
762 %init %{
763 /* Theoretically, we should be checking for errors here,
764 but I do not know of any useful way to signal an error to Python
765 from within a module initialization function. */
766 svn_swig_py_initialize();
769 /* Proxy classes for APR classes */
770 %include proxy_apr.swg
772 #endif
774 #ifdef SWIGRUBY
775 %init %{
776 svn_swig_rb_initialize();
778 rb_define_const(mCore, "SVN_VER_NUM", rb_str_new2(SVN_VER_NUM));
779 rb_define_const(mCore, "SVN_VER_NUMBER", rb_str_new2(SVN_VER_NUMBER));
780 rb_define_const(mCore, "SVN_VERSION", rb_str_new2(SVN_VERSION));
783 %header %{
784 static void apr_pool_wrapper_destroy(apr_pool_wrapper_t *self);
785 static void apr_pool_wrapper_destroy_children(apr_pool_wrapper_t *self);
786 static void apr_pool_wrapper_remove_from_parent(apr_pool_wrapper_t *self);
789 /* Dummy declaration */
790 struct apr_pool_wrapper_t
794 /* Leave memory administration to ruby's GC */
795 %extend apr_pool_wrapper_t
797 static void destroy(VALUE object) {
798 svn_swig_rb_destroy_internal_pool(object);
801 apr_pool_wrapper_t(apr_pool_wrapper_t *parent) {
802 apr_pool_wrapper_t *self;
803 apr_pool_t *parent_pool;
805 self = ALLOC(apr_pool_wrapper_t);
806 if (parent) {
807 parent_pool = parent->pool;
808 APR_ARRAY_PUSH(parent->children, apr_pool_wrapper_t *) = self;
809 } else {
810 parent_pool = NULL;
812 self->pool = svn_pool_create_ex(parent_pool, NULL);
813 self->destroyed = FALSE;
814 self->parent = parent;
815 self->children = apr_array_make(self->pool, 0,
816 sizeof(apr_pool_wrapper_t *));
817 return self;
820 ~apr_pool_wrapper_t() {
821 apr_pool_wrapper_destroy(self);
822 xfree(self);
825 void _destroy(void) {
826 apr_pool_wrapper_destroy(self);
830 %ignore apr_pool_wrapper_destroy;
831 %ignore apr_pool_wrapper_destroy_children;
832 %ignore apr_pool_wrapper_remove_from_parent;
833 %inline %{
834 static void
835 apr_pool_wrapper_destroy(apr_pool_wrapper_t *self)
837 if (!self->destroyed) {
838 self->destroyed = TRUE;
839 apr_pool_wrapper_destroy_children(self);
840 apr_pool_wrapper_remove_from_parent(self);
841 apr_pool_destroy(self->pool);
845 static void
846 apr_pool_wrapper_destroy_children(apr_pool_wrapper_t *self)
848 apr_pool_wrapper_t **child;
850 while ((child = apr_array_pop(self->children))) {
851 if (*child) {
852 apr_pool_wrapper_destroy(*child);
857 static void
858 apr_pool_wrapper_remove_from_parent(apr_pool_wrapper_t *self)
860 if (self->parent) {
861 apr_pool_wrapper_t *child;
862 int i, len;
864 len = self->parent->children->nelts;
865 for (i = 0; i < len; i++) {
866 child = APR_ARRAY_IDX(self->parent->children, i, apr_pool_wrapper_t *);
867 if (child == self) {
868 APR_ARRAY_IDX(self->parent->children, i, apr_pool_wrapper_t *) = NULL;
869 self->parent = NULL;
870 break;
877 /* Dummy declaration */
878 struct svn_stream_t
882 %extend svn_stream_t
884 svn_stream_t(VALUE io) {
885 return svn_swig_rb_make_stream(io);
888 ~svn_stream_t() {
892 /* Dummy declaration */
893 struct svn_auth_baton_t
897 %extend svn_auth_baton_t
899 svn_auth_baton_t(apr_array_header_t *providers, apr_pool_t *pool) {
900 svn_auth_baton_t *self;
901 svn_auth_open(&self, providers, pool);
902 return self;
905 ~svn_auth_baton_t() {
909 %extend svn_diff_file_options_t
911 svn_diff_file_options_t(apr_pool_t *pool) {
912 return svn_diff_file_options_create(pool);
915 ~svn_diff_file_options_t() {
919 %extend svn_commit_info_t
921 svn_commit_info_t(apr_pool_t *pool) {
922 return svn_create_commit_info(pool);
925 ~svn_commit_info_t() {
928 svn_commit_info_t *dup(apr_pool_t *pool) {
929 return svn_commit_info_dup(self, pool);
933 %extend svn_merge_range_t
935 svn_merge_range_t(svn_revnum_t start, svn_revnum_t end,
936 svn_boolean_t inheritable, apr_pool_t *pool) {
937 svn_merge_range_t *self;
938 self = apr_palloc(pool, sizeof(svn_merge_range_t));
939 self->start = start;
940 self->end = end;
941 self->inheritable = inheritable;
942 return self;
945 ~svn_merge_range_t() {
948 svn_merge_range_t *dup(apr_pool_t *pool) {
949 return svn_merge_range_dup(self, pool);
953 %include svn_diff_h.swg
955 %inline %{
956 static VALUE
957 svn_default_charset(void)
959 return PTR2NUM(APR_DEFAULT_CHARSET);
962 static VALUE
963 svn_locale_charset(void)
965 return PTR2NUM(APR_LOCALE_CHARSET);
968 /* prompt providers return baton for protecting GC */
969 static VALUE
970 svn_swig_rb_auth_get_simple_prompt_provider(
971 svn_auth_provider_object_t **provider,
972 svn_auth_simple_prompt_func_t prompt_func,
973 void *prompt_baton,
974 int retry_limit,
975 apr_pool_t *pool)
977 svn_auth_get_simple_prompt_provider(provider, prompt_func, prompt_baton,
978 retry_limit, pool);
979 return rb_ary_new3(1, (VALUE)prompt_baton);
982 static VALUE
983 svn_swig_rb_auth_get_ssl_client_cert_prompt_provider(
984 svn_auth_provider_object_t **provider,
985 svn_auth_ssl_client_cert_prompt_func_t prompt_func,
986 void *prompt_baton,
987 int retry_limit,
988 apr_pool_t *pool)
990 svn_auth_get_ssl_client_cert_prompt_provider(provider, prompt_func,
991 prompt_baton, retry_limit,
992 pool);
993 return rb_ary_new3(1, (VALUE)prompt_baton);
996 static VALUE
997 svn_swig_rb_auth_get_ssl_client_cert_pw_prompt_provider(
998 svn_auth_provider_object_t **provider,
999 svn_auth_ssl_client_cert_pw_prompt_func_t prompt_func,
1000 void *prompt_baton,
1001 int retry_limit,
1002 apr_pool_t *pool)
1004 svn_auth_get_ssl_client_cert_pw_prompt_provider(provider, prompt_func,
1005 prompt_baton, retry_limit,
1006 pool);
1007 return rb_ary_new3(1, (VALUE)prompt_baton);
1010 static VALUE
1011 svn_swig_rb_auth_get_ssl_server_trust_prompt_provider(
1012 svn_auth_provider_object_t **provider,
1013 svn_auth_ssl_server_trust_prompt_func_t prompt_func,
1014 void *prompt_baton,
1015 apr_pool_t *pool)
1017 svn_auth_get_ssl_server_trust_prompt_provider(provider, prompt_func,
1018 prompt_baton, pool);
1019 return rb_ary_new3(1, (VALUE)prompt_baton);
1022 static VALUE
1023 svn_swig_rb_auth_get_username_prompt_provider(
1024 svn_auth_provider_object_t **provider,
1025 svn_auth_username_prompt_func_t prompt_func,
1026 void *prompt_baton,
1027 int retry_limit,
1028 apr_pool_t *pool)
1030 svn_auth_get_username_prompt_provider(provider, prompt_func, prompt_baton,
1031 retry_limit, pool);
1032 return rb_ary_new3(1, (VALUE)prompt_baton);
1035 #endif
1037 #if defined(SWIGPYTHON) || defined(SWIGRUBY)
1038 %inline %{
1039 static svn_error_t *
1040 svn_swig_mergeinfo_merge(apr_hash_t **mergeinfo_inout,
1041 apr_hash_t *changes,
1042 apr_pool_t *pool)
1044 return svn_mergeinfo_merge(*mergeinfo_inout, changes, pool);
1047 static svn_error_t *
1048 svn_swig_mergeinfo_sort(apr_hash_t **mergeinfo_inout, apr_pool_t *pool)
1050 return svn_mergeinfo_sort(*mergeinfo_inout, pool);
1053 static svn_error_t *
1054 svn_swig_rangelist_merge(apr_array_header_t **rangelist_inout,
1055 apr_array_header_t *changes,
1056 apr_pool_t *pool)
1058 return svn_rangelist_merge(rangelist_inout, changes, pool);
1061 static svn_error_t *
1062 svn_swig_rangelist_reverse(apr_array_header_t **rangelist_inout,
1063 apr_pool_t *pool)
1065 return svn_rangelist_reverse(*rangelist_inout, pool);
1068 #endif