httpd-apreq-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r153896 - in httpd/apreq/branches/multi-env-unstable/glue/perl: Makefile.PL t/TEST.PL xsbuilder/apreq_xs_postperl.h xsbuilder/maps/apreq_functions.map xsbuilder/maps/apreq_structures.map xsbuilder/maps/apreq_types.map
Date Tue, 15 Feb 2005 05:13:20 GMT
Author: joes
Date: Mon Feb 14 21:13:17 2005
New Revision: 153896

URL: http://svn.apache.org/viewcvs?view=rev&rev=153896
Log:

First crack at organizing the handle constructors:

             APR::Request                 - wraps apreq_handle_t (abstractly)
APR::Request::CGI, APR::Request::Apache2  - derived, with new() implemented.

Modified:
    httpd/apreq/branches/multi-env-unstable/glue/perl/Makefile.PL
    httpd/apreq/branches/multi-env-unstable/glue/perl/t/TEST.PL
    httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/apreq_xs_postperl.h
    httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/maps/apreq_functions.map
    httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/maps/apreq_structures.map
    httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/maps/apreq_types.map

Modified: httpd/apreq/branches/multi-env-unstable/glue/perl/Makefile.PL
URL: http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/glue/perl/Makefile.PL?view=diff&r1=153895&r2=153896
==============================================================================
--- httpd/apreq/branches/multi-env-unstable/glue/perl/Makefile.PL (original)
+++ httpd/apreq/branches/multi-env-unstable/glue/perl/Makefile.PL Mon Feb 14 21:13:17 2005
@@ -105,9 +105,9 @@
 package My::ParseSource;
 use base qw/ExtUtils::XSBuilder::ParseSource/;
 use constant WIN32 => ($^O =~ /Win32/i);
-my @dirs = ("$base_dir/include");
-sub package {'Apache::libapreq2'}
-sub unwanted_includes {[qw/apreq_tables.h apreq_config.h/]}
+my @dirs = ("$base_dir/include", "$base_dir/module/apache2");
+sub package {'APR::Request'}
+sub unwanted_includes {[qw/apreq_config.h apreq_private_apache2.h/]}
 
 # ParseSource.pm v 0.23 bug: line 214 should read
 # my @dirs = @{$self->include_dirs};
@@ -256,11 +256,104 @@
 sub my_xs_prefix {'apreq_xs_'}
 sub xs_include_dir { $xs_dir }
 
