You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by ja...@apache.org on 2001/09/16 17:16:20 UTC

cvs commit: xml-xerces/perl preSwig.pl

jasons      01/09/16 08:16:20

  Added:       perl     preSwig.pl
  Log:
  	* preSwig.pl (Repository):
  	New process script to strip inline methods off Xerces header files
  	   before they are swig'ed.
  
  Revision  Changes    Path
  1.1                  xml-xerces/perl/preSwig.pl
  
  Index: preSwig.pl
  ===================================================================
  #!/usr/local/bin/perl
  
  use strict;
  use SWIG qw(skip_to_closing_brace);
  use Getopt::Long;
  use File::Basename;
  
  my %OPTIONS;
  my $rc = GetOptions(\%OPTIONS,
  		   'directory=s');
  
  my $USAGE = qq[USAGE: $0: --directory file];
  
  die "No input file provided\n$USAGE"
    unless scalar @ARGV;
  
  die $USAGE unless $rc;
  
  my $file = shift @ARGV;
  
  die "File: $file does not exist"
    unless -f $file;
  
  open(IN,$file) or die "Couldn't open $file for reading";
  
  my $path;
  ($file,$path) = fileparse($file);
  
  $path =~ s|^.*/include/||;
  
  my $outdir = $OPTIONS{directory};
  
  mkdir($outdir) unless -d $outdir;
  $outdir = "$outdir/$path";
  mkdir($outdir) unless -d $outdir;
  
  my $outfile = "$outdir/$file";
  
  open(OUT,">$outfile") or die "Couldn't open $outfile for writing";
  
  my $in_class;
  while (<IN>) {
    if (/class/ && !/;\s*$/) {
      $in_class = 1;
    }
    if ($in_class && /\{\s*$/) {
      # we found the class definition
      print OUT;
      my $subst_func = sub {};
      skip_to_closing_brace(\*IN,$subst_func,\*OUT);
      last;
    }
    if ($in_class && /;\s*$/) {
      $in_class = 0;
    }
    print OUT;
  }
  close(IN);
  close(OUT);
  
  
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org