svn commit: r940287 - in /perl/modperl/trunk: Changes lib/ModPerl/MapUtil.pm

2010-05-02 Thread torsten
Author: torsten
Date: Sun May  2 18:25:41 2010
New Revision: 940287

URL: http://svn.apache.org/viewvc?rev=940287&view=rev
Log:
Implement a mini-preprocess language for map-files in xs/maps.
Syntax is

 #_if_ perl-code
 #_elsif perl-code
 #_else_
 #_end_

and

 #_eval_ perl-code

The main reason for this change is to make structures and functions
available if a certain condition is met only. For example:

 #_if_ do {use Apache2::Build; Apache2::Build::PERL_HAS_ITHREADS}
 ...
 #_end_

The _eval_ variant is thought mainly as a debugging tool:

 #_eval_ warn "here I am"

Modified:
perl/modperl/trunk/Changes
perl/modperl/trunk/lib/ModPerl/MapUtil.pm

Modified: perl/modperl/trunk/Changes
URL: 
http://svn.apache.org/viewvc/perl/modperl/trunk/Changes?rev=940287&r1=940286&r2=940287&view=diff
==
--- perl/modperl/trunk/Changes (original)
+++ perl/modperl/trunk/Changes Sun May  2 18:25:41 2010
@@ -12,6 +12,9 @@ Also refer to the Apache::Test changes l
 
 =item 2.0.5-dev
 
+Implement a mini-preprocess language for map-files in xs/maps.
+[Torsten Foertsch]
+
 Implement APR::Socket::fileno [Torsten Foertsch]
 
 Export PROXYREQ_RESPONSE, a missing PROXYREQ_* constant [Gozer]

Modified: perl/modperl/trunk/lib/ModPerl/MapUtil.pm
URL: 
http://svn.apache.org/viewvc/perl/modperl/trunk/lib/ModPerl/MapUtil.pm?rev=940287&r1=940286&r2=940287&view=diff
==
--- perl/modperl/trunk/lib/ModPerl/MapUtil.pm (original)
+++ perl/modperl/trunk/lib/ModPerl/MapUtil.pm Sun May  2 18:25:41 2010
@@ -1,3 +1,4 @@
+# please insert nothing before this line: -*- mode: cperl; cperl-indent-level: 
4; cperl-continued-statement-offset: 4; indent-tabs-mode: nil -*-
 # Licensed to the Apache Software Foundation (ASF) under one or more
 # contributor license agreements.  See the NOTICE file distributed with
 # this work for additional information regarding copyright ownership.
@@ -86,13 +87,59 @@ package ModPerl::MapBase;
 *function_table = \&ModPerl::MapUtil::function_table;
 *structure_table = \&ModPerl::MapUtil::structure_table;
 
