2
* svn_types.i : SWIG interface file for svn_types.h
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
* ====================================================================
19
/* This interface file only defines types and their related information.
20
There is no module associated with this interface file. */
24
/* -----------------------------------------------------------------------
25
Create a typemap to define "type **" as OUT parameters.
27
Note: SWIGTYPE is just a placeholder for "some arbitrary type". This
28
typemap will be applied onto a "real" type.
30
%typemap(python, in, numinputs=0) SWIGTYPE **OUTPARAM ($*1_type temp) {
33
%typemap(perl5, in, numinputs=0) SWIGTYPE **OUTPARAM ($*1_type temp) {
36
%typemap(ruby, in, numinputs=0) SWIGTYPE **OUTPARAM ($*1_type temp) {
41
%typemap(python, argout, fragment="t_output_helper") SWIGTYPE **OUTPARAM {
42
$result = t_output_helper($result,
43
SWIG_NewPointerObj(*$1, $*1_descriptor, 0));
45
%typemap(perl5, argout) SWIGTYPE **OUTPARAM {
46
ST(argvi) = sv_newmortal();
47
SWIG_MakePtr(ST(argvi++), (void *)*$1, $*1_descriptor,0);
49
%typemap(ruby, argout, fragment="output_helper") SWIGTYPE **OUTPARAM {
50
$result = output_helper($result, SWIG_NewPointerObj(*$1, $*1_descriptor, 0));
53
/* -----------------------------------------------------------------------
54
%apply-ing of typemaps
57
%apply SWIGTYPE **OUTPARAM { svn_stream_t ** };
59
%apply long *OUTPUT { svn_revnum_t * };
60
%apply int *OUTPUT { svn_boolean_t * };
62
/* svn_fs_check_path() */
63
%apply long *OUTPUT { svn_node_kind_t * };
65
/* -----------------------------------------------------------------------
66
Create a typemap for specifying string args that may be NULL.
68
%typemap(python, in, parse="z") const char *MAY_BE_NULL "";
71
%apply const char * { const char *MAY_BE_NULL };
74
%typemap(ruby, in) const char* MAY_BE_NULL
79
$1 = StringValuePtr($input);
83
%typemap(ruby, out) const char *
86
$result = rb_str_new2($1);
92
/* -----------------------------------------------------------------------
93
Define a more refined 'memberin' typemap for 'const char *' members. This
94
is used in place of the 'char *' handler defined automatically.
96
We need to do the free/malloc/strcpy special because of the const
98
%typemap(memberin) const char * {
99
apr_size_t len = strlen($input) + 1;
101
if ($1) free((char *)$1);
102
copied = malloc(len);
103
memcpy(copied, $input, len);
107
/* -----------------------------------------------------------------------
108
Specify how svn_error_t returns are turned into exceptions.
110
%typemap(python, out) svn_error_t * {
112
if ($1->apr_err != SVN_ERR_SWIG_PY_EXCEPTION_SET)
113
svn_swig_py_svn_exception($1);
122
%typemap(perl5,out) svn_error_t * {
124
SV *exception_handler = perl_get_sv ("SVN::Error::handler", FALSE);
126
if (SvOK(exception_handler)) {
129
svn_swig_pl_callback_thunk (CALL_SV, exception_handler,
130
&callback_result, "S", $1,
133
$result = sv_newmortal();
134
SWIG_MakePtr ($result, (void *)$1, $1_descriptor ,0);
140
%typemap(ruby, out) svn_error_t *
143
svn_error_t *error = $1;
146
message = rb_str_new2(error->message ? error->message : "");
148
while (error->child) {
149
error = error->child;
150
if (error->message) {
151
rb_str_concat(message, rb_str_new2("\n"));
152
rb_str_concat(message, rb_str_new2(error->message));
155
svn_error_clear(error);
157
rb_exc_raise(svn_swig_rb_svn_error_new(INT2NUM(error->apr_err),
163
/* -----------------------------------------------------------------------
164
Define an OUTPUT typemap for 'svn_filesize_t *'. For now, we'll
165
treat it as a 'long' even if that isn't entirely correct...
167
%typemap(python,in,numinputs=0) svn_filesize_t * (svn_filesize_t temp)
170
%typemap(perl5,in,numinputs=0) svn_filesize_t * (svn_filesize_t temp)
173
%typemap(ruby,in,numinputs=0) svn_filesize_t * (svn_filesize_t temp)
176
/* We have to use APR_INT64_T_FMT because SWIG won't convert the
177
SVN_FILESIZE_T_FMT to the actual value only APR_INT64_T_FMT */
178
#if APR_INT64_T_FMT == "ld"
180
%typemap(python,argout,fragment="t_output_helper") svn_filesize_t *
181
"$result = t_output_helper($result,PyLong_FromLong((long) (*$1)));";
183
%apply long *OUTPUT { svn_filesize_t * };
187
%typemap(python,argout,fragment="t_output_helper") svn_filesize_t *
188
"$result = t_output_helper($result,
189
PyLong_FromLongLong((apr_int64_t) (*$1)));";
191
/* XXX: apply long long *OUTPUT doesn't track $1 correctly */
192
%typemap(perl5,argout) svn_filesize_t * {
194
sprintf(temp,"%lld", *$1);
195
ST(argvi) = sv_newmortal();
196
sv_setpv((SV*)ST(argvi++), temp);
199
%typemap(ruby,argout,fragment="output_helper") svn_filesize_t *
200
"$result = output_helper($result, LL2NUM((apr_int64_t) (*$1)));";
203
/* -----------------------------------------------------------------------
204
Define a general ptr/len typemap. This takes a single script argument
205
and expands it into a ptr/len pair for the native call.
207
%typemap(python, in) (const char *PTR, apr_size_t LEN) {
208
if (!PyString_Check($input)) {
209
PyErr_SetString(PyExc_TypeError, "expecting a string");
212
$1 = PyString_AS_STRING($input);
213
$2 = PyString_GET_SIZE($input);
216
%typemap(perl5, in) (const char *PTR, apr_size_t LEN) {
218
$1 = SvPV($input, $2);
220
/* set to 0 to avoid warning */
223
SWIG_croak("Expecting a string");
227
/* -----------------------------------------------------------------------
228
Handle retrieving the error message from svn_strerror
231
%typemap(perl5,in,numinputs=0) (char *buf, apr_size_t bufsize) ( char temp[128] ) {
232
memset (temp,0,128); /* paranoia */
237
/* -----------------------------------------------------------------------
238
Define a generic arginit mapping for pools.
241
%typemap(python, arginit) apr_pool_t *pool(apr_pool_t *_global_pool) {
242
/* Assume that the pool here is the last argument in the list */
243
SWIG_ConvertPtr(PyTuple_GET_ITEM(args, PyTuple_GET_SIZE(args) - 1),
244
(void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION | 0);
248
%typemap(perl5, in) apr_pool_t *pool "";
249
%typemap(perl5, default) apr_pool_t *pool(apr_pool_t *_global_pool) {
250
_global_pool = $1 = svn_swig_pl_make_pool (ST(items-1));
252
%typemap(ruby, arginit) apr_pool_t *pool (apr_pool_t *_global_pool) {
254
/* wrong # of arguments: we need at least a pool. */
255
} else if (argc <= $argnum) {
256
if (NIL_P(argv[argc - 1])) {
257
rb_raise(rb_eArgError, "pool must be not nil");
259
/* Assume that the pool here is the last argument in the list */
260
SWIG_ConvertPtr(argv[argc - 1], (void **)&$1, $1_descriptor, 1);
266
%apply apr_pool_t *pool {
267
apr_pool_t *dir_pool,
268
apr_pool_t *file_pool,
269
apr_pool_t *node_pool
273
/* -----------------------------------------------------------------------
274
Callback: svn_log_message_receiver_t
280
%typemap(python, in) (svn_log_message_receiver_t receiver,
281
void *receiver_baton) {
282
$1 = svn_swig_py_log_receiver;
285
%typemap(perl5, in) (svn_log_message_receiver_t receiver,
286
void *receiver_baton) {
287
$1 = svn_swig_pl_thunk_log_receiver;
291
%typemap(ruby, in) (svn_log_message_receiver_t receiver,
292
void *receiver_baton) {
293
$1 = svn_swig_rb_log_receiver;
297
/* -----------------------------------------------------------------------
298
Callback: svn_commit_callback_t
299
svn_ra get_commit_editor()
300
svn_repos_get_commit_editor()
303
%typemap(perl5, in) (svn_commit_callback_t callback, void *callback_baton) {
304
$1 = svn_swig_pl_thunk_commit_callback;
306
svn_swig_pl_hold_ref_in_pool (_global_pool, $input);
309
/* -----------------------------------------------------------------------
310
Callback: svn_cancel_func_t
313
%typemap(python, in) (svn_cancel_func_t cancel_func, void *cancel_baton) {
314
$1 = svn_swig_py_cancel_func;
315
$2 = $input; /* our function is the baton. */
318
/* -----------------------------------------------------------------------
319
svn_stream_t interoperability with language native io handles
322
%typemap(python, in) svn_stream_t *WRAPPED_STREAM {
323
$1 = svn_swig_py_make_stream ($input, _global_pool);
326
%typemap(perl5, in) svn_stream_t * {
327
svn_swig_pl_make_stream (&$1, $input);
330
%typemap(perl5, out) svn_stream_t * {
331
$result = svn_swig_pl_from_stream ($1);
335
%typemap(perl5, argout) svn_stream_t ** {
336
$result = svn_swig_pl_from_stream (*$1);
340
%typemap(ruby, in) svn_stream_t * {
341
$1 = svn_swig_rb_make_stream($input, _global_pool);
344
/* -----------------------------------------------------------------------
345
Wrap the digest output for functions populating digests.
348
%typemap(in, numinputs=0) unsigned char digest[ANY]
349
($*1_type temp[APR_MD5_DIGESTSIZE]) {
353
%typemap(python, argout, fragment="t_output_helper") unsigned char digest[ANY]
355
$result = t_output_helper($result,
356
PyString_FromString(svn_md5_digest_to_cstring ($1, _global_pool)));
359
%typemap(perl5, argout) unsigned char digest[ANY] {
360
ST(argvi) = sv_newmortal();
361
sv_setpv((SV*)ST(argvi++), svn_md5_digest_to_cstring ($1,_global_pool));
364
/* svn_txdelta_send_stream() uses *digest not digest[] . */
365
%apply unsigned char digest[ANY] { unsigned char *digest };
367
/* -----------------------------------------------------------------------
368
useful convertors for svn_opt_revision_t
370
%typemap(perl5, in) svn_opt_revision_t * (svn_opt_revision_t rev) {
372
if ($input == NULL || $input == &PL_sv_undef || !SvOK($input)) {
373
rev.kind = svn_opt_revision_unspecified;
375
else if (sv_isobject($input) && sv_derived_from($input, "_p_svn_opt_revision_t")) {
376
SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, 0);
378
else if (looks_like_number($input)) {
379
rev.kind = svn_opt_revision_number;
380
rev.value.number = SvIV($input);
382
else if (SvPOK($input)) {
383
char *input = SvPV_nolen($input);
384
if (strcasecmp(input, "BASE") == 0)
385
rev.kind = svn_opt_revision_base;
386
else if (strcasecmp(input, "HEAD") == 0)
387
rev.kind = svn_opt_revision_head;
388
else if (strcasecmp(input, "WORKING") == 0)
389
rev.kind = svn_opt_revision_working;
390
else if (strcasecmp(input, "COMMITTED") == 0)
391
rev.kind = svn_opt_revision_committed;
392
else if (strcasecmp(input, "PREV") == 0)
393
rev.kind = svn_opt_revision_previous;
394
else if (*input == '{') {
395
svn_boolean_t matched;
399
char *end = strchr(input,'}');
401
SWIG_croak("unknown opt_revision_t type");
403
err = svn_parse_date (&matched, &tm, input + 1, apr_time_now(),
404
svn_swig_pl_make_pool ((SV *)NULL));
406
svn_error_clear (err);
407
SWIG_croak("unknown opt_revision_t type");
410
SWIG_croak("unknown opt_revision_t type");
412
rev.kind = svn_opt_revision_date;
415
SWIG_croak("unknown opt_revison_t type");
417
SWIG_croak("unknown opt_revision_t type");
420
%typemap(ruby, in) svn_opt_revision_t * (svn_opt_revision_t rev) {
422
svn_swig_rb_set_revision(&rev, $input);
425
/* -----------------------------------------------------------------------
432
%typemap(python,in,numinputs=0) apr_hash_t **dirents = apr_hash_t **OUTPUT;
433
%typemap(python,argout,fragment="t_output_helper") apr_hash_t **dirents {
434
$result = t_output_helper
436
svn_swig_py_convert_hash(*$1, SWIG_TypeQuery("svn_dirent_t *")));
439
%typemap(perl5,in,numinputs=0) apr_hash_t **dirents = apr_hash_t **OUTPUT;
440
%typemap(perl5,argout) apr_hash_t **dirents {
441
ST(argvi++) = svn_swig_pl_convert_hash
442
(*$1, SWIG_TypeQuery("svn_dirent_t *"));
445
/* -----------------------------------------------------------------------
446
Special boolean mapping for ruby.
449
%typemap(ruby, in) svn_boolean_t "$1 = RTEST($input);";
450
%typemap(ruby, out) svn_boolean_t "$result = $1 ? Qtrue : Qfalse;";
452
%typemap(ruby, in, numinputs=0) svn_boolean_t * (svn_boolean_t temp)
457
%typemap(ruby, argout) svn_boolean_t *
459
$result = *$1 ? Qtrue : Qfalse;
462
/* -----------------------------------------------------------------------
463
Handle python thread locking.
465
Swig doesn't allow us to specify a language in the %exception command,
466
so we have to use #ifdefs for the python-specific parts.
471
svn_swig_py_release_py_lock();
475
svn_swig_py_acquire_py_lock();
480
/* -----------------------------------------------------------------------
481
handle config and fs_config in svn_{fs,repos}_create
485
%typemap(ruby, in) apr_hash_t *config (apr_hash_t *temp)
490
$1 = svn_swig_rb_hash_to_apr_hash_swig_type($input, "svn_config_t *", _global_pool);
493
%typemap(ruby, in) apr_hash_t *fs_config
498
$1 = svn_swig_rb_hash_to_apr_hash_string($input, _global_pool);
502
/* -----------------------------------------------------------------------
503
remove destructor for apr_pool and Ruby's GC.
506
#define REMOVE_DESTRUCTOR(type) \
516
/* ----------------------------------------------------------------------- */
519
#include "svn_types.h"
520
#include "svn_time.h"
523
#include "swigutil_py.h"
527
#include "swigutil_pl.h"
531
#include "swigutil_rb.h"