~svn/ubuntu/raring/subversion/ppa

« back to all changes in this revision

Viewing changes to subversion/bindings/swig/svn_types.i

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-12-05 01:26:14 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051205012614-qom4xfypgtsqc2xq
Tags: 1.2.3dfsg1-3ubuntu1
Merge with the final Debian release of 1.2.3dfsg1-3, bringing in
fixes to the clean target, better documentation of the libdb4.3
upgrade and build fixes to work with swig1.3_1.3.27.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * svn_types.i :  SWIG interface file for svn_types.h
 
3
 *
 
4
 * ====================================================================
 
5
 * Copyright (c) 2000-2003 CollabNet.  All rights reserved.
 
6
 *
 
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.
 
12
 *
 
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
 * ====================================================================
 
17
 */
 
18
 
 
19
/* This interface file only defines types and their related information.
 
20
   There is no module associated with this interface file. */
 
21
 
 
22
%import apr.i
 
23
 
 
24
/* -----------------------------------------------------------------------
 
25
   Create a typemap to define "type **" as OUT parameters.
 
26
 
 
27
   Note: SWIGTYPE is just a placeholder for "some arbitrary type". This
 
28
         typemap will be applied onto a "real" type.
 
29
*/
 
30
%typemap(python, in, numinputs=0) SWIGTYPE **OUTPARAM ($*1_type temp) {
 
31
    $1 = ($1_ltype)&temp;
 
32
}
 
33
%typemap(perl5, in, numinputs=0) SWIGTYPE **OUTPARAM ($*1_type temp) {
 
34
    $1 = ($1_ltype)&temp;
 
35
}
 
36
%typemap(ruby, in, numinputs=0) SWIGTYPE **OUTPARAM ($*1_type temp) {
 
37
  temp = NULL;
 
38
  $1 = ($1_ltype)&temp;
 
39
}
 
40
 
 
41
%typemap(python, argout, fragment="t_output_helper") SWIGTYPE **OUTPARAM {
 
42
    $result = t_output_helper($result,
 
43
                              SWIG_NewPointerObj(*$1, $*1_descriptor, 0));
 
44
}
 
45
%typemap(perl5, argout) SWIGTYPE **OUTPARAM {
 
46
    ST(argvi) = sv_newmortal();
 
47
    SWIG_MakePtr(ST(argvi++), (void *)*$1, $*1_descriptor,0);
 
48
}
 
49
%typemap(ruby, argout, fragment="output_helper") SWIGTYPE **OUTPARAM {
 
50
  $result = output_helper($result, SWIG_NewPointerObj(*$1, $*1_descriptor, 0));
 
51
}
 
52
 
 
53
/* -----------------------------------------------------------------------
 
54
   %apply-ing of typemaps
 
55
*/
 
56
 
 
57
%apply SWIGTYPE **OUTPARAM { svn_stream_t ** };
 
58
 
 
59
%apply long *OUTPUT { svn_revnum_t * };
 
60
%apply int *OUTPUT { svn_boolean_t * };
 
61
 
 
62
/* svn_fs_check_path() */
 
63
%apply long *OUTPUT { svn_node_kind_t * };
 
64
 
 
65
/* -----------------------------------------------------------------------
 
66
   Create a typemap for specifying string args that may be NULL.
 
67
*/
 
68
%typemap(python, in, parse="z") const char *MAY_BE_NULL "";
 
69
 
 
70
#ifdef SWIGPERL
 
71
%apply const char * { const char *MAY_BE_NULL };
 
72
#endif
 
73
 
 
74
%typemap(ruby, in) const char* MAY_BE_NULL
 
75
{
 
76
  if (NIL_P($input)) {
 
77
    $1 = NULL;
 
78
  } else {
 
79
    $1 = StringValuePtr($input);
 
80
  }
 
81
}
 
82
 
 
83
%typemap(ruby, out) const char *
 
84
{
 
85
  if ($1) {
 
86
    $result = rb_str_new2($1);
 
87
  } else {
 
88
    $result = Qnil;
 
89
  }
 
90
}
 
