Fix compiler warning due to missing function prototype.
[svn.git] / subversion / bindings / swig / svn_client.i
blobba6ec25d62b860138846e8dcdf38dd678b022a62
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 * svn_client.i: SWIG interface file for svn_client.h
19 #if defined(SWIGPYTHON)
20 %module(package="libsvn") client
21 #elif defined(SWIGPERL)
22 %module "SVN::_Client"
23 #elif defined(SWIGRUBY)
24 %module "svn::ext::client"
25 #endif
27 %include svn_global.swg
28 %import core.i
29 %import svn_delta.i
30 %import svn_wc.i
32 /* -----------------------------------------------------------------------
33 %apply-ing of typemaps defined elsewhere
36 %apply Pointer NONNULL {
37 const svn_opt_revision_t *revision,
38 const svn_opt_revision_t *peg_revision
41 %apply const char *MAY_BE_NULL {
42 const char *native_eol,
43 const char *comment,
44 const char *relative_to_dir,
45 apr_array_header_t *changelists
48 #ifdef SWIGRUBY
49 %apply apr_hash_t *HASH_CSTRING_MAYBENULL {
50 apr_hash_t *mimetypes_map,
51 apr_hash_t *revprop_table
53 #endif
55 #ifdef SWIGRUBY
56 %apply apr_array_header_t *SOURCES {
57 apr_array_header_t *sources
60 %apply apr_array_header_t *REVISION_RANGE_LIST {
61 apr_array_header_t *ranges_to_merge
63 #endif
65 #ifdef SWIGRUBY
66 %apply const char *NOT_NULL {
67 const char *changelist_name
69 #endif
71 %apply const apr_array_header_t *STRINGLIST {
72 apr_array_header_t *src_paths
75 %apply const apr_array_header_t *STRINGLIST_MAY_BE_NULL {
76 apr_array_header_t *changelists
79 %apply apr_array_header_t **OUTPUT_OF_CONST_CHAR_P {
80 apr_array_header_t **paths,
81 apr_array_header_t **suggestions
84 #ifdef SWIGPYTHON
85 %apply svn_stream_t *WRAPPED_STREAM { svn_stream_t * };
86 #endif
88 /* -----------------------------------------------------------------------
89 svn_client_proplist()
90 returns apr_array_header_t * <svn_client_proplist_item_t *>
93 /* svn_client_proplist_item_t is used exclusively for svn_client_proplist().
94 The python bindings convert it to a native python tuple. */
95 #ifdef SWIGPYTHON
96 %ignore svn_client_proplist_item_t;
97 #endif
98 #ifdef SWIGPYTHON
99 %typemap(argout) apr_array_header_t **props {
100 svn_client_proplist_item_t **ppitem;
101 int i;
102 int nelts = (*$1)->nelts;
103 PyObject *list = PyList_New(nelts);
104 if (list == NULL)
105 SWIG_fail;
106 ppitem = (svn_client_proplist_item_t **)(*$1)->elts;
107 for (i = 0; i < nelts; ++i, ++ppitem) {
108 PyObject *item = PyTuple_New(2);
109 PyObject *name = PyString_FromStringAndSize((*ppitem)->node_name->data,
110 (*ppitem)->node_name->len);
111 PyObject *hash = svn_swig_py_prophash_to_dict((*ppitem)->prop_hash);
113 if (item == NULL || name == NULL || hash == NULL) {
114 Py_XDECREF(item);
115 Py_XDECREF(name);
116 Py_XDECREF(hash);
117 Py_DECREF(list);
118 SWIG_fail;
120 PyTuple_SET_ITEM(item, 0, name);
121 PyTuple_SET_ITEM(item, 1, hash);
123 PyList_SET_ITEM(list, i, item);
125 %append_output(list);
127 #endif
129 #ifdef SWIGRUBY
130 %typemap(argout) apr_array_header_t **props {
131 %append_output(svn_swig_rb_apr_array_to_array_proplist_item(*$1));
134 %typemap(out) apr_hash_t *prop_hash
136 $result = svn_swig_rb_prop_hash_to_hash($1);
138 #endif
140 #ifdef SWIGPERL
141 %typemap(argout) apr_array_header_t **props {
142 %append_output(svn_swig_pl_convert_array(*$1,
143 $descriptor(svn_client_proplist_item_t *)));
146 %typemap(out) apr_hash_t *prop_hash {
147 $result = svn_swig_pl_prophash_to_hash($1);
148 argvi++;
150 #endif
152 #if defined(SWIGPYTHON) || defined(SWIGRUBY)
153 %callback_typemap(svn_client_get_commit_log3_t log_msg_func,
154 void *log_msg_baton,
155 svn_swig_py_get_commit_log_func,
157 svn_swig_rb_get_commit_log_func)
158 #endif
160 #ifdef SWIGRUBY
161 %callback_typemap(svn_cancel_func_t cancel_func, void *cancel_baton,
164 svn_swig_rb_cancel_func)
165 #endif
167 %callback_typemap(svn_client_blame_receiver_t receiver, void *receiver_baton,
168 svn_swig_py_client_blame_receiver_func,
169 svn_swig_pl_blame_func,
170 svn_swig_rb_client_blame_receiver_func)
172 #ifdef SWIGRUBY
173 %callback_typemap(svn_wc_notify_func2_t notify_func2, void *notify_baton2,
176 svn_swig_rb_notify_func2)
177 #endif
179 #ifdef SWIGPYTHON
180 %callback_typemap(svn_info_receiver_t receiver, void *receiver_baton,
181 svn_swig_py_info_receiver_func,
185 %callback_typemap(svn_changelist_receiver_t callback_func, void *callback_baton,
186 svn_swig_py_changelist_receiver_func,
189 #endif
191 #ifdef SWIGRUBY
192 %callback_typemap(svn_client_diff_summarize_func_t summarize_func,
193 void *summarize_baton,
196 svn_swig_rb_client_diff_summarize_func)
198 %callback_typemap(svn_client_list_func_t list_func, void *baton,
201 svn_swig_rb_client_list_func)
203 %callback_typemap(svn_proplist_receiver_t receiver, void *receiver_baton,
206 svn_swig_rb_proplist_receiver)
208 %callback_typemap(svn_changelist_receiver_t callback_func, void *callback_baton,
211 svn_swig_rb_changelist_receiver)
212 #endif
214 /* -----------------------------------------------------------------------
215 We use 'svn_wc_status_t *' in some custom code, but it isn't in the
216 API anywhere. Thus, SWIG doesn't generate a typemap entry for it. by
217 adding a simple declaration here, SWIG will insert a name for it.
218 FIXME: This may be untrue. See svn_wc_status, etc.
220 %types(svn_wc_status_t *);
222 /* We also need SWIG to wrap svn_dirent_t and svn_lock_t for us. They
223 don't appear in any API, but svn_client_ls returns a hash of pointers
224 to dirents and locks. */
225 %types(svn_dirent_t *);
226 %types(svn_lock_t *);
228 /* FIXME: What on earth is all this CALLBACK_BATON stuff actually trying to do?
229 Does Python need to do anything similar?
230 Why is some of it in svn_client.i and should it apply on a wider scope?
233 #ifdef SWIGPERL
234 %apply void *CALLBACK_BATON {
235 void *notify_baton,
236 void *log_msg_baton3,
237 void *cancel_baton
239 #endif
241 #ifdef SWIGRUBY
242 /* -----------------------------------------------------------------------
243 CALLBACK_BATON: Do not convert to C object from Ruby object.
245 %typemap(in) void *CALLBACK_BATON
247 $1 = (void *)$input;
250 %apply void *CALLBACK_BATON
252 void *notify_baton2,
253 void *log_msg_baton3,
254 void *cancel_baton
256 #endif
258 /* -----------------------------------------------------------------------
259 * Convert perl hashes back into apr_hash_t * for setting the config
260 * member of the svn_client_ctx_t. This is an ugly hack, it will
261 * always allocate the new apr_hash_t out of the global current_pool
262 * It would be better to make apr_hash_t's into magic variables in
263 * perl that are tied to the apr_hash_t interface. This would
264 * remove the need to convert to and from perl hashs all the time.
266 #ifdef SWIGPERL
267 %typemap(in) apr_hash_t *config {
268 $1 = svn_swig_pl_objs_to_hash_by_name ($input, "svn_config_t *",
269 svn_swig_pl_make_pool ((SV *)NULL));
272 %typemap(out) apr_hash_t *config {
273 $result = svn_swig_pl_convert_hash($1,
274 $descriptor(svn_config_t *));
275 argvi++;
277 #endif
279 #ifdef SWIGPERL
280 /* FIXME: For svn_commit_info_t too? */
281 %typemap(argout) svn_client_commit_info_t ** {
282 if ($1 == NULL) {
283 %append_output(&PL_sv_undef);
284 } else {
285 %append_output(SWIG_NewPointerObj(*$1, $*1_descriptor, 0));
288 #endif
290 /* -----------------------------------------------------------------------
291 * Prop change fields of svn_client_commit_item3_t need to be
292 * converted between array data types. */
294 #ifdef SWIGPERL
295 %typemap(out) apr_array_header_t *incoming_prop_changes {
296 if ($1) {
297 $result = svn_swig_pl_convert_array($1, $descriptor(svn_prop_t *));
298 argvi++;
301 %typemap(out) apr_array_header_t *outgoing_prop_changes {
302 if ($1) {
303 $result = svn_swig_pl_convert_array($1, $descriptor(svn_prop_t *));
304 argvi++;
307 #endif
309 /* -----------------------------------------------------------------------
310 * wrap svn_client_create_context */
312 #ifdef SWIGPERL
313 %typemap(argout) svn_client_ctx_t ** {
314 (*$1)->notify_func = svn_swig_pl_notify_func;
315 (*$1)->notify_baton = (void *) &PL_sv_undef;
316 (*$1)->log_msg_func3 = svn_swig_pl_get_commit_log_func;
317 (*$1)->log_msg_baton3 = (void *) &PL_sv_undef;
318 (*$1)->cancel_func = svn_swig_pl_cancel_func;
319 (*$1)->cancel_baton = (void *) &PL_sv_undef;
320 %append_output(SWIG_NewPointerObj(*$1, $*1_descriptor, 0));
322 #endif
324 /* ----------------------------------------------------------------------- */
326 #ifdef SWIGRUBY
328 #include <apu.h>
329 #include <apr_xlate.h>
331 %ignore svn_client_ctx_t::config;
332 %ignore svn_client_create_context;
333 %ignore svn_client_commit_item_create;
334 %ignore svn_client_commit_item2_dup;
335 %ignore svn_client_commit_item3_dup;
336 %ignore svn_client_copy_source_t::path;
337 %ignore svn_client_copy_source_t::revision;
338 %ignore svn_client_copy_source_t::peg_revision;
340 #endif
342 %include svn_client_h.swg
344 /* Ugliness because the constant is typedefed and SWIG ignores it
345 as a result. */
346 %constant apr_size_t SWIG_SVN_INFO_SIZE_UNKNOWN = -1;
348 #ifdef SWIGPYTHON
350 /* provide Python with access to some thunks. */
351 %constant svn_cancel_func_t svn_swig_py_cancel_func;
352 %constant svn_client_get_commit_log3_t svn_swig_py_get_commit_log_func;
353 %constant svn_wc_notify_func2_t svn_swig_py_notify_func;
355 #endif
357 #ifdef SWIGRUBY
358 %extend svn_client_ctx_t
360 svn_client_ctx_t(apr_pool_t *pool) {
361 svn_error_t *err;
362 svn_client_ctx_t *self;
363 err = svn_client_create_context(&self, pool);
364 if (err)
365 svn_swig_rb_handle_svn_error(err);
366 return self;
369 ~svn_client_ctx_t() {
373 %extend svn_client_commit_item3_t
375 svn_client_commit_item3_t(apr_pool_t *pool) {
376 svn_error_t *err;
377 const svn_client_commit_item3_t *self;
378 err = svn_client_commit_item_create(&self, pool);
379 if (err)
380 svn_swig_rb_handle_svn_error(err);
381 return (svn_client_commit_item3_t *)self;
384 ~svn_client_commit_item3_t() {
387 svn_client_commit_item3_t *dup(apr_pool_t *pool) {
388 return svn_client_commit_item3_dup(self, pool);
392 %extend svn_client_copy_source_t
394 %rename(path) _path;
395 %rename(revision) _revision;
396 %rename(peg_revision) _peg_revision;
398 svn_client_copy_source_t(const char *path,
399 const svn_opt_revision_t *rev,
400 const svn_opt_revision_t *peg_rev,
401 apr_pool_t *pool) {
402 svn_client_copy_source_t *self;
403 svn_opt_revision_t *revision;
404 svn_opt_revision_t *peg_revision;
406 self = apr_palloc(pool, sizeof(*self));
407 self->path = path ? apr_pstrdup(pool, path) : NULL;
409 revision = apr_palloc(pool, sizeof(revision));
410 revision->kind = rev->kind;
411 revision->value.number = rev->value.number;
412 revision->value.date = rev->value.date;
413 self->revision = revision;
415 peg_revision = apr_palloc(pool, sizeof(peg_revision));
416 peg_revision->kind = peg_rev->kind;
417 peg_revision->value.number = peg_rev->value.number;
418 peg_revision->value.date = peg_rev->value.date;
419 self->peg_revision = peg_revision;
421 return self;
424 ~svn_client_copy_source_t() {
427 const char *_path(void) {
428 return self->path;
431 const svn_opt_revision_t *_revision(void) {
432 return self->revision;
435 const svn_opt_revision_t *_peg_revision(void) {
436 return self->peg_revision;
440 %inline %{
441 static VALUE
442 svn_client_set_log_msg_func3(svn_client_ctx_t *ctx,
443 svn_client_get_commit_log3_t log_msg_func,
444 void *log_msg_baton,
445 apr_pool_t *pool)
447 ctx->log_msg_func3 = log_msg_func;
448 ctx->log_msg_baton3 = log_msg_baton;
449 return (VALUE) log_msg_baton;
452 static VALUE
453 svn_client_set_notify_func2(svn_client_ctx_t *ctx,
454 svn_wc_notify_func2_t notify_func2,
455 void *notify_baton2,
456 apr_pool_t *pool)
458 ctx->notify_func2 = notify_func2;
459 ctx->notify_baton2 = notify_baton2;
460 return (VALUE)notify_baton2;
463 static VALUE
464 svn_client_set_cancel_func(svn_client_ctx_t *ctx,
465 svn_cancel_func_t cancel_func,
466 void *cancel_baton,
467 apr_pool_t *pool)
469 ctx->cancel_func = cancel_func;
470 ctx->cancel_baton = cancel_baton;
471 return (VALUE)cancel_baton;
475 static VALUE
476 svn_client_set_config(svn_client_ctx_t *ctx,
477 apr_hash_t *config,
478 apr_pool_t *pool)
480 ctx->config = config;
481 return Qnil;
484 static svn_error_t *
485 svn_client_get_config(svn_client_ctx_t *ctx,
486 apr_hash_t **cfg_hash,
487 apr_pool_t *pool)
489 *cfg_hash = ctx->config;
490 return SVN_NO_ERROR;
493 #endif