[svn:mod_parrot] r650 - in mod_parrot/branches/configure-jeff: . include languages/perl6/lib languages/perl6/lib/Apache languages/perl6/lib/ModPerl6 lib lib/ModParrot/HLL src src/pmc

[email protected] Tue, 23 Jun 2009 11:43:18 -0700 (PDT)
Newsgroups perl.cvs.mod_parrot
Message-ID <[email protected]>
Author: jhorwitz
Date: Tue Jun 23 11:43:17 2009
New Revision: 650

Added:
   mod_parrot/branches/configure-jeff/languages/perl6/lib/Apache/Module.pm
      - copied unchanged from r649, /mod_parrot/trunk/languages/perl6/lib/Apache/Module.pm
Modified:
   mod_parrot/branches/configure-jeff/Configure.pl
   mod_parrot/branches/configure-jeff/Makefile.in
   mod_parrot/branches/configure-jeff/include/mod_parrot.h
   mod_parrot/branches/configure-jeff/languages/perl6/lib/ModPerl6/Registry.pm
   mod_parrot/branches/configure-jeff/languages/perl6/lib/mod_perl6.pm
   mod_parrot/branches/configure-jeff/lib/ModParrot/HLL/perl6.pir
   mod_parrot/branches/configure-jeff/lib/mod_parrot.pir
   mod_parrot/branches/configure-jeff/src/mod_parrot.c
   mod_parrot/branches/configure-jeff/src/module.c
   mod_parrot/branches/configure-jeff/src/parrot_util.c
   mod_parrot/branches/configure-jeff/src/pmc/modparrothandle.pmc

Log:
refactor Configuration
update: merge -r637:649 from trunk


Modified: mod_parrot/branches/configure-jeff/Configure.pl
==============================================================================
--- mod_parrot/branches/configure-jeff/Configure.pl	(original)
+++ mod_parrot/branches/configure-jeff/Configure.pl	Tue Jun 23 11:43:17 2009
@@ -1,6 +1,6 @@
 # $Id$
 
-# Copyright (c) 2004, 2005, 2007 Jeff Horwitz
+# Copyright (c) 2004, 2005, 2007, 2009 Jeff Horwitz
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -17,6 +17,8 @@
 # mod_parrot configuration script
 
 use Getopt::Long;
+use File::Spec::Functions;
+use IO::File;
 
 # parts stolen from mod_perl
 my %threaded_mpms = map { $_ => 1}
@@ -27,59 +29,80 @@
     return $threaded_mpms{$_[0]};
 }
 
-my $parrot_build_dir = '../parrot';
-my $apxs = '/usr/local/apache/bin/apxs';
-my $perl = $^X;
+# set some defaults
+my $parrot_config;
+my $apxs = 'apxs';
 
 my $res = GetOptions(
-    'parrot-build-dir=s' => \$parrot_build_dir,
-    'apxs=s' => \$apxs
+    'with-parrot-config=s' => \$parrot_config,
+    'with-apxs=s' => \$apxs
 );
 
 $res || die "error while parsing options";
 
-sub parrot_config
-{
-    my $config = shift;
-    my $value = `$parrot_build_dir/parrot_config $config`;
-    chomp($value);
-    return $value;
-}
+$parrot_config ||= catfile('parrot_config');
 
 $| = 1;
 
-print "\n";
+# get parrot config data
+my %parrot_config;
+my $fh = IO::File->new;
+$fh->open("$parrot_config --dump |") or die $!;
+while (my $line = $fh->getline) {
+    if ($line =~ /([\w_]+)\s+=>\s+'(.+?)'/) {
+        $parrot_config{$1} = $2;
+    }
+}
+$fh->close();
+
+# SOVERSION is missing, so infer from VERSION
+$parrot_config{'soversion'} = $parrot_config{'VERSION'};
 
-# defines to pass to compiler
-my $defines;
+# kludge to translate $(KEY) to their proper values
+# can't do this in the previous loop -- substitutions might be forward-looking
+for (;;) {
+    my $n = 0;
+    while (my ($k, $v) = each %parrot_config) {
+        $parrot_config{$k} =~ s/\$\(([\w_]+)\)/$parrot_config{lc($1)}/g;
+        $n++ if $parrot_config{$k} =~ /\$\([\w_]+\)/;
+    }
+    last unless $n;
+}
 
-# debugging flags for developers
-my $debug = $ENV{'MP_DEBUG'};
+# populate config hash with the easy stuff
 
