joes 2004/07/18 16:24:51
Modified: glue/perl/t/response/TestApReq request.pm
glue/perl/xsbuilder apreq_xs_tables.h
glue/perl/xsbuilder/Apache/Cookie Apache__Cookie.h
glue/perl/xsbuilder/Apache/Request Apache__Request.h
glue/perl/xsbuilder/Apache/Upload Apache__Upload.h
glue/perl/xsbuilder/maps apreq_functions.map
Log:
Add $table->do, so the callbacks for Apache::Cookie::Table and
Apache::Upload::Table receive the corresponding objects in their second
argument.
Revision Changes Path
1.33 +9 -0 httpd-apreq-2/glue/perl/t/response/TestApReq/request.pm
Index: request.pm
===================================================================
RCS file: /home/cvs/httpd-apreq-2/glue/perl/t/response/TestApReq/request.pm,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- request.pm 14 Jul 2004 17:58:18 -0000 1.32
+++ request.pm 18 Jul 2004 23:24:51 -0000 1.33
@@ -176,6 +176,15 @@
$test_string eq
"test=disable_uploads;foo=bar1;foo=bar2;";
}
+ # TABLE DO TESTS
+ {
+ my $do_data = "";
+ $args->do( sub { $do_data .= "@_"; 1 } );
+ die "do() test failed: '$do_data'" unless
+ $do_data eq "test disable_uploadsfoo bar1foo bar2";
+ }
+
+
[EMAIL PROTECTED]>print("ok");
}
}
1.25 +69 -2 httpd-apreq-2/glue/perl/xsbuilder/apreq_xs_tables.h
Index: apreq_xs_tables.h
===================================================================
RCS file: /home/cvs/httpd-apreq-2/glue/perl/xsbuilder/apreq_xs_tables.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- apreq_xs_tables.h 15 Jul 2004 16:05:53 -0000 1.24
+++ apreq_xs_tables.h 18 Jul 2004 23:24:51 -0000 1.25
@@ -193,7 +193,7 @@
struct apreq_xs_do_arg {
void *env;
- SV *parent;
+ SV *parent, *sub;
PerlInterpreter *perl;
};
@@ -266,7 +266,7 @@
{ \
dXSARGS; \
const char *key = NULL; \
- struct apreq_xs_do_arg d = { NULL, NULL, aTHX }; \
+ struct apreq_xs_do_arg d = { NULL, NULL, NULL, aTHX }; \
void *env; \
SV *sv, *obj; \
\
@@ -399,6 +399,73 @@
sv = newSVpv(te[idx].key, 0); \
ST(0) = sv_2mortal(sv); \
XSRETURN(1); \
+}
+
+
+#define APREQ_XS_DEFINE_TABLE_DO(attr,type,subclass) \
+static int apreq_xs_##attr##_do_sub(void *data, const char *key, \
+ const char *val) \
+{ \
+ struct apreq_xs_do_arg *d = data; \
+ apreq_##type##_t *RETVAL = apreq_value_to_##type( \
+ apreq_strtoval(val)); \
+ dTHXa(d->perl); \
+ dSP; \
+ void *env; \
+ int rv; \
+ \
+ env = d->env; \
+ \
+ ENTER; \
+ SAVETMPS; \
+ \
+ PUSHMARK(SP); \
+ EXTEND(SP,2); \
+ PUSHs(sv_2mortal(newSVpv(key,0))); \
+ PUSHs(sv_2mortal(apreq_xs_##type##2sv(RETVAL, subclass, \
+ d->parent))); \
+ PUTBACK; \
+ rv = call_sv(d->sub, G_SCALAR); \
+ SPAGAIN; \
+ rv = (1 == rv) ? POPi : 1; \
+ PUTBACK; \
+ FREETMPS; \
+ LEAVE; \
+ \
+ return rv; \
+} \
+ \
+static XS(apreq_xs_##attr##_do) \
+{ \
+ dXSARGS; \
+ struct apreq_xs_do_arg d = { NULL, NULL, NULL, aTHX }; \
+ apr_table_t *t; \
+ void *env; \
+ int i, rv; \
+ SV *sv, *obj; \
+ \
+ if (items < 2 || !SvROK(ST(0)) || !SvROK(ST(1))) \
+ Perl_croak(aTHX_ "Usage: $object->do(\\&callback, @keys)"); \
+ sv = ST(0); \
+ obj = apreq_xs_find_obj(aTHX_ sv, #attr); \
+ env = apreq_xs_##attr##_sv2env(obj); \
+ t = apreq_xs_##attr##_sv2table(obj); \
+ d.env = env; \
+ d.parent = obj; \
+ d.sub = ST(1); \
+ \
+ if (items == 2) { \
+ rv = apr_table_do(apreq_xs_##attr##_do_sub, &d, t, NULL); \
+ XSRETURN_IV(rv); \
+ } \
+ \
+ for (i = 2; i < items; ++i) { \
+ const char *key = SvPV_nolen(ST(i)); \
+ rv = apr_table_do(apreq_xs_##attr##_do_sub, &d, t, key, NULL); \
+ if (rv == 0) \
+ break; \
+ } \
+ XSRETURN_IV(rv); \
}
1.29 +1 -1
httpd-apreq-2/glue/perl/xsbuilder/Apache/Cookie/Apache__Cookie.h
Index: Apache__Cookie.h
===================================================================
RCS file:
/home/cvs/httpd-apreq-2/glue/perl/xsbuilder/Apache/Cookie/Apache__Cookie.h,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- Apache__Cookie.h 13 Jul 2004 15:59:35 -0000 1.28
+++ Apache__Cookie.h 18 Jul 2004 23:24:51 -0000 1.29
@@ -71,7 +71,7 @@
APREQ_XS_DEFINE_TABLE_GET(jar, TABLE_PKG, cookie, COOKIE_PKG, 1);
APREQ_XS_DEFINE_TABLE_GET(table, TABLE_PKG, cookie, COOKIE_PKG, 1);
APREQ_XS_DEFINE_TABLE_FETCH(table, cookie, COOKIE_PKG);
-
+APREQ_XS_DEFINE_TABLE_DO(table, cookie, COOKIE_PKG);
APREQ_XS_DEFINE_POOL(jar);
APREQ_XS_DEFINE_POOL(table);
1.47 +1 -1
httpd-apreq-2/glue/perl/xsbuilder/Apache/Request/Apache__Request.h
Index: Apache__Request.h
===================================================================
RCS file:
/home/cvs/httpd-apreq-2/glue/perl/xsbuilder/Apache/Request/Apache__Request.h,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -r1.46 -r1.47
--- Apache__Request.h 14 Jul 2004 03:54:53 -0000 1.46
+++ Apache__Request.h 18 Jul 2004 23:24:51 -0000 1.47
@@ -137,7 +137,7 @@
APREQ_XS_DEFINE_TABLE_GET(request_body, PARAM_TABLE, param, NULL, 1);
APREQ_XS_DEFINE_TABLE_GET(table, PARAM_TABLE, param, NULL, 1);
APREQ_XS_DEFINE_TABLE_FETCH(table, param, NULL);
-
+APREQ_XS_DEFINE_TABLE_DO(table, param, NULL);
APREQ_XS_DEFINE_TABLE_NEXTKEY(table);
APREQ_XS_DEFINE_POOL(request);
1.26 +1 -1
httpd-apreq-2/glue/perl/xsbuilder/Apache/Upload/Apache__Upload.h
Index: Apache__Upload.h
===================================================================
RCS file:
/home/cvs/httpd-apreq-2/glue/perl/xsbuilder/Apache/Upload/Apache__Upload.h,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- Apache__Upload.h 13 Jul 2004 15:59:35 -0000 1.25
+++ Apache__Upload.h 18 Jul 2004 23:24:51 -0000 1.26
@@ -106,7 +106,7 @@
APREQ_XS_DEFINE_TABLE_GET(request_upload, UPLOAD_TABLE, param, UPLOAD_PKG,
RETVAL->bb);
APREQ_XS_DEFINE_TABLE_GET(upload_table, UPLOAD_TABLE, param, UPLOAD_PKG, 1);
APREQ_XS_DEFINE_TABLE_FETCH(upload_table, param, UPLOAD_PKG);
-
+APREQ_XS_DEFINE_TABLE_DO(upload_table, param, UPLOAD_PKG);
APREQ_XS_DEFINE_ENV(upload);
APREQ_XS_DEFINE_POOL(upload_table);
1.32 +3 -1
httpd-apreq-2/glue/perl/xsbuilder/maps/apreq_functions.map
Index: apreq_functions.map
===================================================================
RCS file:
/home/cvs/httpd-apreq-2/glue/perl/xsbuilder/maps/apreq_functions.map,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- apreq_functions.map 13 Jul 2004 15:59:35 -0000 1.31
+++ apreq_functions.map 18 Jul 2004 23:24:51 -0000 1.32
@@ -23,6 +23,7 @@
DEFINE_new | apreq_xs_table_request_make |
DEFINE_NEXTKEY | apreq_xs_table_NEXTKEY |
DEFINE_FIRSTKEY | apreq_xs_table_NEXTKEY |
+ DEFINE_do | apreq_xs_table_do |
########## Apache::Upload:: Functions ##########
@@ -47,6 +48,7 @@
DEFINE_new | apreq_xs_table_request_make |
DEFINE_NEXTKEY | apreq_xs_upload_table_NEXTKEY |
DEFINE_FIRSTKEY | apreq_xs_upload_table_NEXTKEY |
+ DEFINE_do | apreq_xs_upload_table_do |
MODULE=Apache::Upload PACKAGE=Apache::Request PREFIX=Apache__Request_
DEFINE_upload | apreq_xs_request_upload_get |
@@ -90,7 +92,7 @@
DEFINE_new | apreq_xs_table_jar_make |
DEFINE_NEXTKEY | apreq_xs_table_NEXTKEY |
DEFINE_FIRSTKEY | apreq_xs_table_NEXTKEY |
-
+ DEFINE_do | apreq_xs_table_do |
########## Utility Functions ##########