91
 
 
92
/* -----------------------------------------------------------------------
 
93
   Define a more refined 'memberin' typemap for 'const char *' members. This
 
94
   is used in place of the 'char *' handler defined automatically.
 
95
 
 
96
   We need to do the free/malloc/strcpy special because of the const
 
97
*/
 
98
%typemap(memberin) const char * {
 
99
    apr_size_t len = strlen($input) + 1;
 
100
    char *copied;
 
101
    if ($1) free((char *)$1);
 
102
    copied = malloc(len);
 
103
    memcpy(copied, $input, len);
 
104
    $1 = copied;
 
105
}
 
106
 
 
107
/* -----------------------------------------------------------------------
 
108
   Specify how svn_error_t returns are turned into exceptions.
 
109
*/
 
110
%typemap(python, out) svn_error_t * {
 
111
    if ($1 != NULL) {
 
112
        if ($1->apr_err != SVN_ERR_SWIG_PY_EXCEPTION_SET)
 
113
            svn_swig_py_svn_exception($1);
 
114
        else
 
115
            svn_error_clear($1);
 
116
        return NULL;
 
117
    }
 
118
    Py_INCREF(Py_None);
 
119
    $result = Py_None;
 
120
}
 
121
 
 
122
%typemap(perl5,out) svn_error_t * {
 
123
    if ($1) {
 
124
        SV *exception_handler = perl_get_sv ("SVN::Error::handler", FALSE);
 
125
 
 
126
        if (SvOK(exception_handler)) {
 
127
            SV *callback_result;
 
128
 
 
129
            svn_swig_pl_callback_thunk (CALL_SV, exception_handler,
 
130
                                        &callback_result, "S", $1,
 
131
                                        $1_descriptor);
 
132
        } else {
 
133
            $result = sv_newmortal();
 
134
            SWIG_MakePtr ($result, (void *)$1, $1_descriptor ,0);
 
135
            argvi++;
 
136
        }
 
137
    }
 
138
}
 
139
 
 
140
%typemap(ruby, out) svn_error_t *
 
141
{
 
142
  if ($1) {
 
143
    svn_error_t *error = $1;
 
144
    VALUE message;
 
145
 
 
146
    message = rb_str_new2(error->message ? error->message : "");
 
147
    
 
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));
 
153
      }
 
154
    }
 
155
    svn_error_clear(error);
 
156
    
 
157
    rb_exc_raise(svn_swig_rb_svn_error_new(INT2NUM(error->apr_err),
 
158
                                           message));
 
159
  }
 
160
  $result = Qnil;
 
161
}
 
162
 
 
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...  
 
166
*/
 
167
%typemap(python,in,numinputs=0) svn_filesize_t * (svn_filesize_t temp)
 
168
    "$1 = &temp;";
 
169
 
 
170
%typemap(perl5,in,numinputs=0) svn_filesize_t * (svn_filesize_t temp)
 
171
    "$1 = &temp;";
 
172
 
 
173
%typemap(ruby,in,numinputs=0) svn_filesize_t * (svn_filesize_t temp)
 
174
    "$1 = &temp;";
 
175
 
 
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"
 
179
 
 
180
%typemap(python,argout,fragment="t_output_helper") svn_filesize_t *
 
181
    "$result = t_output_helper($result,PyLong_FromLong((long) (*$1)));";
 
182
 
 
183
%apply long *OUTPUT { svn_filesize_t * };
 
184
 
 
185
#else
 
186
 
 
187
%typemap(python,argout,fragment="t_output_helper") svn_filesize_t *
 
188
    "$result = t_output_helper($result,
 
189
                               PyLong_FromLongLong((apr_int64_t) (*$1)));";
 
190
 
 
191
/* XXX: apply long long *OUTPUT doesn't track $1 correctly */
 
192
%typemap(perl5,argout) svn_filesize_t * {
 
193
    char temp[256];
 
194
    sprintf(temp,"%lld", *$1);
 
195
    ST(argvi) = sv_newmortal();
 
196
    sv_setpv((SV*)ST(argvi++), temp);
 
197
};
 
