[svn:mod_parrot] rev 170 - in mod_parrot/trunk: . lib/APR lib/Apache lib/ModParrot t t/conf t/lib

[email protected]
Newsgroups perl.cvs.mod_parrot
Message-ID <[email protected]>
Author: jhorwitz
Date: Wed Jul 20 06:50:11 2005
New Revision: 170

Added:
   mod_parrot/trunk/lib/APR/
   mod_parrot/trunk/lib/APR/Table.imc
Modified:
   mod_parrot/trunk/CHANGES
   mod_parrot/trunk/Makefile.in
   mod_parrot/trunk/call_list.txt
   mod_parrot/trunk/lib/Apache/RequestRec.imc
   mod_parrot/trunk/lib/ModParrot/init.imc
   mod_parrot/trunk/nci.c
   mod_parrot/trunk/t/01RequestRec.t
   mod_parrot/trunk/t/conf/extra.conf.in
   mod_parrot/trunk/t/lib/handlers.imc
Log:
Implement APR::Table class for abstracting apr_table_t
Implement Apache::RequestRec::notes method for manipulating a request's notes


Modified: mod_parrot/trunk/CHANGES
==============================================================================
--- mod_parrot/trunk/CHANGES	(original)
+++ mod_parrot/trunk/CHANGES	Wed Jul 20 06:50:11 2005
@@ -10,6 +10,9 @@ $Id$
        * Parrot*Handler takes an optional language specifier
        * Use parrot-config.imc to fetch parrot configuration
        * Configure.pl no longer requires Apache::Test
+       * New APR::Table class
+       * New Apache::RequestRec notes method
+       * ModParrot::NCI::backtrace returns a backtrace string
 
 0.2    March 28, 2004
        * Formal support for Parrot 0.1.2 "Phoenix"

Modified: mod_parrot/trunk/Makefile.in
==============================================================================
--- mod_parrot/trunk/Makefile.in	(original)
+++ mod_parrot/trunk/Makefile.in	Wed Jul 20 06:50:11 2005
@@ -14,6 +14,7 @@ SOURCE_FILES=mod_parrot.c parrot_util.c 
 PARROT_OBJS=$(PARROT_SOURCE)/src/parrot_config.o
 MPLIBS=	lib/Apache/RequestRec \
 	lib/Apache/Constants \
+	lib/APR/Table \
 	lib/ModParrot/init \
 	lib/ModParrot/HLL/pir \
 	lib/ModParrot/HLL/pugs

Modified: mod_parrot/trunk/call_list.txt
==============================================================================
--- mod_parrot/trunk/call_list.txt	(original)
+++ mod_parrot/trunk/call_list.txt	Wed Jul 20 06:50:11 2005
@@ -8,6 +8,8 @@ i	Pip
 p	J
 t	J
 t	Jp
+p	Jp
 t	Jpt
 i	Jp
 i	JPip
+t	ptt

Added: mod_parrot/trunk/lib/APR/Table.imc
==============================================================================
--- (empty file)
+++ mod_parrot/trunk/lib/APR/Table.imc	Wed Jul 20 06:50:11 2005
@@ -0,0 +1,127 @@
+# $Id$
+
+# Copyright (c) 2005 Jeff Horwitz
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+=head1 NAME
+
+APR/Table.imc
+
+=head1 SYNOPSIS
+
+$P0 = r.'notes'()
+
+$P0.set('foo', 'bar')
+
+$S0 = $P0.get('foo')
+
+=head1 DESCRIPTION
+
+This class abstracts APR's apr_table_t type, used for the storage of key/value
+tables in Apache.
+
+=head2 Methods
+
+=cut
+
+.namespace [ 'APR::Table' ]
+
+.sub _initialize @LOAD
+    .local pmc table_class
+    .local pmc func
+    .local pmc nul
+
+    null nul
+
+    newclass table_class, 'APR::Table'
+    addattribute table_class, 'apr_table'
+
+    dlfunc func, nul, "apr_table_get", "tpt"
+    store_global "APR::NCI", "apr_table_get", func
+
+    dlfunc func, nul, "apr_table_set", "tptt"
+    store_global "APR::NCI", "apr_table_set", func
+.end
+
+.sub __init method
+    .param pmc t
+    .local int offset
+
+    $I0 = find_type 'APR::Table'
+    classoffset offset, self, 'APR::Table'
+    setattribute self, offset, t
+.end
+
+=item C<APR::Table get(STRING key)>
+
+=over 4
+
+Retrieve a value from the table by key.
+
+=back
+
+=cut
+
+.sub get method
+    .param string key
+    .local pmc t
+    .local pmc apr_table_get
+    .local string val
+    .local int offset
+
+    classoffset offset, self, 'APR::Table'
+    getattribute t, self, offset
+    find_global apr_table_get, 'APR::NCI', 'apr_table_get'
+    val = apr_table_get(t, key)
+
+    .pcc_begin_return
+        .return val
+    .pcc_end_return
+.end
+
+=item C<APR::Table set(STRING key, STRING value)>
+
+=over 4
+
+Set a value in the table.
+
+=back
+
+=cut
+
+.sub set method
+    .param string key
+    .param string val
+    .local pmc t
+    .local pmc apr_table_set
+    .local int offset
+
+    classoffset offset, self, 'APR::Table'
+    getattribute t, self, offset
+    find_global apr_table_set, 'APR::NCI', 'apr_table_set'
+    val = apr_table_set(t, key, val)
+.end
+    
+=over 4
+
+=cut
+
+=back
+
+=head1 AUTHOR
+
+Jeff Horwitz
+
+=cut
+