+sub mod_xs {
+    my($self, $module, $complete) = @_;
+    my $dirname = $self->class_dirname($module);
+    my @parts = split '::', $module;
+    my $mod_xs = "$dirname/$parts[-1].xs";
+
+    for ($self -> xs_include_dir, @{ $self->{glue_dirs} }) {
+        my $file = "$_/$mod_xs";
+		$mod_xs = $file if $complete;
+        return $mod_xs if -e $file;
+    }
+
+    undef;
+}
+
+#inline mod_xs directly, so we can put XS directives there
+
+sub write_xs {
+    my($self, $module, $functions) = @_;
+
+    my $fh = $self->open_class_file($module, '.xs');
+    print $fh "$self->{noedit_warning_c}\n";
+
+    my @includes = @{ $self->includes };
+
+    if (my $mod_h = $self->mod_h($module)) {
+        push @includes, $mod_h;
+    }
+
+    for (@includes) {
+        print $fh qq{\#include "$_"\n\n};
+    }
+
+    if (my $mod_xs = $self->mod_xs($module, 1)) {
+        open my $file, $mod_xs or die "can't open $mod_xs: $!";
+        print $fh $_ while <$file>;
+        print $fh "\n\n";
+    }
+
+    my $last_prefix = "";
+    my $fmap = $self -> typemap -> {function_map} ;
+    my $myprefix = $self -> my_xs_prefix ;
+
+    for my $func (@$functions) {
+        my $class = $func->{class};
+        if ($class)
+            {
+            my $prefix = $func->{prefix};
+            $last_prefix = $prefix if $prefix;
+
+            if ($func->{name} =~ /^$myprefix/o) {
+                #e.g. mpxs_Apache__RequestRec_
+                my $class_prefix = $fmap -> class_c_prefix($class);
+                if ($func->{name} =~ /$class_prefix/) {
+                    $prefix = $fmap -> class_xs_prefix($class);
+                }
+            }
+
+            $prefix = $prefix ? "  PREFIX = $prefix" : "";
+            print $fh "MODULE = $module    PACKAGE = $class $prefix\n\n";
+            }
+
+        print $fh $func->{code};
+    }
+
+    if (my $destructor = $self->typemap->destructor($last_prefix)) {
+        my $arg = $destructor->{argspec}[0];
+
+        print $fh <<EOF;
+void
+$destructor->{name}($arg)
+    $destructor->{class} $arg
+
+EOF
+    }
+
+    print $fh "PROTOTYPES: disabled\n\n";
+    print $fh "BOOT:\n";
+    print $fh $self->boot($module);
+    print $fh "    items = items; /* -Wall */\n\n";
+
+    if (my $newxs = $self->{newXS}->{$module}) {
+        for my $xs (@$newxs) {
+            print $fh qq{   cv = newXS("$xs->[0]", $xs->[1], __FILE__);\n};
+            print $fh qq{   GvSHARED_on(CvGV(cv));\n} if ExtUtils::XSBuilder::WrapXS::XSGvSHARED();
+        }
+    }
+
+    close $fh;
+}
+
+
+
 sub mod_pod {
     my($self, $module, $complete) = @_;
     my $dirname = $self->class_dirname($module);
     my @parts = split '::', $module;
-    my $mod_pod = "$dirname/$parts[-1]_pod";
+    my $mod_pod = "$dirname/$parts[-1].pod";
     for ($self -> xs_incsrc_dir, @{ $self->{glue_dirs} }) {
         my $file = "$_/$mod_pod";
         $mod_pod = $file if $complete;
@@ -436,17 +529,29 @@
                             OUTPUT => '$arg = apreq_xs_param2sv($var);',
                             c2perl => 'apreq_xs_param2sv(ptr)',
                            },
-        T_APREQ_REQUEST => {
-                            INPUT  => '$var = apreq_xs_sv2(request,$arg)',
-                            perl2c => 'apreq_xs_sv2(request,sv)',
-                            OUTPUT => '$arg = apreq_xs_2sv($var,\"${ntype}\");',
-                            c2perl => 'apreq_xs_2sv(ptr,\"$class\")',
+        T_APREQ_HANDLE => {
+                            INPUT  => '$var = apreq_xs_perl2c(aTHX_ $arg, "r")',
+                            perl2c => 'apreq_xs_perl2c(aTHX_ sv, "r")',
+                            c2perl => 'sv_setref_pv(newSV(0), class, ptr)',
+                            OUTPUT => <<'EOT',
+    $arg = sv_setref_pv($arg, class, $var);
+    if (!sv_derived_from($arg, \"${ntype}\"))
+        Perl_croak(aTHX_ \"Usage: target class %s isn't derived from ${ntype}\", class);
+EOT
                            },
-        T_APREQ_JAR     => {
-                            INPUT  => '$var = apreq_xs_sv2(jar,$arg)',
-                            perl2c => 'apreq_xs_sv2(jar,sv)',
-                            OUTPUT => '$arg = apreq_xs_2sv($var,\"${ntype}\");',
-                            c2perl => 'apreq_xs_2sv(ptr,\"$class\")',
+        T_APREQ_HANDLE_APACHE2 => {
+                            INPUT  => '$var = apreq_xs_perl2c(aTHX_ $arg, "r")',
+                            OUTPUT => <<'EOT',
+    $arg = sv_setref_pv($arg, class, $var);
+    if (sv_derived_from($arg, \"${ntype}\")) {
+        SV *parent = ST(1); /* r's SV */
+        SV *rv = SvRV($arg);
+        sv_magic(rv, parent, PERL_MAGIC_ext, Nullch, -1);
+        SvMAGIC(rv)->mg_ptr = (void *)r;
+    }
+    else
+        Perl_croak(aTHX_ \"Usage: target class %s isn't derived from ${ntype}\", class);
+EOT
                            },
  T_APREQ_COOKIE_VERSION => {
                             INPUT  => '$var = ((apreq_cookie_version_t)SvTRUE($arg))',

Modified: httpd/apreq/branches/multi-env-unstable/glue/perl/t/TEST.PL
URL: http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/glue/perl/t/TEST.PL?view=diff&r1=153895&r2=153896
==============================================================================
--- httpd/apreq/branches/multi-env-unstable/glue/perl/t/TEST.PL (original)
+++ httpd/apreq/branches/multi-env-unstable/glue/perl/t/TEST.PL Mon Feb 14 21:13:17 2005
@@ -11,9 +11,9 @@
     Win32::GetLongPathName(cwd) : cwd;
 $cwd =~ m{^(.+)/glue/perl$} or die "Can't find base cvs directory";
 my $base_dir = $1;
-my $env_dir = "$base_dir/env";
-my $env_dir_libs = Apache::Build::WIN32 ?
-    "$base_dir/win32/libs" : "$env_dir/.libs";
+my $module_dir = "$base_dir/module";
+my $mod_apreq2_dir = Apache::Build::WIN32 ?
+    "$base_dir/win32/libs" : "$module_dir/apache2/.libs";
 
 use base 'Apache::TestRunPerl';
 
@@ -23,6 +23,7 @@
     my $self = shift;
     # Don't load an installed mod_apreq
     Apache::TestConfig::autoconfig_skip_module_add('mod_apreq.c');
+    Apache::TestConfig::autoconfig_skip_module_add('mod_apreq2.c');
     $self->SUPER::pre_configure();
 }
 
@@ -31,9 +32,10 @@
     my $cfg = $self->{test_config};
     # make sure Win32 uses the just-built libapreq2.dll
     if (WIN32) {
-        $cfg->preamble(qq{LoadFile "$env_dir_libs/libapreq2.dll"\n});
+        my $library_dir = $mod_apreq2_dir;
+        $cfg->preamble(qq{LoadFile "$library_dir/libapreq2.dll"\n});
     }
     $cfg->preamble(IfModule => '!mod_apreq.c',
-               qq(LoadModule apreq_module "$env_dir_libs/mod_apreq.so"\n));
+               qq(LoadModule apreq_module "$mod_apreq2_dir/mod_apreq2.so"\n));
     $self->SUPER::configure_modperl();
 }

Modified: httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/apreq_xs_postperl.h
URL: http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/apreq_xs_postperl.h?view=diff&r1=153895&r2=153896
==============================================================================
--- httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/apreq_xs_postperl.h (original)
+++ httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/apreq_xs_postperl.h Mon Feb
14 21:13:17 2005
@@ -26,6 +26,10 @@
 /* backward compatibility macros support */
 #include "ppport.h"
 
+/* ExtUtils::XSBuilder::ParseSoure trickery... */
+typedef apreq_handle_t apreq_handle_cgi_t;
+typedef apreq_handle_t apreq_handle_apache2_t;
+
 /**
  * @file apreq_xs_postperl.h
  * @brief XS include file for making Cookie.so and Request.so

Modified: httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/maps/apreq_functions.map
URL: http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/maps/apreq_functions.map?view=diff&r1=153895&r2=153896
==============================================================================
--- httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/maps/apreq_functions.map (original)
+++ httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/maps/apreq_functions.map Mon
Feb 14 21:13:17 2005
@@ -103,5 +103,17 @@
 # apreq_expires
 
 
-MODULE=APR::Request  PACKAGE=APR::Request::Handle PREFIX=apreq_
-apreq_jar
+#################### APR::Request stuff ####################
+
+MODULE=APR::Request  PACKAGE=APR::Request
+#DEFINE_jar | apreq_xs_jar |
+#DEFINE_args | apreq_xs_args |
+#DEFINE_body | apreq_xs_body |
+#DEFINE_param | apreq_xs_param |
+
+MODULE=APR::Request::Apache2 PACKAGE=APR::Request::Apache2
+apreq_handle_apache2_t *:DEFINE_new | apreq_handle_apache2 (r) | const char *:class, request_rec
*:r
+
+MODULE=APR::Request::CGI PACKAGE=APR::Request::CGI
+apreq_handle_cgi_t *:DEFINE_new | apreq_handle_cgi (p) | const char *:class, apr_pool_t *:p
+

Modified: httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/maps/apreq_structures.map
URL: http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/maps/apreq_structures.map?view=diff&r1=153895&r2=153896
==============================================================================
--- httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/maps/apreq_structures.map
(original)
+++ httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/maps/apreq_structures.map
Mon Feb 14 21:13:17 2005
@@ -13,7 +13,8 @@
 !   v
 </apreq_param_t>
 
-#<apreq_handle_t MODULE=APR::Request::Handle>
+<apreq_handle_t MODULE=APR::Request::Handle>
+! module
 #!   args
 #!   body
 #!   parser
@@ -21,7 +22,7 @@
 #!  env
 #   args_status
 #   body_status
-#</apreq_handle_t>
+</apreq_handle_t>
 
 <apreq_cookie_t MODULE=APR::Request::Cookie>
   version
@@ -32,6 +33,7 @@
   comment
   commentURL
 ! max_age
+! flags
 !  v
 </apreq_cookie_t>
 
@@ -47,3 +49,6 @@
 !  hook
 > ctx
 </apreq_parser_t>
+
+<apr_table_t MODULE=APR::Request::Table>
+</apr_table_t>
\ No newline at end of file

Modified: httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/maps/apreq_types.map
URL: http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/maps/apreq_types.map?view=diff&r1=153895&r2=153896
==============================================================================
--- httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/maps/apreq_types.map (original)
+++ httpd/apreq/branches/multi-env-unstable/glue/perl/xsbuilder/maps/apreq_types.map Mon Feb
14 21:13:17 2005
@@ -12,14 +12,25 @@
 #apreq_cookie_version_t | APREQ_COOKIE_VERSION
 
 #data structure stuff
+struct request_rec | Apache::RequestRec | T_PTR | r
 struct apr_pool_t           | APR::Pool | T_POOLOBJ
 struct apr_array_header_t   | APR::ArrayHeader
 struct apr_table_t          | APR::Table | T_HASHOBJ
 struct apr_bucket_brigade   | APR::Brigade
-#apr_table_entry_t           | APR::TableEntry
-#struct apr_hash_t           | APR::Hash
-#apr_hash_index_t            | APR::HashIndex
+
+const apr_table_t * | APR::Request::Table | T_HASHOBJ
+#const struct apr_table_t | APR::Request::Table | T_HASHOBJ
 
 struct apreq_param_t        | APR::Request::Param
 struct apreq_cookie_t       | APR::Request::Cookie
-struct apreq_handle_t       | APR::Request::Handle
+
+struct apreq_handle_t         | APR::Request          | T_APREQ_HANDLE
+struct apreq_handle_apache2_t | APR::Request::Apache2 | T_APREQ_HANDLE_APACHE2
+struct apreq_handle_cgi_t     | APR::Request::CGI     | T_APREQ_HANDLE
+
+static APR_INLINE apreq_param_t * | APR::Request::Param
+static APR_INLINE apreq_param_t * | APR::Request::Param
+static APR_INLINE apreq_cookie_t * | APR::Request::Cookie
+static APR_INLINE apreq_cookie_t * | APR::Request::Cookie
+APR_INLINE apr_status_t | IV
+



Mime
View raw message