cvs commit: modperl-2.0/lib/Apache Build.pm ParseSource.pm

2001-03-04 Thread dougm

dougm   01/03/04 15:22:51

  Modified:lib/Apache Build.pm ParseSource.pm
  Log:
  look in MP_INCLUDE_DIR when scanning source
  Apache::Build::AUTOLOAD for accessing MP_* data
  
  Revision  ChangesPath
  1.35  +15 -4 modperl-2.0/lib/Apache/Build.pm
  
  Index: Build.pm
  ===
  RCS file: /home/cvs/modperl-2.0/lib/Apache/Build.pm,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- Build.pm  2001/03/04 19:41:56 1.34
  +++ Build.pm  2001/03/04 23:22:49 1.35
  @@ -13,7 +13,20 @@
   use constant IS_MOD_PERL_BUILD = grep { -e "$_/lib/mod_perl.pm" } qw(. ..);
   
   our $VERSION = '0.01';
  +our $AUTOLOAD;
   
  +sub AUTOLOAD {
  +my $self = shift;
  +my $name = uc ((split '::', $AUTOLOAD)[-1]);
  +unless ($name =~ /^MP_/) {
  +die "no such method: $AUTOLOAD";
  +}
  +unless ($self-{$name}) {
  +return wantarray ? () : undef;
  +}
  +return wantarray ? (split /\s+/, $self-{$name}) : $self-{$name};
  +}
  +
   #--- apxs stuff ---
   
   our $APXS;
  @@ -784,6 +797,8 @@
   my $os = is_win32 ? 'win32' : 'unix';
   my @inc = $self-file_path("src/modules/perl", "xs");
   
  +push @inc, $self-mp_include_dir;
  +
   my $ainc = $self-apxs('-q' = 'INCLUDEDIR');
   if (-d $ainc) {
   push @inc, $ainc;
  @@ -804,10 +819,6 @@
   $ssl_dir = join '/', $self-{MP_SSL_BASE} || '', 'include';
   }
   push @inc, $ssl_dir if -d $ssl_dir;
  -
  -if ($self-{MP_INCLUDE_DIR}) {
  -push @inc, split /\s+/, $self-{MP_INCLUDE_DIR};
  -}
   
   return \@inc;
   }
  
  
  
  1.11  +19 -13modperl-2.0/lib/Apache/ParseSource.pm
  
  Index: ParseSource.pm
  ===
  RCS file: /home/cvs/modperl-2.0/lib/Apache/ParseSource.pm,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- ParseSource.pm2001/03/03 23:08:58 1.10
  +++ ParseSource.pm2001/03/04 23:22:49 1.11
  @@ -10,7 +10,7 @@
   my $class = shift;
   
   my $self = bless {
  -config = Apache::Build-new,
  +config = Apache::Build-build_config,
   @_,
   }, $class;
   
  @@ -65,7 +65,11 @@
   bless $c, 'Apache::ParseSource::Scan';
   }
   
  -sub include_dir { shift-config-apxs(-q = 'INCLUDEDIR') }
  +sub include_dirs {
  +my $self = shift;
  +($self-config-apxs(-q = 'INCLUDEDIR'),
  + $self-config-mp_include_dir);
  +}
   
   sub includes { shift-config-includes }
   
  @@ -76,24 +80,26 @@
   
   require File::Find;
   
  -my $dir = $self-include_dir;
  +my(@dirs) = $self-include_dirs;
   
  -unless (-d $dir) {
  +unless (-d $dirs[0]) {
   die "could not find include directory";
   }
   
   my @includes;
   my $unwanted = join '|', qw(ap_listen internal);
   
  -File::Find::finddepth({
  -   wanted = sub {
  -   return unless /\.h$/;
  -   return if /($unwanted)/o;
  -   my $dir = $File::Find::dir;
  -   push @includes, "$dir/$_";
  -   },
  -   follow = 1,
  -  }, $dir);
  +for my $dir (@dirs) {
  +File::Find::finddepth({
  +   wanted = sub {
  +   return unless /\.h$/;
  +   return if /($unwanted)/o;
  +   my $dir = $File::Find::dir;
  +   push @includes, "$dir/$_";
  +   },
  +   follow = 1,
  +  }, $dir);
  +}
   
   #include apr_*.h before the others
   my @wanted = grep { /apr_\w+\.h$/ } @includes;
  
  
  



cvs commit: modperl-2.0/lib/ModPerl ParseSource.pm

2001-03-04 Thread dougm

dougm   01/03/04 15:26:53

  Added:   lib/ModPerl ParseSource.pm
  Log:
  subclass of Apache::ParseSource for building ModPerl::FunctionTable
  
  Revision  ChangesPath
  1.1  modperl-2.0/lib/ModPerl/ParseSource.pm
  
  Index: ParseSource.pm
  ===
  package ModPerl::ParseSource;
  
  use strict;
  use Config ();
  use Apache::ParseSource ();
  
  our @ISA = qw(Apache::ParseSource);
  our $VERSION = '0.01';
  
  sub includes {
  my $self = shift;
  my $dirs = $self-SUPER::includes;
  return [
  '.', qw(xs src/modules/perl),
  @$dirs,
  "$Config::Config{archlibexp}/CORE",
 ];
  }
  
  sub include_dirs { '.' }
  
  sub find_includes {
  my $self = shift;
  my $includes = $self-SUPER::find_includes;
  #filter/sort
  my @wanted  = grep { /mod_perl\.h/ } @$includes;
  push @wanted, grep { m:xs/modperl_xs_: } @$includes;
  push @wanted, grep { m:xs/A: } @$includes;
  \@wanted;
  }
  
  my $prefixes = join '|', qw(modperl_|mpxs_|mp_xs);
  my $prefix_re = qr{^($prefixes)};
  sub wanted_functions { $prefix_re }
  
  sub write_functions_pm {
  my $self = shift;
  my $file = shift || 'FunctionTable.pm';
  my $name = shift || 'ModPerl::FunctionTable';
  $self-SUPER::write_functions_pm($file, $name);
  }
  
  for my $method (qw(get_constants get_structs write_structs_pm get_structs)) {
  no strict 'refs';
  *$method = sub { die __PACKAGE__ . "-$method not implemented" };
  }
  
  1;
  __END__
  
  
  



cvs commit: modperl-2.0/lib/Apache ParseSource.pm

2001-03-04 Thread dougm

dougm   01/03/04 16:04:55

  Modified:lib/Apache ParseSource.pm
  Log:
  skip version.h (e.g. automake generated and not public)
  
  Revision  ChangesPath
  1.12  +2 -2  modperl-2.0/lib/Apache/ParseSource.pm
  
  Index: ParseSource.pm
  ===
  RCS file: /home/cvs/modperl-2.0/lib/Apache/ParseSource.pm,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ParseSource.pm2001/03/04 23:22:49 1.11
  +++ ParseSource.pm2001/03/05 00:04:55 1.12
  @@ -87,13 +87,13 @@
   }
   
   my @includes;
  -my $unwanted = join '|', qw(ap_listen internal);
  +my $unwanted = join '|', qw(ap_listen internal version);
   
   for my $dir (@dirs) {
   File::Find::finddepth({
  wanted = sub {
  return unless /\.h$/;
  -   return if /($unwanted)/o;
  +   return if /^($unwanted)/o;
  my $dir = $File::Find::dir;
  push @includes, "$dir/$_";
  },
  
  
  



cvs commit: modperl-2.0/xs/APR/Lock - New directory

2001-03-04 Thread dougm

dougm   01/03/04 19:43:15

  modperl-2.0/xs/APR/Lock - New directory



cvs commit: modperl-2.0/xs/APR/APR - New directory

2001-03-04 Thread dougm

dougm   01/03/04 19:43:12

  modperl-2.0/xs/APR/APR - New directory



cvs commit: modperl-2.0/lib/ModPerl FunctionMap.pm

2001-03-04 Thread dougm

dougm   01/03/04 19:44:58

  Added:   lib/ModPerl FunctionMap.pm
  Log:
  module for mapping functions
  
  Revision  ChangesPath
  1.1  modperl-2.0/lib/ModPerl/FunctionMap.pm
  
  Index: FunctionMap.pm
  ===
  package ModPerl::FunctionMap;
  
  use strict;
  use warnings FATAL = 'all';
  use ModPerl::MapUtil qw();
  use ModPerl::ParseSource ();
  use Apache::FunctionTable ();
  use ModPerl::FunctionTable ();
  
  our @ISA = qw(ModPerl::MapBase);
  
  sub new {
  my $class = shift;
  bless {}, $class;
  }
  
  #for adding to function.map
  sub generate {
  my $self = shift;
  
  my $missing = $self-check;
  return unless $missing;
  
  print " $_\n" for @$missing;
  }
  
  sub disabled { shift-{disabled} }
  
  #look for functions that do not exist in *.map
  sub check {
  my $self = shift;
  my $map = $self-get;
  
  my @missing;
  my $mp_func = ModPerl::ParseSource-wanted_functions;
  
  for my $name (map $_-{name}, @{ $self-function_table() }) {
  next if exists $map-{$name};
  push @missing, $name unless $name =~ /^($mp_func)/o;
  }
  
  return @missing ? \@missing : undef;
  }
  
  #look for functions in *.map that do not exist
  my $special_name = qr{(^DEFINE_|DESTROY$)};
  
  sub check_exists {
  my $self = shift;
  
  my %functions = map { $_-{name}, 1 } @{ $self-function_table() };
  my @missing = ();
  
  for my $name (keys %{ $self-{map} }) {
  next if $functions{$name};
  push @missing, $name unless $name =~ $special_name;
  }
  
  return @missing ? \@missing : undef;
  }
  
  my $keywords = join '|', qw(MODULE PACKAGE PREFIX);
  
  sub guess_prefix {
  my $entry = shift;
  
  my($name, $class) = ($entry-{name}, $entry-{class});
  my $prefix = "";
  $name =~ s/^DEFINE_//;
  
  (my $guess = lc($entry-{class} || $entry-{module}) . '_') =~ s/::/_/g;
  $guess =~ s/apache_/ap_/;
  
  if ($name =~ /^$guess/) {
  $prefix = $guess;
  }
  else {
  if ($name =~ /^(apr?_)/) {
  $prefix = $1;
  }
  }
  
  #print "GUESS prefix=$guess, name=$entry-{name} - $prefix\n";
  
  return $prefix;
  }
  
  sub parse {
  my($self, $fh, $map) = @_;
  my %cur;
  my $disabled = 0;
  
  while ($fh-readline) {
  if (/($keywords)=/o) {
  $disabled = s/^\W//; #module is disabled
  my %words = $self-parse_keywords($_);
  
  if ($words{MODULE}) {
  %cur = ();
  }
  
  for (keys %words) {
  $cur{$_} = $words{$_};
  }
  
  next;
  }
  
  my($name, $dispatch, $argspec, $alias) = split /\s*\|\s*/;
  my $return_type;
  
  if ($name =~ s/^([^:]+)://) {
  $return_type = $1;
  }
  
  if ($name =~ s/^(\W)// or not $cur{MODULE} or $disabled) {
  #notimplemented or cooked by hand
  $map-{$name} = undef;
  push @{ $self-{disabled}-{ $1 || '!' } }, $name;
  next;
  }
  
  my $entry = $map-{$name} = {
 name= $alias || $name,
 dispatch= $dispatch,
 argspec = $argspec ? [split /\s*,\s*/, $argspec] : "",
 return_type = $return_type,
 alias   = $alias,
  };
  
  if (my $package = $cur{PACKAGE}) {
  unless ($package eq 'guess') {
  $cur{CLASS} = $package;
  }
  }
  else {
  $cur{CLASS} = $cur{MODULE};
  }
  
  for (keys %cur) {
  $entry-{lc $_} = $cur{$_};
  }
  
  $entry-{prefix} ||= guess_prefix($entry);
  
  #avoid 'use of uninitialized value' warnings
  $entry-{$_} ||= "" for keys %{ $entry };
  if ($entry-{dispatch} =~ /_$/) {
  $entry-{dispatch} .= $name;
  }
  }
  }
  
  sub get {
  my $self = shift;
  
  $self-{map} ||= $self-parse_map_files;
  }
  
  sub prefixes {
  my $self = shift;
  $self = ModPerl::FunctionMap-new unless ref $self;
  
  my $map = $self-get;
  my %prefix;
  
  while (my($name, $ent) = each %$map) {
  next unless $ent-{prefix};
  $prefix{ $ent-{prefix} }++;
  }
  
  [keys %prefix]
  }
  
  1;
  __END__
  
  
  



cvs commit: modperl-2.0/lib/ModPerl TypeMap.pm

2001-03-04 Thread dougm

dougm   01/03/04 19:45:23

  Added:   lib/ModPerl TypeMap.pm
  Log:
  module for mapping types and data structures
  
  Revision  ChangesPath
  1.1  modperl-2.0/lib/ModPerl/TypeMap.pm
  
  Index: TypeMap.pm
  ===
  package ModPerl::TypeMap;
  
  use strict;
  use warnings FATAL = 'all';
  
  use Apache::StructureTable ();
  use Apache::FunctionTable ();
  use ModPerl::FunctionMap ();
  use ModPerl::StructureMap ();
  use ModPerl::MapUtil qw(list_first);
  
  our @ISA = qw(ModPerl::MapBase);
  
  sub new {
  my $class = shift;
  my $self = bless { INCLUDE = [] }, $class;
  
  $self-{function_map}  = ModPerl::FunctionMap-new,
  $self-{structure_map} = ModPerl::StructureMap-new,
  
  $self-get;
  $self;
  }
  
  my %special = map { $_, 1 } qw(UNDEFINED NOTIMPL CALLBACK);
  
  sub special {
  my($self, $class) = @_;
  return $special{$class};
  }
  
  sub function_map  { shift-{function_map}-get  }
  sub structure_map { shift-{structure_map}-get }
  
  sub parse {
  my($self, $fh, $map) = @_;
  
  while ($fh-readline) {
  if (/E=/) {
  my %args = $self-parse_keywords($_);
  while (my($key,$val) = each %args) {
  push @{ $self-{$key} }, $val;
  }
  next;
  }
  
  my @aliases;
  my($type, $class) = (split /\s*\|\s*/, $_)[0,1];
  $class ||= 'UNDEFINED';
  
  if ($type =~ s/^struct\s+(.*)/$1/) {
  push @aliases,
$type, "$type *", "const $type *",
"struct $type *", "const struct $type *",
"$type **";
  
  my $cname = $class;
  if ($cname =~ s/::/__/) {
  push @{ $self-{typedefs} }, [$type, $cname];
  }
  }
  elsif ($type =~ /_t$/) {
  push @aliases, $type, "$type *", "const $type *";
  }
  else {
  push @aliases, $type;
  }
  
  for (@aliases) {
  $map-{$_} = $class;
  }
  }
  }
  
  sub get {
  my $self = shift;
  
  $self-{map} ||= $self-parse_map_files;
  }
  
  my $ignore = join '|', qw{
  ap_LINK ap_HOOK _ UINT union._
  union.block_hdr cleanup process_chain
  iovec struct.rlimit Sigfunc in_addr_t
  };
  
  sub should_ignore {
  my($self, $type) = @_;
  return 1 if $type =~ /^($ignore)/o;
  }
  
  sub is_callback {
  my($self, $type) = @_;
  return 1 if $type =~ /\(/ and $type =~ /\)/; #XXX: callback
  }
  
  sub exists {
  my($self, $type) = @_;
  
  return 1 if $self-is_callback($type) || $self-should_ignore($type);
  
  $type =~ s/\[\d+\]$//; #char foo[64]
  
  return exists $self-get-{$type};
  }
  
  sub map_type {
  my($self, $type) = @_;
  my $class = $self-get-{$type};
  
  return unless $class and ! $self-special($class);
  #return if $type =~ /\*\*$/; #XXX
  if ($class =~ /::/) {
  return $class;
  }
  else {
  return $type;
  }
  }
  
  sub null_type {
  my($self, $type) = @_;
  my $class = $self-get-{$type};
  
  if ($class =~ /^[INU]V/) {
  return '0';
  }
  else {
  return 'NULL';
  }
  }
  
  sub can_map {
  my $self = shift;
  my $map = shift;
  
  return 1 if $map-{argspec};
  
  for (@_) {
  return unless $self-map_type($_);
  }
  
  return 1;
  }
  
  sub map_arg {
  my($self, $arg) = @_;
  return {
 name= $arg-{name},
 default = $arg-{default},
 type= $self-map_type($arg-{type}),
 rtype   = $arg-{type},
  }
  }
  
  sub map_args {
  my($self, $func) = @_;
  
  my $entry = $self-function_map-{ $func-{name} };
  my $argspec = $entry-{argspec};
  my $args = [];
  
  if ($argspec) {
  $entry-{orig_args} = [ map $_-{name}, @{ $func-{args} } ];
  
  for my $arg (@$argspec) {
  my $default;
  ($arg, $default) = split /=/, $arg, 2;
  my($type, $name) = split ':', $arg, 2;
  
  if ($type and $name) {
  push @$args, {
 name = $name,
 type = $type,
 default = $default,
  };
  }
  else {
  my $e = list_first { $_-{name} eq $arg } @{ $func-{args} };
  if ($e) {
  push @$args, { %$e, default = $default };
  }
  elsif ($arg eq '...') {
  push @$args, { name = '...', type = 'SV *' };
  }
  else {
  warn "bad argspec: $func-{name} ($arg)\n";
  }
  }
  }
  }
  else {
  $args = $func-{args};
  }
  
  return [ map $self-map_arg($_), @$args ]
  }
  
 

cvs commit: modperl-2.0/lib/ModPerl StructureMap.pm

2001-03-04 Thread dougm

dougm   01/03/04 19:45:47

  Added:   lib/ModPerl StructureMap.pm
  Log:
  module for mapping data structures
  
  Revision  ChangesPath
  1.1  modperl-2.0/lib/ModPerl/StructureMap.pm
  
  Index: StructureMap.pm
  ===
  package ModPerl::StructureMap;
  
  use strict;
  use warnings FATAL = 'all';
  use Apache::StructureTable ();
  use ModPerl::MapUtil ();
  
  our @ISA = qw(ModPerl::MapBase);
  
  sub new {
  my $class = shift;
  bless {}, $class;
  }
  
  sub generate {
  my $self = shift;
  my $map = $self-get;
  
  for my $entry (@$Apache::StructureTable) {
  my $type = $entry-{type};
  my $elts = $entry-{elts};
  
  next unless @$elts;
  next if $type =~ $self-{IGNORE_RE};
  next unless grep {
  not exists $map-{$type}-{ $_-{name} }
  } @$elts;
  
  print "$type\n";
  for my $e (@$elts) {
  print "   $e-{name}\n";
  }
  print "/$type\n\n";
  }
  }
  
  sub disabled { shift-{disabled} }
  
  sub check {
  my $self = shift;
  my $map = $self-get;
  
  my @missing;
  
  for my $entry (@$Apache::StructureTable) {
  my $type = $entry-{type};
  
  for my $name (map $_-{name}, @{ $entry-{elts} }) {
  next if exists $map-{$type}-{$name};
  next if $type =~ $self-{IGNORE_RE};
  push @missing, "$type.$name";
  }
  }
  
  return @missing ? \@missing : undef;
  }
  
  sub check_exists {
  my $self = shift;
  
  my %structures;
  for my $entry (@$Apache::StructureTable) {
  $structures{ $entry-{type} } = { map {
  $_-{name}, 1
  } @{ $entry-{elts} } };
  }
  
  my @missing;
  
  while (my($type, $elts) = each %{ $self-{map} }) {
  for my $name (keys %$elts) {
  next if exists $structures{$type}-{$name};
  push @missing, "$type.$name";
  }
  }
  
  return @missing ? \@missing : undef;
  }
  
  sub parse {
  my($self, $fh, $map) = @_;
  
  my($disabled, $class);
  my %cur;
  
  while ($fh-readline) {
  if (m:^(\W?)/?([^]+):) {
  $disabled = $1;
  my $args = $2;
  
  %cur = ();
  if ($args =~ /E=/) {
  %cur = $self-parse_keywords($args);
  }
  
  $class = $cur{STRUCT} || $args;
  $self-{MODULES}-{$class} = $cur{MODULE} if $cur{MODULE};
  
  next;
  }
  elsif (s/^(\w+):\s*//) {
  push @{ $self-{$1} }, split /\s+/;
  next;
  }
  
  if (s/^(\W)\s*// or $disabled) {
  $map-{$class}-{$_} = undef;
  push @{ $self-{disabled}-{ $1 || '!' } }, "$class.$_";
  }
  else {
  $map-{$class}-{$_} = 1;
  }
  }
  
  if (my $ignore = $self-{IGNORE}) {
  $ignore = join '|', @$ignore;
  $self-{IGNORE_RE} = qr{^($ignore)};
  }
  else {
  $self-{IGNORE_RE} = qr{^$};
  }
  }
  
  sub get {
  my $self = shift;
  
  $self-{map} ||= $self-parse_map_files;
  }
  
  1;
  __END__
  
  
  



cvs commit: modperl-2.0/lib/ModPerl WrapXS.pm

2001-03-04 Thread dougm

dougm   01/03/04 19:47:33

  Added:   lib/ModPerl WrapXS.pm
  Log:
  module to generating the Makefile.PL, .pm and .xs for a module
  
  Revision  ChangesPath
  1.1  modperl-2.0/lib/ModPerl/WrapXS.pm
  
  Index: WrapXS.pm
  ===
  package ModPerl::WrapXS;
  
  use strict;
  use warnings FATAL = 'all';
  
  use Apache::Build ();
  use ModPerl::Code ();
  use ModPerl::TypeMap ();
  use ModPerl::MapUtil qw(function_table xs_glue_dirs);
  use File::Path qw(rmtree mkpath);
  use Cwd qw(fastcwd);
  use Data::Dumper;
  
  our $VERSION = '0.01';
  
  my(@xs_includes) = ('mod_perl.h',
  map "modperl_xs_$_.h", qw(util typedefs sv_convert));
  
  sub new {
  my $class = shift;
  
  my $self = bless {
 typemap   = ModPerl::TypeMap-new,
 includes  = \@xs_includes,
 glue_dirs = [xs_glue_dirs()],
  }, $class;
  
  for (qw(c hash)) {
  my $w = "noedit_warning_$_";
  my $method = "ModPerl::Code::$w";
  $self-{$w} = $self-$method();
  }
  
  $self-typemap-get;
  $self;
  }
  
  sub typemap  { shift-{typemap} }
  
  sub includes { shift-{includes} }
  
  sub function_list {
  my $self = shift;
  my(@list) = @{ function_table() };
  
  while (my($name, $val) = each %{ $self-typemap-function_map }) {
  #entries that do not exist in C::Scan generated tables
  next unless $name =~ /^DEFINE_/;
  push @list, $val;
  }
  
  return \@list;
  }
  
  sub get_functions {
  my $self = shift;
  my $typemap = $self-typemap;
  
  for my $entry (@{ $self-function_list() }) {
  my $func;
  next unless $func = $typemap-map_function($entry);
  
  my($name, $module, $class, $args) =
@{ $func } { qw(perl_name module class args) };
  
  #eg ap_fputs()
  if ($name =~ s/^DEFINE_//) {
  $func-{name} =~ s/^DEFINE_//;
  
  if (needs_prefix($func-{name})) {
  #e.g. DEFINE_add_output_filter
  $func-{name} = make_prefix($func-{name}, $class);
  }
  }
  
  my $xs_parms = join ', ',
map { defined $_-{default} ?
"$_-{name}=$_-{default}" : $_-{name} } @$args;
  
  (my $parms = $xs_parms) =~ s/=[^,]+//g; #strip defaults
  
  my $proto = join "\n",
(map "$_-{type} $_-{name}", @$args), "";
  
  my($dispatch, $orig_args) =
@{ $func } {qw(dispatch orig_args)};
  
  if ($dispatch =~ /^MPXS_/) {
  $name =~ s/^$func-{prefix}//;
  push @{ $self-{newXS}-{ $module } },
["$class\::$name", $dispatch];
  next;
  }
  
  my $passthru = @$args  $args-[0]-{name} eq '...';
  if ($passthru) {
  $parms = '...';
  $proto = '';
  }
  
  my $return_type =
$name =~ /^DESTROY$/ ? 'void' : $func-{return_type};
  
  my $code = EOF;
  $return_type
  $name($xs_parms)
  $proto
  EOF
  
  if ($dispatch || $orig_args) {
  my $thx = "";
  
  if ($dispatch) {
  $thx = 'aTHX_ ' if $dispatch =~ /^mpxs_/i;
  }
  else {
  if ($orig_args and @$orig_args == @$args) {
  #args were reordered
  $parms = join ', ', @$orig_args;
  }
  
  $dispatch = $func-{name};
  }
  
  if ($passthru) {
  $parms = 'items, MARK+1, SP';
  }
  
  my $retval = $return_type eq 'void' ?
["", ""] : ["RETVAL = ", "OUTPUT:\nRETVAL\n"];
  
  $code .= EOF;
  CODE:
  $retval-[0]$dispatch($thx$parms);
  
  $retval-[1]
  EOF
  }
  
  $func-{code} = $code;
  push @{ $self-{XS}-{ $module } }, $func;
  }
  }
  
  sub get_value {
  my $e = shift;
  my $val = 'val';
  
  if ($e-{class} eq 'PV') {
  if (my $pool = $e-{pool}) {
  $pool =~ s/^\./obj-/;
  $val = "((ST(1) == PL_sv_undef) ? NULL :
  (SvPOK(ST(1)) ?
  apr_pstrndup($pool, SvPVX(ST(1)), SvCUR(ST(1))) :
  apr_pstrdup($pool, val)))";
  }
  }
  
  return $val;
  }
  
  sub get_structures {
  my $self = shift;
  my $typemap = $self-typemap;
  
  for my $entry (@$Apache::StructureTable) {
  my $struct = $typemap-map_structure($entry);
  next unless $struct;
  
  my $class = $struct-{class};
  
  for my $e (@{ $struct-{elts} }) {
  my($name, $default, $type) =
@{$e}{qw(name default type)};
  
  (my $cast = $type) =~ s/:/_/g;
  my $val = get_value($e);
  
  my $code = EOF;
  

cvs commit: modperl-2.0/xs modperl_xs_util.h

2001-03-04 Thread dougm

dougm   01/03/04 19:48:15

  Added:   xs   modperl_xs_util.h
  Log:
  utilties for extensions
  
  Revision  ChangesPath
  1.1  modperl-2.0/xs/modperl_xs_util.h
  
  Index: modperl_xs_util.h
  ===
  #ifndef MODPERL_XS_H
  #define MODPERL_XS_H
  
  #ifndef dAX
  #define dAXI32 ax = mark - PL_stack_base + 1
  #endif
  
  #ifndef dITEMS
  #define dITEMS I32 items = SP - MARK
  #endif
  
  #define mpxs_sv_grow(sv, len) \
  (void)SvUPGRADE(sv, SVt_PV); \
  SvGROW(sv, len+1)
  
  #define mpxs_sv_cur_set(sv, len) \
  SvCUR_set(sv, len); \
  *SvEND(sv) = '\0'; \
  SvPOK_only(sv)
  
  #define mpxs_set_targ(func, arg) \
  STMT_START { \
  dXSTARG; \
  XSprePUSH; \
  func(aTHX_ TARG, arg); \
  PUSHTARG; \
  XSRETURN(1); \
  } STMT_END
  
  #define mpxs_cv_name() \
  HvNAME(GvSTASH(CvGV(cv))), GvNAME(CvGV(cv))
  
  #define mpxs_sv_is_object(sv) \
  (SvROK(sv)  (SvTYPE(SvRV(sv)) == SVt_PVMG))
  
  #define mpxs_sv_object_deref(sv) \
  (mpxs_sv_is_object(sv) ? SvIV((SV*)SvRV(sv)) : NULL)
  
  #define mpxs_sv2_obj(obj, sv) \
  (obj = mp_xs_sv2_##obj(sv))
  
  #define mpxs_usage_items_1(arg) \
  if (items != 1) { \
  Perl_croak(aTHX_ "usage: %s::%s(%s)", \
 mpxs_cv_name(), arg); \
  }
  
  #define mpxs_usage_va(i, obj, msg) \
  if ((items  i) || !(mpxs_sv2_obj(obj, *MARK))) \
  croak("usage: %s", msg); \
  MARK++
  
  #define mpxs_usage_va_1(obj, msg) mpxs_usage_va(1, obj, msg)
  
  #define mpxs_usage_va_2(obj, arg, msg) \
  mpxs_usage_va(2, obj, msg); \
  arg = *MARK++
  
  #endif /* MODPERL_XS_H */
  
  
  



cvs commit: modperl-2.0/xs/maps apache_functions.map apache_structures.map apache_types.map

2001-03-04 Thread dougm

dougm   01/03/04 19:49:12

  Added:   xs/maps  apache_functions.map apache_structures.map
apache_types.map
  Log:
  the function/structure/type maps for apache
  
  Revision  ChangesPath
  1.1  modperl-2.0/xs/maps/apache_functions.map
  
  Index: apache_functions.map
  ===
  ##  Apache functions  ##
  
  #keywords:
  # MODULE  = the module name
  #   e.g. Apache::Connection - Apache/Connection.{pm,xs}
  #
  # PACKAGE = the package name functions belong to, defaults to MODULE
  #   value of 'guess' indicates that package name should be
  #   guessed based on first argument found that maps to a Perl class
  #   fallsback on the prefix (ap_ - Apache, apr_ - APR)
  #
  # PREFIX  = prefix to be stripped
  #   defaults to PACKAGE, converted to C name convention, e.g.
  #   APR::Base64 - apr_base64_
  #   if the converted prefix does not match, defaults to ap_ or apr_
  
  #format of entries:
  # C function name | dispatch function name | argspec | Perl alias
  
  # dispatch function name defaults to C function name
  # if the dispatch name is just a prefix (mpxs_, MPXS_)
  # the C function name is appended to it
  # the return type can be specified before the C function name,
  # defaults to return_type in {Apache,ModPerl}::FunctionTable
  
  # the argspec defaults to arguments in {Apache,ModPerl}::FunctionTable
  # argument types can be specified to override those in the FunctionTable
  # default values can be specified, e.g. arg=default_value
  # argspec of '...' indicates passthru, calling the function with
  # (aTHX_ I32 items, SP **sp, SV **MARK)
  
  # the alias will be created in the current PACKAGE
  
  # function names that do not begin with /^\w/ are skipped
  # for details see: %ModPerl::MapUtil::disabled_map
  
  MODULE=Apache::RequestUtil   PACKAGE=guess
   ap_finalize_request_protocol
   ap_default_port_for_request
   ap_default_port_for_scheme
   ap_default_type
   ap_get_server_name
   ap_get_server_port
  !ap_content_type_tolower
   ap_get_status_line
   ap_is_initial_req
  
  #MODULE=Apache::RequestConfig
   ap_document_root
   ap_get_limit_req_body
   ap_get_limit_xml_body
  ap_core_translate
  
  MODULE=Apache::SubRequest   PACKAGE=guess
   ap_sub_req_lookup_file
   ap_sub_req_lookup_uri
   ap_sub_req_method_uri
   ap_sub_req_output_filter
   ap_set_sub_req_protocol
  -ap_finalize_sub_req_protocol
   ap_internal_redirect
   ap_internal_redirect_handler
  
  MODULE=Apache::SubRequestPACKAGE=Apache::SubRequest
   ap_destroy_sub_req
   ap_run_sub_req
  
  MODULE=Apache::RequestIO   PACKAGE=Apache::RequestRec
   ap_discard_request_body
  !ap_getline
   ap_get_client_block   | mpxs_ | r, SV *:buffer, bufsiz
   ap_setup_client_block |   | r, read_policy=REQUEST_CHUNKED_ERROR
   ap_should_client_block
   ap_rflush
  PREFIX=ap_r
   ap_rwrite | | r, buf, nbyte
  ~ap_rprintf
  !ap_rputc
  ~ap_rputs
   ap_rvputs | mpxs_ | ... | puts
  -ap_vrprintf
  
   mpxs_Apache__RequestRec_TIEHANDLE
  
  MODULE=Apache::Response   PACKAGE=guess
   ap_make_etag
   ap_set_content_length
   ap_set_etag
   ap_meets_conditions
   ap_rationalize_mtime
   ap_update_mtime
   ap_send_error_response
   ap_send_fd
   ap_send_mmap
   ap_send_size
   ap_set_keepalive
   ap_set_last_modified
   ap_custom_response
  
  MODULE=Apache::Access   PACKAGE=guess
   ap_allow_methods
   ap_allow_options
   ap_allow_overrides
   ap_get_remote_logname
  !ap_requires
   ap_satisfies
  
  #MODULE=Apache::Auth
   ap_auth_name
   ap_auth_type
   ap_get_basic_auth_pw
   ap_note_auth_failure
   ap_note_basic_auth_failure
   ap_note_digest_auth_failure
   ap_some_auth_required
  
  !MODULE=Apache::ScriptUtil   PACKAGE=guess
   ap_add_cgi_vars
   ap_add_common_vars
   ap_create_environment
   ap_find_path_info
  -ap_scan_script_header_err
  -ap_scan_script_header_err_core
  -ap_scan_script_header_err_strs
  
  MODULE=Apache::ServerUtil   PACKAGE=guess
   ap_add_version_component
   ap_construct_server
   ap_construct_url | | r,uri,p
   ap_error_log2stderr
  
  #MODULE=Apache::ServerConfig
   ap_exists_config_define
   ap_get_local_host
   ap_get_server_built
   ap_get_server_version
   ap_psignature | | r,prefix
   ap_server_root_relative
  
  MODULE=Apache::Connection   PACKAGE=guess
   ap_get_remote_host
   ap_read_request
  ap_update_vhost_given_ip
   ap_new_connection
  
  !MODULE=Apache::Log   PACKAGE=guess
   ap_log_assert
   ap_log_error
   ap_log_perror
   ap_log_pid
   ap_log_rerror
  ap_open_stderr_log
  ap_open_logs
  
  !MODULE=Apache::Module
  -ap_add_loaded_module
  -ap_add_module
  -ap_add_named_module
   ap_find_linked_module
   ap_find_module_name
   ap_remove_loaded_module
   ap_remove_module
  ap_single_module_configure
  ap_setup_prelinked_modules
  ap_show_directives
  ap_show_modules
  ap_register_hooks
  
  !MODULE=Apache::Directive

cvs commit: modperl-2.0/xs/maps apr_functions.map apr_structures.map apr_types.map

2001-03-04 Thread dougm

dougm   01/03/04 19:49:21

  Added:   xs/maps  apr_functions.map apr_structures.map apr_types.map
  Log:
  the function/structure/type maps for apr
  
  Revision  ChangesPath
  1.1  modperl-2.0/xs/maps/apr_functions.map
  
  Index: apr_functions.map
  ===
  ##  APR Functions  ##
  
  !MODULE=APR::Poll
   apr_poll_socket_add
   apr_poll_socket_clear
   apr_poll_data_get
   apr_poll_revents_get
   apr_poll_socket_mask
   apr_poll
   apr_poll_socket_remove
   apr_poll_data_set
   apr_poll_setup
  
  !MODULE=APR::Time
   apr_ansi_time_to_apr_time
  -apr_ctime
   apr_implode_time
  -apr_time_now
  -apr_sleep
   apr_rfc822_date
   apr_strftime
   apr_explode_gmt
   apr_explode_localtime
  
  !MODULE=APR::Array
   apr_array_append
   apr_array_cat
   apr_array_pstrcat
   apr_array_copy
   apr_array_copy_hdr
   apr_array_make
   apr_array_push
  
  MODULE=APR::Socket
   apr_bind
  !apr_accept
   apr_listen
   apr_connect
   apr_recv
   apr_send
   apr_shutdown
  
  MODULE=APR::Socket
   apr_socket_close
  !apr_socket_create
   apr_socket_addr_get
   apr_socket_data_get
   apr_socket_data_set
   apr_getsocketopt
   apr_setsocketopt
  -apr_sendfile
  -apr_sendv
   apr_socket_from_file
  
  !MODULE=APR::SocketAddr
   apr_sockaddr_info_get
   apr_sockaddr_ip_get
   apr_sockaddr_ip_set
   apr_sockaddr_port_set
   apr_sockaddr_port_get
  
  MODULE=APR::Brigade
   apr_brigade_create | mpxs_ | SV *:CLASS, p | new
   apr_brigade_destroy
   apr_brigade_partition
   apr_brigade_printf
   apr_brigade_putstrs
   apr_brigade_split
  -apr_brigade_to_iovec
  -apr_brigade_vprintf
  -apr_brigade_vputstrs
   apr_brigade_length
   apr_brigade_write
   apr_brigade_puts
   apr_brigade_putc
  
  !MODULE=APR::Bucket
   apr_bucket_copy_notimpl
   apr_bucket_shared_copy
   apr_bucket_eos_create
   apr_bucket_file_create
   apr_bucket_flush_create
   apr_bucket_heap_create
   apr_bucket_immortal_create
   apr_bucket_mmap_create
   apr_bucket_pipe_create
   apr_bucket_pool_create
   apr_bucket_socket_create
   apr_bucket_transient_create
   apr_bucket_destroy_notimpl
   apr_bucket_shared_destroy
   apr_bucket_eos_make
   apr_bucket_file_make
   apr_bucket_flush_make
   apr_bucket_heap_make
   apr_bucket_immortal_make
   apr_bucket_mmap_make
   apr_bucket_pipe_make
   apr_bucket_pool_make
   apr_bucket_shared_make
   apr_bucket_socket_make
   apr_bucket_transient_make
   apr_bucket_setaside_notimpl
   apr_bucket_split_notimpl
   apr_bucket_shared_split
   apr_bucket_simple_split
   apr_bucket_simple_copy
  
  MODULE=APR::Pool
  apr_pool_free_blocks_num_bytes
   apr_pool_num_bytes
   apr_pool_cleanup_for_exec
   apr_pool_clear
   apr_pool_destroy
   apr_pool_t *:apr_pool_create | mpxs_ | SV *:obj | new
   apr_pool_userdata_get
   apr_pool_userdata_set
  apr_pool_alloc_init
  apr_pool_alloc_term
   apr_pool_cleanup_kill
   apr_pool_cleanup_run
  -apr_pool_cleanup_null
   apr_pool_cleanup_register
   apr_pool_sub_make
   apr_pool_note_subprocess
  -apr_palloc
  -apr_pcalloc
  -apr_pmemdup
  
  MODULE=APR::Lock
  !apr_lock_child_init
   apr_lock_t *:apr_lock_create | mpxs_ | \
SV *:CLASS, cont, type=0, scope=1, fname="lock.file" | new
  -apr_lock_destroy
   apr_lock_DESTROY | | lock
   apr_lock_data_get
   apr_lock_data_set
   apr_lock_acquire
   apr_lock_release
  
  MODULE=APR::Table
   apr_table_clear
   apr_table_copy| | t, p
   apr_table_make
   apr_table_overlap
   apr_table_overlay | | base, overlay, p
   apr_table_add
  -apr_table_addn
   apr_table_do
   apr_table_get
   apr_table_merge
  -apr_table_mergen
   apr_table_set
  -apr_table_setn
   apr_table_unset
  -apr_table_vdo
  
  !MODULE=APR::File
  -apr_file_open
  -apr_file_close
  -apr_file_namedpipe_create
   apr_file_pipe_create
  -apr_file_dup
  -apr_file_flush
  -apr_file_eof
  -apr_file_error
  -apr_file_gets
  -apr_file_printf
  -apr_file_write_full
  -apr_file_read_full
  -apr_file_getc
  -apr_file_ungetc
  -apr_file_putc
  -apr_file_puts
  -apr_file_read
  -apr_file_write
  -apr_file_writev
  -apr_file_seek
   apr_file_data_get
   apr_file_info_get
   apr_file_name_get
   apr_file_pool_get
   apr_file_pipe_timeout_get
   apr_file_pipe_timeout_set
   apr_file_lock
   apr_file_unlock
   apr_file_open_stderr
   apr_file_open_stdout
  -apr_file_remove
  -apr_file_rename
   apr_file_data_set
   apr_file_perms_set
  
  -MODULE=APR::Finfo
   apr_lstat
   apr_stat
  
  !MODULE=APR::Strings
   apr_collapse_spaces
  -apr_cpystrn
   apr_fnmatch
   apr_is_fnmatch
  -apr_psprintf
  -apr_pstrcat
  -apr_pstrdup
  -apr_pstrndup
  -apr_pvsprintf
   apr_strnatcasecmp
   apr_strnatcmp
  -apr_tokenize_to_argv
  
  !MODULE=APR::ProcAttr
   apr_procattr_create
   apr_procattr_child_err_set
   apr_procattr_child_in_set
   apr_procattr_child_out_set
   apr_procattr_cmdtype_set
   apr_procattr_detach_set
   apr_procattr_dir_set
   apr_procattr_io_set
   

cvs commit: modperl-2.0/xs/APR/UUID APR__UUID.h

2001-03-04 Thread dougm

dougm   01/03/04 19:53:29

  Added:   xs/APR/Base64 APR__Base64.h
   xs/APR/Brigade APR__Brigade.h
   xs/APR/Lib APR__Lib.h
   xs/APR/Lock APR__Lock.h
   xs/APR/Pool APR__Pool.h
   xs/APR/UUID APR__UUID.h
  Log:
  start of the wrapper functions for APR
  
  Revision  ChangesPath
  1.1  modperl-2.0/xs/APR/Base64/APR__Base64.h
  
  Index: APR__Base64.h
  ===
  static MP_INLINE void mpxs_apr_base64_encode(pTHX_ SV *sv, SV *arg)
  {
  STRLEN len;
  int encoded_len;
  char *data = SvPV(arg, len);
  mpxs_sv_grow(sv, apr_base64_encode_len(len));
  encoded_len = apr_base64_encode_binary(SvPVX(sv), data, len);
  mpxs_sv_cur_set(sv, encoded_len);
  }
  
  static MP_INLINE void mpxs_apr_base64_decode(pTHX_ SV *sv, SV *arg)
  {
  STRLEN len;
  int decoded_len;
  char *data = SvPV(arg, len);
  mpxs_sv_grow(sv, apr_base64_decode_len(data));
  decoded_len = apr_base64_decode_binary(SvPVX(sv), data);
  mpxs_sv_cur_set(sv, decoded_len);
  }
  
  static XS(MPXS_apr_base64_encode)
  {
  dXSARGS;
  
  mpxs_usage_items_1("data");
  
  mpxs_set_targ(mpxs_apr_base64_encode, ST(0));
  }
  
  static XS(MPXS_apr_base64_decode)
  {
  dXSARGS;
  
  mpxs_usage_items_1("data");
  
  mpxs_set_targ(mpxs_apr_base64_decode, ST(0));
  }
  
  
  
  1.1  modperl-2.0/xs/APR/Brigade/APR__Brigade.h
  
  Index: APR__Brigade.h
  ===
  static MP_INLINE apr_bucket_brigade *mpxs_apr_brigade_create(pTHX_ SV *CLASS,
   apr_pool_t *p)
  {
  return apr_brigade_create(p);
  }
  
  
  
  1.1  modperl-2.0/xs/APR/Lib/APR__Lib.h
  
  Index: APR__Lib.h
  ===
  static MP_INLINE void mpxs_apr_strerror(pTHX_ SV *sv, SV *arg)
  {
  apr_status_t statcode = mp_xs_sv2_status(arg);
  char *ptr;
  mpxs_sv_grow(sv, 128-1);
  ptr = apr_strerror(statcode, SvPVX(sv), SvLEN(sv));
  mpxs_sv_cur_set(sv, strlen(ptr)); /*XXX*/
  }
  
  static MP_INLINE void mpxs_apr_generate_random_bytes(pTHX_ SV *sv, SV *arg)
  {
  int len = (int)SvIV(arg);
  mpxs_sv_grow(sv, len);
  (void)apr_generate_random_bytes(SvPVX(sv), len);
  mpxs_sv_cur_set(sv, len);
  }
  
  static XS(MPXS_apr_strerror)
  {
  dXSARGS;
  
  mpxs_usage_items_1("status_code");
  
  mpxs_set_targ(mpxs_apr_strerror, ST(0));
  }
  
  static XS(MPXS_apr_generate_random_bytes)
  {
  dXSARGS;
  
  mpxs_usage_items_1("length");
  
  mpxs_set_targ(mpxs_apr_generate_random_bytes, ST(0));
  }
  
  
  
  1.1  modperl-2.0/xs/APR/Lock/APR__Lock.h
  
  Index: APR__Lock.h
  ===
  #define apr_lock_DESTROY(lock) (void)apr_lock_destroy(lock)
  
  static MP_INLINE apr_lock_t *mpxs_apr_lock_create(pTHX_ SV *CLASS,
apr_pool_t *p,
apr_locktype_e type,
apr_lockscope_e scope,
const char *fname)
  {
  apr_lock_t *retval=NULL;
  (void)apr_lock_create(retval, type, scope, fname, p);
  return retval;
  }
  
  
  
  1.1  modperl-2.0/xs/APR/Pool/APR__Pool.h
  
  Index: APR__Pool.h
  ===
  #define apr_pool_DESTROY(p) apr_pool_destroy(p)
  
  static MP_INLINE apr_pool_t *mpxs_apr_pool_create(pTHX_ SV *obj)
  {
  apr_pool_t *parent = (apr_pool_t *)mpxs_sv_object_deref(obj);
  apr_pool_t *retval = NULL;
  (void)apr_pool_create(retval, parent);
  return retval;
  }
  
  
  
  1.1  modperl-2.0/xs/APR/UUID/APR__UUID.h
  
  Index: APR__UUID.h
  ===
  #define mpxs_apr_uuid_alloc() \
  (apr_uuid_t *)safemalloc(sizeof(apr_uuid_t))
  
  static MP_INLINE apr_uuid_t *mpxs_apr_uuid_get(pTHX_ SV *CLASS)
  {
  apr_uuid_t *uuid = mpxs_apr_uuid_alloc();
  apr_uuid_get(uuid);
  return uuid;
  }
  
  static MP_INLINE void mp_apr_uuid_format(pTHX_ SV *sv, SV *obj)
  {
  apr_uuid_t *uuid = mp_xs_sv2_uuid(obj);
  mpxs_sv_grow(sv, APR_UUID_FORMATTED_LENGTH);
  apr_uuid_format(SvPVX(sv), uuid);
  mpxs_sv_cur_set(sv, APR_UUID_FORMATTED_LENGTH);
  }
  
  static MP_INLINE apr_uuid_t *mpxs_apr_uuid_parse(pTHX_ SV *CLASS, char *buf)
  {
  apr_uuid_t *uuid = mpxs_apr_uuid_alloc();
  apr_uuid_parse(uuid, buf);
  return uuid;
  }
  
  static XS(MPXS_apr_uuid_format)
  {
  dXSARGS;
  
  mpxs_usage_items_1("uuid");
  
  mpxs_set_targ(mp_apr_uuid_format, ST(0));
  }
  

cvs commit: modperl-2.0/xs/Apache/RequestIO Apache__RequestIO.h

2001-03-04 Thread dougm

dougm   01/03/04 19:54:18

  Added:   xs/Apache/Filter Apache__Filter.h
   xs/Apache/RequestIO Apache__RequestIO.h
  Log:
  start of the wrapper functions for Apache
  
  Revision  ChangesPath
  1.1  modperl-2.0/xs/Apache/Filter/Apache__Filter.h
  
  Index: Apache__Filter.h
  ===
  #define mpxs_Apache__RequestRec_add_output_filter(r, name, ctx) \
  ap_add_output_filter(name, ctx, r, NULL)
  
  
  
  1.1  modperl-2.0/xs/Apache/RequestIO/Apache__RequestIO.h
  
  Index: Apache__RequestIO.h
  ===
  #define mpxs_write_loop(func,obj) \
  while (MARK = SP) { \
  apr_ssize_t wlen; \
  char *buf = SvPV(*MARK, wlen); \
  apr_status_t rv = func(obj, buf, wlen); \
  if (rv != APR_SUCCESS) { \
  croak(modperl_apr_strerror(rv)); \
  } \
  bytes += wlen; \
  MARK++; \
  }
  
  #if 0
  #define MP_USE_AP_RWRITE
  #endif
  
  #ifdef MP_USE_AP_RWRITE
  
  #define mpxs_call_rwrite(r,buf,len) \
  ap_rwrite(buf, len, r)
  
  #define mpxs_rwrite_loop(func,obj) \
  while (MARK = SP) { \
  STRLEN len; \
  char *buf = SvPV(*MARK, len); \
  int wlen = func(obj, buf, len); \
  bytes += wlen; \
  MARK++; \
  }
  
  #endif
  
  static MP_INLINE apr_size_t mpxs_ap_rvputs(pTHX_ I32 items,
 SV **MARK, SV **SP)
  {
  modperl_srv_config_t *scfg;
  modperl_request_config_t *rcfg;
  apr_size_t bytes = 0;
  request_rec *r;
  dMP_TIMES;
  
  mpxs_usage_va_1(r, "$r-puts(...)");
  
  rcfg = modperl_request_config_get(r);
  scfg = modperl_srv_config_get(r-server);
  
  MP_START_TIMES();
  
  #ifdef MP_USE_AP_RWRITE
  mpxs_rwrite_loop(mpxs_call_rwrite, r);
  #else
  mpxs_write_loop(modperl_wbucket_write, rcfg-wbucket);
  #endif
  
  MP_END_TIMES();
  MP_PRINT_TIMES("r-puts");
  
  /* XXX: flush if $| */
  
  return bytes;
  }
  
  static MP_INLINE long mpxs_ap_get_client_block(pTHX_ request_rec *r,
 SV *buffer, int bufsiz)
  {
  long nrd = 0;
  
  mpxs_sv_grow(buffer, bufsiz);
  
  nrd = ap_get_client_block(r, SvPVX(buffer), bufsiz);
  
  if (nrd  0) {
  mpxs_sv_cur_set(buffer, nrd);
  SvTAINTED_on(buffer);
  }
  else {
  sv_setsv(buffer, PL_sv_undef); /* XXX */
  }
  
  return nrd;
  }
  
  static MP_INLINE SV *mpxs_Apache__RequestRec_TIEHANDLE(SV *classname,
 SV *obj)
  {
  return obj;
  }
  
  
  



cvs commit: modperl-2.0/util xs_generate.pl

2001-03-04 Thread dougm

dougm   01/03/04 19:55:08

  Added:   util xs_generate.pl
  Log:
  script to generate the xs code
  
  Revision  ChangesPath
  1.1  modperl-2.0/util/xs_generate.pl
  
  Index: xs_generate.pl
  ===
  use lib qw(lib);
  
  use ModPerl::WrapXS ();
  
  my $xs = ModPerl::WrapXS-new;
  
  $xs-generate;
  
  
  
  



cvs commit: modperl-2.0/util xs_check.pl

2001-03-04 Thread dougm

dougm   01/03/04 19:55:56

  Added:   util xs_check.pl
  Log:
  script to check if things are lined up properly, whats missing, what doesnt exist, 
etc.
  
  Revision  ChangesPath
  1.1  modperl-2.0/util/xs_check.pl
  
  Index: xs_check.pl
  ===
  use lib qw(lib);
  
  use strict;
  use warnings qw(FATAL all);
  
  use ModPerl::TypeMap ();
  use ModPerl::FunctionMap ();
  use ModPerl::StructureMap ();
  use ModPerl::WrapXS ();
  use ModPerl::MapUtil qw(disabled_reason);
  
  my %check = (
  types  = ModPerl::TypeMap-new,
  functions  = ModPerl::FunctionMap-new,
  structures = ModPerl::StructureMap-new,
  );
  
  my %missing;
  while (my($things, $obj) = each %check) {
  $missing{$things} = $obj-check;
  if (my $missing = $missing{$things}) {
  my $n = @$missing;
  print "$n $things are not mapped:\n";
  print "-- $_\n" for @$missing;
  }
  else {
  print "all $things are mapped\n";
  }
  }
  
  my %check_exists = (
  functions = $check{functions},
  structure_members = $check{structures},
  types = $check{types},
  );
  
  while (my($things, $obj) = each %check_exists) {
  if (my $missing = $obj-check_exists) {
  my $n = @$missing;
  print "$n mapped $things do not exist:\n";
  print "-- $_\n" for @$missing;
  }
  else {
  print "all mapped $things exist\n";
  }
  }
  
  my %unmapped = map { $_,1 } @{ $missing{functions} } if $missing{functions};
  my $typemap = $check{types};
  my $function_map = $check{functions};
  my @missing;
  
  for my $entry (@$Apache::FunctionTable) {
  my $func;
  my $name = $entry-{name};
  next if $unmapped{$name};
  next unless $function_map-{map}-{$name};
  next if $func = $typemap-map_function($entry);
  push @missing, $name;
  }
  
  if (@missing) {
  my $n = @missing;
  print "unable to glue $n mapped functions:\n";
  print "-- $_\n" for @missing;
  }
  else {
  print "all mapped functions are glued\n";
  }
  
  my $stats = ModPerl::WrapXS-new-stats;
  my($total_modules, $total_xsubs);
  
  while (my($module, $n) = each %$stats) {
  $total_modules++;
  $total_xsubs += $n;
  }
  
  print "$total_modules total modules, ",
"$total_xsubs total xsubs\n";
  
  while (my($module, $n) = each %$stats) {
  print "$module: $n\n";
  }
  
  for (qw(functions structure_members)) {
  my $disabled = $check_exists{$_}-disabled;
  my $total = 0;
  for my $names (values %$disabled) {
  $total += @$names;
  }
  print "$total $_ are not wrapped:\n";
  while (my($r, $names) = each %$disabled) {
  printf "%4d are %s\n", scalar @$names, disabled_reason($r);
  }
  }
  
  if (@ARGV) {
  my $key = '!';
  for (qw(functions structure_members)) {
  my $disabled = $check_exists{$_}-disabled;
  my $names = $disabled-{$key};
  printf "%s $_:\n", disabled_reason($key);
  for my $name (sort @$names) {
  print "   $name\n";
  }
  }
  }
  
  
  



cvs commit: modperl-2.0/util source_scan.pl

2001-03-04 Thread dougm

dougm   01/03/04 19:57:40

  Modified:util source_scan.pl
  Log:
  specify Apache/APR prefixes to look for
  pass @ARGV to optionally specify apxs
  build the ModPerl::FunctionTable module
  
  Revision  ChangesPath
  1.3   +10 -1 modperl-2.0/util/source_scan.pl
  
  Index: source_scan.pl
  ===
  RCS file: /home/cvs/modperl-2.0/util/source_scan.pl,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- source_scan.pl2001/01/22 20:21:49 1.2
  +++ source_scan.pl2001/03/05 03:57:40 1.3
  @@ -4,11 +4,20 @@
   
   use strict;
   use Apache::ParseSource ();
  +use ModPerl::ParseSource ();
  +use ModPerl::FunctionMap ();
   
  -my $p = Apache::ParseSource-new;
  +my $p = Apache::ParseSource-new(prefixes = ModPerl::FunctionMap-prefixes,
  + @ARGV);
   
   $p-parse;
   
   $p-write_functions_pm;
   
   $p-write_structs_pm;
  +
  +$p = ModPerl::ParseSource-new(@ARGV);
  +
  +$p-parse;
  +
  +$p-write_functions_pm;
  
  
  



cvs commit: modperl-2.0/xs/maps - New directory

2001-03-04 Thread dougm

dougm   01/03/04 19:42:11

  modperl-2.0/xs/maps - New directory



cvs commit: modperl-2.0/xs Makefile.PL

2001-03-04 Thread dougm

dougm   01/03/04 20:02:02

  Added:   xs   Makefile.PL
  Log:
  Makefile.PL
  
  Revision  ChangesPath
  1.1  modperl-2.0/xs/Makefile.PL
  
  Index: Makefile.PL
  ===
  use ExtUtils::MakeMaker;
  
  WriteMakefile(NAME = "ModPerl::XS",
VERSION = '0.01');
  
  
  



cvs commit: modperl-2.0/xs/APR - New directory

2001-03-04 Thread dougm

dougm   01/03/04 19:42:12

  modperl-2.0/xs/APR - New directory



cvs commit: modperl-2.0/xs/Apache - New directory

2001-03-04 Thread dougm

dougm   01/03/04 19:42:12

  modperl-2.0/xs/Apache - New directory



cvs commit: modperl-2.0/xs/APR/Brigade - New directory

2001-03-04 Thread dougm

dougm   01/03/04 19:43:12

  modperl-2.0/xs/APR/Brigade - New directory



cvs commit: modperl-2.0/xs/APR/Lib - New directory

2001-03-04 Thread dougm

dougm   01/03/04 19:43:13

  modperl-2.0/xs/APR/Lib - New directory



cvs commit: modperl-2.0/xs/APR/UUID - New directory

2001-03-04 Thread dougm

dougm   01/03/04 19:43:13

  modperl-2.0/xs/APR/UUID - New directory



cvs commit: modperl-2.0/xs/APR/Base64 - New directory

2001-03-04 Thread dougm

dougm   01/03/04 19:43:14

  modperl-2.0/xs/APR/Base64 - New directory