[svn:mod_parrot] r255 - in mod_parrot/trunk: lib/Apache t t/conf t/lib

[email protected]
Newsgroups perl.cvs.mod_parrot
Message-ID <[email protected]>
Author: jhorwitz
Date: Mon Sep 17 13:03:35 2007
New Revision: 255

Modified:
   mod_parrot/trunk/lib/Apache/RequestRec.pir
   mod_parrot/trunk/t/01RequestRec.t
   mod_parrot/trunk/t/conf/extra.conf.in
   mod_parrot/trunk/t/lib/handlers.pir

Log:
implement pmc_notes


Modified: mod_parrot/trunk/lib/Apache/RequestRec.pir
==============================================================================
--- mod_parrot/trunk/lib/Apache/RequestRec.pir	(original)
+++ mod_parrot/trunk/lib/Apache/RequestRec.pir	Mon Sep 17 13:03:35 2007
@@ -50,6 +50,7 @@
 
     newpdd15class rr_class, [ 'Apache'; 'RequestRec' ]
     addattribute rr_class, 'r'
+    addattribute rr_class, 'pmc_notes'
 
     dlfunc func, nul, "ap_rputs", "itp"
     set_root_global [ 'Apache'; 'NCI' ], "ap_rputs", func
@@ -79,10 +80,14 @@
 .sub init :vtable :method
     .local pmc request_rec
     .local pmc r
+    .local pmc pmc_notes
 
     request_rec = get_root_global [ '_modparrot'; 'NCI' ], 'request_rec'
     r = request_rec( )
     setattribute self, 'r', r
+
+    pmc_notes = new .Hash
+    setattribute self, 'pmc_notes', pmc_notes
 .end
 
 #.sub init_pmc :vtable :method
@@ -461,6 +466,34 @@
 
 =back
 
+=item C<PMC pmc_notes()>
+
+=over 4
+
+Get or set a PMC note.  Use this for storing notes more complex than a string.
+Only mod_parrot languages have access to PMC notes.
+
+=back
+
+=cut
+
+.sub pmc_notes :method
+    .param string key
+    .param pmc val :optional
+    .param int update_val :opt_flag
+    .local pmc pmc_notes
+
+    getattribute pmc_notes, self, 'pmc_notes'
+
+    if update_val == 0 goto FETCH_VAL
+    pmc_notes[key] = val
+
+FETCH_VAL:
+    val = pmc_notes[key]
+
+    .return(val)
+.end
+
 =head1 AUTHOR
 
 Jeff Horwitz

Modified: mod_parrot/trunk/t/01RequestRec.t
==============================================================================
--- mod_parrot/trunk/t/01RequestRec.t	(original)
+++ mod_parrot/trunk/t/01RequestRec.t	Mon Sep 17 13:03:35 2007
@@ -7,7 +7,7 @@
 
 my $content;
 
-plan tests => 35, (need_lwp);
+plan tests => 36, (need_lwp);
 
 # Apache::RequestRec->content_type
 my $res = GET '/parrot-test/RequestRec-content_type';
@@ -39,6 +39,11 @@
 chomp($content = $res->content);
 is($content, 'bar', 'notes');
 
+# Apache::RequestRec->pmc_notes
+$res = GET '/parrot-test/RequestRec-pmc_notes';
+chomp($content = $res->content);
+is($content, 'testing 123', 'pmc_notes');
+
 # Apache::RequestRec->status
 $res = GET '/parrot-test/RequestRec-status';
 is($res->code, 201, 'status');

Modified: mod_parrot/trunk/t/conf/extra.conf.in
==============================================================================
--- mod_parrot/trunk/t/conf/extra.conf.in	(original)
+++ mod_parrot/trunk/t/conf/extra.conf.in	Mon Sep 17 13:03:35 2007
@@ -45,6 +45,12 @@
     ParrotHandler ModParrot::Test::notes
 </Location>
 
+<Location /parrot-test/RequestRec-pmc_notes>
+    SetHandler parrot-code
+    ParrotLanguage PIR
+    ParrotHandler ModParrot::Test::pmc_notes
+</Location>
+
 <Location /parrot-test/RequestRec-status>
     SetHandler parrot-code
     ParrotLanguage PIR

Modified: mod_parrot/trunk/t/lib/handlers.pir
==============================================================================
--- mod_parrot/trunk/t/lib/handlers.pir	(original)
+++ mod_parrot/trunk/t/lib/handlers.pir	Mon Sep 17 13:03:35 2007
@@ -564,6 +564,25 @@
     .return($I0)
 .end
 
+.namespace [ 'ModParrot::Test::pmc_notes' ]
+
+.sub _handler
+    .param pmc r
+    .local pmc ap_const
+
+    $P0 = new String
+    $P0 = 'testing 123'
+    r.'pmc_notes'('test', $P0)
+    $P1 = r.'pmc_notes'('test')
+    $S0 = $P1
+    r.'puts'($S0)
+
+    ap_const = get_root_global [ 'Apache'; 'Constants' ], 'ap_constants'
+    $I0 = ap_const['OK']
+
+    .return($I0)
+.end
+
 .namespace [ 'ModParrot::Test::status' ]
 
 .sub _handler
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.