96
102
return (void *)result;
105
static void *convert_pl_svn_string_t(SV *value, void *dummy, apr_pool_t *pool)
107
svn_string_t *result = apr_palloc(pool, sizeof(svn_string_t));
108
/* just the in typemap for svn_string_t */
109
result->data = SvPV(value, result->len);
110
return (void *)result;
113
/* Convert a revision range and return a svn_opt_revision_range_t*.
115
* - a _p_svn_opt_revision_range_t object
116
* - a reference to a two-element array, [start, end],
117
* where start and end is anything accepted by svn_swig_pl_set_revision
118
* If value is not acceptable and *(svn_boolean_t *)ctx is FALSE,
119
* convert_pl_revision_range returns NULL, otherwise it croak()s.
121
static void *convert_pl_revision_range(SV *value, void *ctx, apr_pool_t *pool)
123
svn_boolean_t croak_on_error = *(svn_boolean_t *)ctx;
125
if (sv_isobject(value) && sv_derived_from(value, "_p_svn_opt_revision_range_t")) {
126
svn_opt_revision_range_t *range;
127
/* this will assign to range */
128
SWIG_ConvertPtr(value, (void **)&range, _SWIG_TYPE("svn_opt_revision_range_t *"), 0);
133
&& SvTYPE(SvRV(value)) == SVt_PVAV
134
&& av_len((AV *)SvRV(value)) == 1) {
135
/* value is a two-element ARRAY */
136
AV* array = (AV *)SvRV(value);
137
svn_opt_revision_t temp_start, temp_end;
138
svn_opt_revision_t *start, *end;
139
svn_opt_revision_range_t *range;
141
/* Note: Due to how svn_swig_pl_set_revision works,
142
* either the passed in svn_opt_revision_t is modified
143
* (and the original pointer returned) or a different pointer
144
* is returned. svn_swig_pl_set_revision may return NULL
145
* only if croak_on_error is FALSE.
147
start = svn_swig_pl_set_revision(&temp_start,
148
*av_fetch(array, 0, 0), croak_on_error);
151
end = svn_swig_pl_set_revision(&temp_end,
152
*av_fetch(array, 1, 0), croak_on_error);
156
/* allocate a new range and copy in start and end fields */
157
range = apr_palloc(pool, sizeof(*range));
158
range->start = *start;
164
croak("unknown revision range: "
165
"must be an array of length 2 whose elements are acceptable "
166
"as opt_revision_t or a _p_svn_opt_revision_range_t object");
99
170
/* perl -> c hash convertors */
100
171
static apr_hash_t *svn_swig_pl_to_hash(SV *source,
101
172
pl_element_converter_t cv,
117
188
SV* item = hv_iternextsv(h, &key, &retlen);
118
189
void *val = cv(item, ctx, pool);
119
apr_hash_set(hash, apr_pstrmemdup(pool, key, retlen), retlen, val);
190
svn_hash_sets(hash, apr_pstrmemdup(pool, key, retlen), val);
281
/* Convert a single revision range or an array of revisions ranges
282
* Note: We can't simply use svn_swig_pl_to_array() as is, since
283
* it immediatley checks whether source is an array reference and then
284
* proceeds to treat this as the "array of ..." case. But a revision range
285
* may be specified as a (two-element) array. Hence we first try to
286
* convert source as a single revision range. Failing that and if it's
287
* an array we then call svn_swig_pl_to_array(). Otherwise we croak().
289
const apr_array_header_t *svn_swig_pl_array_to_apr_array_revision_range(
290
SV *source, apr_pool_t *pool)
292
svn_boolean_t croak_on_error = FALSE;
293
svn_opt_revision_range_t *range;
295
if (range = convert_pl_revision_range(source, &croak_on_error, pool)) {
296
apr_array_header_t *temp = apr_array_make(pool, 1,
297
sizeof(svn_opt_revision_range_t *));
299
APR_ARRAY_IDX(temp, 0, svn_opt_revision_range_t *) = range;
303
if (SvROK(source) && SvTYPE(SvRV(source)) == SVt_PVAV) {
304
croak_on_error = TRUE;
305
return svn_swig_pl_to_array(source, convert_pl_revision_range,
306
&croak_on_error, pool);
309
croak("must pass a single revision range or a reference to an array of revision ranges");
311
/* This return is actually unreachable because of the croak above,
312
* however, Visual Studio's compiler doesn't like if all paths don't have
313
* a return and errors out otherwise. */
205
317
/* element convertors for c -> perl */
206
318
typedef SV *(*element_converter_t)(void *value, void *ctx);
422
SV *svn_swig_pl_revnums_to_list(const apr_array_header_t *array)
424
return convert_array(array, (element_converter_t)convert_svn_revnum_t,
428
/* perl -> c svn_opt_revision_t conversion */
429
svn_opt_revision_t *svn_swig_pl_set_revision(svn_opt_revision_t *rev,
431
svn_boolean_t croak_on_error)
433
#define maybe_croak(argv) do { if (croak_on_error) croak argv; \
434
else return NULL; } while (0)
436
if (source == NULL || source == &PL_sv_undef || !SvOK(source)) {
437
rev->kind = svn_opt_revision_unspecified;
439
else if (sv_isobject(source) && sv_derived_from(source, "_p_svn_opt_revision_t")) {
440
/* this will assign to rev */
441
SWIG_ConvertPtr(source, (void **)&rev, _SWIG_TYPE("svn_opt_revision_t *"), 0);
443
else if (looks_like_number(source)) {
444
rev->kind = svn_opt_revision_number;
445
rev->value.number = SvIV(source);
447
else if (SvPOK(source)) {
448
char *input = SvPV_nolen(source);
449
if (svn_cstring_casecmp(input, "BASE") == 0)
450
rev->kind = svn_opt_revision_base;
451
else if (svn_cstring_casecmp(input, "HEAD") == 0)
452
rev->kind = svn_opt_revision_head;
453
else if (svn_cstring_casecmp(input, "WORKING") == 0)
454
rev->kind = svn_opt_revision_working;
455
else if (svn_cstring_casecmp(input, "COMMITTED") == 0)
456
rev->kind = svn_opt_revision_committed;
457
else if (svn_cstring_casecmp(input, "PREV") == 0)
458
rev->kind = svn_opt_revision_previous;
459
else if (*input == '{') {
460
svn_boolean_t matched;
464
char *end = strchr(input,'}');
466
maybe_croak(("unknown opt_revision_t string \"%s\": "
467
"missing closing brace for \"{DATE}\"", input));
469
err = svn_parse_date (&matched, &tm, input + 1, apr_time_now(),
470
svn_swig_pl_make_pool ((SV *)NULL));
472
svn_error_clear (err);
473
maybe_croak(("unknown opt_revision_t string \"{%s}\": "
474
"internal svn_parse_date error", input + 1));
477
maybe_croak(("unknown opt_revision_t string \"{%s}\": "
478
"svn_parse_date failed to parse it", input + 1));
480
rev->kind = svn_opt_revision_date;
481
rev->value.date = tm;
483
maybe_croak(("unknown opt_revision_t string \"%s\": must be one of "
484
"\"BASE\", \"HEAD\", \"WORKING\", \"COMMITTED\", "
485
"\"PREV\" or a \"{DATE}\"", input));
487
maybe_croak(("unknown opt_revision_t type: must be undef, a number, "
488
"a string (one of \"BASE\", \"HEAD\", \"WORKING\", "
489
"\"COMMITTED\", \"PREV\" or a \"{DATE}\") "
490
"or a _p_svn_opt_revision_t object"));
304
496
/* put the va_arg in stack and invoke caller_func with func.
984
1210
return SVN_NO_ERROR;
1213
svn_error_t *svn_swig_pl_thunk_gnome_keyring_unlock_prompt(char **keyring_password,
1214
const char *keyring_name,
1220
/* The baton is the actual prompt function passed from perl, so we
1221
* call that one and process the result. */
1222
svn_swig_pl_callback_thunk(CALL_SV,
1226
if (!SvOK(result) || result == &PL_sv_undef) {
1227
*keyring_password = NULL;
1229
else if (SvPOK(result)) {
1230
*keyring_password = apr_pstrdup(pool, SvPV(result, len));
1233
SvREFCNT_dec(result);
1234
croak("not a string");
1237
SvREFCNT_dec(result);
1238
return SVN_NO_ERROR;
987
1241
svn_error_t *svn_swig_pl_thunk_simple_prompt(svn_auth_cred_simple_t **cred,
989
1243
const char *realm,
1517
/* Thunked version of svn_wc_status_func2_t callback type. */
1518
void svn_swig_pl_status_func2(void *baton,
1520
svn_wc_status2_t *status)
1522
swig_type_info *statusinfo = _SWIG_TYPE("svn_wc_status2 _t *");
1524
if (!SvOK((SV *)baton)) {
1528
svn_swig_pl_callback_thunk(CALL_SV, baton, NULL, "sS",
1529
path, status, statusinfo);
1533
/* Thunked version of svn_wc_status_func3_t callback type. */
1534
svn_error_t *svn_swig_pl_status_func3(void *baton,
1536
svn_wc_status2_t *status,
1540
svn_error_t *ret_val = SVN_NO_ERROR;
1542
swig_type_info *statusinfo = _SWIG_TYPE("svn_wc_status2 _t *");
1544
if (!SvOK((SV *)baton)) {
1548
svn_swig_pl_callback_thunk(CALL_SV, baton, &result, "sSS",
1549
path, status, statusinfo,
1552
if (sv_derived_from(result, "_p_svn_error_t")) {
1553
swig_type_info *errorinfo = _SWIG_TYPE("svn_error_t *");
1554
if (SWIG_ConvertPtr(result, (void *)&ret_val, errorinfo, 0) < 0) {
1555
SvREFCNT_dec(result);
1556
croak("Unable to convert from SWIG Type");
1560
SvREFCNT_dec(result);
1263
1565
/* Thunked version of svn_client_blame_receiver_t callback type. */
1264
1566
svn_error_t *svn_swig_pl_blame_func(void *baton,
1265
1567
apr_int64_t line_no,