[svn:mod_parrot] r249 - in mod_parrot/trunk: . docs include lib lib/ModParrot src t/conf

[email protected]
Newsgroups perl.cvs.mod_parrot
Message-ID <[email protected]>
Author: jhorwitz
Date: Tue Sep 11 08:37:31 2007
New Revision: 249

Added:
   mod_parrot/trunk/lib/mod_parrot.pir
Removed:
   mod_parrot/trunk/lib/ModParrot/init.pir
Modified:
   mod_parrot/trunk/Makefile.in
   mod_parrot/trunk/docs/apache-conf.txt
   mod_parrot/trunk/include/modparrot_config.h
   mod_parrot/trunk/src/mod_parrot.c
   mod_parrot/trunk/src/modparrot_config.c
   mod_parrot/trunk/t/conf/extra.conf.in

Log:
implement ParrotIncludePath directive to add parrot library search paths
move all initialization and library preloading in mod_parrot.pir



Modified: mod_parrot/trunk/Makefile.in
==============================================================================
--- mod_parrot/trunk/Makefile.in	(original)
+++ mod_parrot/trunk/Makefile.in	Tue Sep 11 08:37:31 2007
@@ -29,7 +29,7 @@
 MPLIBS=	lib/Apache/RequestRec \
 	lib/Apache/Constants \
 	lib/APR/Table \
-	lib/ModParrot/init \
+	lib/mod_parrot \
 	lib/ModParrot/HLL/pir \
 	lib/ModParrot/HLL/perl6 \
 	lib/ModParrot/HLL/nqp

Modified: mod_parrot/trunk/docs/apache-conf.txt
==============================================================================
--- mod_parrot/trunk/docs/apache-conf.txt	(original)
+++ mod_parrot/trunk/docs/apache-conf.txt	Tue Sep 11 08:37:31 2007
@@ -8,6 +8,13 @@
 Context:     server config
 Description: Specify path to init.pbc
 
+ParrotIncludePath
+----------
+Syntax:      ParrotIncludePath path1[:path2]...
+Default:     none
+Context:     server config
+Description: colon separated list of search paths for Parrot libraries
+
 ParrotLoad
 ----------
 Syntax:      ParrotLoad path

Modified: mod_parrot/trunk/include/modparrot_config.h
==============================================================================
--- mod_parrot/trunk/include/modparrot_config.h	(original)
+++ mod_parrot/trunk/include/modparrot_config.h	Tue Sep 11 08:37:31 2007
@@ -30,6 +30,7 @@
     apr_pool_t *pool;
     char *init_path;
     int trace_flags;
+    char *include_path;
     apr_array_header_t *preload;
     modparrot_handler_info *open_logs_handler;
     modparrot_handler_info *child_init_handler;
@@ -92,3 +93,4 @@
 const char *modparrot_cmd_trace(cmd_parms *, void *, const char *);
 const char *modparrot_cmd_language(cmd_parms *, void *, const char *);
 const char *modparrot_cmd_load(cmd_parms *, void *, const char *);
+const char *modparrot_cmd_include_path(cmd_parms *, void *, const char *);

