[svn:mod_parrot] r186 - in mod_parrot/branches/autogen: . build/lib build/lib/Generator

[email protected]
Newsgroups perl.cvs.mod_parrot
Message-ID <[email protected]>
Author: jhorwitz
Date: Mon Aug  1 17:30:32 2005
New Revision: 186

Modified:
   mod_parrot/branches/autogen/Configure.pl
   mod_parrot/branches/autogen/Makefile.in
   mod_parrot/branches/autogen/build/lib/Generator/ApacheRequestRec.pm
   mod_parrot/branches/autogen/build/lib/generate_source.pl
Log:
support both old and new calling conventions in autogenerated code


Modified: mod_parrot/branches/autogen/Configure.pl
==============================================================================
--- mod_parrot/branches/autogen/Configure.pl	(original)
+++ mod_parrot/branches/autogen/Configure.pl	Mon Aug  1 17:30:32 2005
@@ -52,16 +52,16 @@ print "\n";
 
 my $defines;
 print "Determining Parrot calling conventions...";
-my $out = `$parrot_build_dir/parrot cc_test.imc`;
-chomp($out);
-if ($out eq 'new') {
+my $calling_conventions = `$parrot_build_dir/parrot cc_test.imc`;
+chomp($calling_conventions);
+if ($calling_conventions eq 'new') {
     $defines = '-DPARROT_NEW_CALL_CONV';
 }
 else {
-    die 'calling convention test failed!' if $out ne 'old';
+    die 'calling convention test failed!' if $calling_conventions ne 'old';
 }
 
-print "$out\n";
+print "$calling_conventions\n";
 
 # where are apache includes?
 my $apache_include_dir = `$apxs -q INCLUDEDIR`;
@@ -95,6 +95,7 @@ $template =~ s/\@PERL\@/$perl/g;
 $template =~ s/\@PARROT_SOURCE\@/$parrot_build_dir/g;
 $template =~ s/\@PARROT\@/$parrot_build_dir\/parrot/g;
 $template =~ s/\@APACHE_INCLUDE_DIR\@/$apache_include_dir/g;
+$template =~ s/\@CALLING_CONVENTIONS\@/$calling_conventions/g;
 open(MAKEFILE, ">Makefile") or die $!;
 print MAKEFILE $template;
 close(MAKEFILE);

Modified: mod_parrot/branches/autogen/Makefile.in
==============================================================================
--- mod_parrot/branches/autogen/Makefile.in	(original)
+++ mod_parrot/branches/autogen/Makefile.in	Mon Aug  1 17:30:32 2005
@@ -11,6 +11,7 @@ APXS=@APXS@
 PARROT_SOURCE=@PARROT_SOURCE@
 PARROT=@PARROT@
 APACHE_INCLUDE_DIR=@APACHE_INCLUDE_DIR@
+CALLING_CONVENTIONS=@CALLING_CONVENTIONS@
 
 SOURCE_FILES=mod_parrot.c parrot_util.c modparrot_config.c nci.c context.c
 PARROT_OBJS=$(PARROT_SOURCE)/src/parrot_config.o
@@ -41,7 +42,7 @@ libraries:
 
 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) --calling-conventions=$(CALLING_CONVENTIONS)
 
 gen-src-clean:
 	rm -rf build/src

Modified: mod_parrot/branches/autogen/build/lib/Generator/ApacheRequestRec.pm
==============================================================================
--- mod_parrot/branches/autogen/build/lib/Generator/ApacheRequestRec.pm	(original)
+++ mod_parrot/branches/autogen/build/lib/Generator/ApacheRequestRec.pm	Mon Aug  1 17:30:32 2005
@@ -125,7 +125,10 @@ sub get_imc_int_template
 {
     my $self = shift;
 
-    my $template = <<'END'
+    my $template;
+
+    if ($self->{calling_conventions} eq 'new') {
+        $template = <<'END'
 .sub %%NAME%% method
     .param int data :optional
     .param int update_r :opt_count
@@ -134,10 +137,33 @@ sub get_imc_int_template
     .local pmc request_rec_%%NAME%%
     .local int %%NAME%%
 
-    # XXX - for old calling conventions
+    classoffset offset, self, 'Apache::RequestRec'
+    getattribute r, self, offset
+
+    find_global request_rec_%%NAME%%, 'ModParrot::NCI', 'request_rec_%%NAME%%'
+    %%NAME%% = request_rec_%%NAME%%( r , data, update_r )
+
+    .pcc_begin_return
+        .return %%NAME%%
+    .pcc_end_return
+.end
+
+END
+;
+    }
+    else {
+        $template = <<'END'
+.sub %%NAME%% method
+    .param int data
+    .local pmc r
+    .local int offset
+    .local pmc request_rec_%%NAME%%
+    .local int %%NAME%%
+    .local int update_r
+
     # whether or not we should update r with the new value.
-    # if I1 == 0 goto done
-    # update_r = 1
+    if I1 == 0 goto done
+    update_r = 1
 
 done:
     classoffset offset, self, 'Apache::RequestRec'
@@ -153,6 +179,7 @@ done:
 
 END
 ;
+    }
 
     return $template;
 }

Modified: mod_parrot/branches/autogen/build/lib/generate_source.pl
==============================================================================
--- mod_parrot/branches/autogen/build/lib/generate_source.pl	(original)
+++ mod_parrot/branches/autogen/build/lib/generate_source.pl	Mon Aug  1 17:30:32 2005
@@ -24,9 +24,11 @@ use Generator::ApacheConstants;
 use Generator::ApacheRequestRec;
 
 my $apache_include_dir = '/usr/local/apache2/include/';
+my $calling_conventions = 'new';
 
 GetOptions(
     'apache-include-dir=s' => \$apache_include_dir,
+    'calling-conventions=s' => \$calling_conventions,
 ) || die 'Could not get command line args.';
 
 # This is where the generated source lives.
@@ -41,9 +43,10 @@ if ($@ && $@ !~ /File exists/) {
 }
 
 my %args = (
-   'apache_include_dir' => $apache_include_dir . '/',
-   'nci_src'            => 'build/src/nci/',
-   'imc_src'            => 'build/src/imc/',
+   'apache_include_dir'  => $apache_include_dir . '/',
+   'calling_conventions' => $calling_conventions,
+   'nci_src'             => 'build/src/nci/',
+   'imc_src'             => 'build/src/imc/',
 );
 
 ModParrot::Config::Generator::ApacheConstants->new(%args)->run();
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.