198
 
 
199
%typemap(ruby,argout,fragment="output_helper") svn_filesize_t *
 
200
    "$result = output_helper($result, LL2NUM((apr_int64_t) (*$1)));";
 
201
#endif 
 
202
 
 
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.
 
206
*/
 
207
%typemap(python, in) (const char *PTR, apr_size_t LEN) {
 
208
    if (!PyString_Check($input)) {
 
209
        PyErr_SetString(PyExc_TypeError, "expecting a string");
 
210
        return NULL;
 
211
    }
 
212
    $1 = PyString_AS_STRING($input);
 
213
    $2 = PyString_GET_SIZE($input);
 
214
}
 
215
 
 
216
%typemap(perl5, in) (const char *PTR, apr_size_t LEN) {
 
217
    if (SvPOK($input)) {
 
218
        $1 = SvPV($input, $2);
 
219
    } else {
 
220
        /* set to 0 to avoid warning */
 
221
        $1 = 0;
 
222
        $2 = 0;
 
223
        SWIG_croak("Expecting a string");
 
224
    }
 
225
}
 
226
 
 
227
/* -----------------------------------------------------------------------
 
228
   Handle retrieving the error message from svn_strerror
 
229
*/
 
230
 
 
231
%typemap(perl5,in,numinputs=0) (char *buf, apr_size_t bufsize) ( char temp[128] ) {
 
232
    memset (temp,0,128); /* paranoia */
 
233
    $1 = temp;
 
234
    $2 = 128;
 
235
}
 
236
 
 
237
/* -----------------------------------------------------------------------
 
238
   Define a generic arginit mapping for pools.
 
239
*/
 
240
 
 
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);
 
245
    _global_pool = $1;
 
246
}
 
247
 
 
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));
 
251
}
 
252
%typemap(ruby, arginit) apr_pool_t *pool (apr_pool_t *_global_pool) {
 
253
  if (argc == 0) {
 
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");
 
258
    }
 
259
    /* Assume that the pool here is the last argument in the list */
 
260
    SWIG_ConvertPtr(argv[argc - 1], (void **)&$1, $1_descriptor, 1);
 
261
    _global_pool = $1;
 
262
  }
 
263
}
 
264
 
 
265
#ifdef SWIGPERL
 
266
%apply apr_pool_t *pool {
 
267
    apr_pool_t *dir_pool,
 
268
    apr_pool_t *file_pool,
 
269
    apr_pool_t *node_pool
 
270
};
 
271
#endif
 
272
 
 
273
/* -----------------------------------------------------------------------
 
274
   Callback: svn_log_message_receiver_t
 
275
   svn_client_log()
 
276
   svn_ra get_log()
 
277
   svn_repos_get_logs()
 
278
*/
 
279
 
 
280
%typemap(python, in) (svn_log_message_receiver_t receiver, 
 
281
                      void *receiver_baton) {
 
282
    $1 = svn_swig_py_log_receiver;
 
283
    $2 = (void *)$input;
 
284
}
 
285
%typemap(perl5, in) (svn_log_message_receiver_t receiver, 
 
286
                     void *receiver_baton) {
 
287
    $1 = svn_swig_pl_thunk_log_receiver;
 
288
    $2 = (void *)$input;
 
289
}
 
290
 
 
291
%typemap(ruby, in) (svn_log_message_receiver_t receiver, 
 
292
                    void *receiver_baton) {
 
293
    $1 = svn_swig_rb_log_receiver;
 
294
    $2 = (void *)$input;
 
295
}
 
296
 
 
297
/* -----------------------------------------------------------------------
 
298
   Callback: svn_commit_callback_t
 
299
   svn_ra get_commit_editor()
 
300
   svn_repos_get_commit_editor()
 
301
*/
 
