joes 2003/05/30 12:15:23
Modified: glue/perl/xsbuilder/maps apreq_functions.map
apreq_structures.map apreq_types.map
Added: glue/perl/xsbuilder apreq_xs_postperl.h
glue/perl/xsbuilder/Apache/Cookie Apache__Cookie.h
glue/perl/xsbuilder/Apache/Request Apache__Request.h
Request_pm
Log:
Add custom perl2c/c2perl converters.
Revision Changes Path
1.1 httpd-apreq-2/glue/perl/xsbuilder/apreq_xs_postperl.h
Index: apreq_xs_postperl.h
===================================================================
#ifndef APREQ_XS_POSTPERL_H
#define APREQ_XS_POSTPERL_H
/* conversion function template based on modperl-2's sv2request_rec */
#define APREQ_XS_DEFINE_SV2(type) \
static \
SV *apreq_xs_hv_find_##type(pTHX_ SV *in) \
{ \
static char *keys[] = { #type, "_" #type, NULL }; \
HV *hv = (HV *)SvRV(in); \
SV *sv = Nullsv; \
int i; \
\
for (i=0; keys[i]; i++) { \
int klen = i + 1; /* assumes keys[] will never change */ \
SV **svp; \
\
if ((svp = hv_fetch(hv, keys[i], klen, FALSE)) && (sv = *svp)) { \
if (SvROK(sv) && (SvTYPE(SvRV(sv)) == SVt_PVHV)) { \
/* dig deeper */ \
return apreq_xs_hv_find_##type(aTHX_ sv); \
} \
break; \
} \
} \
\
if (!sv) { \
Perl_croak(aTHX_ \
"`%s' object hash no `" #type "' key!", \
HvNAME(SvSTASH(SvRV(in)))); \
} \
\
return SvROK(sv) ? SvRV(sv) : sv; \
} \
APR_INLINE \
static \
apreq_##type##_t *apreq_xs_sv2##type(pTHX_ SV* in) \
{ \
SV *sv = Nullsv; \
MAGIC *mg; \
\
if (SvROK(in)) { \
SV *rv = (SV*)SvRV(in); \
switch (SvTYPE(rv)) { \
case SVt_PVHV: \
rv = apreq_xs_hv_find_##type(aTHX_ in); \
if (SvTYPE(rv) != SVt_PVIV) \
break; \
case SVt_PVIV: \
return (apreq_##type##_t *)SvIVX(rv); \
default: \
Perl_croak(aTHX_ "panic: unsupported apreq_" #type \
"_t type \%d", \
SvTYPE(rv)); \
} \
} \
return NULL; \
} \
APR_INLINE \
static \
SV *apreq_xs_##type##2sv(apreq_##type##_t *t) \
{ \
SV *sv = newSViv(0); \
SvUPGRADE(sv, SVt_PVIV); \
SvGROW(sv, sizeof *t); \
SvIVX(sv) = (IV)t; \
SvIOK_on(sv); \
SvPOK_on(sv); \
return sv; \
}
#define APREQ_XS_DEFINE_TIEDSV(type, class) \
static int apreq_xs_##type##_free(SV* sv, MAGIC *mg); \
const static MGVTBL apreq_xs_##type##_magic = { 0, 0, 0, 0, \
apreq_xs_##type##_free }; \
\
static int apreq_xs_##type##_free(SV* sv, MAGIC *mg) \
{ \
/* need to prevent perl from freeing the apreq value */ \
SvPVX(sv) = NULL; \
SvCUR_set(sv,0); \
SvPOK_off(sv); \
return 0; \
} \
\
\
APR_INLINE \
static SV *apreq_xs_##type##2sv(apreq_##type##_t *t) \
{ \
SV *sv = newSV(0); \
SvUPGRADE(sv, SVt_PV); \
SvPVX(sv) = t->v.data; \
SvCUR_set(sv, t->v.size); \
\
sv_magicext(sv, NULL, PERL_MAGIC_tiedscalar, \
(MGVTBL *)&apreq_xs_##type##_magic, (char *)t, 0); \
\
/* disable get/set magic (only use "free" magic) */ \
SvSMAGICAL_off(sv); \
SvGMAGICAL_off(sv); \
SvRMAGICAL_on(sv); \
\
/* initialize sv as an object, so "tied" will return object ref */ \
SvSTASH(sv) = gv_stashpv(class, TRUE); \
SvOBJECT_on(sv); \
\
SvREADONLY_on(sv); \
SvTAINT(sv); \
return sv; \
} \
APR_INLINE \
static apreq_##type##_t *apreq_xs_sv2##type(pTHX_ SV *sv) \
{ \
return apreq_value_to_##type(apreq_strtoval(SvPVX(sv))); \
}
#endif /* APREQ_XS_POSTPERL_H */
1.1
httpd-apreq-2/glue/perl/xsbuilder/Apache/Cookie/Apache__Cookie.h
Index: Apache__Cookie.h
===================================================================
APREQ_XS_DEFINE_SV2(jar);
APREQ_XS_DEFINE_TIEDSV(cookie, "Apache::Cookie");
1.1
httpd-apreq-2/glue/perl/xsbuilder/Apache/Request/Apache__Request.h
Index: Apache__Request.h
===================================================================
APREQ_XS_DEFINE_SV2(request);
APREQ_XS_DEFINE_TIEDSV(param, "Apache::Request::Param");
1.1
httpd-apreq-2/glue/perl/xsbuilder/Apache/Request/Request_pm
Index: Request_pm
===================================================================
# local customizations for Apache::Request
package Apache::Request::Value;
package Apache::Request;
sub new
{
my $req = Apache::Request::request(shift);
# parse @_ to configure $req
return $req;
}
1.2 +1 -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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- apreq_functions.map 27 May 2003 10:06:48 -0000 1.1
+++ apreq_functions.map 30 May 2003 19:15:22 -0000 1.2
@@ -33,7 +33,7 @@
apreq_add_cookie
-MODULE=Apache::Request PACKAGE=Apache::Request::Utils PREFIX=apreq_
+MODULE=Apache::Request PACKAGE=Apache::Request::Util PREFIX=apreq_
apreq_log
apreq_join
apreq_index
1.2 +13 -29
httpd-apreq-2/glue/perl/xsbuilder/maps/apreq_structures.map
Index: apreq_structures.map
===================================================================
RCS file:
/home/cvs/httpd-apreq-2/glue/perl/xsbuilder/maps/apreq_structures.map,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- apreq_structures.map 27 May 2003 10:06:48 -0000 1.1
+++ apreq_structures.map 30 May 2003 19:15:22 -0000 1.2
@@ -7,12 +7,12 @@
disable_uploads
</apreq_cfg_t>
-<apreq_value_t MODULE=Apache::Request>
- name
- status
- size
-! data[1]
-</apreq_value_t>
+#<apreq_value_t MODULE=Apache::Request>
+# name
+# status
+# size
+# data[1]
+#</apreq_value_t>
<apreq_param_t MODULE=Apache::Request>
! charset
@@ -22,7 +22,7 @@
! v
</apreq_param_t>
-<apreq_request_t>
+<apreq_request_t MODULE=Apache::Request>
args
body
! parser
@@ -30,22 +30,22 @@
! env
</apreq_request_t>
-<apreq_cookie_t>
+<apreq_cookie_t MODULE=Apache::Cookie>
! version
path
domain
port
! secure
-! comment
-! commentURL
+ comment
+ commentURL
! time
! v
</apreq_cookie_t>
<apreq_jar_t MODULE=Apache::Cookie>
cookies
-> pool
-> env
+ pool
+ env
</apreq_jar_t>
@@ -56,25 +56,9 @@
ctx
</apreq_hook_t>
-<apreq_parser_t MODULE=Apache::Request>
+!<apreq_parser_t MODULE=Apache::Request>
parser
content_type
hook
> ctx
</apreq_parser_t>
-
-
-!<apr_array_header_t>
-> pool
-> elt_size
- nelts
-> nalloc
- elts
-</apr_array_header_t>
-
-!<apr_table_entry_t>
- key
- val
-> key_checksum
-</apr_table_entry_t>
-
1.2 +4 -5 httpd-apreq-2/glue/perl/xsbuilder/maps/apreq_types.map
Index: apreq_types.map
===================================================================
RCS file: /home/cvs/httpd-apreq-2/glue/perl/xsbuilder/maps/apreq_types.map,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- apreq_types.map 27 May 2003 10:06:48 -0000 1.1
+++ apreq_types.map 30 May 2003 19:15:22 -0000 1.2
@@ -9,8 +9,7 @@
#struct apr_hash_t | APR::Hash
#apr_hash_index_t | APR::HashIndex
-struct apreq_value_t | Apache::Request::Value
-struct apreq_param_t | Apache::Request::Param
-struct apreq_cookie_t | Apache::Cookie
-struct apreq_request_t | Apache::Request
-struct apreq_jar_t | Apache::Cookie::Jar
+struct apreq_param_t | Apache::Request::Param | T_APREQ_PARAM
+struct apreq_request_t | Apache::Request | T_APREQ_REQUEST
+struct apreq_jar_t | Apache::Cookie::Jar | T_APREQ_JAR
+struct apreq_cookie_t | Apache::Cookie | T_APREQ_COOKIE