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"
27 %include svn_global.swg
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
,
44 const char
*relative_to_dir
,
45 apr_array_header_t
*changelists
49 %apply apr_hash_t
*HASH_CSTRING_MAYBENULL
{
50 apr_hash_t
*mimetypes_map
,
51 apr_hash_t
*revprop_table
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
66 %apply const char
*NOT_NULL
{
67 const char
*changelist_name
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
85 %apply svn_stream_t
*WRAPPED_STREAM
{ svn_stream_t
* };
88 /* -----------------------------------------------------------------------
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.
*/
96 %ignore svn_client_proplist_item_t
;
99 %typemap
(argout
) apr_array_header_t
**props
{
100 svn_client_proplist_item_t
**ppitem
;
102 int nelts
= (*$
1)->nelts
;
103 PyObject
*list
= PyList_New
(nelts
);
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) {
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
);
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);
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);
152 #if defined
(SWIGPYTHON
) || defined
(SWIGRUBY
)
153 %callback_typemap
(svn_client_get_commit_log3_t log_msg_func
,
155 svn_swig_py_get_commit_log_func
,
157 svn_swig_rb_get_commit_log_func
)
161 %callback_typemap
(svn_cancel_func_t cancel_func
, void
*cancel_baton
,
164 svn_swig_rb_cancel_func
)
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
)
173 %callback_typemap
(svn_wc_notify_func2_t notify_func2
, void
*notify_baton2
,
176 svn_swig_rb_notify_func2
)
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
,
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
)
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?
234 %apply void
*CALLBACK_BATON
{
236 void
*log_msg_baton3
,
242 /* -----------------------------------------------------------------------
243 CALLBACK_BATON
: Do not convert to C object from Ruby object.
245 %typemap
(in
) void
*CALLBACK_BATON
250 %apply void
*CALLBACK_BATON
253 void
*log_msg_baton3
,
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.
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
*));
280 /* FIXME
: For svn_commit_info_t too?
*/
281 %typemap
(argout
) svn_client_commit_info_t
** {
283 %append_output
(&PL_sv_undef);
285 %append_output
(SWIG_NewPointerObj
(*$
1, $
*1_descriptor
, 0));
290 /* -----------------------------------------------------------------------
291 * Prop change fields of svn_client_commit_item3_t need to be
292 * converted between array data types.
*/
295 %typemap
(out
) apr_array_header_t
*incoming_prop_changes
{
297 $result
= svn_swig_pl_convert_array
($
1, $descriptor
(svn_prop_t
*));
301 %typemap
(out
) apr_array_header_t
*outgoing_prop_changes
{
303 $result
= svn_swig_pl_convert_array
($
1, $descriptor
(svn_prop_t
*));
309 /* -----------------------------------------------------------------------
310 * wrap svn_client_create_context
*/
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));
324 /* ----------------------------------------------------------------------- */
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
;
342 %include svn_client_h.swg
344 /* Ugliness because the constant is typedefed and SWIG ignores it
346 %constant apr_size_t SWIG_SVN_INFO_SIZE_UNKNOWN
= -1;
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
;
358 %extend svn_client_ctx_t
360 svn_client_ctx_t
(apr_pool_t
*pool
) {
362 svn_client_ctx_t
*self
;
363 err
= svn_client_create_context
(&self, pool);
365 svn_swig_rb_handle_svn_error
(err
);
369 ~svn_client_ctx_t
() {
373 %extend svn_client_commit_item3_t
375 svn_client_commit_item3_t
(apr_pool_t
*pool
) {
377 const svn_client_commit_item3_t
*self
;
378 err
= svn_client_commit_item_create
(&self, pool);
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
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
,
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
;
424 ~svn_client_copy_source_t
() {
427 const char
*_path
(void
) {
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
;
442 svn_client_set_log_msg_func3
(svn_client_ctx_t
*ctx
,
443 svn_client_get_commit_log3_t log_msg_func
,
447 ctx-
>log_msg_func3
= log_msg_func
;
448 ctx-
>log_msg_baton3
= log_msg_baton
;
449 return
(VALUE) log_msg_baton
;
453 svn_client_set_notify_func2
(svn_client_ctx_t
*ctx
,
454 svn_wc_notify_func2_t notify_func2
,
458 ctx-
>notify_func2
= notify_func2
;
459 ctx-
>notify_baton2
= notify_baton2
;
460 return
(VALUE)notify_baton2
;
464 svn_client_set_cancel_func
(svn_client_ctx_t
*ctx
,
465 svn_cancel_func_t cancel_func
,
469 ctx-
>cancel_func
= cancel_func
;
470 ctx-
>cancel_baton
= cancel_baton
;
471 return
(VALUE)cancel_baton
;
476 svn_client_set_config
(svn_client_ctx_t
*ctx
,
480 ctx-
>config
= config
;
485 svn_client_get_config
(svn_client_ctx_t
*ctx
,
486 apr_hash_t
**cfg_hash
,
489 *cfg_hash
= ctx-
>config
;