302
 
 
303
%typemap(perl5, in) (svn_commit_callback_t callback, void *callback_baton) {
 
304
    $1 = svn_swig_pl_thunk_commit_callback;
 
305
    $2 = (void *)$input;
 
306
    svn_swig_pl_hold_ref_in_pool (_global_pool, $input);
 
307
};
 
308
 
 
309
/* -----------------------------------------------------------------------
 
310
   Callback: svn_cancel_func_t
 
311
*/
 
312
 
 
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. */
 
316
}
 
317
 
 
318
/* -----------------------------------------------------------------------
 
319
   svn_stream_t interoperability with language native io handles
 
320
*/
 
321
 
 
322
%typemap(python, in) svn_stream_t *WRAPPED_STREAM {
 
323
    $1 = svn_swig_py_make_stream ($input, _global_pool);
 
324
}
 
325
 
 
326
%typemap(perl5, in) svn_stream_t * {
 
327
    svn_swig_pl_make_stream (&$1, $input);
 
328
}
 
329
 
 
330
%typemap(perl5, out) svn_stream_t * {
 
331
    $result = svn_swig_pl_from_stream ($1);
 
332
    argvi++;
 
333
}
 
334
 
 
335
%typemap(perl5, argout) svn_stream_t ** {
 
336
    $result = svn_swig_pl_from_stream (*$1);
 
337
    argvi++;
 
338
}
 
339
 
 
340
%typemap(ruby, in) svn_stream_t * {
 
341
    $1 = svn_swig_rb_make_stream($input, _global_pool);
 
342
}
 
343
 
 
344
/* -----------------------------------------------------------------------
 
345
   Wrap the digest output for functions populating digests.
 
346
*/
 
347
 
 
348
%typemap(in, numinputs=0) unsigned char digest[ANY]
 
349
    ($*1_type temp[APR_MD5_DIGESTSIZE]) {
 
350
    $1 = ($1_ltype)temp;
 
351
}
 
352
 
 
353
%typemap(python, argout, fragment="t_output_helper") unsigned char digest[ANY]
 
354
{
 
355
    $result = t_output_helper($result,
 
356
        PyString_FromString(svn_md5_digest_to_cstring ($1, _global_pool)));
 
357
}
 
358
 
 
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));
 
362
}
 
363
 
 
364
/* svn_txdelta_send_stream() uses *digest not digest[] . */
 
365
%apply unsigned char digest[ANY] { unsigned char *digest };
 
366
 
 
367
/* -----------------------------------------------------------------------
 
368
  useful convertors for svn_opt_revision_t
 
369
*/
 
370
%typemap(perl5, in) svn_opt_revision_t * (svn_opt_revision_t rev) {
 
371
    $1 = &rev;
 
372
    if ($input == NULL || $input == &PL_sv_undef || !SvOK($input)) {
 
373
        rev.kind = svn_opt_revision_unspecified;
 
374
    }
 
375
    else if (sv_isobject($input) && sv_derived_from($input, "_p_svn_opt_revision_t")) {
 
376
        SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, 0);
 
377
    }
 
378
    else if (looks_like_number($input)) {
 
379
        rev.kind = svn_opt_revision_number;
 
380
        rev.value.number = SvIV($input);
 
381
    }
 
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;
 
396
            apr_time_t tm;
 
397
            svn_error_t *err;
 
398
 
 
399
            char *end = strchr(input,'}');
 
400
            if (!end)
 
401
                SWIG_croak("unknown opt_revision_t type");
 
402
            *end = '\0';
 
403
            err = svn_parse_date (&matched, &tm, input + 1, apr_time_now(),
 
404
                                  svn_swig_pl_make_pool ((SV *)NULL));
 
405
            if (err) {
 
406
                svn_error_clear (err);
 
407
                SWIG_croak("unknown opt_revision_t type");
 
408
            }
 
409
            if (!matched)
 
410
                SWIG_croak("unknown opt_revision_t type");
 
411
 
 
412
            rev.kind = svn_opt_revision_date;
 
413
            rev.value.date = tm;
 
414
        } else
 
415
            SWIG_croak("unknown opt_revison_t type");
 