Modified: mod_parrot/trunk/lib/Apache/RequestRec.imc
==============================================================================
--- mod_parrot/trunk/lib/Apache/RequestRec.imc	(original)
+++ mod_parrot/trunk/lib/Apache/RequestRec.imc	Wed Jul 20 06:50:11 2005
@@ -439,6 +439,37 @@ for basic authentication.
     ap_note_basic_auth_failure( r )
 .end
 
+=item C<PMC notes()>
+
+=over 4
+
+Returns the request's notes table as an APR::Table object.
+
+=back
+
+=cut
+
+.sub notes method
+    .local pmc r
+    .local pmc notes
+    .local pmc t
+    .local pmc request_rec_notes
+    .local int offset
+ 
+    classoffset offset, self, 'Apache::RequestRec'
+    getattribute r, self, offset
+
+    find_global request_rec_notes, 'ModParrot::NCI', 'request_rec_notes'
+    notes = request_rec_notes( r )
+
+    find_type $I0, 'APR::Table'
+    t = new $I0, notes
+
+    .pcc_begin_return
+        .return t
+    .pcc_end_return
+.end
+
 =back
 
 =head1 AUTHOR

Modified: mod_parrot/trunk/lib/ModParrot/init.imc
==============================================================================
--- mod_parrot/trunk/lib/ModParrot/init.imc	(original)
+++ mod_parrot/trunk/lib/ModParrot/init.imc	Wed Jul 20 06:50:11 2005
@@ -41,6 +41,9 @@
     dlfunc func, nul, "mpnci_request_rec_user", "tJpt"
     store_global "ModParrot::NCI", "request_rec_user", func
 
+    dlfunc func, nul, "mpnci_request_rec_notes", "pJp"
+    store_global "ModParrot::NCI", "request_rec_notes", func
+
     dlfunc func, nul, "mpnci_request_rec_content_type", "tJpt"
     store_global "ModParrot::NCI", "request_rec_content_type", func
 

Modified: mod_parrot/trunk/nci.c
==============================================================================
--- mod_parrot/trunk/nci.c	(original)
+++ mod_parrot/trunk/nci.c	Wed Jul 20 06:50:11 2005
@@ -124,6 +124,11 @@ char *mpnci_request_rec_user(Parrot_Inte
     return(r->user);
 }
 
+apr_table_t *mpnci_request_rec_notes(Parrot_Interp interp, request_rec *r)
+{
+    return(r->notes);
+}
+
 const char *mpnci_request_rec_content_type(Parrot_Interp interp, request_rec *r,
                                            char *t)
 {

Modified: mod_parrot/trunk/t/01RequestRec.t
==============================================================================
--- mod_parrot/trunk/t/01RequestRec.t	(original)
+++ mod_parrot/trunk/t/01RequestRec.t	Wed Jul 20 06:50:11 2005
@@ -7,7 +7,7 @@ use Test::More;
 
 my $content;
 
-plan tests => 8, (need_lwp);
+plan tests => 9, (need_lwp);
 
 # Apache::RequestRec->content_type
 my $res = GET '/parrot-test/RequestRec-content_type';
@@ -29,11 +29,16 @@ $res = GET '/parrot-test/RequestRec-args
 chomp($content = $res->content);
 is($content, 'test_string', 'echo passed parameter');
 
-# Apache::RequestRec->RequestRec-hostname
+# Apache::RequestRec->hostname
 $res = GET '/parrot-test/RequestRec-hostname';
 chomp($content = $res->content);
 like($content, qr/^localhost/, 'verify hostname');
 
+# Apache::RequestRec->notes
+$res = GET '/parrot-test/RequestRec-notes';
+chomp($content = $res->content);
+is($content, 'bar', 'notes');
+
 # Apache::RequestRec->log_rerror
 $res = GET '/parrot-test/RequestRec-log_rerror';
 # read whole error_log into memory -- should be small

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	Wed Jul 20 06:50:11 2005
@@ -5,6 +5,7 @@
 ParrotInit @ServerRoot@/../lib/ModParrot/init.pbc
 ParrotLoad @ServerRoot@/../lib/ModParrot/HLL/pir.pbc
 ParrotLoad @ServerRoot@/../lib/Apache/Constants.pbc
+ParrotLoad @ServerRoot@/../lib/APR/Table.pbc
 ParrotLoad @ServerRoot@/../lib/Apache/RequestRec.pbc
 ParrotLoad @ServerRoot@/lib/handlers.pbc
 
@@ -42,6 +43,12 @@ ParrotLoad @ServerRoot@/../lib/pugs/Apac
     ParrotHandler ModParrot::Test::hostname
 </Location>
 
+<Location /parrot-test/RequestRec-notes>
+    SetHandler parrot-code
+    ParrotLanguage PIR
+    ParrotHandler ModParrot::Test::notes
+</Location>
+
 <Location /parrot-test/RequestRec-log_rerror>
     SetHandler parrot-code
     ParrotLanguage PIR

Modified: mod_parrot/trunk/t/lib/handlers.imc
==============================================================================
--- mod_parrot/trunk/t/lib/handlers.imc	(original)
+++ mod_parrot/trunk/t/lib/handlers.imc	Wed Jul 20 06:50:11 2005
@@ -242,3 +242,22 @@ authz_done:
         .return $I0
     .pcc_end_return
 .end
+
+.namespace [ 'ModParrot::Test::notes' ]
+
+.sub _handler
+    .param pmc r
+    .local pmc ap_const
+
+    $P0 = r.'notes'( )
+    $P0.'set'('foo', 'bar')
+    $S0 = $P0.'get'('foo')
+    r.'puts'($S0)
+
+    ap_const = find_global 'Apache::Constants', 'ap_constants'
+    $I0 = ap_const['OK']
+
+    .pcc_begin_return
+        .return $I0
+    .pcc_end_return
+.end
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.