2
* core.i : SWIG interface file for various core SVN and APR components
4
* ====================================================================
5
* Copyright (c) 2000-2003 CollabNet. All rights reserved.
7
* This software is licensed as described in the file COPYING, which
8
* you should have received as part of this distribution. The terms
9
* are also available at http://subversion.tigris.org/license-1.html.
10
* If newer versions of this license are posted there, you may use a
11
* newer version instead, at your option.
13
* This software consists of voluntary contributions made by many
14
* individuals. For exact contribution history, see the revision
15
* history and logs, available at http://subversion.tigris.org/.
16
* ====================================================================
21
#elif defined(SWIGRUBY)
22
%module "svn::ext::core"
31
#include <apr_general.h>
34
#include "svn_pools.h"
35
#include "svn_version.h"
37
#include "svn_props.h"
40
#include "svn_config.h"
41
#include "svn_version.h"
44
#include "svn_error_codes.h"
48
#include "swigutil_py.h"
52
#include "swigutil_pl.h"
56
#include "swigutil_rb.h"
60
/* We don't want to hear about supposedly bad constant values */
61
#pragma SWIG nowarn=305
63
/* ### for now, let's ignore this thing. */
68
/* -----------------------------------------------------------------------
69
The following struct members have to be read-only because otherwise
70
strings assigned to then would never be freed, resulting in memory
71
leaks. This prevents the swig warning "Warning(451): Setting const
72
char * member may leak memory."
74
%immutable svn_log_changed_path_t::copyfrom_path;
75
%immutable svn_dirent_t::last_author;
76
%immutable svn_error_t::message;
77
%immutable svn_error_t::file;
79
/* -----------------------------------------------------------------------
80
We want the error code enums wrapped so we must include svn_error_codes.h
81
before anything else does.
84
%include svn_error_codes.h
86
/* -----------------------------------------------------------------------
87
Include svn_types.i early. Other .i files will import svn_types.i which
88
then includes svn_types.h, making further includes get skipped. We want
89
to actually generate wrappers for svn_types.h, so do an _include_ right
90
now, before any _import_ has happened.
96
/* -----------------------------------------------------------------------
103
/* -----------------------------------------------------------------------
104
completely ignore a number of functions. the presumption is that the
105
scripting language already has facilities for these things (or they
106
are relatively trivial).
109
/* svn_io.h: We cherry-pick certain functions from this file. To aid in this,
110
* EVERY function in the file is listed in the order it appears, and is either
111
* %ignore-d, or present as a comment, explicitly documenting that we wrap it.
114
%ignore svn_io_check_path;
115
%ignore svn_io_check_special_path;
116
%ignore svn_io_check_resolved_path;
117
/* This is useful for implementing svn_ra_callbacks_t->open_tmp_file */
118
// svn_io_open_unique_file
119
%ignore svn_io_create_unique_link;
120
%ignore svn_io_read_link;
121
%ignore svn_io_temp_dir;
122
%ignore svn_io_copy_file;
123
%ignore svn_io_copy_link;
124
%ignore svn_io_copy_dir_recursively;
125
%ignore svn_io_make_dir_recursively;
126
%ignore svn_io_dir_empty;
127
%ignore svn_io_append_file;
128
%ignore svn_io_set_file_read_only;
129
%ignore svn_io_set_file_read_write;
130
%ignore svn_io_set_file_executable;
131
%ignore svn_io_is_file_executable;
132
%ignore svn_io_read_length_line;
133
%ignore svn_io_file_affected_time;
134
%ignore svn_io_set_file_affected_time;
135
%ignore svn_io_filesizes_different_p;
136
// svn_io_file_checksum
137
// svn_io_files_contents_same_p
138
%ignore svn_io_file_create;
139
%ignore svn_io_file_lock;
140
%ignore svn_io_file_lock2;
141
%ignore svn_io_file_flush_to_disk;
142
%ignore svn_io_dir_file_copy;
144
/* Not useful from scripting languages. Custom streams should be achieved
145
* by passing a scripting language native stream into a svn_stream_t *
146
* parameter, and letting a typemap using svn_swig_xx_make_stream() take
147
* care of the details. */
148
%ignore svn_stream_create;
149
%ignore svn_stream_set_baton;
150
%ignore svn_stream_set_read;
151
%ignore svn_stream_set_write;
152
%ignore svn_stream_set_close;
154
/* The permitted svn_stream and svn_stringbuf functions could possibly
155
* be used by a script, in conjunction with other APIs which return or
156
* accept streams. This requires that the relevant language's custom
157
* svn_stream_t wrapping code does not obstruct this usage. */
159
// svn_stream_from_aprfile
160
// svn_stream_for_stdout
161
// svn_stream_from_stringbuf
162
// svn_stream_compressed
167
%ignore svn_stream_read;
168
%ignore svn_stream_write;
169
%ignore svn_stream_close;
172
/* Scripts can do the printf, then write to a stream.
173
* We can't really handle the variadic, so ignore it. */
174
%ignore svn_stream_printf;
176
// svn_stream_readline
178
// svn_stringbuf_from_file
179
// svn_stringbuf_from_aprfile
181
%ignore svn_io_remove_file;
182
%ignore svn_io_remove_dir;
183
%ignore svn_io_get_dirents;
184
%ignore svn_io_dir_walk;
185
%ignore svn_io_run_cmd;
186
%ignore svn_io_run_diff;
187
%ignore svn_io_run_diff3;
188
// svn_io_detect_mimetype
189
%ignore svn_io_file_open;
190
%ignore svn_io_file_close;
191
%ignore svn_io_file_getc;
192
%ignore svn_io_file_info_get;
193
%ignore svn_io_file_read;
194
%ignore svn_io_file_read_full;
195
%ignore svn_io_file_seek;
196
%ignore svn_io_file_write;
197
%ignore svn_io_file_write_full;
199
%ignore svn_io_file_rename;
200
%ignore svn_io_dir_make;
201
%ignore svn_io_dir_make_hidden;
202
%ignore svn_io_dir_make_sgid;
203
%ignore svn_io_dir_open;
204
%ignore svn_io_dir_remove_nonrecursive;
205
%ignore svn_io_dir_read;
206
%ignore svn_io_read_version_file;
207
%ignore svn_io_write_version_file;
210
%ignore apr_check_dir_empty;
212
/* bad pool convention */
213
%ignore svn_opt_print_generic_help;
215
/* Ugliness because the constants are typedefed and SWIG ignores them
217
%constant svn_revnum_t SWIG_SVN_INVALID_REVNUM = -1;
218
%constant svn_revnum_t SWIG_SVN_IGNORED_REVNUM = -1;
220
/* -----------------------------------------------------------------------
221
these types (as 'type **') will always be an OUT param
223
%apply SWIGTYPE **OUTPARAM {
224
svn_auth_baton_t **, svn_diff_t **, svn_config_t **
227
/* -----------------------------------------------------------------------
228
handle the MIME type return value of svn_io_detect_mimetype()
230
%apply const char **OUTPUT { const char ** };
232
/* -----------------------------------------------------------------------
233
fix up the svn_stream_read() ptr/len arguments
235
%typemap(python, in) (char *buffer, apr_size_t *len) ($*2_type temp) {
236
if (!PyInt_Check($input)) {
237
PyErr_SetString(PyExc_TypeError,
238
"expecting an integer for the buffer size");
241
temp = PyInt_AsLong($input);
243
PyErr_SetString(PyExc_ValueError,
244
"buffer size must be a positive integer");
248
$2 = ($2_ltype)&temp;
250
%typemap(perl5, in) (char *buffer, apr_size_t *len) ($*2_type temp) {
253
$2 = ($2_ltype)&temp;
255
%typemap(ruby, in) (char *buffer, apr_size_t *len) ($*2_type temp) {
256
temp = NUM2LONG($input);
258
$2 = ($2_ltype)&temp;
261
/* ### need to use freearg or somesuch to ensure the string is freed.
262
### watch out for 'return' anywhere in the binding code. */
264
%typemap(python, argout, fragment="t_output_helper") (char *buffer, apr_size_t *len) {
265
$result = t_output_helper($result, PyString_FromStringAndSize($1, *$2));
268
%typemap(perl5, argout) (char *buffer, apr_size_t *len) {
269
$result = sv_newmortal();
270
sv_setpvn ($result, $1, *$2);
274
%typemap(ruby, argout, fragment="output_helper") (char *buffer, apr_size_t *len)
276
$result = output_helper($result, *$2 == 0 ? Qnil : rb_str_new($1, *$2));
280
/* -----------------------------------------------------------------------
281
fix up the svn_stream_write() ptr/len arguments
283
%typemap(python, in) (const char *data, apr_size_t *len) ($*2_type temp) {
284
if (!PyString_Check($input)) {
285
PyErr_SetString(PyExc_TypeError,
286
"expecting a string for the buffer");
289
$1 = PyString_AS_STRING($input);
290
temp = PyString_GET_SIZE($input);
291
$2 = ($2_ltype)&temp;
293
%typemap(perl5, in) (const char *data, apr_size_t *len) ($*2_type temp) {
294
$1 = SvPV($input, temp);
295
$2 = ($2_ltype)&temp;
297
%typemap(ruby, in) (const char *data, apr_size_t *len) ($*2_type temp)
299
$1 = StringValuePtr($input);
300
temp = RSTRING($input)->len;
301
$2 = ($2_ltype)&temp;
304
%typemap(python, argout, fragment="t_output_helper") (const char *data, apr_size_t *len) {
305
$result = t_output_helper($result, PyInt_FromLong(*$2));
308
%typemap(perl5, argout, fragment="t_output_helper") (const char *data, apr_size_t *len) {
309
$result = sv_2mortal (newSViv(*$2));
312
%typemap(ruby, argout, fragment="output_helper") (const char *data, apr_size_t *len)
314
$result = output_helper($result, LONG2NUM(*$2));
317
/* -----------------------------------------------------------------------
318
auth provider convertors
320
%typemap(perl5, in) apr_array_header_t *providers {
321
$1 = (apr_array_header_t *) svn_swig_pl_objs_to_array($input, SWIGTYPE_p_svn_auth_provider_object_t, _global_pool);
324
%typemap(python, in) apr_array_header_t *providers {
325
svn_auth_provider_object_t *provider;
327
if (!PySequence_Check($input)) {
328
PyErr_SetString(PyExc_TypeError, "not a sequence");
331
targlen = PySequence_Length($input);
332
$1 = apr_array_make(_global_pool, targlen, sizeof(provider));
333
($1)->nelts = targlen;
335
SWIG_ConvertPtr(PySequence_GetItem($input, targlen),
337
$descriptor(svn_auth_provider_object_t *),
338
SWIG_POINTER_EXCEPTION | 0);
339
APR_ARRAY_IDX($1, targlen, svn_auth_provider_object_t *) = provider;
343
%typemap(ruby, in) apr_array_header_t *providers
345
$1 = svn_swig_rb_array_to_auth_provider_object_apr_array($input, _global_pool);
348
/* -----------------------------------------------------------------------
349
auth parameter set/get
351
%typemap(python, in) const void *value {
352
if (PyString_Check($input)) {
353
$1 = (void *)PyString_AS_STRING($input);
355
else if (PyLong_Check($input)) {
356
$1 = (void *)PyLong_AsLong($input);
358
else if (PyInt_Check($input)) {
359
$1 = (void *)PyInt_AsLong($input);
362
PyErr_SetString(PyExc_TypeError, "not a known type");
367
%ignore svn_auth_get_parameter;
369
/* -----------------------------------------------------------------------
370
describe how to pass a FILE* as a parameter (svn_stream_from_stdio)
372
%typemap(python, in) FILE * {
373
$1 = PyFile_AsFile($input);
375
PyErr_SetString(PyExc_ValueError, "Must pass in a valid file object");
379
%typemap(perl5, in) FILE * {
380
$1 = PerlIO_exportFILE (IoIFP (sv_2io ($input)), NULL);
383
/* -----------------------------------------------------------------------
384
wrap some specific APR functionality
387
apr_status_t apr_initialize(void);
388
void apr_terminate(void);
390
apr_status_t apr_time_ansi_put(apr_time_t *result, time_t input);
392
void apr_pool_destroy(apr_pool_t *p);
393
void apr_pool_clear(apr_pool_t *p);
395
apr_status_t apr_file_open_stdout (apr_file_t **out, apr_pool_t *pool);
396
apr_status_t apr_file_open_stderr (apr_file_t **out, apr_pool_t *pool);
398
/* -----------------------------------------------------------------------
399
pool functions renaming since swig doesn't take care of the #define's
401
%rename (svn_pool_create) svn_pool_create_ex;
402
%ignore svn_pool_create_ex_debug;
403
%typemap(default) apr_allocator_t *allocator {
407
/* -----------------------------------------------------------------------
408
Default pool handling for perl.
412
/* Fix for SWIG 1.3.24 */
413
#if SWIG_VERSION == 0x010324
414
%typemap(varin) apr_pool_t * {
416
if (SWIG_ConvertPtr($input, (void **) &temp, $1_descriptor,0) < 0) {
417
croak("Type error in argument $argnum of $symname. Expected $1_mangle");
419
$1 = ($1_ltype) temp;
423
apr_pool_t *current_pool;
425
#if SWIG_VERSION <= 0x10324
427
#define SVN_SWIGEXPORT(t) SWIGEXPORT(t)
431
#define SVN_SWIGEXPORT(t) SWIGEXPORT t
437
static apr_pool_t *current_pool = 0;
439
SVN_SWIGEXPORT(apr_pool_t *)
440
svn_swig_pl_get_current_pool (void)
446
svn_swig_pl_set_current_pool (apr_pool_t *pool)
455
/* -----------------------------------------------------------------------
456
wrap config functions
459
%typemap(perl5,in,numinputs=0) apr_hash_t **cfg_hash = apr_hash_t **OUTPUT;
460
%typemap(perl5,argout) apr_hash_t **cfg_hash {
461
ST(argvi++) = svn_swig_pl_convert_hash(*$1, SWIGTYPE_p_svn_config_t);
464
%typemap(perl5, in) (svn_config_enumerator_t callback, void *baton) {
465
$1 = svn_swig_pl_thunk_config_enumerator,
469
%typemap(ruby, in, numinputs=0) apr_hash_t **cfg_hash = apr_hash_t **OUTPUT;
470
%typemap(ruby, argout) apr_hash_t **cfg_hash {
471
$result = svn_swig_rb_apr_hash_to_hash_swig_type(*$1, "svn_config_t *");
474
%typemap(python,in,numinputs=0) apr_hash_t **cfg_hash = apr_hash_t **OUTPUT;
475
%typemap(python,argout,fragment="t_output_helper") apr_hash_t **cfg_hash {
476
$result = t_output_helper(
478
SWIG_NewPointerObj(*$1, SWIGTYPE_p_apr_hash_t, 0));
481
/* Allow None to be passed as config_dir argument */
482
%typemap(python,in,parse="z") const char *config_dir "";
483
%typemap(ruby, in) const char *config_dir {
487
$1 = StringValuePtr($input);
492
PyObject *svn_swig_py_exception_type(void);
496
%typemap(ruby, in, numinputs=0)
497
apr_array_header_t **propdiffs (apr_array_header_t *temp)
502
%typemap(ruby, argout, fragment="output_helper") apr_array_header_t **propdiffs
504
$result = output_helper($result, svn_swig_rb_apr_array_to_array_prop(*$1));
507
%apply apr_hash_t *PROPHASH {
508
apr_hash_t *target_props,
509
apr_hash_t *source_props
512
%typemap(ruby, in) apr_array_header_t *proplist
514
$1 = svn_swig_rb_array_to_apr_array_prop($input, _global_pool);
517
%apply apr_array_header_t **OUTPUT_OF_PROP {
518
apr_array_header_t **entry_props,
519
apr_array_header_t **wc_props,
520
apr_array_header_t **regular_props
523
/* ----------------------------------------------------------------------- */
527
%include svn_version.h
540
%include svn_config.h
541
%include svn_version.h
545
/* SWIG won't follow through to APR's defining this to be empty, so we
546
need to do it manually, before SWIG sees this in svn_io.h. */
547
#define __attribute__(x)
558
/* This is a hack. I dunno if we can count on SWIG calling the module "m" */
559
PyModule_AddObject(m, "SubversionException",
560
svn_swig_py_register_exception());
564
SubversionException = _core.SubversionException
570
%rename(svn_stream_read) svn_stream_read_;
571
%rename(svn_stream_write) svn_stream_write_;
572
%rename(svn_stream_close) svn_stream_close_;
575
svn_stream_read_ (svn_stream_t *stream, char *buffer,
576
apr_size_t *len, apr_pool_t *pool)
579
rb_raise(rb_eArgError, "pool must be not nil");
581
return svn_stream_read(stream, buffer, len);
584
svn_stream_write_ (svn_stream_t *stream, const char *data,
585
apr_size_t *len, apr_pool_t *pool)
588
rb_raise(rb_eArgError, "pool must be not nil");
590
return svn_stream_write(stream, data, len);
593
svn_stream_close_ (svn_stream_t *stream, apr_pool_t *pool)
596
rb_raise(rb_eArgError, "pool must be not nil");
598
return svn_stream_close(stream);
601
REMOVE_DESTRUCTOR(svn_error_t)
602
REMOVE_DESTRUCTOR(svn_dirent_t)
603
REMOVE_DESTRUCTOR(svn_prop_t)
604
REMOVE_DESTRUCTOR(svn_log_changed_path_t)
605
REMOVE_DESTRUCTOR(svn_version_checklist_t)
606
REMOVE_DESTRUCTOR(svn_opt_subcommand_desc_t)
607
REMOVE_DESTRUCTOR(svn_opt_revision_t)
608
REMOVE_DESTRUCTOR(svn_opt_revision_t_value)
609
REMOVE_DESTRUCTOR(svn_auth_provider_t)
610
REMOVE_DESTRUCTOR(svn_auth_provider_object_t)
611
REMOVE_DESTRUCTOR(svn_auth_cred_simple_t)
612
REMOVE_DESTRUCTOR(svn_auth_cred_username_t)
613
REMOVE_DESTRUCTOR(svn_auth_cred_ssl_client_cert_t)
614
REMOVE_DESTRUCTOR(svn_auth_cred_ssl_client_cert_pw_t)
615
REMOVE_DESTRUCTOR(svn_auth_ssl_server_cert_info_t)
616
REMOVE_DESTRUCTOR(svn_auth_cred_ssl_server_trust_t)
617
REMOVE_DESTRUCTOR(svn_diff_fns_t)
618
REMOVE_DESTRUCTOR(svn_diff_output_fns_t)