+my @condition;
+
 sub readline {
 my $fh = shift;
 
 while (<$fh>) {
 chomp;
 s/^\s+//; s/\s+$//;
-s/^\#.*//;
+
+# this implements
+# #_if_ cmd
+# ...
+# #_else_
+# #_end_
+if (/^\s*#\s*_(if|unless|els(?:e|if)|end)_(?:\s(.+))?/) {
+my ($cmd, $param) = ($1, $2);
+if ($cmd eq 'if') {
+unshift @condition, 0+!!eval $param;
+}
+elsif ($cmd eq 'elsif') {
+die "parse error ($ModPerl::MapUtil::MapFile line $.)".
+" #_elsif_ without #_if_"
+unless @condition;
+if ($condition[0] == 0) {
+$condition[0]+=!!eval $param;
+} else {
+$condition[0]++;
+}
+}
+elsif ($cmd eq 'else') {
+die "parse error ($ModPerl::MapUtil::MapFile line $.)".
+" #_elsif_ without #_if_"
+unless @condition;
+$condition[0]+=1;
+}
+elsif ($cmd eq 'unless') {
+unshift @condition, 0+!eval $param;
+}
+elsif ($cmd eq 'end') {
+shift @condition;
+}
+}
+next if @condition and $condition[0] != 1;
+
+if (/^\s*#\s*_(eval)_(?:\s(.+))?/) {
+my ($cmd, $param) = ($1, $2);
+if ($cmd eq 'eval') {
+eval "#line $. $ModPerl::MapUtil::MapFile\n".$param;
+die $@ if $@;
+}
+next;
+}
+
 s/\s*\#.*//;
 
 next unless $_;
@@ -169,6 +216,7 @@ sub parse_map_files {
 open my $fh, $file or die "open $file: $!";
 local $ModPerl::MapUtil::MapFile = $file;
 bless $fh, __PACKAGE__;
+@condition=();  # see readline() above
 $self->parse($fh, $map);
 close $fh;
 }




svn commit: r940293 - in /perl/modperl/branches/threading: ./ Changes lib/ModPerl/MapUtil.pm

2010-05-02 Thread torsten
Author: torsten
Date: Sun May  2 18:32:14 2010
New Revision: 940293

URL: http://svn.apache.org/viewvc?rev=940293&view=rev
Log:
Merged revisions 940287 via svnmerge from 
https://svn.eu.apache.org/repos/asf/perl/modperl/trunk


  r940287 | torsten | 2010-05-02 20:25:41 +0200 (Sun, 02 May 2010) | 23 lines
  
  Implement a mini-preprocess language for map-files in xs/maps.
  Syntax is
  
   #_if_ perl-code
   #_elsif perl-code
   #_else_
   #_end_
  
  and
  
   #_eval_ perl-code
  
  The main reason for this change is to make structures and functions
  available if a certain condition is met only. For example:
  
   #_if_ do {use Apache2::Build; Apache2::Build::PERL_HAS_ITHREADS}
   ...
   #_end_
  
  The _eval_ variant is thought mainly as a debugging tool:
  
   #_eval_ warn "here I am"


Modified:
perl/modperl/branches/threading/   (props changed)
perl/modperl/branches/threading/Changes
perl/modperl/branches/threading/lib/ModPerl/MapUtil.pm

Propchange: perl/modperl/branches/threading/
--
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun May  2 18:32:14 2010
@@ -1 +1 @@
-/perl/modperl/trunk:594682-672484,672819-681118,693357,700369,732889-736218,751909-752425,757553-774171,807116,807332-807649,907778-932879,933373-933563,935519,936643
+/perl/modperl/trunk:594682-672484,672819-681118,693357,700369,732889-736218,751909-752425,757553-774171,807116,807332-807649,907778-932879,933373-933563,935519,936643,940287

Propchange: perl/modperl/branches/threading/
--
--- svnmerge-integrated (original)
+++ svnmerge-integrated Sun May  2 18:32:14 2010
@@ -1 +1 @@
-/perl/modperl/trunk:1-712967,712969-936647
+/perl/modperl/trunk:1-712967,712969-940291

Modified: perl/modperl/branches/threading/Changes
URL: 
http://svn.apache.org/viewvc/perl/modperl/branches/threading/Changes?rev=940293&r1=940292&r2=940293&view=diff
==
--- perl/modperl/branches/threading/Changes (original)
+++ perl/modperl/branches/threading/Changes Sun May  2 18:32:14 2010
@@ -31,6 +31,9 @@ Expose modperl_interp_t via ModPerl::Int
 
 =item 2.0.5-dev
 
+Implement a mini-preprocess language for map-files in xs/maps.
+[Torsten Foertsch]
+
 Implement APR::Socket::fileno [Torsten Foertsch]
 
 Export PROXYREQ_RESPONSE, a missing PROXYREQ_* constant [Gozer]

Modified: perl/modperl/branches/threading/lib/ModPerl/MapUtil.pm
URL: 
http://svn.apache.org/viewvc/perl/modperl/branches/threading/lib/ModPerl/MapUtil.pm?rev=940293&r1=940292&r2=940293&view=diff
==
--- perl/modperl/branches/threading/lib/ModPerl/MapUtil.pm (original)
+++ perl/modperl/branches/threading/lib/ModPerl/MapUtil.pm Sun May  2 18:32:14 
2010
@@ -87,13 +87,59 @@ package ModPerl::MapBase;
 *function_table = \&ModPerl::MapUtil::function_table;
 *structure_table = \&ModPerl::MapUtil::structure_table;
 
+my @condition;
+
 sub readline {
 my $fh = shift;
 
 while (<$fh>) {
 chomp;
 s/^\s+//; s/\s+$//;
-s/^\#.*//;
+
+# this implements
+# #_if_ cmd
+# ...
+# #_else_
+# #_end_
+if (/^\s*#\s*_(if|unless|els(?:e|if)|end)_(?:\s(.+))?/) {
+my ($cmd, $param) = ($1, $2);
+if ($cmd eq 'if') {
+unshift @condition, 0+!!eval $param;
+}
+elsif ($cmd eq 'elsif') {
+die "parse error ($ModPerl::MapUtil::MapFile line $.)".
+" #_elsif_ without #_if_"
+unless @condition;
+if ($condition[0] == 0) {
+$condition[0]+=!!eval $param;
+} else {
+$condition[0]++;
+}
+}
+elsif ($cmd eq 'else') {
+die "parse error ($ModPerl::MapUtil::MapFile line $.)".
+" #_elsif_ without #_if_"
+unless @condition;
+$condition[0]+=1;
+}
+elsif ($cmd eq 'unless') {
+unshift @condition, 0+!eval $param;
+}
+elsif ($cmd eq 'end') {
+shift @condition;
+}
+}
+next if @condition and $condition[0] != 1;
+
+if (/^\s*#\s*_(eval)_(?:\s(.+))?/) {
+my ($cmd, $param) = ($1, $2);
+if ($cmd eq 'eval') {
+eval "#line $. $ModPerl::MapUtil::MapFile\n".$param;
+die $@ if $@;
+}
+next;
+}
+
 s/\s*\#.*//;
 
 next unless $_;
@@ -170,6 +216,7 @@ sub parse_map_files {
 open my $fh, $file or die "open $file: $!";
 local $ModPerl::MapUtil::MapFile = $file;
 bless $fh, __PACKAGE__;
+@condition=();  # see readline() abo

svn commit: r940297 - in /perl/modperl/branches/threading: src/modules/perl/ t/response/TestModperl/ t/response/TestPerl/ xs/maps/

2010-05-02 Thread torsten
Author: torsten
Date: Sun May  2 18:45:49 2010
New Revision: 940297

URL: http://svn.apache.org/viewvc?rev=940297&view=rev
Log:
now it compiles and tests with a non-threaded perl

Modified:
perl/modperl/branches/threading/src/modules/perl/modperl_cmd.c
perl/modperl/branches/threading/src/modules/perl/modperl_types.h
perl/modperl/branches/threading/t/response/TestModperl/interpreter.pm
perl/modperl/branches/threading/t/response/TestPerl/ithreads3.pm
perl/modperl/branches/threading/xs/maps/modperl_functions.map
perl/modperl/branches/threading/xs/maps/modperl_structures.map
perl/modperl/branches/threading/xs/maps/modperl_types.map

Modified: perl/modperl/branches/threading/src/modules/perl/modperl_cmd.c
URL: 
http://svn.apache.org/viewvc/perl/modperl/branches/threading/src/modules/perl/modperl_cmd.c?rev=940297&r1=940296&r2=940297&view=diff
==
--- perl/modperl/branches/threading/src/modules/perl/modperl_cmd.c (original)
+++ perl/modperl/branches/threading/src/modules/perl/modperl_cmd.c Sun May  2 
18:45:49 2010
@@ -556,8 +556,10 @@ MP_CMD_SRV_DECLARE(perldo)
   arg, NULL);
 }
 
+#ifdef USE_ITHREADS
 MP_TRACE_i(MP_FUNC, "using interp %lx to execute perl section:\n%s",
scfg->mip->parent, arg);
+#endif
 
 {
 SV *server = MP_PERLSECTIONS_SERVER_SV;

Modified: perl/modperl/branches/threading/src/modules/perl/modperl_types.h
URL: 
http://svn.apache.org/viewvc/perl/modperl/branches/threading/src/modules/perl/modperl_types.h?rev=940297&r1=940296&r2=940297&view=diff
==
--- perl/modperl/branches/threading/src/modules/perl/modperl_types.h (original)
+++ perl/modperl/branches/threading/src/modules/perl/modperl_types.h Sun May  2 
18:45:49 2010
@@ -40,6 +40,8 @@ typedef struct {
 server_rec  *s;
 } modperl_rcs_t;
 
+typedef struct modperl_config_con_t modperl_config_con_t;
+
 #ifdef USE_ITHREADS
 
 typedef struct modperl_list_t modperl_list_t;
@@ -52,7 +54,7 @@ struct modperl_list_t {
 typedef struct modperl_interp_t modperl_interp_t;
 typedef struct modperl_interp_pool_t modperl_interp_pool_t;
 typedef struct modperl_tipool_t modperl_tipool_t;
-typedef struct modperl_config_con_t modperl_config_con_t;
+typedef struct modperl_tipool_config_t modperl_tipool_config_t;
 
 struct modperl_interp_t {
 modperl_interp_pool_t *mip;
@@ -80,13 +82,13 @@ typedef struct {
 modperl_list_t *listp);
 } modperl_tipool_vtbl_t;
 
-typedef struct {
+typedef struct modperl_tipool_config_t {
 int start; /* number of items to create at startup */
 int min_spare; /* minimum number of spare items */
 int max_spare; /* maximum number of spare items */
 int max; /* maximum number of items */
 int max_requests; /* maximum number of requests per item */
-} modperl_tipool_config_t;
+};
 
 struct modperl_tipool_t {
 perl_mutex tiplock;

Modified: perl/modperl/branches/threading/t/response/TestModperl/interpreter.pm
URL: 
http://svn.apache.org/viewvc/perl/modperl/branches/threading/t/response/TestModperl/interpreter.pm?rev=940297&r1=940296&r2=940297&view=diff
==
--- perl/modperl/branches/threading/t/response/TestModperl/interpreter.pm 
(original)
+++ perl/modperl/branches/threading/t/response/TestModperl/interpreter.pm Sun 
May  2 18:45:49 2010
@@ -7,10 +7,6 @@ use warnings FATAL => 'all';
 use Apache::Test;
 use Apache::TestUtil;
 
-use ModPerl::Interpreter ();
-use ModPerl::InterpPool ();
-use ModPerl::TiPool ();
-use ModPerl::TiPoolConfig ();
 use Apache2::MPM ();
 
 use Apache2::Const -compile => 'OK';
@@ -20,7 +16,14 @@ sub handler {
 
 my $is_threaded=Apache2::MPM->is_threaded;
 
-plan $r, tests => $is_threaded?17:5;
+plan $r, tests => $is_threaded?17:5, need
+need_threads,
+{"perl >= 5.8.1 is required (this is $])" => ($] >= 5.008001)};
+
+require ModPerl::Interpreter;
+require ModPerl::InterpPool;
+require ModPerl::TiPool;
+require ModPerl::TiPoolConfig;
 
 my $interp = ModPerl::Interpreter->current;
 

Modified: perl/modperl/branches/threading/t/response/TestPerl/ithreads3.pm
URL: 
http://svn.apache.org/viewvc/perl/modperl/branches/threading/t/response/TestPerl/ithreads3.pm?rev=940297&r1=940296&r2=940297&view=diff
==
--- perl/modperl/branches/threading/t/response/TestPerl/ithreads3.pm (original)
+++ perl/modperl/branches/threading/t/response/TestPerl/ithreads3.pm Sun May  2 
18:45:49 2010
@@ -10,7 +10,6 @@ use Apache2::RequestUtil ();
 use Apache2::Connection ();
 use Apache2::ConnectionUtil ();
 use APR::Pool ();
-use ModPerl::Interpreter ();
 use ModPerl::Util ();
 use APR::Table ();
 use Apache2::Const -compile => 'OK', 'DECLINED';
@@ -24,12 +23,21 @@ use 

svn commit: r940303 - /perl/modperl/branches/threading/src/modules/perl/modperl_types.h

2010-05-02 Thread torsten
Author: torsten
Date: Sun May  2 18:53:12 2010
New Revision: 940303

URL: http://svn.apache.org/viewvc?rev=940303&view=rev
Log:
silence a warning (useless storage class specifier in empty declaration)

Modified:
perl/modperl/branches/threading/src/modules/perl/modperl_types.h

Modified: perl/modperl/branches/threading/src/modules/perl/modperl_types.h
URL: 
http://svn.apache.org/viewvc/perl/modperl/branches/threading/src/modules/perl/modperl_types.h?rev=940303&r1=940302&r2=940303&view=diff
==
--- perl/modperl/branches/threading/src/modules/perl/modperl_types.h (original)
+++ perl/modperl/branches/threading/src/modules/perl/modperl_types.h Sun May  2 
18:53:12 2010
@@ -82,7 +82,7 @@ typedef struct {
 modperl_list_t *listp);
 } modperl_tipool_vtbl_t;
 
-typedef struct modperl_tipool_config_t {
+struct modperl_tipool_config_t {
 int start; /* number of items to create at startup */
 int min_spare; /* minimum number of spare items */
 int max_spare; /* maximum number of spare items */