[svn:mod_parrot] r592 - in mod_parrot/trunk: . include languages/perl6/lib lib lib/ModParrot/Apache lib/ModParrot/HLL src
[email protected] Sun, 18 Jan 2009 09:46:00 -0800 (PST)
| Newsgroups | perl.cvs.mod_parrot |
|---|---|
| Message-ID | <[email protected]> |
Author: jhorwitz
Date: Sun Jan 18 09:45:59 2009
New Revision: 592
Added:
mod_parrot/trunk/lib/ModParrot/Apache/CmdParms.pir
Modified:
mod_parrot/trunk/Makefile.in
mod_parrot/trunk/include/mod_parrot.h
mod_parrot/trunk/languages/perl6/lib/mod_perl6.pm
mod_parrot/trunk/lib/ModParrot/HLL/pir.pir
mod_parrot/trunk/lib/mod_parrot.pir
mod_parrot/trunk/src/module.c
mod_parrot/trunk/src/nci.c
mod_parrot/trunk/src/parrot_util.c
Log:
implement ModParrot;Apache;CmdParms and pass to HLL modules where appropriate
Modified: mod_parrot/trunk/Makefile.in
==============================================================================
--- mod_parrot/trunk/Makefile.in (original)
+++ mod_parrot/trunk/Makefile.in Sun Jan 18 09:45:59 2009
@@ -49,6 +49,7 @@
lib/ModParrot/Apache/ServerRec.pbc \
lib/ModParrot/Apache/Constants.pbc \
lib/ModParrot/Apache/Module.pbc \
+ lib/ModParrot/Apache/CmdParms.pbc \
lib/ModParrot/APR/Pool.pbc \
lib/ModParrot/APR/Table.pbc \
lib/mod_parrot.pbc \
Modified: mod_parrot/trunk/include/mod_parrot.h
==============================================================================
--- mod_parrot/trunk/include/mod_parrot.h (original)
+++ mod_parrot/trunk/include/mod_parrot.h Sun Jan 18 09:45:59 2009
@@ -107,8 +107,16 @@
#define modparrot_wrap_apr_pool(i, x) \
(modparrot_wrap_apache_type(i, "ModParrot;APR;Pool", "apr_pool", x))
+#define modparrot_wrap_conn_rec(i, x) \
+ (modparrot_wrap_apache_type(i, "ModParrot;Apache;ConnRec", \
+ "conn_rec", x))
+
#define modparrot_wrap_server_rec(i, x) \
(modparrot_wrap_apache_type(i, "ModParrot;Apache;ServerRec", \
"server_rec", x))
+#define modparrot_wrap_cmd_parms(i, x) \
+ (modparrot_wrap_apache_type(i, "ModParrot;Apache;CmdParms", \
+ "cmd_parms", x))
+
#endif /* _MODPARROT_H */
Modified: mod_parrot/trunk/languages/perl6/lib/mod_perl6.pm
==============================================================================
--- mod_parrot/trunk/languages/perl6/lib/mod_perl6.pm (original)
+++ mod_parrot/trunk/languages/perl6/lib/mod_perl6.pm Sun Jan 18 09:45:59 2009
@@ -41,7 +41,7 @@
}
}
-sub server_create()
+sub server_create($parms)
{
my %cfg;
@@ -58,7 +58,7 @@
return %cfg;
}
-sub dir_create()
+sub dir_create($parms)
{
my %cfg;
@@ -238,111 +238,111 @@
return $status;
}
-sub cmd_perl6openlogshandler(%mconfig, @args)
+sub cmd_perl6openlogshandler($parms, %mconfig, @args)
{
my %cfg := ModParrot::Apache::Module::get_config("modparrot_perl6_module");
%cfg<open_logs_handler> = @args[0];
}
-sub cmd_perl6postconfighandler(%mconfig, @args)
+sub cmd_perl6postconfighandler($parms, %mconfig, @args)
{
my %cfg := ModParrot::Apache::Module::get_config("modparrot_perl6_module");
%cfg<post_config_handler> = @args[0];
}
-sub cmd_perl6childinithandler(%mconfig, @args)
+sub cmd_perl6childinithandler($parms, %mconfig, @args)
{
my %cfg := ModParrot::Apache::Module::get_config("modparrot_perl6_module");
%cfg<child_init_handler> = @args[0];
}
-sub cmd_perl6preconnectionhandler(%mconfig, @args)
+sub cmd_perl6preconnectionhandler($parms, %mconfig, @args)
{
my %cfg := ModParrot::Apache::Module::get_config("modparrot_perl6_module");
%cfg<pre_connection_handler> = @args[0];
}
-sub cmd_perl6processconnectionhandler(%mconfig, @args)
+sub cmd_perl6processconnectionhandler($parms, %mconfig, @args)
{
my %cfg := ModParrot::Apache::Module::get_config("modparrot_perl6_module");
%cfg<process_connection_handler> = @args[0];
}
-sub cmd_perl6postreadrequesthandler(%mconfig, @args)
+sub cmd_perl6postreadrequesthandler($parms, %mconfig, @args)
{
my %cfg := ModParrot::Apache::Module::get_config("modparrot_perl6_module");
%cfg<post_read_request_handler> = @args[0];
}
-sub cmd_perl6maptostoragehandler(%mconfig, @args)
+sub cmd_perl6maptostoragehandler($parms, %mconfig, @args)
{
my %cfg := ModParrot::Apache::Module::get_config("modparrot_perl6_module");
%cfg<map_to_storage_handler> = @args[0];
}
-sub cmd_perl6transhandler(%mconfig, @args)
+sub cmd_perl6transhandler($parms, %mconfig, @args)
{
my %cfg := ModParrot::Apache::Module::get_config("modparrot_perl6_module");
%cfg<trans_handler> = @args[0];
}
-sub cmd_perl6headerparserhandler(%dircfg, @args)
+sub cmd_perl6headerparserhandler($parms, %dircfg, @args)
{
%dircfg<header_parser_handler> = @args[0];
}
-sub cmd_perl6accesshandler(%dircfg, @args)
+sub cmd_perl6accesshandler($parms, %dircfg, @args)
{
%dircfg<access_handler> = @args[0];
}
-sub cmd_perl6authenhandler(%dircfg, @args)
+sub cmd_perl6authenhandler($parms, %dircfg, @args)
{
%dircfg<authen_handler> = @args[0];
}
-sub cmd_perl6authzhandler(%dircfg, @args)
+sub cmd_perl6authzhandler($parms, %dircfg, @args)
{
%dircfg<authz_handler> = @args[0];
}
-sub cmd_perl6responsehandler(%dircfg, @args)
+sub cmd_perl6responsehandler($parms, %dircfg, @args)
{
%dircfg<response_handler> = @args[0];
}
-sub cmd_perl6typehandler(%dircfg, @args)
+sub cmd_perl6typehandler($parms, %dircfg, @args)
{
%dircfg<type_handler> = @args[0];
}
-sub cmd_perl6fixuphandler(%dircfg, @args)
+sub cmd_perl6fixuphandler($parms, %dircfg, @args)
{
%dircfg<fixup_handler> = @args[0];
}
-sub cmd_perl6loghandler(%dircfg, @args)
+sub cmd_perl6loghandler($parms, %dircfg, @args)
{
%dircfg<log_handler> = @args[0];
}
-sub cmd_perl6cleanuphandler(%dircfg, @args)
+sub cmd_perl6cleanuphandler($parms, %dircfg, @args)
{
%dircfg<cleanup_handler> = @args[0];
}
-sub cmd_perl6cleanuphandler(%dircfg, @args)
+sub cmd_perl6cleanuphandler($parms, %dircfg, @args)
{
%dircfg<cleanup_handler> = @args[0];
}
-sub cmd_perl6module(%mconfig, @args)
+sub cmd_perl6module($parms, %mconfig, @args)
{
my %cfg := ModParrot::Apache::Module::get_config("modparrot_perl6_module");
push(%cfg<preloaded_modules>, @args[0]);
}
-sub cmd_perl6options(%mconfig, @args)
+sub cmd_perl6options($parms, %mconfig, @args)
{
if (@args[0] ~~ /(\+|\-)(.+)/) {
my $modifier = ~$0;
Added: mod_parrot/trunk/lib/ModParrot/Apache/CmdParms.pir
==============================================================================
--- (empty file)
+++ mod_parrot/trunk/lib/ModParrot/Apache/CmdParms.pir Sun Jan 18 09:45:59 2009
@@ -0,0 +1,153 @@
+# $Id$
+
+# Copyright (c) 2008 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
+
+Apache/CmdParms.pir
+
+=head1 SYNOPSIS
+
+.sub cmd_foo
+ .param pmc parms
+ .param pmc cfg
+ .param pmc args
+ .local pmc this_server_rec
+
+ this_server_rec = parms.'server'()
+
+ ...
+
+.end
+
+=head1 DESCRIPTION
+
+This code implements the ModParrot;Apache;CmdParms class, an encapsulation of
+Apache's cmd_parms structure. It is passed to directive callbacks.
+
+=head2 Methods
+
+=over 4
+
+=cut
+
+# XXX How to write server side tests for this?
+
+.namespace [ 'ModParrot'; 'Apache'; 'CmdParms' ]
+
+.sub _initialize :load
+ .local pmc cmd_class
+ .local pmc func
+
+ newclass cmd_class, [ 'ModParrot'; 'Apache'; 'CmdParms' ]
+ addattribute cmd_class, 'cmd_parms'
+.end
+
+=item C<PMC server()>
+
+Returs the ModParrot;Apache;ServerRec object associated with the command.
+
+=cut
+
+.sub server :method
+ .local pmc func
+ .local pmc cmd_parms_struct
+ .local pmc server_struct
+ .local pmc server
+
+ func = get_root_global [ 'ModParrot'; 'NCI' ], 'cmd_parms_server'
+ cmd_parms_struct = getattribute self, 'cmd_parms'
+ server_struct = func(cmd_parms_struct)
+ $P0 = new 'Hash'
+ $P0['server_rec'] = server_struct
+ server = new [ 'ModParrot'; 'Apache'; 'ServerRec' ], $P0
+
+ .return(server)
+.end
+
+=item C<PMC pool()>
+
+Returs the command's pool as a ModParrot;APR;Pool object.
+
+=cut
+
+.sub pool :method
+ .local pmc func
+ .local pmc cmd_parms_struct
+ .local pmc apr_pool_struct
+ .local pmc pool
+
+ func = get_root_global [ 'ModParrot'; 'NCI' ], 'cmd_parms_pool'
+ cmd_parms_struct = getattribute self, 'cmd_parms'
+ apr_pool_struct = func(cmd_parms_struct)
+ $P0 = new 'Hash'
+ $P0['apr_pool'] = apr_pool_struct
+ pool = new [ 'ModParrot'; 'APR'; 'Pool' ], $P0
+
+ .return(pool)
+.end
+
+=item C<PMC temp_pool()>
+
+Returs the command's temporary (config) pool as a ModParrot;APR;Pool object.
+
+=cut
+
+.sub temp_pool :method
+ .local pmc func
+ .local pmc cmd_parms_struct
+ .local pmc apr_pool_struct
+ .local pmc pool
+
+ func = get_root_global [ 'ModParrot'; 'NCI' ], 'cmd_parms_temp_pool'
+ cmd_parms_struct = getattribute self, 'cmd_parms'
+ apr_pool_struct = func(cmd_parms_struct)
+ $P0 = new 'Hash'
+ $P0['apr_pool'] = apr_pool_struct
+ pool = new [ 'ModParrot'; 'APR'; 'Pool' ], $P0
+
+ .return(pool)
+.end
+
+=item C<PMC cmd()>
+
+XXX UNIMPLEMENTED XXX
+
+Returs the command associated with the CmdParms object as a
+ModParrot;Apache;CommandRec object.
+
+=cut
+
+.sub cmd :method
+ .local pmc func
+ .local pmc cmd_parms_struct
+ .local pmc command_struct
+ .local pmc command
+
+ func = get_root_global [ 'ModParrot'; 'NCI' ], 'cmd_parms_cmd'
+ cmd_parms_struct = getattribute self, 'cmd_parms'
+ command_struct = func(cmd_parms_struct)
+ $P0 = new 'Hash'
+ $P0['command_rec'] = command_struct
+ command = new [ 'ModParrot'; 'Apache'; 'CommandRec' ], $P0
+
+ .return(command)
+.end
+
+=head1 AUTHOR
+
+Jeff Horwitz
+
+=cut
Modified: mod_parrot/trunk/lib/ModParrot/HLL/pir.pir
==============================================================================
--- mod_parrot/trunk/lib/ModParrot/HLL/pir.pir (original)
+++ mod_parrot/trunk/lib/ModParrot/HLL/pir.pir Sun Jan 18 09:45:59 2009
@@ -101,15 +101,13 @@
.namespace [ 'ModParrot'; 'HLL'; 'PIR' ]
.sub server_create
- .param pmc p
- .param pmc s
+ .param pmc parms
$P0 = new 'Hash'
.return($P0)
.end
.sub dir_create
- .param pmc p
- .param pmc s
+ .param pmc parms
$P0 = new 'Hash'
.return($P0)
.end
@@ -123,6 +121,7 @@
#.end
.sub cmd_parrotopenlogshandler
+ .param pmc parms
.param pmc mconfig
.param pmc args
.local pmc cfg, get_config
@@ -134,6 +133,7 @@
.end
.sub cmd_parrotpostconfighandler
+ .param pmc parms
.param pmc mconfig
.param pmc args
.local pmc cfg, get_config
@@ -145,6 +145,7 @@
.end
.sub cmd_parrotchildinithandler
+ .param pmc parms
.param pmc mconfig
.param pmc args
.local pmc cfg, get_config
@@ -156,6 +157,7 @@
.end
.sub cmd_parrotpreconnectionhandler
+ .param pmc parms
.param pmc mconfig
.param pmc args
.local pmc cfg, get_config
@@ -167,6 +169,7 @@
.end
.sub cmd_parrotprocessconnectionhandler
+ .param pmc parms
.param pmc mconfig
.param pmc args
.local pmc cfg, get_config
@@ -178,6 +181,7 @@
.end
.sub cmd_parrotmaptostoragehandler
+ .param pmc parms
.param pmc dircfg
.param pmc args
@@ -186,6 +190,7 @@
.end
.sub cmd_parrottranshandler
+ .param pmc parms
.param pmc dircfg
.param pmc args
@@ -194,6 +199,7 @@
.end
.sub cmd_parrotpostreadrequesthandler
+ .param pmc parms
.param pmc dircfg
.param pmc args
@@ -202,6 +208,7 @@
.end
.sub cmd_parrotheaderparserhandler
+ .param pmc parms
.param pmc dircfg
.param pmc args
@@ -210,6 +217,7 @@
.end
.sub cmd_parrotauthenhandler
+ .param pmc parms
.param pmc dircfg
.param pmc args
@@ -218,6 +226,7 @@
.end
.sub cmd_parrotauthzhandler
+ .param pmc parms
.param pmc dircfg
.param pmc args
@@ -226,6 +235,7 @@
.end
.sub cmd_parrotaccesshandler
+ .param pmc parms
.param pmc dircfg
.param pmc args
@@ -234,6 +244,7 @@
.end
.sub cmd_parrothandler
+ .param pmc parms
.param pmc dircfg
.param pmc args
@@ -242,6 +253,7 @@
.end
.sub cmd_parrottypehandler
+ .param pmc parms
.param pmc dircfg
.param pmc args
@@ -250,6 +262,7 @@
.end
.sub cmd_parrotfixuphandler
+ .param pmc parms
.param pmc dircfg
.param pmc args
@@ -258,6 +271,7 @@
.end
.sub cmd_parrotloghandler
+ .param pmc parms
.param pmc dircfg
.param pmc args
Modified: mod_parrot/trunk/lib/mod_parrot.pir
==============================================================================
--- mod_parrot/trunk/lib/mod_parrot.pir (original)
+++ mod_parrot/trunk/lib/mod_parrot.pir Sun Jan 18 09:45:59 2009
@@ -120,6 +120,18 @@
dlfunc func, lib, "mpnci_get_module_config", "PJtpi"
set_root_global [ 'ModParrot'; 'NCI' ], "get_module_config", func
+ dlfunc func, lib, "mpnci_cmd_parms_server", "pJp"
+ set_root_global [ 'ModParrot'; 'NCI' ], "cmd_parms_server", func
+
+ dlfunc func, lib, "mpnci_cmd_parms_pool", "pJp"
+ set_root_global [ 'ModParrot'; 'NCI' ], "cmd_parms_pool", func
+
+ dlfunc func, lib, "mpnci_cmd_parms_temp_poolserver", "pJp"
+ set_root_global [ 'ModParrot'; 'NCI' ], "cmd_parms_temp_poolserver", func
+
+ dlfunc func, lib, "mpnci_cmd_parms_cmd", "pJp"
+ set_root_global [ 'ModParrot'; 'NCI' ], "cmd_parms_cmd", func
+
# load required libraries
load_bytecode 'P6object.pbc'
load_bytecode 'ModParrot/Interpreter.pbc'
@@ -128,6 +140,7 @@
load_bytecode 'ModParrot/Apache/Module.pbc'
load_bytecode 'ModParrot/Apache/RequestRec.pbc'
load_bytecode 'ModParrot/Apache/ServerRec.pbc'
+ load_bytecode 'ModParrot/Apache/CmdParms.pbc'
load_bytecode 'ModParrot/APR/Pool.pbc'
load_bytecode 'ModParrot/APR/Table.pbc'
@@ -145,6 +158,8 @@
$P0.'register'($P1, 'name' => 'Apache;RequestRec')
$P1 = get_class ['ModParrot'; 'Apache'; 'ServerRec']
$P0.'register'($P1, 'name' => 'Apache;ServerRec')
+ $P1 = get_class ['ModParrot'; 'Apache'; 'CmdParms']
+ $P0.'register'($P1, 'name' => 'Apache;CmdParms')
$P1 = get_class ['ModParrot';'APR'; 'Pool']
$P0.'register'($P1, 'name' => 'APR;Pool')
$P1 = get_class ['ModParrot';'APR'; 'Table']
Modified: mod_parrot/trunk/src/module.c
==============================================================================
--- mod_parrot/trunk/src/module.c (original)
+++ mod_parrot/trunk/src/module.c Sun Jan 18 09:45:59 2009
@@ -197,8 +197,7 @@
{
modparrot_context *ctxp;
Parrot_PMC args;
- Parrot_PMC pool_pmc;
- Parrot_PMC sr_pmc;
+ Parrot_PMC parms_pmc;
modparrot_module_cmd_data *data = cmd->cmd->cmd_data;
modparrot_module_info *minfo = data->modp->dynamic_load_handle;
modparrot_module_config *srvcfg, *dircfg;
@@ -208,6 +207,10 @@
ctxp = modparrot_startup(cmd->temp_pool, cmd->server, NULL);
ctxp->pconf = cmd->pool;
+ /* create a ModParrot;Apache;CmdParms object to pass to the handlers */
+ parms_pmc = modparrot_wrap_cmd_parms(ctxp->interp, cmd);
+ Parrot_register_pmc(ctxp->interp, parms_pmc);
+
/* create/fetch module server config */
srvcfg = (modparrot_module_config *)ap_get_module_config(
cmd->server->module_config, data->modp);
@@ -215,10 +218,8 @@
if (!srvcfg->cfg) {
srvcfg->name = apr_pstrdup(cmd->pool, data->modp->name);
if (minfo->server_create_sub) {
- pool_pmc = modparrot_wrap_apr_pool(ctxp->interp, cmd->pool);
- sr_pmc = modparrot_wrap_server_rec(ctxp->interp, cmd->server);
srvcfg->cfg = Parrot_call_sub(ctxp->interp,
- minfo->server_create_sub, "PPP", pool_pmc, sr_pmc);
+ minfo->server_create_sub, "PP", parms_pmc);
if (!PMC_IS_NULL(srvcfg->cfg)) {
Parrot_register_pmc(ctxp->interp, srvcfg->cfg);
}
@@ -232,10 +233,8 @@
if (!dircfg->cfg) {
dircfg->name = apr_pstrdup(cmd->pool, data->modp->name);
if (minfo->dir_create_sub) {
- pool_pmc = modparrot_wrap_apr_pool(ctxp->interp, cmd->pool);
- sr_pmc = modparrot_wrap_server_rec(ctxp->interp, cmd->server);
dircfg->cfg = Parrot_call_sub(ctxp->interp,
- minfo->dir_create_sub, "PPP", pool_pmc, sr_pmc);
+ minfo->dir_create_sub, "PP", parms_pmc);
if (!PMC_IS_NULL(dircfg->cfg)) {
Parrot_register_pmc(ctxp->interp, dircfg->cfg);
}
@@ -245,10 +244,11 @@
args = make_cmd_args_array(ctxp->interp, cmd->pool, 3, arg1, arg2, arg3);
- /* XXX add cmd_parms to this when it's implemented */
- ret = Parrot_call_sub_ret_int(ctxp->interp, data->func, "IPP",
+ ret = Parrot_call_sub_ret_int(ctxp->interp, data->func, "IPPP", parms_pmc,
dircfg->cfg, args);
+ Parrot_unregister_pmc(ctxp->interp, parms_pmc);
+
return NULL;
}
Modified: mod_parrot/trunk/src/nci.c
==============================================================================
--- mod_parrot/trunk/src/nci.c (original)
+++ mod_parrot/trunk/src/nci.c Sun Jan 18 09:45:59 2009
@@ -58,7 +58,7 @@
return(r->per_dir_config);
}
-struct server_rec *mpnci_request_rec_server(Parrot_Interp interp,
+server_rec *mpnci_request_rec_server(Parrot_Interp interp,
request_rec *r)
{
return(r->server);
@@ -290,6 +290,21 @@
return(cmd->server);
}
+apr_pool_t *mpnci_cmd_parms_pool(Parrot_Interp interp, cmd_parms *cmd)
+{
+ return(cmd->pool);
+}
+
+apr_pool_t *mpnci_cmd_parms_temp_pool(Parrot_Interp interp, cmd_parms *cmd)
+{
+ return(cmd->temp_pool);
+}
+
+const command_rec *mpnci_cmd_parms_cmd(Parrot_Interp interp, cmd_parms *cmd)
+{
+ return(cmd->cmd);
+}
+
/* XXX still need this so HLLs can tweak mod_parrot configurations */
#if 0
#define SET_DIRCFG_INFO(x) if (update) { ctxp->dircfg->x = handler_info; } \
Modified: mod_parrot/trunk/src/parrot_util.c
==============================================================================
--- mod_parrot/trunk/src/parrot_util.c (original)
+++ mod_parrot/trunk/src/parrot_util.c Sun Jan 18 09:45:59 2009
@@ -280,9 +280,9 @@
else {
obj = Parrot_Class_instantiate(interp, _class, PMCNULL);
}
- Parrot_register_pmc(interp, obj);
Parrot_unregister_pmc(interp, init);
Parrot_unregister_pmc(interp, _class);
+ /* NOTE: we leave it up to the caller to register the PMC */
return(obj);
}