Alien-SVN
view release on metacpan or search on metacpan
src/subversion/subversion/bindings/swig/core.i view on Meta::CPAN
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* core.i: SWIG module interface file for libsvn_subr, a few pieces of
* APR functionality, and anything else that does not fit into any
* of the more specific module files.
*/
#if defined(SWIGPYTHON)
%module(package="libsvn") core
#elif defined(SWIGPERL)
%module "SVN::_Core"
#elif defined(SWIGRUBY)
%module "svn::ext::core"
#endif
%include svn_global.swg
%{
#include <apr.h>
#include <apr_general.h>
#include <apr_md5.h>
#include "svn_diff.h"
#include "svn_private_config.h"
%}
#ifdef SWIGRUBY
%{
#include <apu.h>
#include <apr_xlate.h>
%}
#endif
/* ### for now, let's ignore this thing. */
%ignore svn_prop_t;
/* -----------------------------------------------------------------------
The following struct members have to be read-only because otherwise
strings assigned to then would never be freed, resulting in memory
leaks. This prevents the swig warning "Warning(451): Setting const
char * member may leak memory."
*/
%immutable svn_log_changed_path_t::copyfrom_path;
%immutable svn_dirent_t::last_author;
%immutable svn_error_t::message;
%immutable svn_error_t::file;
/* -----------------------------------------------------------------------
completely ignore a number of functions. the presumption is that the
scripting language already has facilities for these things (or they
are relatively trivial).
*/
/* svn_io.h: We cherry-pick certain functions from this file. To aid in this,
* EVERY function in the file is listed in the order it appears, and is either
* %ignore-d, or present as a comment, explicitly documenting that we wrap it.
*/
%ignore svn_io_check_path;
%ignore svn_io_check_special_path;
%ignore svn_io_check_resolved_path;
/* This is useful for implementing svn_ra_callbacks_t->open_tmp_file */
// svn_io_open_unique_file2
// svn_io_open_unique_file
%ignore svn_io_create_unique_link;
%ignore svn_io_read_link;
%ignore svn_io_temp_dir;
%ignore svn_io_copy_file;
%ignore svn_io_copy_link;
%ignore svn_io_copy_dir_recursively;
%ignore svn_io_make_dir_recursively;
%ignore svn_io_dir_empty;
%ignore svn_io_append_file;
%ignore svn_io_set_file_read_only;
%ignore svn_io_set_file_read_write;
%ignore svn_io_set_file_read_write_carefully;
src/subversion/subversion/bindings/swig/core.i view on Meta::CPAN
%append_output(*$2 == 0 ? Qnil : rb_str_new($1, *$2));
free($1);
}
#endif
/* -----------------------------------------------------------------------
fix up the svn_stream_write() ptr/len arguments
*/
#ifdef SWIGPYTHON
%typemap(in) (const char *data, apr_size_t *len) ($*2_type temp) {
if (!PyString_Check($input)) {
PyErr_SetString(PyExc_TypeError,
"expecting a string for the buffer");
SWIG_fail;
}
$1 = PyString_AS_STRING($input);
temp = PyString_GET_SIZE($input);
$2 = ($2_ltype)&temp;
}
#endif
#ifdef SWIGPERL
%typemap(in) (const char *data, apr_size_t *len) ($*2_type temp) {
$1 = SvPV($input, temp);
$2 = ($2_ltype)&temp;
}
#endif
#ifdef SWIGRUBY
%typemap(in) (const char *data, apr_size_t *len) ($*2_type temp)
{
$1 = StringValuePtr($input);
temp = RSTRING_LEN($input);
$2 = ($2_ltype)&temp;
}
#endif
#ifdef SWIGPYTHON
%typemap(argout) (const char *data, apr_size_t *len) {
%append_output(PyInt_FromLong(*$2));
}
#endif
#ifdef SWIGPERL
%typemap(argout) (const char *data, apr_size_t *len) {
%append_output(sv_2mortal(newSViv(*$2)));
}
#endif
#ifdef SWIGRUBY
%typemap(argout) (const char *data, apr_size_t *len) {
%append_output(LONG2NUM(*$2));
}
#endif
/* -----------------------------------------------------------------------
auth parameter set/get
*/
/* set */
#ifdef SWIGPYTHON
%typemap(in) const void *value
(apr_pool_t *_global_pool = NULL, PyObject *_global_py_pool = NULL)
{
if (_global_pool == NULL)
{
if (svn_swig_py_get_parent_pool(args, $descriptor(apr_pool_t *),
&_global_py_pool, &_global_pool))
SWIG_fail;
}
if (PyString_Check($input)) {
char *value = PyString_AS_STRING($input);
$1 = apr_pstrdup(_global_pool, value);
}
else if (PyLong_Check($input)) {
$1 = apr_palloc(_global_pool, sizeof(apr_uint32_t));
*((apr_uint32_t *)$1) = PyLong_AsLong($input);
}
else if (PyInt_Check($input)) {
$1 = apr_palloc(_global_pool, sizeof(apr_uint32_t));
*((apr_uint32_t *)$1) = PyInt_AsLong($input);
}
else if ($input == Py_None) {
$1 = NULL;
}
else if (svn_swig_ConvertPtr($input, (void **)&$1, $descriptor(svn_auth_ssl_server_cert_info_t *)) == 0) {
}
else {
PyErr_SetString(PyExc_TypeError, "not a known type");
SWIG_fail;
}
}
#endif
/*
- all values are converted to char*
- assume the first argument is Ruby object for svn_auth_baton_t*
*/
#ifdef SWIGRUBY
%typemap(in) const void *value
{
if (NIL_P($input)) {
$1 = (void *)NULL;
} else {
VALUE _rb_pool;
apr_pool_t *_global_pool;
char *value = StringValuePtr($input);
svn_swig_rb_get_pool(1, argv, Qnil, &_rb_pool, &_global_pool);
$1 = (void *)apr_pstrdup(_global_pool, value);
}
}
#endif
/* get */
/* assume the value is char* */
#ifdef SWIGRUBY
%typemap(out) const void *
{
char *value = $1;
if (value) {
$result = rb_str_new2(value);
} else {
$result = Qnil;
}
}
#endif
#ifndef SWIGRUBY
%ignore svn_auth_get_parameter;
#endif
/* -----------------------------------------------------------------------
svn_io_parse_mimetypes_file()
*/
#ifdef SWIGRUBY
%apply apr_hash_t **HASH_CSTRING {
apr_hash_t **type_map
}
#endif
/* -----------------------------------------------------------------------
svn_io_detect_mimetype2()
*/
%apply apr_hash_t *HASH_CSTRING {
apr_hash_t *mimetype_map
}
/* -----------------------------------------------------------------------
describe how to pass a FILE* as a parameter (svn_stream_from_stdio)
*/
#ifdef SWIGPYTHON
%typemap(in) FILE * {
$1 = PyFile_AsFile($input);
if ($1 == NULL) {
PyErr_SetString(PyExc_ValueError, "Must pass in a valid file object");
SWIG_fail;
}
}
#endif
#ifdef SWIGPERL
%typemap(in) FILE * {
$1 = PerlIO_exportFILE (IoIFP (sv_2io ($input)), NULL);
}
#endif
/* -----------------------------------------------------------------------
wrap some specific APR functionality
src/subversion/subversion/bindings/swig/core.i view on Meta::CPAN
#if SWIG_VERSION <= 0x010324
%{
#define SVN_SWIGEXPORT(t) SWIGEXPORT(t)
%}
#else
%{
#define SVN_SWIGEXPORT(t) SWIGEXPORT t
%}
#endif
%{
static apr_pool_t *current_pool = 0;
SVN_SWIGEXPORT(apr_pool_t *)
svn_swig_pl_get_current_pool (void)
{
return current_pool;
}
SVN_SWIGEXPORT(void)
svn_swig_pl_set_current_pool (apr_pool_t *pool)
{
current_pool = pool;
}
%}
#endif
/* -----------------------------------------------------------------------
wrap config functions
*/
#ifdef SWIGPERL
%callback_typemap(svn_config_enumerator_t callback, void *baton,
,
svn_swig_pl_thunk_config_enumerator,
)
#endif
#ifndef SWIGPERL
%callback_typemap(svn_config_enumerator2_t callback, void *baton,
svn_swig_py_config_enumerator2,
,
svn_swig_rb_config_enumerator)
%callback_typemap(svn_config_section_enumerator2_t callback, void *baton,
svn_swig_py_config_section_enumerator2,
,
svn_swig_rb_config_section_enumerator)
#endif
/* Allow None to be passed as config_dir argument */
#ifdef SWIGPYTHON
%typemap(in,parse="z") const char *config_dir "";
#endif
/* -----------------------------------------------------------------------
thunk the various authentication prompt functions.
PERL NOTE: store the inputed SV in _global_callback for use in the
later argout typemap
*/
#ifdef SWIGPERL
%define %authprompt_callback_typemap(AuthType)
%typemap(in) (svn_auth_ ## AuthType ## _prompt_func_t prompt_func,
void *prompt_baton) {
$1 = svn_swig_pl_thunk_ ## AuthType ## _prompt;
$2 = $input;
_global_callback = $input;
}
%enddef
#else
%define %authprompt_callback_typemap(AuthType)
%callback_typemap(svn_auth_ ## AuthType ## _prompt_func_t prompt_func,
void *prompt_baton,
svn_swig_py_auth_ ## AuthType ## _prompt_func,,
svn_swig_rb_auth_ ## AuthType ## _prompt_func)
%enddef
#endif
%authprompt_callback_typemap(simple)
%authprompt_callback_typemap(username)
%authprompt_callback_typemap(ssl_server_trust)
%authprompt_callback_typemap(ssl_client_cert)
%authprompt_callback_typemap(ssl_client_cert_pw)
%authprompt_callback_typemap(gnome_keyring_unlock)
#ifdef SWIGPYTHON
/* pl and rb aren't yet implemented */
%callback_typemap_maybenull(svn_config_auth_walk_func_t walk_func,
void *walk_baton,
svn_swig_py_config_auth_walk_func,
svn_swig_pl_config_auth_walk_func,
svn_swig_rb_config_auth_walk_func)
#endif
/* -----------------------------------------------------------------------
* For all the various functions that set a callback baton create a reference
* for the baton (which in this case is an SV pointing to the callback)
* and make that a return from the function. The perl side should
* then store the return in the object the baton is attached to.
* If the function already returns a value then this value is follows that
* function. In the case of the prompt functions auth_open_helper in Core.pm
* is used to split up these values.
*/
#ifdef SWIGPERL
%typemap(argout) void *CALLBACK_BATON (SV * _global_callback) {
/* callback baton */
%append_output(sv_2mortal(newRV_inc(_global_callback)));
}
%typemap(in) void *CALLBACK_BATON (SV * _global_callback) {
_global_callback = $input;
$1 = (void *) _global_callback;
}
%apply void *CALLBACK_BATON {
void *prompt_baton
};
#endif
/* -----------------------------------------------------------------------
These APIs take an "inout" parameter that necessitates more careful
definition.
*/
%ignore svn_mergeinfo_merge;
%ignore svn_mergeinfo_sort;
%ignore svn_rangelist_merge;
%ignore svn_rangelist_reverse;
#ifdef SWIGRUBY
%ignore svn_auth_open;
%ignore svn_diff_file_options_create;
%ignore svn_create_commit_info;
%ignore svn_commit_info_dup;
%ignore svn_opt_args_to_target_array2;
%ignore svn_opt_args_to_target_array3;
%ignore svn_opt_parse_num_args;
%ignore svn_opt_parse_all_args;
#endif
#ifdef SWIGPYTHON
# The auth baton depends on the providers, so we preserve a
# reference to them inside the wrapper. This way, if all external
# references to the providers are gone, they will still be alive,
# keeping the baton valid.
%feature("pythonappend") svn_auth_open %{
val.__dict__["_deps"] = list(args[0])
%}
#endif
/* ----------------------------------------------------------------------- */
%include svn_error_codes_h.swg
%include svn_time_h.swg
%include svn_types_h.swg
%include svn_pools_h.swg
%include svn_version_h.swg
/* The constant SVN_PROP_REVISION_ALL_PROPS is a C fragment, not a single
data value, so the SWIG parser will raise a 305 warning if we don't
suppress it. */
#pragma SWIG nowarn=305
%include svn_props_h.swg
#pragma SWIG nowarn=+305
%include svn_opt_h.swg
%include svn_cmdline_h.swg
%include svn_auth_h.swg
%include svn_config_h.swg
%include svn_utf_h.swg
%include svn_nls_h.swg
( run in 0.404 second using v1.01-cache-2.11-cpan-97f6503c9c8 )