[svn:mod_parrot] r535 - in mod_parrot/trunk: . lib/ModParrot/APR t/response/TestAPI
[email protected] Mon, 8 Dec 2008 15:41:31 -0800 (PST)
| Newsgroups | perl.cvs.mod_parrot |
|---|---|
| Message-ID | <[email protected]> |
Author: jhorwitz
Date: Mon Dec 8 15:41:30 2008
New Revision: 535
Modified:
mod_parrot/trunk/README
mod_parrot/trunk/call_list.txt
mod_parrot/trunk/lib/ModParrot/APR/Pool.pir
mod_parrot/trunk/t/response/TestAPI/apr_pool.pir
Log:
implement parent_get and tag methods
Modified: mod_parrot/trunk/README
==============================================================================
--- mod_parrot/trunk/README (original)
+++ mod_parrot/trunk/README Mon Dec 8 15:41:30 2008
@@ -6,9 +6,6 @@
allowing you to write handlers in Parrot or any language targeted to the
Parrot VM.
-This software is a complete rewrite of the original version developed by
-Ask Bjorn-Hansen, Robert Spier, and Kevin Falcone.
-
STATUS
------
mod_parrot is slowly maturing. While its design is stable now, it should
@@ -19,7 +16,7 @@
REQUIREMENTS
------------
* Apache 2.0.x or 2.2.x (2.4 may work but is untested)
-* Parrot 0.8.0 or a recent source tree (all tests pass as of r32075)
+* A recent checkout of Parrot (all tests pass as of r33428)
* Perl 5.8.0 or later for configuration
* Apache::Test 1.26 or later (for tests)
@@ -32,13 +29,12 @@
3) make libraries
4) make test
5) make install
-6) Copy the lib directory to a directory of your choosing. This *should* be
- installed in a more standard place, but we'll just copy it anywhere for now.
CONFIGURING APACHE
------------------
-NOTE: This is a very basic configuration for pure PIR handlers. See the
-web site for documentation on configuring handlers in other languages.
+NOTE: This is a very basic configuration for a PIR response handler, and is
+only meant as an example. In addition to thie READEM, please see the
+documentation for the HLL layer(s) you are interested in using.
1) Verify mod_parrot is activated in httpd.conf:
@@ -46,21 +42,25 @@
2) Tell Apache how to initialize mod_parrot using ParrotInit:
- ParrotInit /path/to/lib/mod_parrot.pbc
+ ParrotInit /path/to/mod_parrot/lib/mod_parrot.pbc
Alternatively you can copy mod_parrot.pbc to parrot's runtime directory
and set the PARROT_RUNTIME environment variable to that directory.
mod_parrot will then be able to find this file automatically.
-3) Load the PIR HLL layer:
+3) Tell mod_parrot where to find its libraries:
+
+ ParrotIncludePath /path/to/mod_parrot/lib
+
+4) Load the PIR HLL layer:
ParrotLoadImmediate ModParrot/HLL/pir.pbc
-4) Load your Parrot handler with ParrotLoad. It can be PIR or compiled PBC.
+5) Load your Parrot handler with ParrotLoad. It can be PIR or compiled PBC.
ParrotLoad /path/to/your/code
-5) Configure a location and set the handler to "parrot-code", the official
+6) Configure a location and set the handler to "parrot-code", the official
mod_parrot handler string. Use ParrotHandler to tell mod_parrot what to
run for the content handler by passing it the namespace you used in your
code:
@@ -70,15 +70,6 @@
ParrotHandler MyApp
</Location>
- Or use ParrotAuthenHandler for an authentication handler:
-
- <Location /parrot/private>
- ParrotAuthenHandler MyAuthHandler
- AuthType basic
- AuthName Test
- Require valid-user
- </Location>
-
Or use one or more of the other Parrot*Handlers.
6) Restart Apache.
Modified: mod_parrot/trunk/call_list.txt
==============================================================================
--- mod_parrot/trunk/call_list.txt (original)
+++ mod_parrot/trunk/call_list.txt Mon Dec 8 15:41:30 2008
@@ -21,3 +21,4 @@
p JttPP
P Jtpi
i Vppp
+v pt
Modified: mod_parrot/trunk/lib/ModParrot/APR/Pool.pir
==============================================================================
--- mod_parrot/trunk/lib/ModParrot/APR/Pool.pir (original)
+++ mod_parrot/trunk/lib/ModParrot/APR/Pool.pir Mon Dec 8 15:41:30 2008
@@ -45,6 +45,9 @@
newclass pool_class, [ 'ModParrot'; 'APR'; 'Pool' ]
addattribute pool_class, 'apr_pool'
+
+ # the parent attribute is only used for instantiation
+ # see the "parent_get" method to query APR for the parent
addattribute pool_class, 'parent'
dlfunc func, nul, "apr_pool_create_ex", "iVppp"
@@ -55,6 +58,12 @@
dlfunc func, nul, "apr_pool_destroy", "vp"
set_root_global [ 'APR'; 'NCI' ], "apr_pool_destroy", func
+
+ dlfunc func, nul, "apr_pool_parent_get", "pp"
+ set_root_global [ 'APR'; 'NCI' ], "apr_pool_parent_get", func
+
+ dlfunc func, nul, "apr_pool_tag", "vpt"
+ set_root_global [ 'APR'; 'NCI' ], "apr_pool_tag", func
.end
.sub init :vtable :method
@@ -146,6 +155,43 @@
func(pool)
.end
+=item C<APR;Pool parent_get()>
+
+Returns the pool's parent pool, or a null PMC if the pool has no parent.
+
+=cut
+
+.sub parent_get :method
+ .local pmc func, pool, parent
+
+ func = get_root_global [ 'APR'; 'NCI' ], "apr_pool_parent_get"
+ pool = getattribute self, 'apr_pool'
+ null parent
+ $P0 = func(pool)
+ if null $P0 goto return_pool
+ $P1 = new 'Hash'
+ $P1['apr_pool'] = $P0
+ parent = new ['ModParrot'; 'APR'; 'Pool'], $P1
+ return_pool:
+ .return(parent)
+.end
+
+=item C<tag(STRING name)>
+
+Sets the tag for a pool. This is for C-level debugging, as there is no API
+for retrieving the tag from a pool.
+
+=cut
+
+.sub tag :method
+ .param string tag
+ .local pmc func, pool
+
+ func = get_root_global [ 'APR'; 'NCI' ], "apr_pool_tag"
+ pool = getattribute self, 'apr_pool'
+ func(pool, tag)
+.end
+
=back
=head1 AUTHOR
Modified: mod_parrot/trunk/t/response/TestAPI/apr_pool.pir
==============================================================================
--- mod_parrot/trunk/t/response/TestAPI/apr_pool.pir (original)
+++ mod_parrot/trunk/t/response/TestAPI/apr_pool.pir Mon Dec 8 15:41:30 2008
@@ -17,7 +17,7 @@
ap_const = get_root_global [ 'ModParrot'; 'Apache'; 'Constants' ], 'table'
- r.'puts'("1..5\n")
+ r.'puts'("1..7\n")
START_1:
push_eh NOT_OK_1
@@ -65,7 +65,7 @@
r.'puts'("ok 4 - create pool (with request pool parent)\n")
START_5:
- push_eh NOT_OK_3
+ push_eh NOT_OK_5
$P0 = r.'pool'()
$P1 = new 'Undef'
$P2 = get_global 'test_cleanup_handler'
@@ -77,6 +77,30 @@
OK_5:
r.'puts'("ok 5 - cleanup_register\n")
+ START_6:
+ push_eh NOT_OK_6
+ $P0 = r.'pool'()
+ $P0.'tag'('test')
+ pop_eh
+ goto OK_6
+ NOT_OK_6:
+ r.'puts'("not ")
+ OK_6:
+ r.'puts'("ok 6 - tag\n")
+
+trace 7
+ START_7:
+ push_eh NOT_OK_7
+ $P0 = r.'pool'()
+ $P1 = $P0.'parent_get'()
+ pop_eh
+ $S0 = typeof $P1
+ if $S0 == 'ModParrot;APR;Pool' goto OK_7
+ NOT_OK_7:
+ r.'puts'("not ")
+ OK_7:
+ r.'puts'("ok 7 - parent_get\n")
+
$I0 = ap_const['OK']
.return($I0)
.end