Alien-SVN
view release on metacpan or search on metacpan
src/subversion/subversion/bindings/swig/perl/libsvn_swig_perl/swigutil_pl.c view on Meta::CPAN
case 'U': /* apr_uint64_t */
c = malloc(30);
snprintf(c,30,"%" APR_UINT64_T_FMT,va_arg(ap, apr_uint64_t));
XPUSHs(sv_2mortal(newSVpv(c, 0)));
free(c);
break;
case 'z': /* apr_size_t */
if (sizeof(apr_size_t) >= 8)
{
c = malloc(30);
snprintf(c,30,"%" APR_SIZE_T_FMT,va_arg(ap, apr_size_t));
XPUSHs(sv_2mortal(newSVpv(c, 0)));
free(c);
}
else
{
XPUSHs(sv_2mortal(newSViv(va_arg(ap, apr_size_t))));
}
break;
}
}
va_end(ap);
PUTBACK;
switch (caller_func) {
case CALL_SV:
count = call_sv(func, call_flags );
break;
case CALL_METHOD:
count = call_method(func, call_flags );
break;
default:
croak("unkonwn calling type");
break;
}
SPAGAIN ;
if (((call_flags & G_SCALAR) && count != 1) ||
((call_flags & G_VOID) && count != 0))
croak("Wrong number of returns");
if (result) {
*result = POPs;
SvREFCNT_inc(*result);
}
PUTBACK;
FREETMPS ;
LEAVE ;
return SVN_NO_ERROR;
}
/*** Editor Wrapping ***/
/* this could be more perlish */
typedef struct item_baton {
SV *editor; /* the editor handling the callbacks */
SV *baton; /* the dir/file baton (or NULL for edit baton) */
} item_baton;
static item_baton * make_baton(apr_pool_t *pool,
SV *editor, SV *baton)
{
item_baton *newb = apr_palloc(pool, sizeof(*newb));
newb->editor = editor;
newb->baton = baton;
return newb;
}
static svn_error_t * close_baton(void *baton, const char *method, apr_pool_t *pool)
{
item_baton *ib = baton;
if (ib->baton) {
SVN_ERR(svn_swig_pl_callback_thunk(CALL_METHOD,
(void *)method, NULL,
"OOS", ib->editor, ib->baton,
pool, POOLINFO));
SvREFCNT_dec(ib->baton);
}
else {
SVN_ERR(svn_swig_pl_callback_thunk(CALL_METHOD,
(void *)method, NULL,
"OS", ib->editor, pool, POOLINFO));
}
return SVN_NO_ERROR;
}
static svn_error_t * thunk_set_target_revision(void *edit_baton,
svn_revnum_t target_revision,
apr_pool_t *pool)
{
item_baton *ib = edit_baton;
SVN_ERR(svn_swig_pl_callback_thunk(CALL_METHOD,
(void *)"set_target_revision", NULL,
"Or", ib->editor, target_revision));
return SVN_NO_ERROR;
}
static svn_error_t * thunk_open_root(void *edit_baton,
svn_revnum_t base_revision,
apr_pool_t *dir_pool,
void **root_baton)
{
item_baton *ib = edit_baton;
SV *result;
SVN_ERR(svn_swig_pl_callback_thunk(CALL_METHOD,
(void *)"open_root", &result,
"OrS", ib->editor, base_revision,
dir_pool, POOLINFO));
src/subversion/subversion/bindings/swig/perl/libsvn_swig_perl/swigutil_pl.c view on Meta::CPAN
"SS",
commit_info, _SWIG_TYPE("svn_commit_info_t *"),
pool, POOLINFO);
return SVN_NO_ERROR;
}
/* Wrap RA */
static svn_error_t * thunk_open_tmp_file(apr_file_t **fp,
void *callback_baton,
apr_pool_t *pool)
{
SV *result;
swig_type_info *tinfo = _SWIG_TYPE("apr_file_t *");
svn_swig_pl_callback_thunk(CALL_METHOD, (void *)"open_tmp_file",
&result, "OS", callback_baton, pool, POOLINFO);
if (SWIG_ConvertPtr(result, (void *)fp, tinfo,0) < 0) {
croak("Unable to convert from SWIG Type");
}
SvREFCNT_dec(result);
return SVN_NO_ERROR;
}
svn_error_t *thunk_get_wc_prop(void *baton,
const char *relpath,
const char *name,
const svn_string_t **value,
apr_pool_t *pool)
{
SV *result;
char *data;
STRLEN len;
svn_swig_pl_callback_thunk(CALL_METHOD, (void *)"get_wc_prop",
&result, "OssS", baton, relpath, name,
pool, POOLINFO);
/* this is svn_string_t * typemap in */
if (!SvOK(result) || result == &PL_sv_undef) {
*value = NULL;
}
else if (SvPOK(result)) {
data = SvPV(result, len);
*value = svn_string_ncreate(data, len, pool);
}
else {
SvREFCNT_dec(result);
croak("not a string");
}
SvREFCNT_dec(result);
return SVN_NO_ERROR;
}
svn_error_t *svn_ra_make_callbacks(svn_ra_callbacks_t **cb,
void **c_baton,
SV *perl_callbacks,
apr_pool_t *pool)
{
SV *auth_baton;
*cb = apr_pcalloc(pool, sizeof(**cb));
(*cb)->open_tmp_file = thunk_open_tmp_file;
(*cb)->get_wc_prop = thunk_get_wc_prop;
(*cb)->set_wc_prop = NULL;
(*cb)->push_wc_prop = NULL;
(*cb)->invalidate_wc_props = NULL;
auth_baton = *hv_fetch((HV *)SvRV(perl_callbacks), "auth", 4, 0);
if (SWIG_ConvertPtr(auth_baton,
(void **)&(*cb)->auth_baton, _SWIG_TYPE("svn_auth_baton_t *"),0) < 0) {
croak("Unable to convert from SWIG Type");
}
*c_baton = perl_callbacks;
svn_swig_pl_hold_ref_in_pool(pool, perl_callbacks);
return SVN_NO_ERROR;
}
svn_error_t *svn_swig_pl_thunk_gnome_keyring_unlock_prompt(char **keyring_password,
const char *keyring_name,
void *baton,
apr_pool_t *pool)
{
SV *result;
STRLEN len;
/* The baton is the actual prompt function passed from perl, so we
* call that one and process the result. */
svn_swig_pl_callback_thunk(CALL_SV,
baton, &result,
"sS", keyring_name,
pool, POOLINFO);
if (!SvOK(result) || result == &PL_sv_undef) {
*keyring_password = NULL;
}
else if (SvPOK(result)) {
*keyring_password = apr_pstrdup(pool, SvPV(result, len));
}
else {
SvREFCNT_dec(result);
croak("not a string");
}
SvREFCNT_dec(result);
return SVN_NO_ERROR;
}
svn_error_t *svn_swig_pl_thunk_simple_prompt(svn_auth_cred_simple_t **cred,
void *baton,
const char *realm,
const char *username,
svn_boolean_t may_save,
apr_pool_t *pool)
{
/* Be nice and allocate the memory for the cred structure before passing it
* off to the perl space */
*cred = apr_pcalloc(pool, sizeof(**cred));
if (!*cred) {
croak("Could not allocate memory for cred structure");
}
svn_swig_pl_callback_thunk(CALL_SV,
baton, NULL,
"SssbS", *cred, _SWIG_TYPE("svn_auth_cred_simple_t *"),
realm, username, may_save, pool, POOLINFO);
return SVN_NO_ERROR;
}
svn_error_t *svn_swig_pl_thunk_username_prompt(svn_auth_cred_username_t **cred,
void *baton,
const char *realm,
svn_boolean_t may_save,
apr_pool_t *pool)
{
/* Be nice and allocate the memory for the cred structure before passing it
* off to the perl space */
( run in 3.131 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )