perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Geoffrey Young <ge...@modperlcookbook.org>
Subject $parms->info(), take 2
Date Thu, 29 May 2003 14:16:23 GMT
ok, here is an updated patch, with the XS cleaned up a bit.

the important change between this version and the last is that $parms->info() is now 
read-only.  I couldn't think of a case where you would want to write to the info slot, and

doing so would just cause erroneous results - since directive handlers typically rely on 
that data to make decisions about how directives are to be handled, changing that value in

the middle of the config process would almost certainly be bad.

also included is adding the -u flag to part of getdiff.pl.  I know that's not platform 
independent, but -u was used elsewhere in getdiff.pl and I'm sure you don't want people 
sending in non-unified diffs :)

--Geoff

Index: Changes
===================================================================
RCS file: /home/cvspublic/modperl-2.0/Changes,v
retrieving revision 1.189
diff -u -r1.189 Changes
--- Changes     20 May 2003 06:53:47 -0000      1.189
+++ Changes     29 May 2003 13:53:56 -0000
@@ -12,6 +12,9 @@

  =item 1.99_10-dev

+implement $parms->info.  directive handlers should now be complete.
+[Geoffrey Young]
+
  MP_GTOP now works with modern GCC
  [Philippe M. Chiasson <gozer@cpan.org]

Index: src/modules/perl/modperl_module.c
===================================================================
RCS file: /home/cvspublic/modperl-2.0/src/modules/perl/modperl_module.c,v
retrieving revision 1.13
diff -u -r1.13 modperl_module.c
--- src/modules/perl/modperl_module.c   12 May 2003 13:00:15 -0000      1.13
+++ src/modules/perl/modperl_module.c   29 May 2003 13:53:56 -0000
@@ -13,12 +13,6 @@
      modperl_module_info_t *minfo;
  } modperl_module_cfg_t;

-typedef struct {
-    module *modp;
-    const char *cmd_data;
-    const char *func_name;
-} modperl_module_cmd_data_t;
-
  #define MP_MODULE_INFO(modp) \
      (modperl_module_info_t *)modp->dynamic_load_handle

@@ -711,7 +705,7 @@
          cmd->cmd_data = info;

          /* no default if undefined */
-        if (!(errmsg = modperl_module_cmd_fetch(aTHX_ obj, "data", &val))) {
+        if (!(errmsg = modperl_module_cmd_fetch(aTHX_ obj, "cmd_data", &val))) {
              info->cmd_data = apr_pstrdup(p, SvPV(val, len));
          }

Index: src/modules/perl/modperl_types.h
===================================================================
RCS file: /home/cvspublic/modperl-2.0/src/modules/perl/modperl_types.h,v
retrieving revision 1.66
diff -u -r1.66 modperl_types.h
--- src/modules/perl/modperl_types.h    17 Apr 2003 08:04:47 -0000      1.66
+++ src/modules/perl/modperl_types.h    29 May 2003 13:53:56 -0000
@@ -242,4 +242,10 @@
      char *path_info;
  } modperl_uri_t;

+typedef struct {
+    module *modp;
+    const char *cmd_data;
+    const char *func_name;
+} modperl_module_cmd_data_t;
+
  #endif /* MODPERL_TYPES_H */
