2 * ====================================================================
3 * Copyright
(c
) 2000-2006 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_delta.i
: SWIG interface file for svn_delta.h
19 #if defined
(SWIGPYTHON
)
20 %module
(package
="libsvn") delta
21 #elif defined
(SWIGPERL
)
23 #elif defined
(SWIGRUBY
)
24 %module
"svn::ext::delta"
27 %include svn_global.swg
30 /* -----------------------------------------------------------------------
31 %apply-ing of typemaps defined elsewhere
34 %apply const char
*MAY_BE_NULL
{
35 const char
*error_info
,
36 const char
*copyfrom_path
,
37 const char
*copy_path
,
38 const char
*base_checksum
,
39 const char
*text_checksum
43 %apply svn_stream_t
*WRAPPED_STREAM
{ svn_stream_t
* };
46 /* -----------------------------------------------------------------------
47 mark window.new_data as readonly since we would need a pool to set it
48 properly
(e.g. to allocate an svn_string_t structure
).
50 %immutable svn_txdelta_window_t
::new_data
;
52 /* -----------------------------------------------------------------------
53 thunk editors for the various language bindings.
57 void svn_swig_py_make_editor
(const svn_delta_editor_t
**editor
,
64 %typemap
(in
) (const svn_delta_editor_t
*EDITOR, void
*BATON
) {
65 svn_delta_make_editor
(&$1, &$2, $input, _global_pool);
68 void svn_delta_wrap_window_handler
(svn_txdelta_window_handler_t
*handler
,
76 %typemap
(in
) (const svn_delta_editor_t
*EDITOR, void
*BATON
)
78 if
(RTEST
(rb_obj_is_kind_of
($input
,
79 svn_swig_rb_svn_delta_editor
()))) {
80 $
1 = svn_swig_rb_to_swig_type
($input
,
81 "svn_delta_editor_t *",
83 $
2 = svn_swig_rb_to_swig_type
(rb_funcall
($input
, rb_intern
("baton"), 0),
84 "void *", _global_pool
);
86 svn_swig_rb_make_delta_editor
(&$1, &$2, $input, _global_pool);
92 /* Python users have to use svn_swig_py_make_editor manually
, which sucks.
93 Maybe we could allow people to pass a python object in the editor parameter
,
94 and None as the baton
, and automatically invoke svn_swig_py_make_editor
,
95 rather than forcing the svn_swig_py_make_editor to be done manually.
96 Of course
, ideally
, the baton parameter would vanish from the python
97 side entirely
, but we can't kill compatibility like that until
2.0.
99 %apply
(const svn_delta_editor_t
*EDITOR, void
*BATON
)
101 (const svn_delta_editor_t
*editor
, void
*baton
),
102 (const svn_delta_editor_t
*editor
, void
*edit_baton
),
103 (const svn_delta_editor_t
*editor
, void
*file_baton
),
104 (const svn_delta_editor_t
*diff_editor
, void
*diff_baton
),
105 (const svn_delta_editor_t
*update_editor
, void
*update_baton
),
106 (const svn_delta_editor_t
*switch_editor
, void
*switch_baton
),
107 (const svn_delta_editor_t
*status_editor
, void
*status_baton
)
111 /* -----------------------------------------------------------------------
112 handle svn_txdelta_window_handler_t
/baton pair.
116 %typemap
(in
) (svn_txdelta_window_handler_t handler
,
119 if
(RTEST
(rb_obj_is_kind_of
($input
,
120 svn_swig_rb_svn_delta_text_delta_window_handler
()))) {
121 $
1 = svn_swig_rb_to_swig_type
($input
,
122 "svn_txdelta_window_handler_t",
124 $
2 = svn_swig_rb_to_swig_type
(rb_funcall
($input
, rb_intern
("baton"), 0),
125 "void *", _global_pool
);
127 $
1 = svn_swig_rb_txdelta_window_handler
;
128 $
2 = (void
*)svn_swig_rb_make_baton
($input
, _global_svn_swig_rb_pool
);
133 /* -----------------------------------------------------------------------
134 handle svn_delta_path_driver
().
138 %callback_typemap
(svn_delta_path_driver_cb_func_t callback_func
,
139 void
*callback_baton
,
140 svn_swig_py_delta_path_driver_cb_func
,
142 svn_swig_rb_delta_path_driver_cb_func
)
145 /* ----------------------------------------------------------------------- */
151 /* -----------------------------------------------------------------------
152 handle svn_txdelta_window_t
::ops
155 %ignore svn_txdelta_window_t
::ops
;
158 svn_txdelta_window_t_ops_get
(svn_txdelta_window_t
*window
)
160 return svn_swig_rb_txdelta_window_t_ops_get
(window
);
166 %include svn_delta_h.swg
171 svn_swig_rb_delta_editor_get_target_revision
(VALUE editor
)
173 static ID id_target_revision_address
= 0;
174 VALUE rb_target_address
;
175 svn_revnum_t
*target_address
;
177 if
(id_target_revision_address
== 0)
178 id_target_revision_address
= rb_intern
("@target_revision_address");
180 if
(!RTEST
(rb_ivar_defined
(editor
, id_target_revision_address
)))
183 rb_target_address
= rb_ivar_get
(editor
, id_target_revision_address
);
184 if
(NIL_P
(rb_target_address
))
187 target_address
= (svn_revnum_t
*)(NUM2LONG
(rb_target_address
));
191 return LONG2NUM
(*target_address
);
196 /* -----------------------------------------------------------------------
197 handle svn_txdelta_apply_instructions
()
202 svn_swig_rb_txdelta_apply_instructions
(svn_txdelta_window_t
*window
,
208 tlen
= window-
>tview_len
+ 1;
209 tbuf
= ALLOCA_N
(char
, tlen
);
210 svn_txdelta_apply_instructions
(window
, sbuf
, tbuf
, &tlen);
212 return rb_str_new
(tbuf
, tlen
);
217 /* -----------------------------------------------------------------------
218 handle svn_txdelta_to_svndiff
().
223 svn_txdelta_apply_wrapper
(svn_stream_t
*source
,
224 svn_stream_t
*target
,
225 unsigned char
*result_digest
,
226 const char
*error_info
,
227 svn_txdelta_window_handler_t
*handler
,
228 void
**handler_baton
,
231 svn_txdelta_apply
(source
, target
, result_digest
, error_info
,
232 pool
, handler
, handler_baton
);
236 svn_delta_editor_invoke_open_root_wrapper
(svn_delta_editor_t
*editor
,
238 svn_revnum_t base_revision
,
240 apr_pool_t
*dir_pool
)
242 return svn_delta_editor_invoke_open_root
(editor
, edit_baton
,
243 base_revision
, dir_pool
, root_baton
);
247 svn_delta_editor_invoke_add_directory_wrapper
(svn_delta_editor_t
*editor
,
250 const char
*copyfrom_path
,
251 svn_revnum_t copyfrom_revision
,
253 apr_pool_t
*dir_pool
)
255 return svn_delta_editor_invoke_add_directory
(editor
, path
, parent_baton
,
256 copyfrom_path
, copyfrom_revision
,
257 dir_pool
, child_baton
);
261 svn_delta_editor_invoke_open_directory_wrapper
(svn_delta_editor_t
*editor
,
264 svn_revnum_t base_revision
,
266 apr_pool_t
*dir_pool
)
268 return svn_delta_editor_invoke_open_directory
(editor
, path
, parent_baton
,
269 base_revision
, dir_pool
,
274 svn_delta_editor_invoke_add_file_wrapper
(svn_delta_editor_t
*editor
,
277 const char
*copyfrom_path
,
278 svn_revnum_t copyfrom_revision
,
280 apr_pool_t
*file_pool
)
282 return svn_delta_editor_invoke_add_file
(editor
, path
, parent_baton
,
285 file_pool
, file_baton
);
289 svn_delta_editor_invoke_open_file_wrapper
(svn_delta_editor_t
*editor
,
292 svn_revnum_t base_revision
,
294 apr_pool_t
*file_pool
)
296 return svn_delta_editor_invoke_open_file
(editor
, path
, parent_baton
,
298 file_pool
, file_baton
);
302 svn_delta_editor_invoke_apply_textdelta_wrapper
(svn_delta_editor_t
*editor
,
304 const char
*base_checksum
,
305 svn_txdelta_window_handler_t
*handler
,
306 void
**handler_baton
,
309 return svn_delta_editor_invoke_apply_textdelta
(editor
, file_baton
,
311 handler
, handler_baton
);
315 svn_txdelta_invoke_window_handler_wrapper
(VALUE obj
,
316 svn_txdelta_window_t
*window
,
319 return svn_swig_rb_invoke_txdelta_window_handler_wrapper
(obj
, window
, pool
);
323 svn_txdelta_editor_invoke_apply_textdelta_wrapper
(VALUE obj
,
324 svn_txdelta_window_t
*window
,
327 return svn_swig_rb_invoke_txdelta_window_handler_wrapper
(obj
, window
, pool
);
331 svn_txdelta_md5_digest_as_cstring
(svn_txdelta_stream_t
*stream
,
334 const unsigned char
*digest
;
336 digest
= svn_txdelta_md5_digest
(stream
);
339 return svn_md5_digest_to_cstring
(digest
, pool
);