On Tue, Oct 09, 2001 at 01:06:43PM +0800, Philippe M. Chiasson wrote: > Here is $r->pnotes() implementes, mostly stolen from 1.x but it works and all > tests pass fine for me.
But darn, it leaks memory, as the pnotes HV never gets freed. Please wait
for an updated patch later...
Oupss...
> /home/gozer/sources/mod_perl2/deps/perl/bin/perl build/cvsdiff
> Index: t/response/TestAPI/request_rec.pm
> ===================================================================
> RCS file: /home/anoncvs/mod_perl-2-cvs/t/response/TestAPI/request_rec.pm,v
> retrieving revision 1.8
> diff -u -I'$Id' -I'$Revision' -r1.8 request_rec.pm
> --- t/response/TestAPI/request_rec.pm 2001/09/28 20:11:02 1.8
> +++ t/response/TestAPI/request_rec.pm 2001/10/09 04:54:25
> @@ -11,7 +11,7 @@
> sub handler {
> my $r = shift;
>
> - plan $r, tests => 48;
> + plan $r, tests => 53;
>
> #Apache->request($r); #PerlOptions +GlobalRequest takes care
> my $gr = Apache->request;
> @@ -78,7 +78,17 @@
> ok $r->subprocess_env;
>
> ok $r->notes;
> -
> +
> + ok $r->pnotes;
> +
> + ok t_cmp('HASH', ref($r->pnotes), qq{ref($r->pnotes)});
> +
> + ok t_cmp(undef, $r->pnotes('pnotes_foo','pnotes_bar'),
>qq{\$r->pnotes(key,val)});
> +
> + ok t_cmp("pnotes_bar", $r->pnotes('pnotes_foo') , qq{\$r->pnotes(key)});
> +
> + ok t_cmp('pnotes_bar', $r->pnotes()->{'pnotes_foo'}, qq{\$r->pnotes()->{}});
> +
> ok $r->content_type;
>
> ok $r->handler;
>
> Index: todo/api.txt
> ===================================================================
> RCS file: /home/anoncvs/mod_perl-2-cvs/todo/api.txt,v
> retrieving revision 1.8
> diff -u -I'$Id' -I'$Revision' -r1.8 api.txt
> --- todo/api.txt 2001/10/06 01:03:27 1.8
> +++ todo/api.txt 2001/10/09 04:54:25
> @@ -9,9 +9,6 @@
> need apr_finfo_t <-> struct stat conversion (might already be there,
> haven't looked close enough yet)
>
> -$r->pnotes:
> -not yet implemented
> -
> $r->subprocess_env:
> in void context should populate %ENV as 1.x does
>
>
> Index: xs/Apache/RequestUtil/Apache__RequestUtil.h
> ===================================================================
> RCS file: /home/anoncvs/mod_perl-2-cvs/xs/Apache/RequestUtil/Apache__RequestUtil.h,v
> retrieving revision 1.7
> diff -u -I'$Id' -I'$Revision' -r1.7 Apache__RequestUtil.h
> --- xs/Apache/RequestUtil/Apache__RequestUtil.h 2001/09/28 20:11:02 1.7
> +++ xs/Apache/RequestUtil/Apache__RequestUtil.h 2001/10/09 04:54:26
> @@ -177,5 +177,41 @@
> return retval;
> }
>
> +
> +static MP_INLINE
> +SV *mpxs_Apache__RequestRec_pnotes(pTHX_ request_rec *r, SV *k, SV *val)
> +{
> + MP_dRCFG;
> + char *key = NULL;
> + SV *retval = &PL_sv_undef;
> + STRLEN len;
> +
> + if (!rcfg)
> + return retval;
> +
> + if (!rcfg->pnotes)
> + rcfg->pnotes = newHV();
> +
> + if (k)
> + key = SvPV(k, len);
> +
> + if (key) {
> + if (hv_exists(rcfg->pnotes, key, len)) {
> + retval = SvREFCNT_inc(*hv_fetch(rcfg->pnotes, key, len, FALSE));
> + sv_2mortal(retval);
> + }
> +
> + if (val) {
> + hv_store(rcfg->pnotes, key, len, SvREFCNT_inc(val), FALSE);
> + }
> + }
> + else {
> + retval = newRV_inc((SV *)rcfg->pnotes);
> + SvREFCNT_inc(sv_2mortal(retval));
> + }
> +
> + return retval;
> +}
> +
> #define mpxs_Apache__RequestRec_dir_config(r, key, sv_val) \
> modperl_dir_config(aTHX_ r, r->server, key, sv_val)
>
> Index: xs/maps/modperl_functions.map
> ===================================================================
> RCS file: /home/anoncvs/mod_perl-2-cvs/xs/maps/modperl_functions.map,v
> retrieving revision 1.21
> diff -u -I'$Id' -I'$Revision' -r1.21 modperl_functions.map
> --- xs/maps/modperl_functions.map 2001/10/07 23:02:41 1.21
> +++ xs/maps/modperl_functions.map 2001/10/09 04:54:26
> @@ -8,6 +8,8 @@
> mpxs_Apache__RequestRec_push_handlers
> mpxs_Apache__RequestRec_set_handlers
> mpxs_Apache__RequestRec_get_handlers
> +SV *:DEFINE_pnotes | mpxs_Apache__RequestRec_pnotes | request_rec *:r, SV
>*:key=NULL, SV *:value=NULL
> +
>
> #protocol module helpers
> mpxs_Apache__RequestRec_location_merge
>
>
>
> --
> Philippe M. Chiasson <[EMAIL PROTECTED]>
> Extropia's Resident System Guru
> http://www.eXtropia.com/
>
> There are many ways to make yourself unforgetable. And you
> can just forget about most of 'em.
> -- Larry Wall
>
> perl -e '$$=\${gozer};{$_=unpack(P26,pack(L,$$));/^Just Another Perl
>Hacker!\n$/&&print||$$++&&redo}'
--
Philippe M. Chiasson <[EMAIL PROTECTED]>
Extropia's Resident System Guru
http://www.eXtropia.com/
There are many ways to make yourself unforgetable. And you
can just forget about most of 'em.
-- Larry Wall
perl -e '$$=\${gozer};{$_=unpack(P26,pack(L,$$));/^Just Another Perl
Hacker!\n$/&&print||$$++&&redo}'
msg01991/pgp00000.pgp
Description: PGP signature