Index: t/response/TestDirective/perlloadmodule.pm
===================================================================
RCS file: /home/cvspublic/modperl-2.0/t/response/TestDirective/perlloadmodule.pm,v
retrieving revision 1.2
diff -u -r1.2 perlloadmodule.pm
--- t/response/TestDirective/perlloadmodule.pm  13 Dec 2002 10:06:55 -0000      1.2
+++ t/response/TestDirective/perlloadmodule.pm  29 May 2003 13:53:56 -0000
@@ -23,6 +23,7 @@
      },
      {
       name => 'MyOtherTest',
+     cmd_data => 'some info',
      },
      {
       name => 'ServerTest',
@@ -72,11 +73,13 @@
  sub MyTest {
      my($self, $parms, @args) = @_;
      $self->{MyTest} = \@args;
+    $self->{MyTestInfo} = $parms->info;
  }

  sub MyOtherTest {
      my($self, $parms, $arg) = @_;
      $self->{MyOtherTest} = $arg;
+    $self->{MyOtherTestInfo} = $parms->info;
  }

  sub ServerTest {
@@ -97,7 +100,7 @@
      my $dir_cfg = $self->get_config($s, $r->per_dir_config);
      my $srv_cfg = $self->get_config($s);

-    plan $r, tests => 7;
+    plan $r, tests => 9;

      t_debug("per-dir config:", $dir_cfg);
      t_debug("per-srv config:", $srv_cfg);
@@ -116,8 +119,13 @@
      ok t_cmp('value', $dir_cfg->{MyOtherTest},
               'MyOtherTest value');

+    ok t_cmp('some info', $dir_cfg->{MyOtherTestInfo},
+             'MyOtherTest cmd_data');
+
      ok t_cmp(['one', 'two'], $dir_cfg->{MyTest},
               'MyTest one two');
+
+    ok ! $dir_cfg->{MyTestInfo};

      ok t_cmp('per-server', $srv_cfg->{ServerTest});

Index: util/getdiff.pl
===================================================================
RCS file: /home/cvspublic/modperl-2.0/util/getdiff.pl,v
retrieving revision 1.1
diff -u -r1.1 getdiff.pl
--- util/getdiff.pl     13 Aug 2001 02:18:38 -0000      1.1
+++ util/getdiff.pl     29 May 2003 13:53:57 -0000
@@ -12,7 +12,7 @@
  # patch -p0 < newtest.patch

  # cvs diff
-my $o = `cvs diff`;
+my $o = `cvs diff -u`;

  # strip '? filename' cvs lines for unknown files
  $o =~ s/^\?.*\n//gm;
Index: xs/maps/modperl_functions.map
===================================================================
RCS file: /home/cvspublic/modperl-2.0/xs/maps/modperl_functions.map,v
retrieving revision 1.56
diff -u -r1.56 modperl_functions.map
--- xs/maps/modperl_functions.map       1 Apr 2003 05:20:50 -0000       1.56
+++ xs/maps/modperl_functions.map       29 May 2003 13:53:57 -0000
@@ -130,3 +130,5 @@
   mpxs_Apache__Directive_as_hash
   Apache__Directive_lookup | MPXS_ | ...

+MODULE=Apache::CmdParms
+ Apache__CmdParms_info | MPXS_ | ...
Index: xs/tables/current/Apache/StructureTable.pm
===================================================================
RCS file: /home/cvspublic/modperl-2.0/xs/tables/current/Apache/StructureTable.pm,v
retrieving revision 1.35
diff -u -r1.35 StructureTable.pm
--- xs/tables/current/Apache/StructureTable.pm  24 Aug 2002 17:14:40 -0000      1.35
+++ xs/tables/current/Apache/StructureTable.pm  29 May 2003 13:53:57 -0000
@@ -2499,10 +2499,6 @@
      'type' => 'cmd_parms',
      'elts' => [
        {
-        'type' => 'void *',
-        'name' => 'info'
-      },
-      {
          'type' => 'int',
          'name' => 'override'
        },
Index: xs/tables/current/ModPerl/FunctionTable.pm
===================================================================
RCS file: /home/cvspublic/modperl-2.0/xs/tables/current/ModPerl/FunctionTable.pm,v
retrieving revision 1.114
diff -u -r1.114 FunctionTable.pm
--- xs/tables/current/ModPerl/FunctionTable.pm  12 May 2003 13:00:15 -0000      1.114
+++ xs/tables/current/ModPerl/FunctionTable.pm  29 May 2003 13:53:58 -0000
@@ -6641,6 +6641,19 @@
        }
      ]
    },
+  {
+    'return_type' => 'char *',
+    'name' => 'Apache__CmdParms_info',
+    'attr' => [
+      'static'
+    ],
+    'args' => [
+      {
+        'type' => 'PerlInterpreter *',
+        'name' => 'my_perl'
+      },
+    ]
+  },
  ];



--- /dev/null   Tue May  5 16:32:27 1998
+++ xs/Apache/CmdParms/Apache__CmdParms.h       Thu May 29 09:47:03 2003
@@ -0,0 +1,24 @@
+#include "modperl_module.h"
+
+static XS(MPXS_Apache__CmdParms_info)
+{
+    dXSARGS;
+
+    mpxs_usage_items_1("cmd_parms");
+
+    mpxs_PPCODE({
+        cmd_parms *obj;
+        const char *data;
+
+        obj = mp_xs_sv2_Apache__CmdParms(ST(0));
+
+        data = ((modperl_module_cmd_data_t *)obj->info)->cmd_data;
+
+        if (data) {
+            XPUSHs(sv_2mortal(newSVpv(data, 0)));
+        }
+        else {
+            XPUSHs(&PL_sv_undef);
+        }
+    });
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Mime
View raw message