-# apache configs
-my $apache_include_dir = `$apxs -q INCLUDEDIR`;
-my $apr_include_dir = `$apxs -q APR_INCLUDEDIR`;
-my $apu_include_dir = `$apxs -q APU_INCLUDEDIR`;
-my $ap_cflags = `$apxs -q CFLAGS`;
-my $extra_cppflags = `$apxs -q EXTRA_CPPFLAGS`;
-my $libexec_dir = `$apxs -q LIBEXECDIR`;
-my $cc = `$apxs -q CC`;
-my $libtool = `$apxs -q LIBTOOL`;
+my %config = (
+    apache_include_dir   => `$apxs -q INCLUDEDIR`,
+    apr_include_dir      => `$apxs -q APR_INCLUDEDIR`,
+    apu_include_dir      => `$apxs -q APU_INCLUDEDIR`,
+    apxs                 => $apxs,
+    cc                   => `$apxs -q CC`,
+    extra_cppflags       => `$apxs -q EXTRA_CPPFLAGS`,
+    libexecdir           => `$apxs -q LIBEXECDIR`,
+    libtool              => `$apxs -q LIBTOOL`,
+    parrot               => catfile($parrot_config{'build_dir'}, 'parrot'),
+    parrot_blib_dir      => $parrot_config{'blib_dir'},
+    parrot_build_dir     => $parrot_config{'build_dir'},
+    perl                 => $^X,
+);
+
+# now onto the more complex stuff
 
-# discover mpm -- we don't use this yet, but we might
 my $mpm = `$apxs -q MPM_NAME`;
 $mpm or die "Couldn't find Apache MPM";
 chomp($mpm);
-print "Configuring mod_parrot for $mpm MPM.\n";
+print "\nConfiguring mod_parrot for $mpm MPM.\n";
+$config{mpm} = $mpm;
+$config{ap_cflags} = `$apxs -q CFLAGS`;
+chomp($config{ap_cflags});
+$config{cflags} = " -I$parrot_config{'build_dir'}/include -Iinclude $config{ap_cflags}";
+$config{cflags} .= " -DMPM_IS_THREADED" if (mpm_is_threaded($mpm));
+$config{libs} = "$parrot_config{'libparrot_linkflags'}" .
+    " $parrot_config{'libparrot_ldflags'}" .
+    " -R " . catfile($parrot_config{'build_dir'}, $parrot_config{'blib_dir'}) .
+    " $parrot_config{'libparrot_linkflags'} $parrot_config{'libparrot_ldflags'}";
 
-# we can't use the config verbatim -- apxs chokes on it, so we use what we can
-chomp($ap_cflags);
-my $cflags = " -I$parrot_build_dir/include -Iinclude $ap_cflags";
-$cflags .= " -DMPM_IS_THREADED" if (mpm_is_threaded($mpm));
-my $libs = parrot_config('libs') . " -lparrot";
-my $blib_dir = parrot_config('blib_dir');
-my $ldflags = parrot_config('libparrot_ldflags') .
-    " -R$parrot_build_dir/$blib_dir";
+# we have our config hash, so create the makefile
 
 print "Generating Makefile...";
 my $template;
@@ -89,29 +112,14 @@
     $template = <MAKEFILE_IN>;
     close(MAKEFILE_IN);
 }
-$template =~ s/\@CC\@/$cc/g;
-$template =~ s/\@LIBTOOL\@/$libtool/g;
-$template =~ s/\@DEFINES\@/$defines/g;
-$template =~ s/\@CFLAGS\@/$cflags/g;
-$template =~ s/\@DEBUG\@/$debug/g;
-$template =~ s/\@EXTRA_CPPFLAGS\@/$extra_cppflags/g;
-$template =~ s/\@LDFLAGS\@/$ldflags/g;
-$template =~ s/\@LIBS\@/$libs/g;
-$template =~ s/\@LIBEXECDIR\@/$libexec_dir/g;
-$template =~ s/\@APXS\@/$apxs/g;
-$template =~ s/\@PERL\@/$perl/g;
-$template =~ s/\@PARROT_SOURCE\@/$parrot_build_dir/g;
-$template =~ s/\@PARROT_BLIB_DIR\@/$parrot_build_dir\/$blib_dir/g;
-$template =~ s/\@PARROT\@/$parrot_build_dir\/parrot/g;
-$template =~ s/\@APACHE_INCLUDE_DIR\@/$apache_include_dir/g;
-$template =~ s/\@APR_INCLUDE_DIR\@/$apr_include_dir/g;
-$template =~ s/\@APU_INCLUDE_DIR\@/$apu_include_dir/g;
-$template =~ s/\@CALLING_CONVENTIONS\@/$calling_conventions/g;
+$template =~ s/\@(.+?)\@/$config{$1}/g;
 open(MAKEFILE, ">Makefile") or die $!;
 print MAKEFILE $template;
 close(MAKEFILE);
 print "done.\n";
 