416
    } else
 
417
        SWIG_croak("unknown opt_revision_t type");
 
418
}
 
419
 
 
420
%typemap(ruby, in) svn_opt_revision_t * (svn_opt_revision_t rev) {
 
421
  $1 = &rev;
 
422
  svn_swig_rb_set_revision(&rev, $input);
 
423
}
 
424
 
 
425
/* -----------------------------------------------------------------------
 
426
   apr_hash_t **dirents
 
427
   svn_client_ls()
 
428
   svn_io_get_dirents()
 
429
   svn_ra get_dir()
 
430
*/
 
431
 
 
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
 
435
        ($result,
 
436
         svn_swig_py_convert_hash(*$1, SWIG_TypeQuery("svn_dirent_t *")));
 
437
}
 
438
 
 
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 *"));
 
443
}
 
444
 
 
445
/* -----------------------------------------------------------------------
 
446
   Special boolean mapping for ruby.
 
447
*/
 
448
 
 
449
%typemap(ruby, in) svn_boolean_t "$1 = RTEST($input);";
 
450
%typemap(ruby, out) svn_boolean_t "$result = $1 ? Qtrue : Qfalse;";
 
451
 
 
452
%typemap(ruby, in, numinputs=0) svn_boolean_t * (svn_boolean_t temp)
 
453
{
 
454
  $1 = &temp;
 
455
}
 
456
 
 
457
%typemap(ruby, argout) svn_boolean_t *
 
458
{
 
459
  $result = *$1 ? Qtrue : Qfalse;
 
460
}
 
461
 
 
462
/* -----------------------------------------------------------------------
 
463
   Handle python thread locking.
 
464
 
 
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.
 
467
*/
 
468
 
 
469
%exception {
 
470
#ifdef SWIGPYTHON
 
471
    svn_swig_py_release_py_lock();
 
472
#endif
 
473
    $action
 
474
#ifdef SWIGPYTHON
 
475
    svn_swig_py_acquire_py_lock();
 
476
#endif
 
477
}
 
478
 
 
479
 
 
480
/* -----------------------------------------------------------------------
 
481
   handle config and fs_config in svn_{fs,repos}_create
 
482
*/
 
483
 
 
484
 
 
485
%typemap(ruby, in) apr_hash_t *config (apr_hash_t *temp)
 
486
{
 
487
  if (NIL_P($input)) {
 
488
    $1 = NULL;
 
489
  } else {
 
490
    $1 = svn_swig_rb_hash_to_apr_hash_swig_type($input, "svn_config_t *", _global_pool);
 
491
  }
 
492
}
 
493
%typemap(ruby, in) apr_hash_t *fs_config
 
494
{
 
495
  if (NIL_P($input)) {
 
496
    $1 = NULL;
 
497
  } else {
 
498
    $1 = svn_swig_rb_hash_to_apr_hash_string($input, _global_pool);
 
499
  }
 
500
}
 
501
 
 
502
/* -----------------------------------------------------------------------
 
503
   remove destructor for apr_pool and Ruby's GC.
 
504
*/
 
505
#ifdef SWIGRUBY
 
506
#define REMOVE_DESTRUCTOR(type)                 \
 
507
%extend type                                    \
 
508
{                                               \
 
509
  ~type(type *obj)                              \
 
510
    {                                           \
 
511
      /* do nothing */                          \
 
512
    }                                           \
 
513
}
 
514
#endif
 
515
 
 
516
/* ----------------------------------------------------------------------- */
 
517
 
 
518
%{
 
519
#include "svn_types.h"
 
520
#include "svn_time.h"
 
521
 
 
522
#ifdef SWIGPYTHON
 
523
#include "swigutil_py.h"
 
524
#endif
 
525
 
 
526
#ifdef SWIGPERL
 
527
#include "swigutil_pl.h"
 
528
#endif
 
529
 
 
530
#ifdef SWIGRUBY
 
531
#include "swigutil_rb.h"
 
532
#endif
 
533
%}
 
534
 
 
535
%include svn_types.h