Added: mod_parrot/trunk/lib/mod_parrot.pir
==============================================================================
--- (empty file)
+++ mod_parrot/trunk/lib/mod_parrot.pir	Tue Sep 11 08:37:31 2007
@@ -0,0 +1,112 @@
+# this file should be autogenerated
+
+# Copyright (c) 2004, 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.
+
+.namespace [ '_modparrot' ]
+
+.include 'iglobals.pasm'
+
+# use when NCI can dlfunc from the current image
+.sub modparrot_init
+    .local pmc func
+    .local pmc nul
+
+    null nul
+
+    .include "build/src/pir/request_rec_dlfunc.pir"
+
+    dlfunc func, nul, "mpnci_backtrace", "tJ"
+    set_root_global [ '_modparrot'; 'NCI' ], "backtrace", func
+
+    dlfunc func, nul, "mpnci_request_rec", "pJ"
+    set_root_global [ '_modparrot'; 'NCI' ], "request_rec", func
+
+    dlfunc func, nul, "mpnci_request_rec_main", "pJp"
+    set_root_global [ '_modparrot'; 'NCI' ], "request_rec_main", func
+
+    dlfunc func, nul, "mpnci_request_rec_next", "pJp"
+    set_root_global [ '_modparrot'; 'NCI' ], "request_rec_next", func
+
+    dlfunc func, nul, "mpnci_request_rec_prev", "pJp"
+    set_root_global [ '_modparrot'; 'NCI' ], "request_rec_prev", func
+
+    dlfunc func, nul, "mpnci_request_rec_user", "tJpti"
+    set_root_global [ '_modparrot'; 'NCI' ], "request_rec_user", func
+
+    dlfunc func, nul, "mpnci_request_rec_notes", "pJp"
+    set_root_global [ '_modparrot'; 'NCI' ], "request_rec_notes", func
+
+    dlfunc func, nul, "mpnci_request_rec_get_basic_auth_pw", "iJpP"
+    set_root_global [ '_modparrot'; 'NCI' ], "request_rec_get_basic_auth_pw", func
+
+    dlfunc func, nul, "mpnci_rwrite", "iJPip"
+    set_root_global [ '_modparrot'; 'NCI' ], "rwrite", func
+
+    dlfunc func, nul, "mpnci_conf_pool", "pJ"
+    set_root_global [ '_modparrot'; 'NCI' ], "conf_pool", func
+
+    dlfunc func, nul, "mpnci_temp_pool", "pJ"
+    set_root_global [ '_modparrot'; 'NCI' ], "temp_pool", func
+
+    dlfunc func, nul, "mpnci_log_pool", "pJ"
+    set_root_global [ '_modparrot'; 'NCI' ], "log_pool", func
+
+    dlfunc func, nul, "mpnci_child_pool", "pJ"
+    set_root_global [ '_modparrot'; 'NCI' ], "child_pool", func
+
+    dlfunc func, nul, "mpnci_server_rec", "pJ"
+    set_root_global [ '_modparrot'; 'NCI' ], "server_rec", func
+
+    dlfunc func, nul, "mpnci_conn_rec", "pJ"
+    set_root_global [ '_modparrot'; 'NCI' ], "conn_rec", func
+
+    dlfunc func, nul, "mpnci_csd", "pJ"
+    set_root_global [ '_modparrot'; 'NCI' ], "csd", func
+
+    # load required libraries
+    load_bytecode 'Apache/Constants.pbc'
+    load_bytecode 'Apache/RequestRec.pbc'
+    load_bytecode 'APR/Table.pbc'
+    load_bytecode 'ModParrot/HLL/pir.pbc'
+.end
+
+.sub modparrot_set_include_path
+    .param string pathstring
+    .local string path
+    .local pmc pathlist
+    .local pmc interp
+    .local pmc lib_paths
+    .local pmc include_paths
+    .local int count
+
+    getinterp interp
+    lib_paths = interp[.IGLOBALS_LIB_PATHS]
+
+    # XXX replace magic constant -- see parrot's t/compilers/imcc/syn/file.t
+    include_paths = lib_paths[1]
+
+    pathlist = split ':', pathstring
+    count = elements pathlist
+    $I0 = count
+
+PATH_LOOP:
+    dec $I0
+    path = pathlist[$I0]
+    unshift include_paths, path
+    if $I0 > 0 goto PATH_LOOP
+
+    .return(count)
+.end
+

Modified: mod_parrot/trunk/src/mod_parrot.c
==============================================================================
--- mod_parrot/trunk/src/mod_parrot.c	(original)
+++ mod_parrot/trunk/src/mod_parrot.c	Tue Sep 11 08:37:31 2007
@@ -60,7 +60,17 @@
 
     /* run initialization code */
     if (cfg->init_path) {
+
+        /* load the init code */
         modparrot_load_bytecode(interp, cfg->init_path);
+
+        /* set additional include paths from apache config */
+        if (cfg->include_path) {
+            modparrot_call_sub_IS(interp, "_modparrot",
+                "modparrot_set_include_path", &i, cfg->include_path);
+        }
+
+        /* initialize parrot side */
         modparrot_call_sub(interp, "_modparrot", "modparrot_init");
     }
 
@@ -72,7 +82,6 @@
 
     /* load ParrotLoad files */
     for (i = 0; i < cfg->preload->nelts; i++) {
-        /* char *filename = ((char **)cfg->preload->elts)[i]; */
         modparrot_handler_info *l =
             &((modparrot_handler_info *)cfg->preload->elts)[i];
         char *ext = strrchr(l->id, '.');
@@ -1042,6 +1051,13 @@
         RSRC_CONF,
         "preload Parrot code"
     ),
+    AP_INIT_TAKE1(
+        "ParrotIncludePath",
+        modparrot_cmd_include_path,
+        NULL,
+        RSRC_CONF,
+        "set the Parrot include path"
+    ),
     { NULL }
 };
 

Modified: mod_parrot/trunk/src/modparrot_config.c
==============================================================================
--- mod_parrot/trunk/src/modparrot_config.c	(original)
+++ mod_parrot/trunk/src/modparrot_config.c	Tue Sep 11 08:37:31 2007
@@ -44,6 +44,7 @@
     cfg->trace_flags = 0;
     cfg->init_path = MODPARROT_DEFAULT_INIT;
     cfg->preload = apr_array_make(p, 2, sizeof(modparrot_handler_info));
+    cfg->include_path = NULL;
 
     return (void *)cfg;
 }
@@ -367,3 +368,12 @@
     cfg->init_path = (char *)apr_pstrdup(cmd->pool, path);
     return NULL;
 }
+
+const char *modparrot_cmd_include_path(cmd_parms *cmd, void *mconfig, const char *path)
+{
+    modparrot_srv_config *cfg;
+
+    cfg = GET_SERVER_CONFIG(cmd);
+    cfg->include_path = (char *)apr_pstrdup(cmd->pool, path);
+    return NULL;
+}

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	Tue Sep 11 08:37:31 2007
@@ -2,11 +2,8 @@
     LoadModule parrot_module @ServerRoot@/../src/.libs/mod_parrot.so
 </IfModule>
 
-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
+ParrotIncludePath @ServerRoot@/../lib
+ParrotInit @ServerRoot@/../lib/mod_parrot.pbc
 ParrotLoad @ServerRoot@/lib/handlers.pbc
 
 # enable for test debugging
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.