+# configure Apache::Test
+
 print "Creating testing infrastructure...";
 eval "use Apache::Test 1.26";
 unless ($@) {
@@ -130,7 +138,7 @@
     package main;
     use Apache::TestMM;
     push(@ARGV, '-apxs', $apxs);
-    push(@ARGV, '-defines', "PARROT_BUILD_DIR=$parrot_build_dir");
+    push(@ARGV, '-defines', "PARROT_BUILD_DIR=$parrot_config{'build_dir'}");
     Apache::TestMM::filter_args();
     ModParrot::TestRun->generate_script();
     print "done.\n";

Modified: mod_parrot/branches/configure-jeff/Makefile.in
==============================================================================
--- mod_parrot/branches/configure-jeff/Makefile.in	(original)
+++ mod_parrot/branches/configure-jeff/Makefile.in	Tue Jun 23 11:43:17 2009
@@ -1,24 +1,22 @@
 # $Id$
 
-# This file is autogenerated.  Changes will be lost after reconfiguration.
-
-CC=@CC@
-LIBTOOL=@LIBTOOL@
-APR_INCLUDE_DIR=@APR_INCLUDE_DIR@
-APU_INCLUDE_DIR=@APU_INCLUDE_DIR@
-DEFINES=@DEFINES@
-CFLAGS=@CFLAGS@
-DEBUG=@DEBUG@
-EXTRA_CPPFLAGS=@EXTRA_CPPFLAGS@
-LDFLAGS=@LDFLAGS@
-LIBS=@LIBS@
-LIBEXECDIR=@LIBEXECDIR@
-PERL=@PERL@
-APXS=@APXS@
-PARROT_SOURCE=@PARROT_SOURCE@
-PARROT_BLIB_DIR=@PARROT_BLIB_DIR@
-PARROT=@PARROT@
-APACHE_INCLUDE_DIR=@APACHE_INCLUDE_DIR@
+CC=@cc@
+LIBTOOL=@libtool@
+APACHE_INCLUDE_DIR=@apache_include_dir@
+APR_INCLUDE_DIR=@apr_include_dir@
+APU_INCLUDE_DIR=@apu_include_dir@
+DEFINES=@defines@
+CFLAGS=@cflags@
+DEBUG=@debug@
+EXTRA_CPPFLAGS=@extra_cppflags@
+LDFLAGS=@ldflags@
+LIBS=@libs@
+LIBEXECDIR=@libexecdir@
+PERL=@perl@
+APXS=@apxs@
+PARROT_SOURCE=@parrot_build_dir@
+PARROT_BLIB_DIR=@parrot_blib_dir@
+PARROT=@parrot@
 PARROT_DYNEXT=$(PARROT_SOURCE)/runtime/parrot/dynext
 BUILD_DYNPMC=$(PERL) $(PARROT_SOURCE)/tools/build/dynpmc.pl
 MODPARROT_GROUP=modparrot_group.so
@@ -100,7 +98,7 @@
 
 gen-src:
 	@echo Generating Source...
-	perl build/lib/generate_source.pl --apache-include-dir=$(APACHE_INCLUDE_DIR)
+	$(PERL) build/lib/generate_source.pl --apache-include-dir=$(APACHE_INCLUDE_DIR)
 
 gen-src-clean:
 	rm -rf build/src

Modified: mod_parrot/branches/configure-jeff/include/mod_parrot.h
==============================================================================
--- mod_parrot/branches/configure-jeff/include/mod_parrot.h	(original)
+++ mod_parrot/branches/configure-jeff/include/mod_parrot.h	Tue Jun 23 11:43:17 2009
@@ -108,6 +108,9 @@
     char *);
 char *modparrot_backtrace(Parrot_Interp);
 Parrot_PMC get_sub_pmc(Parrot_Interp , char *, char *);
+Parrot_PMC modparrot_get_meta_handler(Parrot_Interp , char *, char *);
+int modparrot_call_meta_handler_sub(Parrot_Interp, Parrot_PMC, int *,
+    Parrot_PMC);
 apr_array_header_t *mp_ctx_pool_init(apr_pool_t *, Parrot_Interp, int);
 void mp_ctx_pool_destroy(apr_array_header_t *);
 modparrot_context *reserve_ctx(apr_array_header_t *, int index);

