[svn:mod_parrot] r582 - in mod_parrot/trunk: lib/ModParrot/HLL src
[email protected] Mon, 5 Jan 2009 16:39:05 -0800 (PST)
| Newsgroups | perl.cvs.mod_parrot |
|---|---|
| Message-ID | <[email protected]> |
Author: jhorwitz
Date: Mon Jan 5 16:39:04 2009
New Revision: 582
Modified:
mod_parrot/trunk/lib/ModParrot/HLL/pir.pir
mod_parrot/trunk/src/module.c
Log:
pass pool and server_rec args to config create hooks
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 Mon Jan 5 16:39:04 2009
@@ -103,13 +103,17 @@
.namespace [ 'ModParrot'; 'HLL'; 'PIR' ]
.sub server_create
- $P0 = new 'Hash'
- .return($P0)
+ .param pmc p
+ .param pmc s
+ $P0 = new 'Hash'
+ .return($P0)
.end
.sub dir_create
- $P0 = new 'Hash'
- .return($P0)
+ .param pmc p
+ .param pmc s
+ $P0 = new 'Hash'
+ .return($P0)
.end
# XXX implement merging
Modified: mod_parrot/trunk/src/module.c
==============================================================================
--- mod_parrot/trunk/src/module.c (original)
+++ mod_parrot/trunk/src/module.c Mon Jan 5 16:39:04 2009
@@ -40,6 +40,12 @@
/* used when we have no other way of getting the server config */
static server_rec *our_server;
+/* XXX mod_parrot can crash on x86_64 w/o this.
+ * there's no prototype in the standard parrot includes, so compiler assumes
+ * return type of 'int', and sizeof(int) != sizeof(pointer) on x86_64.
+ */
+Parrot_PMC Parrot_Class_instantiate(PARROT_INTERP, PMC *, PMC *init);
+
static apr_status_t modparrot_remove_module(void *data)
{
module *modp = (module *)data;
@@ -190,6 +196,78 @@
return(args);
}
+static Parrot_PMC modparrot_wrap_apr_pool(Parrot_Interp interp, apr_pool_t *p)
+{
+ Parrot_PMC pool_class;
+ Parrot_PMC pool_pmc;
+ Parrot_PMC pointer_pmc;
+ Parrot_PMC namespace;
+ Parrot_PMC init;
+ int typenum;
+
+ typenum = Parrot_PMC_typenum(interp, "ResizableStringArray");
+ namespace = (Parrot_PMC)Parrot_PMC_new(interp, typenum);
+ Parrot_register_pmc(interp, namespace);
+ Parrot_PMC_set_intval(interp, namespace, 3);
+ Parrot_PMC_set_cstring_intkey(interp, namespace, 0, "ModParrot");
+ Parrot_PMC_set_cstring_intkey(interp, namespace, 1, "APR");
+ Parrot_PMC_set_cstring_intkey(interp, namespace, 2, "Pool");
+ pool_class = Parrot_oo_get_class(interp, namespace);
+ Parrot_unregister_pmc(interp, namespace);
+
+ typenum = Parrot_PMC_typenum(interp, "UnManagedStruct");
+ pointer_pmc = (Parrot_PMC)Parrot_PMC_new(interp, typenum);
+ Parrot_PMC_set_pointer(interp, pointer_pmc, p);
+
+ typenum = Parrot_PMC_typenum(interp, "Hash");
+ init = (Parrot_PMC)Parrot_PMC_new(interp, typenum);
+ Parrot_register_pmc(interp, init);
+ Parrot_PMC_set_pmc_keyed_str(interp, init,
+ string_from_literal(interp, "apr_pool"), pointer_pmc);
+ pool_pmc = Parrot_Class_instantiate(interp, pool_class, init);
+ Parrot_register_pmc(interp, pool_pmc);
+ Parrot_unregister_pmc(interp, init);
+ Parrot_unregister_pmc(interp, pool_class);
+
+ return(pool_pmc);
+}
+
+static Parrot_PMC modparrot_wrap_server_rec(Parrot_Interp interp, server_rec *s)
+{
+ Parrot_PMC sr_class;
+ Parrot_PMC sr_pmc;
+ Parrot_PMC pointer_pmc;
+ Parrot_PMC namespace;
+ Parrot_PMC init;
+ int typenum;
+
+ typenum = Parrot_PMC_typenum(interp, "ResizableStringArray");
+ namespace = (Parrot_PMC)Parrot_PMC_new(interp, typenum);
+ Parrot_register_pmc(interp, namespace);
+ Parrot_PMC_set_intval(interp, namespace, 3);
+ Parrot_PMC_set_cstring_intkey(interp, namespace, 0, "ModParrot");
+ Parrot_PMC_set_cstring_intkey(interp, namespace, 1, "Apache");
+ Parrot_PMC_set_cstring_intkey(interp, namespace, 2, "ServerRec");
+ sr_class = Parrot_oo_get_class(interp, namespace);
+ Parrot_unregister_pmc(interp, namespace);
+
+ typenum = Parrot_PMC_typenum(interp, "UnManagedStruct");
+ pointer_pmc = (Parrot_PMC)Parrot_PMC_new(interp, typenum);
+ Parrot_PMC_set_pointer(interp, pointer_pmc, s);
+
+ typenum = Parrot_PMC_typenum(interp, "Hash");
+ init = (Parrot_PMC)Parrot_PMC_new(interp, typenum);
+ Parrot_register_pmc(interp, init);
+ Parrot_PMC_set_pmc_keyed_str(interp, init,
+ string_from_literal(interp, "server_rec"), pointer_pmc);
+ sr_pmc = Parrot_Class_instantiate(interp, sr_class, init);
+ Parrot_register_pmc(interp, sr_pmc);
+ Parrot_unregister_pmc(interp, init);
+ Parrot_unregister_pmc(interp, sr_class);
+
+ return(sr_pmc);
+}
+
static const char *modparrot_module_cmd_take123(cmd_parms *cmd, void *mconfig,
const char *arg1,
const char *arg2,
@@ -197,6 +275,8 @@
{
modparrot_context *ctxp;
Parrot_PMC args;
+ Parrot_PMC pool_pmc;
+ Parrot_PMC sr_pmc;
modparrot_module_cmd_data *data = cmd->cmd->cmd_data;
modparrot_module_info *minfo = data->modp->dynamic_load_handle;
modparrot_module_config *srvcfg, *dircfg;
@@ -214,8 +294,10 @@
srvcfg->name = apr_pstrdup(cmd->pool, data->modp->name);
if (minfo->server_create_sub) {
/* XXX pass in pool and server_rec objects when implemented */
+ 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, "P");
+ minfo->server_create_sub, "PPP", pool_pmc, sr_pmc);
if (!PMC_IS_NULL(srvcfg->cfg)) {
Parrot_register_pmc(ctxp->interp, srvcfg->cfg);
}
@@ -230,8 +312,10 @@
dircfg->name = apr_pstrdup(cmd->pool, data->modp->name);
if (minfo->dir_create_sub) {
/* XXX pass in pool and server_rec objects when implemented */
+ 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, "P");
+ minfo->dir_create_sub, "PPP", pool_pmc, sr_pmc);
if (!PMC_IS_NULL(dircfg->cfg)) {
Parrot_register_pmc(ctxp->interp, dircfg->cfg);
}