Modified: mod_parrot/branches/configure-jeff/languages/perl6/lib/ModPerl6/Registry.pm
==============================================================================
--- mod_parrot/branches/configure-jeff/languages/perl6/lib/ModPerl6/Registry.pm	(original)
+++ mod_parrot/branches/configure-jeff/languages/perl6/lib/ModPerl6/Registry.pm	Tue Jun 23 11:43:17 2009
@@ -56,8 +56,8 @@
 
 sub handler($r)
 {
-    my %cfg = ModParrot::Apache::Module::get_config("modparrot_perl6_module");
-    my %dircfg = ModParrot::Apache::Module::get_config(
+    my %cfg = Apache::Module::get_config("modparrot_perl6_module");
+    my %dircfg = Apache::Module::get_config(
         "modparrot_perl6_module", $r.per_dir_config());
 
     my $script = $r.filename();

Modified: mod_parrot/branches/configure-jeff/languages/perl6/lib/mod_perl6.pm
==============================================================================
--- mod_parrot/branches/configure-jeff/languages/perl6/lib/mod_perl6.pm	(original)
+++ mod_parrot/branches/configure-jeff/languages/perl6/lib/mod_perl6.pm	Tue Jun 23 11:43:17 2009
@@ -19,6 +19,7 @@
 use v6;
 use ModParrot::Const;
 use Apache::Const;
+use Apache::Module;
 
 # for perl 6 functionality not yet supported by rakudo
 use ModPerl6::Fudge;
@@ -29,9 +30,7 @@
     parseheaders
 >.map({($_,1)});
 our @server_phases = <open_logs post_config child_init pre_connection
-     process_connection post_read_request map_to_storage>;
-# XXX workaround parsing bug w/ 8 elements
-@server_phases.push('trans'); 
+     process_connection post_read_request map_to_storage trans>;
 our @dir_phases = <header_parser access authen authz response type fixup log
          cleanup>;
 
@@ -51,12 +50,6 @@
     %cfg<preloaded_modules> = [];
     %cfg<postconfig_requires> = [];
 
-    # server-scope config
-    # XXX we shouldn't need to prepopulate these, but things segfault otherwise
-    for @server_phases.map({$_ ~ '_handler'}) -> $h {
-        %cfg{$h} = undef;
-    }
-
     return %cfg;
 }
 
@@ -64,12 +57,6 @@
 {
     my %cfg;
 
-    # section-scope config
-    # XXX we shouldn't need to prepopulate these, but things segfault otherwise
-    for @dir_phases.map({$_ ~ '_handler'}) -> $h {
-        %cfg{$h} = undef;
-    }
-
     # options set with Perl6Options
     %cfg<options> = {
         parseheaders => False,
@@ -163,8 +150,8 @@
 sub header_parser_handler($ctx)
 {
     my $r = $ctx.request_rec();
-    my %cfg = ModParrot::Apache::Module::get_config("modparrot_perl6_module");
-    my %dircfg = ModParrot::Apache::Module::get_config("modparrot_perl6_module",
+    my %cfg = Apache::Module::get_config("modparrot_perl6_module");
+    my %dircfg = Apache::Module::get_config("modparrot_perl6_module",
         $r.per_dir_config());
 
     # first phase that has a dir config, so register any cleanup handlers
@@ -172,7 +159,7 @@
         $r.pool.cleanup_register(&cleanup_handler, %dircfg<cleanup_handler>);
     }
 
-    # back to the post_read_request handler
+    # back to the header_parser handler
     my $handler = %dircfg<header_parser_handler>;
     unless ($handler) {
         return $Apache::Const::OK;
@@ -182,16 +169,58 @@
     return $status;
 }
 
+sub access_handler($ctx)
+{
+    my $r = $ctx.request_rec();
+
+    my %cfg = Apache::Module::get_config("modparrot_perl6_module");
+    my %dircfg = Apache::Module::get_config("modparrot_perl6_module",
+        $r.per_dir_config());
+
+    my $handler = %dircfg<access_handler>;
+
+    my $status = call_handler($handler, $r);
+    return $status;
+}
+
+sub authen_handler($ctx)
+{
+    my $r = $ctx.request_rec();
+
+    my %cfg = Apache::Module::get_config("modparrot_perl6_module");
+    my %dircfg = Apache::Module::get_config("modparrot_perl6_module",
+        $r.per_dir_config());
+
+    my $handler = %dircfg<authen_handler>;
+
+    my $status = call_handler($handler, $r);
+    return $status;
+}
+
+sub authz_handler($ctx)
+{
+    my $r = $ctx.request_rec();
+
+    my %cfg = Apache::Module::get_config("modparrot_perl6_module");
+    my %dircfg = Apache::Module::get_config("modparrot_perl6_module",
+        $r.per_dir_config());
+
+    my $handler = %dircfg<authz_handler>;
+
+    my $status = call_handler($handler, $r);
+    return $status;
+}
+
 sub response_handler($ctx)
 {
     my $r = $ctx.request_rec();
 
-    unless ($r.handler() ~~ any(<modperl6 perl6-script>)) {
+    unless ($r.handler() ~~ 'modperl6'|'perl6-script') {
         return $Apache::Const::DECLINED;
     }
 
-    my %cfg = ModParrot::Apache::Module::get_config("modparrot_perl6_module");
-    my %dircfg = ModParrot::Apache::Module::get_config("modparrot_perl6_module",
+    my %cfg = Apache::Module::get_config("modparrot_perl6_module");
+    my %dircfg = Apache::Module::get_config("modparrot_perl6_module",
         $r.per_dir_config());
 
     my $handler = %dircfg<response_handler>;
@@ -216,7 +245,7 @@
     #my $s = $ctx.server_rec();
     my $s = undef;
 
-    my %cfg = ModParrot::Apache::Module::get_config("modparrot_perl6_module");
+    my %cfg = Apache::Module::get_config("modparrot_perl6_module");
 
     # preload modules
     # NOTE: Perl6Module is a directory scope directive
@@ -247,49 +276,49 @@
 
 sub cmd_perl6openlogshandler($parms, %mconfig, @args)
 {
-    my %cfg := ModParrot::Apache::Module::get_config("modparrot_perl6_module");
+    my %cfg := Apache::Module::get_config("modparrot_perl6_module");
     %cfg<open_logs_handler> = @args[0];
 }
 
 sub cmd_perl6postconfighandler($parms, %mconfig, @args)
 {
-    my %cfg := ModParrot::Apache::Module::get_config("modparrot_perl6_module");
+    my %cfg := Apache::Module::get_config("modparrot_perl6_module");
     %cfg<post_config_handler> = @args[0];
 }
 
 sub cmd_perl6childinithandler($parms, %mconfig, @args)
 {
-    my %cfg := ModParrot::Apache::Module::get_config("modparrot_perl6_module");
+    my %cfg := Apache::Module::get_config("modparrot_perl6_module");
     %cfg<child_init_handler> = @args[0];
 }
 
 sub cmd_perl6preconnectionhandler($parms, %mconfig, @args)
 {
-    my %cfg := ModParrot::Apache::Module::get_config("modparrot_perl6_module");
+    my %cfg := Apache::Module::get_config("modparrot_perl6_module");
     %cfg<pre_connection_handler> = @args[0];
 }
 
 sub cmd_perl6processconnectionhandler($parms, %mconfig, @args)
 {
-    my %cfg := ModParrot::Apache::Module::get_config("modparrot_perl6_module");
+    my %cfg := Apache::Module::get_config("modparrot_perl6_module");
     %cfg<process_connection_handler> = @args[0];
 }
 
 sub cmd_perl6postreadrequesthandler($parms, %mconfig, @args)
 {
-    my %cfg := ModParrot::Apache::Module::get_config("modparrot_perl6_module");
+    my %cfg := Apache::Module::get_config("modparrot_perl6_module");
     %cfg<post_read_request_handler> = @args[0];
 }
 
 sub cmd_perl6maptostoragehandler($parms, %mconfig, @args)
 {
-    my %cfg := ModParrot::Apache::Module::get_config("modparrot_perl6_module");
+    my %cfg := Apache::Module::get_config("modparrot_perl6_module");
     %cfg<map_to_storage_handler> = @args[0];
 }
 
 sub cmd_perl6transhandler($parms, %mconfig, @args)
 {
-    my %cfg := ModParrot::Apache::Module::get_config("modparrot_perl6_module");
+    my %cfg := Apache::Module::get_config("modparrot_perl6_module");
     %cfg<trans_handler> = @args[0];
 }
 
@@ -336,16 +365,11 @@
 sub cmd_perl6cleanuphandler($parms, %dircfg, @args)
 {
     %dircfg<cleanup_handler> = @args[0];
-}
-
-sub cmd_perl6cleanuphandler($parms, %dircfg, @args)
-{
-    %dircfg<cleanup_handler> = @args[0];
 } 
 
 sub cmd_perl6module($parms, %mconfig, @args)
 {
-    my %cfg := ModParrot::Apache::Module::get_config("modparrot_perl6_module");
+    my %cfg := Apache::Module::get_config("modparrot_perl6_module");
     push(%cfg<preloaded_modules>, @args[0]);
 }
 
@@ -391,6 +415,27 @@
         'errmsg' => 'usage: Perl6PostConfigHandler handler-name'
     },
     {
+        'name' => 'Perl6AccessHandler',
+        'args_how' => $Apache::Const::TAKE1,
+        'func' => &cmd_perl6accesshandler,
+        'req_override' => $Apache::Const::OR_AUTHCFG,
+        'errmsg' => 'usage: Perl6AccessHandler handler-name'
+    },
+    {
+        'name' => 'Perl6AuthenHandler',
+        'args_how' => $Apache::Const::TAKE1,
+        'func' => &cmd_perl6authenhandler,
+        'req_override' => $Apache::Const::OR_AUTHCFG,
+        'errmsg' => 'usage: Perl6AuthenHandler handler-name'
+    },
+    {
+        'name' => 'Perl6AuthzHandler',
+        'args_how' => $Apache::Const::TAKE1,
+        'func' => &cmd_perl6authzhandler,
+        'req_override' => $Apache::Const::OR_AUTHCFG,
+        'errmsg' => 'usage: Perl6AuthzHandler handler-name'
+    },
+    {
         'name' => 'Perl6ResponseHandler',
         'args_how' => $Apache::Const::TAKE1,
         'func' => &cmd_perl6responsehandler,
@@ -418,10 +463,13 @@
     $ModParrot::Const::MP_HOOK_OPEN_LOGS,
     $ModParrot::Const::MP_HOOK_POST_CONFIG,
     $ModParrot::Const::MP_HOOK_HEADER_PARSER,
+    $ModParrot::Const::MP_HOOK_ACCESS,
+    $ModParrot::Const::MP_HOOK_AUTHEN,
+    $ModParrot::Const::MP_HOOK_AUTHZ,
     $ModParrot::Const::MP_HOOK_RESPONSE
 );
 
-ModParrot::Apache::Module::add(
+Apache::Module::add(
     'modparrot_perl6_module',
     'perl6',
     @cmds,

Modified: mod_parrot/branches/configure-jeff/lib/ModParrot/HLL/perl6.pir
==============================================================================
--- mod_parrot/branches/configure-jeff/lib/ModParrot/HLL/perl6.pir	(original)
+++ mod_parrot/branches/configure-jeff/lib/ModParrot/HLL/perl6.pir	Tue Jun 23 11:43:17 2009
@@ -15,10 +15,28 @@
 # limitations under the License.
 
 .sub __onload :anon :load
+    $P0 = get_hll_global 'P6metaclass'
+    $P1 = get_class ['ModParrot'; 'Apache'; 'RequestRec']
+    $P0.'register'($P1, 'name' => 'Apache;RequestRec', 'perl6' :named('hll'))
+    $P1 = get_class ['ModParrot'; 'Apache'; 'ServerRec']
+    $P0.'register'($P1, 'name' => 'Apache;ServerRec', 'perl6' :named('hll'))
+    $P1 = get_class ['ModParrot'; 'Apache'; 'CmdParms']
+    $P0.'register'($P1, 'name' => 'Apache;CmdParms', 'perl6' :named('hll'))
+    $P1 = get_class ['ModParrot';'APR'; 'Pool']
+    $P0.'register'($P1, 'name' => 'APR;Pool', 'perl6' :named('hll'))
+    $P1 = get_class ['ModParrot';'APR'; 'Table']
+    $P0.'register'($P1, 'name' => 'APR;Table', 'perl6' :named('hll'))
+    $P1 = get_class ['ModParrot'; 'Interpreter']
+    $P0.'register'($P1, 'perl6' :named('hll'))
+    $P1 = get_class ['ModParrot'; 'Context']
+    $P0.'register'($P1, 'perl6' :named('hll'))
+    $P1 = get_class ['ModParrotHandle']
+    $P0.'register'($P1, 'perl6' :named('hll'))
+
     load_bytecode 'languages/rakudo/perl6.pbc'
 
     # load mod_perl6.pm, which may be precompiled
-    $P0 = compreg 'Perl6'
+    $P0 = compreg 'perl6'
     $P1 = $P0.'compile'('use mod_perl6')
     $P1()
 .end

Modified: mod_parrot/branches/configure-jeff/lib/mod_parrot.pir
==============================================================================
--- mod_parrot/branches/configure-jeff/lib/mod_parrot.pir	(original)
+++ mod_parrot/branches/configure-jeff/lib/mod_parrot.pir	Tue Jun 23 11:43:17 2009
@@ -157,33 +157,6 @@
     load_bytecode 'ModParrot/APR/Pool.pbc'
     load_bytecode 'ModParrot/APR/Table.pbc'
 
-    # some languages make use of the Perl6 metamodel, so we register several
-    # mod_parrot classes as Perl6 meta classes so languages can access them
-    # natively.  use 'name' to register the class under a different name,
-    # letting mod_parrot provide scaffolding for functionality not yet
-    # available in the HLL layer.
-
-    # XXX this MUST be done before the mod_parrot classes are instantiated,
-    # so it can't be done in the HLL modules.  this needs to be fixed.
-
-    $P0 = get_hll_global 'P6metaclass'
-    $P1 = get_class ['ModParrot'; 'Apache'; 'RequestRec']
-    $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']
-    $P0.'register'($P1, 'name' => 'APR;Table')
-    $P1 = get_class ['ModParrot'; 'Interpreter']
-    $P0.'register'($P1)
-    $P1 = get_class ['ModParrot'; 'Context']
-    $P0.'register'($P1)
-    $P1 = get_class ['ModParrotHandle']
-    $P0.'register'($P1)
-
     # global to indicate that we're actually running
     $P0 = new 'Integer'
     $P0 = 1

Modified: mod_parrot/branches/configure-jeff/src/mod_parrot.c
==============================================================================
--- mod_parrot/branches/configure-jeff/src/mod_parrot.c	(original)
+++ mod_parrot/branches/configure-jeff/src/mod_parrot.c	Tue Jun 23 11:43:17 2009
@@ -48,12 +48,6 @@
 /* declare our module */
 extern module AP_MODULE_DECLARE_DATA parrot_module;
 
-/* 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);
-
 void modparrot_init_globals(apr_pool_t *p)
 {
     int i;
@@ -354,6 +348,7 @@
     Parrot_PMC ctx_class;
     Parrot_PMC ctx_pmc;
     Parrot_PMC namespace;
+    Parrot_PMC sub;
     Parrot_Int typenum;
     int res;
 
@@ -366,11 +361,12 @@
     ctx_class = Parrot_oo_get_class(interp, namespace);
     Parrot_unregister_pmc(interp, namespace);
 
-    ctx_pmc = Parrot_Class_instantiate(interp, ctx_class, PMCNULL);
+    ctx_pmc = VTABLE_instantiate(interp, ctx_class, PMCNULL);
     Parrot_register_pmc(interp, ctx_pmc);
 
     if (!hll) hll = MODPARROT_DEFAULT_HLL;
-    res = modparrot_call_sub_IP(interp, hll, hook, ret, ctx_pmc);
+    sub = modparrot_get_meta_handler(interp, hll, hook);
+    res = modparrot_call_meta_handler_sub(interp, sub, ret, ctx_pmc);
     Parrot_unregister_pmc(interp, ctx_pmc);
     return res ? 1 : 0;
 }

Modified: mod_parrot/branches/configure-jeff/src/module.c
==============================================================================
--- mod_parrot/branches/configure-jeff/src/module.c	(original)
+++ mod_parrot/branches/configure-jeff/src/module.c	Tue Jun 23 11:43:17 2009
@@ -582,22 +582,22 @@
     }
     modp->dynamic_load_handle = minfo;
 
-    if (sub = get_sub_pmc(interp, namespace, "server_create")) {
+    if (sub = modparrot_get_meta_handler(interp, namespace, "server_create")) {
         MP_TRACE_m(s, "registering server_create for module '%s'", name);
         modp->create_server_config = modparrot_module_srv_create;
         minfo->server_create_sub = sub;
     }
-    if (sub = get_sub_pmc(interp, namespace, "server_merge")) {
+    if (sub = modparrot_get_meta_handler(interp, namespace, "server_merge")) {
         MP_TRACE_m(s, "registering server_merge for module '%s'", name);
         modp->merge_server_config = modparrot_module_srv_merge;
         minfo->server_merge_sub = sub;
     }
-    if (sub = get_sub_pmc(interp, namespace, "dir_create")) {
+    if (sub = modparrot_get_meta_handler(interp, namespace, "dir_create")) {
         MP_TRACE_m(s, "registering dir_create for module '%s'", name);
         modp->create_dir_config = modparrot_module_dir_create;
         minfo->dir_create_sub = sub;
     }
-    if (sub = get_sub_pmc(interp, namespace, "dir_merge")) {
+    if (sub = modparrot_get_meta_handler(interp, namespace, "dir_merge")) {
         MP_TRACE_m(s, "registering dir_merge for module '%s'", name);
         modp->merge_dir_config = modparrot_module_dir_merge;
         minfo->dir_merge_sub = sub;

Modified: mod_parrot/branches/configure-jeff/src/parrot_util.c
==============================================================================
--- mod_parrot/branches/configure-jeff/src/parrot_util.c	(original)
+++ mod_parrot/branches/configure-jeff/src/parrot_util.c	Tue Jun 23 11:43:17 2009
@@ -23,13 +23,6 @@
 #include "mod_parrot.h"
 #include "../src/pmc/pmc_continuation.h"
 
-
-/* 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 Parrot_PMC get_sub_pmc_s(Parrot_Interp interp, char *namespace, char *name)
 {
     Parrot_PMC sub;
@@ -137,6 +130,48 @@
     return(1);
 }
 
+Parrot_PMC modparrot_get_meta_handler(Parrot_Interp interp, char *hll,
+    char *name)
+{
+    Parrot_PMC sub;
+    Parrot_PMC namespace;
+    Parrot_PMC hllns;
+    Parrot_PMC ourns;
+    int typenum, hllid;
+
+    typenum = Parrot_PMC_typenum(interp, "ResizablePMCArray");
+    ourns = (Parrot_PMC)Parrot_PMC_new(interp, typenum);
+    Parrot_register_pmc(interp, ourns);
+    Parrot_PMC_set_intval(interp, ourns, 3);
+    Parrot_PMC_set_cstring_intkey(interp, ourns, 0, "ModParrot");
+    Parrot_PMC_set_cstring_intkey(interp, ourns, 1, "HLL");
+    Parrot_PMC_set_cstring_intkey(interp, ourns, 2, hll);
+
+    /* if PIR, use default namespace, else look in HLL namespace */
+    if (!strcmp(hll, "PIR")) {
+        namespace = ourns;
+        sub = Parrot_find_global_k(interp, namespace, MAKE_PARROT_STRING(name));
+    }
+    else {
+        /* XXX cache these during module creation */
+        hllid = Parrot_get_HLL_id(interp, MAKE_PARROT_STRING(hll));
+        hllns = Parrot_get_HLL_namespace(interp, hllid);
+        namespace = Parrot_get_namespace_keyed(interp, hllns, ourns);
+        sub = Parrot_find_global_n(interp, namespace, MAKE_PARROT_STRING(name));
+    }
+
+    Parrot_unregister_pmc(interp, namespace);
+
+    return(sub);
+}
+
+int modparrot_call_meta_handler_sub(Parrot_Interp interp, Parrot_PMC sub,
+    int *ret, Parrot_PMC ctx_pmc)
+{
+    *ret = Parrot_call_sub_ret_int(interp, sub, "IP", ctx_pmc);
+    return(1);
+}
+
 int modparrot_call_sub_Iv(Parrot_Interp interp, char *namespace, char *name,
     int *ret)
 {
@@ -278,10 +313,10 @@
         Parrot_PMC_set_pmc_keyed_str(interp, init,
             Parrot_str_new(interp, init_key, strlen(init_key)),
                 pointer_pmc);
-        obj = Parrot_Class_instantiate(interp, _class, init);
+        obj = VTABLE_instantiate(interp, _class, init);
     }
     else {
-        obj = Parrot_Class_instantiate(interp, _class, PMCNULL);
+        obj = VTABLE_instantiate(interp, _class, PMCNULL);
     }
     Parrot_unregister_pmc(interp, init);
     Parrot_unregister_pmc(interp, _class);

Modified: mod_parrot/branches/configure-jeff/src/pmc/modparrothandle.pmc
==============================================================================
--- mod_parrot/branches/configure-jeff/src/pmc/modparrothandle.pmc	(original)
+++ mod_parrot/branches/configure-jeff/src/pmc/modparrothandle.pmc	Tue Jun 23 11:43:17 2009
@@ -110,13 +110,13 @@
     VTABLE void mark() {
         Parrot_ModParrotHandle_attributes * const data_struct = PARROT_MODPARROTHANDLE(SELF);
         if (data_struct->r)
-            pobject_lives(interp, (PObj *)data_struct->r);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)data_struct->r);
         if (data_struct->mode)
-            pobject_lives(interp, (PObj *)data_struct->mode);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)data_struct->mode);
         if (data_struct->encoding)
-            pobject_lives(interp, (PObj *)data_struct->encoding);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)data_struct->encoding);
         if (data_struct->filename)
-            pobject_lives(interp, (PObj *)data_struct->filename);
+            Parrot_gc_mark_PObj_alive(interp, (PObj *)data_struct->filename);
     }
 
 /*
@@ -239,7 +239,7 @@
         PMC *attrpmc;
         PMC *r;
 
-        GET_ATTR_r(INTERP, SELF, r)
+        GET_ATTR_r(INTERP, SELF, r);
         if (r) {
             attrname = Parrot_str_new_constant(INTERP, "r");
             attrpmc = VTABLE_get_attr_str(INTERP, r, attrname);