[svn:parrot] r48642 - in branches/tt677_toolsdirs/tools: build dev util
jkeenan at svn.parrot.org
jkeenan at svn.parrot.org
Tue Aug 24 22:52:21 UTC 2010
Author: jkeenan
Date: Tue Aug 24 22:52:21 2010
New Revision: 48642
URL: https://trac.parrot.org/parrot/changeset/48642
Log:
Per plan outlined in TT #677, move addoptags.pl and headerizer.pl from tools/build/ to tools/dev/. Move 7 files from tools/util/ to new directory tools/release/. Add two READMEs.
Added:
branches/tt677_toolsdirs/tools/build/README (contents, props changed)
- copied, changed from r48641, branches/tt677_toolsdirs/tools/release/README
branches/tt677_toolsdirs/tools/dev/addopstags.pl (props changed)
- copied unchanged from r48639, branches/tt677_toolsdirs/tools/build/addopstags.pl
branches/tt677_toolsdirs/tools/dev/headerizer.pl (props changed)
- copied unchanged from r48639, branches/tt677_toolsdirs/tools/build/headerizer.pl
branches/tt677_toolsdirs/tools/dev/ncidef2pasm.pl (props changed)
- copied unchanged from r48639, branches/tt677_toolsdirs/tools/util/ncidef2pasm.pl
branches/tt677_toolsdirs/tools/dev/parrot-config.pir (props changed)
- copied unchanged from r48639, branches/tt677_toolsdirs/tools/util/parrot-config.pir
branches/tt677_toolsdirs/tools/dev/perlcritic-cage.conf
- copied unchanged from r48639, branches/tt677_toolsdirs/tools/util/perlcritic-cage.conf
branches/tt677_toolsdirs/tools/dev/perlcritic.conf (props changed)
- copied unchanged from r48639, branches/tt677_toolsdirs/tools/util/perlcritic.conf
branches/tt677_toolsdirs/tools/dev/perltidy.conf (props changed)
- copied unchanged from r48639, branches/tt677_toolsdirs/tools/util/perltidy.conf
branches/tt677_toolsdirs/tools/dev/pgegrep (props changed)
- copied unchanged from r48639, branches/tt677_toolsdirs/tools/util/pgegrep
branches/tt677_toolsdirs/tools/dev/update_copyright.pl (props changed)
- copied unchanged from r48639, branches/tt677_toolsdirs/tools/util/update_copyright.pl
Deleted:
branches/tt677_toolsdirs/tools/build/addopstags.pl
branches/tt677_toolsdirs/tools/build/headerizer.pl
branches/tt677_toolsdirs/tools/util/ncidef2pasm.pl
branches/tt677_toolsdirs/tools/util/parrot-config.pir
branches/tt677_toolsdirs/tools/util/perlcritic-cage.conf
branches/tt677_toolsdirs/tools/util/perlcritic.conf
branches/tt677_toolsdirs/tools/util/perltidy.conf
branches/tt677_toolsdirs/tools/util/pgegrep
branches/tt677_toolsdirs/tools/util/update_copyright.pl
Copied and modified: branches/tt677_toolsdirs/tools/build/README (from r48641, branches/tt677_toolsdirs/tools/release/README)
==============================================================================
--- branches/tt677_toolsdirs/tools/release/README Tue Aug 24 22:45:00 2010 (r48641, copy source)
+++ branches/tt677_toolsdirs/tools/build/README Tue Aug 24 22:52:21 2010 (r48642)
@@ -1,5 +1,13 @@
# $Id$
-README for tools/release/
+README for tools/build/
This directory is intended to hold programs, templates and configuration files
-useful during the release process.
+invoked by the default 'make' target ('make all'), with or without
+command-line options, during the Parrot build process.
+
+Programs, templates and configuration files invoked by 'make install' or
+'make install-dev' should be placed in tools/release/.
+
+Other things being equal, programs, templates and configuration files invoked
+by all other 'make' targets (e.g., 'make headerizer') should be placed in
+tools/dev/.
Deleted: branches/tt677_toolsdirs/tools/build/addopstags.pl
==============================================================================
--- branches/tt677_toolsdirs/tools/build/addopstags.pl Tue Aug 24 22:52:21 2010 (r48641)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,54 +0,0 @@
-#!perl
-
-# Copyright (C) 2004-2006, Parrot Foundation.
-# $Id$
-
-use strict;
-use warnings;
-
-=head1 NAME
-
-tools/build/addopstags.pl - add src/ops/*.ops to tags
-
-=head1 SYNOPSIS
-
- perl tools/build/addopstags.pl src/ops/*.ops
-
-=head1 DESCRIPTION
-
-Add src/ops/*.ops to tags file.
-
-=cut
-
-my %seen;
-my @tags;
-
-# Pull ops tags
-while (<>) {
- if (/\bop \s+ (\w+) \s* \(/x) {
- next if $seen{$1}++;
-
- # tag file excmd xflags
- push @tags, join( "\t", $1, $ARGV, qq{$.;"}, "f" ) . "\n";
- }
-}
-continue {
- close ARGV if eof; # reset $.
-}
-
-# Pull existing tags
-open my $T, '<', 'tags';
-push @tags, <$T>;
-close $T;
-
-# Spit 'em out sorted
-open $T, '>', 'tags';
-print $T sort @tags;
-close $T;
-
-# Local Variables:
-# mode: cperl
-# cperl-indent-level: 4
-# fill-column: 100
-# End:
-# vim: expandtab shiftwidth=4:
Deleted: branches/tt677_toolsdirs/tools/build/headerizer.pl
==============================================================================
--- branches/tt677_toolsdirs/tools/build/headerizer.pl Tue Aug 24 22:52:21 2010 (r48641)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,464 +0,0 @@
-#! perl
-# Copyright (C) 2001-2010, Parrot Foundation.
-# $Id$
-
-=head1 NAME
-
-tools/build/headerizer.pl - Generates the function header parts of .h
-files from .c files
-
-=head1 SYNOPSIS
-
- $ perl tools/build/headerizer.pl [object files]
-
-Generates C function declarations based on the function definitions in
-the C source code.
-
-=head1 DESCRIPTION
-
-The headerizer works off of directives in the source and header files.
-
-One source file's public declarations can only go into one header file.
-However, one header file can have declarations from multiple source files.
-In other words, headers-to-source is one-to-many.
-
-=over 4
-
-=item C<HEADERIZER BEGIN:> F<source-filename> / C<HEADERIZER END:> F<source-filename>
-
-Marks the beginning and end of a block of declarations in a header file.
-
- # In file foo.h
- /* HEADERIZER BEGIN: src/foo.c */
- /* HEADERIZER END: src/foo.c */
-
- /* HEADERIZER BEGIN: src/bar.c */
- /* HEADERIZER END: src/bar.c */
-
-=item C<HEADERIZER HFILE:> F<header-filename>
-
-Tells the headerizer where the declarations for the functions should go
-
- # In file foo.c
- /* HEADERIZER HFILE: foo.h */
-
- # In file bar.c
- /* HEADERIZER HFILE: foo.h */
-
-=back
-
-=head1 COMMAND-LINE OPTIONS
-
-=over 4
-
-=item C<--macro=X>
-
-Print a list of all functions that have macro X. For example, --macro=PARROT_EXPORT.
-
-=back
-
-=cut
-
-use strict;
-use warnings;
-
-use Getopt::Long;
-use lib qw( lib );
-use Parrot::Config;
-use Parrot::Headerizer;
-
-my $headerizer = Parrot::Headerizer->new;
-
-main();
-
-=head1 FUNCTIONS
-
-=head2 extract_function_declaration_and_update_source( $cfile_name )
-
-Extract all the function declarations from the C file specified by
-I<$cfile_name>, and update the comment blocks within.
-
-=cut
-
-sub extract_function_declarations_and_update_source {
- my $cfile_name = shift;
-
- open( my $fhin, '<', $cfile_name ) or die "Can't open $cfile_name: $!";
- my $text = join( '', <$fhin> );
- close $fhin;
-
- my @func_declarations = $headerizer->extract_function_declarations( $text );
- for my $decl ( @func_declarations ) {
- my $specs = $headerizer->function_components_from_declaration( $cfile_name, $decl );
- my $name = $specs->{name};
-
- my $heading = $headerizer->generate_documentation_signature($decl);
-
- $text =~ s/=item C<[^>]*\b$name\b[^>]*>\n+/$heading\n\n/sm or do {
- warn "$cfile_name: $name has no POD\n" unless $name =~ /^yy/; # lexer funcs don't have to have POD
- }
- }
- open( my $fhout, '>', $cfile_name ) or die "Can't create $cfile_name: $!";
- print {$fhout} $text;
- close $fhout;
-
- return @func_declarations;
-}
-
-
-sub attrs_from_args {
- my $func = shift;
- my @args = @_;
-
- my @attrs = ();
- my @mods = ();
-
- my $name = $func->{name};
- my $file = $func->{file};
- my $n = 0;
- for my $arg (@args) {
- ++$n;
- if ( $arg =~ m{ARG(?:MOD|OUT)(?:_NULLOK)?\((.+?)\)} ) {
- my $modified = $1;
- if ( $modified =~ s/.*\*/*/ ) {
- # We're OK
- }
- else {
- $modified =~ s/.* (\w+)$/$1/ or die qq{Unable to figure out the modified parm out of "$modified"};
- }
- push( @mods, "FUNC_MODIFIES($modified)" );
- }
- if ( $arg =~ m{(ARGIN|ARGOUT|ARGMOD|ARGFREE_NOTNULL|NOTNULL)\(} || $arg eq 'PARROT_INTERP' ) {
- push( @attrs, "__attribute__nonnull__($n)" );
- }
- if ( ( $arg =~ m{\*} ) && ( $arg !~ /\b(SHIM|((ARGIN|ARGOUT|ARGMOD)(_NULLOK)?)|ARGFREE(_NOTNULL)?)\b/ ) ) {
- if ( $name !~ /^yy/ ) { # Don't complain about the lexer auto-generated funcs
- $headerizer->squawk( $file, $name, qq{"$arg" isn't protected with an ARGIN, ARGOUT or ARGMOD (or a _NULLOK variant), or ARGFREE} );
- }
- }
- if ( ($arg =~ /\bconst\b/) && ($arg =~ /\*/) && ($arg !~ /\*\*/) && ($arg =~ /\b(ARG(MOD|OUT))\b/) ) {
- $headerizer->squawk( $file, $name, qq{"$arg" is const, but that $1 conflicts with const} );
- }
- }
-
- return (@attrs, at mods);
-}
-
-sub asserts_from_args {
- my @args = @_;
- my @asserts;
-
- for my $arg (@args) {
- if ( $arg =~ m{(ARGIN|ARGOUT|ARGMOD|ARGFREE_NOTNULL|NOTNULL)\((.+)\)} ) {
- my $var = $2;
- if($var =~ /\(*\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*\)\s*\(/) {
- # argument is a function pointer
- $var = $1;
- }
- else {
- # try to isolate the variable's name;
- # strip off everything before the final space or asterisk.
- $var =~ s{.+[* ]([^* ]+)$}{$1};
- # strip off a trailing "[]", if any.
- $var =~ s{\[\]$}{};
- }
- push( @asserts, "PARROT_ASSERT_ARG($var)" );
- }
- if( $arg eq 'PARROT_INTERP' ) {
- push( @asserts, "PARROT_ASSERT_ARG(interp)" );
- }
- }
-
- return (@asserts);
-}
-
-sub make_function_decls {
- my @funcs = @_;
-
- my @decls;
- foreach my $func (@funcs) {
- my $multiline = 0;
-
- my $return = $func->{return_type};
- my $alt_void = ' ';
-
- # Splint can't handle /*@alt void@*/ on pointers, although this page
- # http://www.mail-archive.com/lclint-interest@virginia.edu/msg00139.html
- # seems to say that we can.
- if ( $func->{is_ignorable} && ($return !~ /\*/) ) {
- $alt_void = " /*\@alt void@*/\n";
- }
-
- my $decl = sprintf( "%s%s%s(", $return, $alt_void, $func->{name} );
- $decl = "static $decl" if $func->{is_static};
-
- my @args = @{ $func->{args} };
- my @attrs = attrs_from_args( $func, @args );
-
- for my $arg (@args) {
- if ( $arg =~ m{SHIM\((.+)\)} ) {
- $arg = $1;
- if ( $func->{is_static} || ( $arg =~ /\*/ ) ) {
- $arg = "SHIM($arg)";
- }
- else {
- $arg = "NULLOK($arg)";
- }
- }
- }
-
- my $argline = join( ", ", @args );
- if ( length( $decl . $argline ) <= 75 ) {
- $decl = "$decl$argline)";
- }
- else {
- if ( $args[0] =~ /^((SHIM|PARROT)_INTERP|Interp)\b/ ) {
- $decl .= ( shift @args );
- $decl .= "," if @args;
- }
- $argline = join( ",", map { "\n\t$_" } @args );
- $decl = "$decl$argline)";
- $multiline = 1;
- }
-
- my $attrs = join( "", map { "\n\t\t$_" } @attrs );
- if ($attrs) {
- $decl .= $attrs;
- $multiline = 1;
- }
- my @macros = @{ $func->{macros} };
- $multiline = 1 if @macros;
-
- $decl .= $multiline ? ";\n" : ";";
- $decl = join( "\n", @macros, $decl );
- $decl =~ s/\t/ /g;
- push( @decls, $decl );
- }
-
- foreach my $func (@funcs) {
- my @args = @{ $func->{args} };
- my @asserts = asserts_from_args( @args );
-
- my $assert = "#define ASSERT_ARGS_" . $func->{name};
- if(length($func->{name}) > 29) {
- $assert .= " \\\n ";
- }
- $assert .= " __attribute__unused__ int _ASSERT_ARGS_CHECK = (";
- if(@asserts) {
- $assert .= "\\\n ";
- $assert .= join(" \\\n , ", @asserts);
- }
- else {
- $assert .= "0";
- }
- $assert .= ")";
- push(@decls, $assert);
- }
-
- return @decls;
-}
-
-sub read_file {
- my $filename = shift;
-
- open my $fh, '<', $filename or die "couldn't read '$filename': $!";
- my $text = do { local $/ = undef; <$fh> };
- close $fh;
-
- return $text;
-}
-
-sub write_file {
- my $filename = shift;
- my $text = shift;
-
- open my $fh, '>', $filename or die "couldn't write '$filename': $!";
- print {$fh} $text;
- close $fh;
-}
-
-sub replace_headerized_declarations {
- my $source_code = shift;
- my $sourcefile = shift;
- my $hfile = shift;
- my @funcs = @_;
-
- # Allow a way to not headerize statics
- if ( $source_code =~ m{/\*\s*HEADERIZER NONE:\s*$sourcefile\s*\*/} ) {
- return $source_code;
- }
-
- @funcs = sort api_first_then_alpha @funcs;
-
- my @function_decls = make_function_decls(@funcs);
-
- my $function_decls = join( "\n", @function_decls );
- my $STARTMARKER = qr{/\* HEADERIZER BEGIN: $sourcefile \*/\n};
- my $ENDMARKER = qr{/\* HEADERIZER END: $sourcefile \*/\n?};
- my $DO_NOT_TOUCH = q{/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */};
-
- $source_code =~
- s{($STARTMARKER)(?:.*?)($ENDMARKER)}
- {$1$DO_NOT_TOUCH\n\n$function_decls\n$DO_NOT_TOUCH\n$2}s
- or die "Need begin/end HEADERIZER markers for $sourcefile in $hfile\n";
-
- return $source_code;
-}
-
-sub api_first_then_alpha {
- return ( ( $b->{is_api} || 0 ) <=> ( $a->{is_api} || 0 ) )
- || ( lc $a->{name} cmp lc $b->{name} );
-}
-
-sub main {
- my $macro_match;
- GetOptions(
- 'macro=s' => \$macro_match,
- ) or exit(1);
-
- die 'No files specified.' unless @ARGV;
- my %ofiles;
- ++$ofiles{$_} for @ARGV;
- my @ofiles = sort keys %ofiles;
- for (@ofiles) {
- print "$_ is specified more than once.\n" if $ofiles{$_} > 1;
- }
- my %sourcefiles;
- my %sourcefiles_with_statics;
- my %api;
-
- # Walk the object files and find corresponding source (either .c or .pmc)
- for my $ofile (@ofiles) {
- next if $ofile =~ m/^\Qsrc$PConfig{slash}ops\E/;
-
- $ofile =~ s/\\/\//g;
-
- my $is_yacc = ($ofile =~ /\.y$/);
- if ( !$is_yacc ) {
- my $sfile = $ofile;
- $sfile =~ s/\Q$PConfig{o}\E$/.s/;
- next if -f $sfile;
- }
-
- my $cfile = $ofile;
- $cfile =~ s/\Q$PConfig{o}\E$/.c/ or $is_yacc
- or die "$cfile doesn't look like an object file";
-
- my $pmcfile = $ofile;
- $pmcfile =~ s/\Q$PConfig{o}\E$/.pmc/;
-
- my $from_pmc = -f $pmcfile && !$is_yacc;
-
- my $sourcefile = $from_pmc ? $pmcfile : $cfile;
-
- my $source_code = read_file( $sourcefile );
- die qq{can't find HEADERIZER HFILE directive in "$sourcefile"}
- unless $source_code =~
- m{ /\* \s+ HEADERIZER\ HFILE: \s+ ([^*]+?) \s+ \*/ }sx;
-
- my $hfile = $1;
- if ( ( $hfile ne 'none' ) && ( not -f $hfile ) ) {
- die qq{"$hfile" not found (referenced from "$sourcefile")};
- }
-
- my @decls;
- if ( $macro_match ) {
- @decls = $headerizer->extract_function_declarations( $source_code );
- }
- else {
- @decls = extract_function_declarations_and_update_source( $sourcefile );
- }
-
- for my $decl (@decls) {
- my $components = $headerizer->function_components_from_declaration( $sourcefile, $decl );
- push( @{ $sourcefiles{$hfile}->{$sourcefile} }, $components ) unless $hfile eq 'none';
- push( @{ $sourcefiles_with_statics{$sourcefile} }, $components ) if $components->{is_static};
- if ( $macro_match ) {
- if ( grep { $_ eq $macro_match } @{$components->{macros}} ) {
- push( @{ $api{$sourcefile} }, $components );
- }
- }
- }
- } # for @cfiles
-
- if ( $macro_match ) {
- my $nfuncs = 0;
- for my $cfile ( sort keys %api ) {
- my @funcs = sort { $a->{name} cmp $b->{name} } @{$api{$cfile}};
- print "$cfile\n";
- for my $func ( @funcs ) {
- print " $func->{name}\n";
- ++$nfuncs;
- }
- }
- my $s = $nfuncs == 1 ? '' : 's';
- print "$nfuncs $macro_match function$s\n";
- }
- else { # Normal headerization and updating
- # Update all the .h files
- for my $hfile ( sort keys %sourcefiles ) {
- my $sourcefiles = $sourcefiles{$hfile};
-
- my $header = read_file($hfile);
-
- for my $cfile ( sort keys %{$sourcefiles} ) {
- my @funcs = @{ $sourcefiles->{$cfile} };
- @funcs = grep { not $_->{is_static} } @funcs; # skip statics
-
- $header = replace_headerized_declarations( $header, $cfile, $hfile, @funcs );
- }
-
- write_file( $hfile, $header );
- }
-
- # Update all the .c files in place
- for my $cfile ( sort keys %sourcefiles_with_statics ) {
- my @funcs = @{ $sourcefiles_with_statics{$cfile} };
- @funcs = grep { $_->{is_static} } @funcs;
-
- my $source = read_file($cfile);
- $source = replace_headerized_declarations( $source, 'static', $cfile, @funcs );
-
- write_file( $cfile, $source );
- }
- print "Headerization complete.\n";
- }
-
- my %warnings = %{$headerizer->{warnings}};
- if ( keys %warnings ) {
- my $nwarnings = 0;
- my $nwarningfuncs = 0;
- my $nwarningfiles = 0;
- for my $file ( sort keys %warnings ) {
- ++$nwarningfiles;
- print "$file\n";
- my $funcs = $warnings{$file};
- for my $func ( sort keys %{$funcs} ) {
- ++$nwarningfuncs;
- for my $error ( @{ $funcs->{$func} } ) {
- print " $func: $error\n";
- ++$nwarnings;
- }
- }
- }
-
- print "$nwarnings warnings in $nwarningfuncs funcs in $nwarningfiles C files\n";
- }
-
- return;
-}
-
-# From earlier documentation:
-# * Generate docs from funcs
-# * Somehow handle static functions in the source file
-# * the .c files MUST have a /* HEADERIZER HFILE: foo/bar.h */ directive in them
-# * Support for multiple .c files pointing at the same .h file
-# * Does NOT remove all blocks in the .h file, so if a .c file
-# disappears, its block is "orphaned" and will remain there.
-
-# Local Variables:
-# mode: cperl
-# cperl-indent-level: 4
-# fill-column: 100
-# End:
-# vim: expandtab shiftwidth=4:
Copied: branches/tt677_toolsdirs/tools/dev/addopstags.pl (from r48639, branches/tt677_toolsdirs/tools/build/addopstags.pl)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/tt677_toolsdirs/tools/dev/addopstags.pl Tue Aug 24 22:52:21 2010 (r48642, copy of r48639, branches/tt677_toolsdirs/tools/build/addopstags.pl)
@@ -0,0 +1,54 @@
+#!perl
+
+# Copyright (C) 2004-2006, Parrot Foundation.
+# $Id$
+
+use strict;
+use warnings;
+
+=head1 NAME
+
+tools/build/addopstags.pl - add src/ops/*.ops to tags
+
+=head1 SYNOPSIS
+
+ perl tools/build/addopstags.pl src/ops/*.ops
+
+=head1 DESCRIPTION
+
+Add src/ops/*.ops to tags file.
+
+=cut
+
+my %seen;
+my @tags;
+
+# Pull ops tags
+while (<>) {
+ if (/\bop \s+ (\w+) \s* \(/x) {
+ next if $seen{$1}++;
+
+ # tag file excmd xflags
+ push @tags, join( "\t", $1, $ARGV, qq{$.;"}, "f" ) . "\n";
+ }
+}
+continue {
+ close ARGV if eof; # reset $.
+}
+
+# Pull existing tags
+open my $T, '<', 'tags';
+push @tags, <$T>;
+close $T;
+
+# Spit 'em out sorted
+open $T, '>', 'tags';
+print $T sort @tags;
+close $T;
+
+# Local Variables:
+# mode: cperl
+# cperl-indent-level: 4
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:
Copied: branches/tt677_toolsdirs/tools/dev/headerizer.pl (from r48639, branches/tt677_toolsdirs/tools/build/headerizer.pl)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/tt677_toolsdirs/tools/dev/headerizer.pl Tue Aug 24 22:52:21 2010 (r48642, copy of r48639, branches/tt677_toolsdirs/tools/build/headerizer.pl)
@@ -0,0 +1,464 @@
+#! perl
+# Copyright (C) 2001-2010, Parrot Foundation.
+# $Id$
+
+=head1 NAME
+
+tools/build/headerizer.pl - Generates the function header parts of .h
+files from .c files
+
+=head1 SYNOPSIS
+
+ $ perl tools/build/headerizer.pl [object files]
+
+Generates C function declarations based on the function definitions in
+the C source code.
+
+=head1 DESCRIPTION
+
+The headerizer works off of directives in the source and header files.
+
+One source file's public declarations can only go into one header file.
+However, one header file can have declarations from multiple source files.
+In other words, headers-to-source is one-to-many.
+
+=over 4
+
+=item C<HEADERIZER BEGIN:> F<source-filename> / C<HEADERIZER END:> F<source-filename>
+
+Marks the beginning and end of a block of declarations in a header file.
+
+ # In file foo.h
+ /* HEADERIZER BEGIN: src/foo.c */
+ /* HEADERIZER END: src/foo.c */
+
+ /* HEADERIZER BEGIN: src/bar.c */
+ /* HEADERIZER END: src/bar.c */
+
+=item C<HEADERIZER HFILE:> F<header-filename>
+
+Tells the headerizer where the declarations for the functions should go
+
+ # In file foo.c
+ /* HEADERIZER HFILE: foo.h */
+
+ # In file bar.c
+ /* HEADERIZER HFILE: foo.h */
+
+=back
+
+=head1 COMMAND-LINE OPTIONS
+
+=over 4
+
+=item C<--macro=X>
+
+Print a list of all functions that have macro X. For example, --macro=PARROT_EXPORT.
+
+=back
+
+=cut
+
+use strict;
+use warnings;
+
+use Getopt::Long;
+use lib qw( lib );
+use Parrot::Config;
+use Parrot::Headerizer;
+
+my $headerizer = Parrot::Headerizer->new;
+
+main();
+
+=head1 FUNCTIONS
+
+=head2 extract_function_declaration_and_update_source( $cfile_name )
+
+Extract all the function declarations from the C file specified by
+I<$cfile_name>, and update the comment blocks within.
+
+=cut
+
+sub extract_function_declarations_and_update_source {
+ my $cfile_name = shift;
+
+ open( my $fhin, '<', $cfile_name ) or die "Can't open $cfile_name: $!";
+ my $text = join( '', <$fhin> );
+ close $fhin;
+
+ my @func_declarations = $headerizer->extract_function_declarations( $text );
+ for my $decl ( @func_declarations ) {
+ my $specs = $headerizer->function_components_from_declaration( $cfile_name, $decl );
+ my $name = $specs->{name};
+
+ my $heading = $headerizer->generate_documentation_signature($decl);
+
+ $text =~ s/=item C<[^>]*\b$name\b[^>]*>\n+/$heading\n\n/sm or do {
+ warn "$cfile_name: $name has no POD\n" unless $name =~ /^yy/; # lexer funcs don't have to have POD
+ }
+ }
+ open( my $fhout, '>', $cfile_name ) or die "Can't create $cfile_name: $!";
+ print {$fhout} $text;
+ close $fhout;
+
+ return @func_declarations;
+}
+
+
+sub attrs_from_args {
+ my $func = shift;
+ my @args = @_;
+
+ my @attrs = ();
+ my @mods = ();
+
+ my $name = $func->{name};
+ my $file = $func->{file};
+ my $n = 0;
+ for my $arg (@args) {
+ ++$n;
+ if ( $arg =~ m{ARG(?:MOD|OUT)(?:_NULLOK)?\((.+?)\)} ) {
+ my $modified = $1;
+ if ( $modified =~ s/.*\*/*/ ) {
+ # We're OK
+ }
+ else {
+ $modified =~ s/.* (\w+)$/$1/ or die qq{Unable to figure out the modified parm out of "$modified"};
+ }
+ push( @mods, "FUNC_MODIFIES($modified)" );
+ }
+ if ( $arg =~ m{(ARGIN|ARGOUT|ARGMOD|ARGFREE_NOTNULL|NOTNULL)\(} || $arg eq 'PARROT_INTERP' ) {
+ push( @attrs, "__attribute__nonnull__($n)" );
+ }
+ if ( ( $arg =~ m{\*} ) && ( $arg !~ /\b(SHIM|((ARGIN|ARGOUT|ARGMOD)(_NULLOK)?)|ARGFREE(_NOTNULL)?)\b/ ) ) {
+ if ( $name !~ /^yy/ ) { # Don't complain about the lexer auto-generated funcs
+ $headerizer->squawk( $file, $name, qq{"$arg" isn't protected with an ARGIN, ARGOUT or ARGMOD (or a _NULLOK variant), or ARGFREE} );
+ }
+ }
+ if ( ($arg =~ /\bconst\b/) && ($arg =~ /\*/) && ($arg !~ /\*\*/) && ($arg =~ /\b(ARG(MOD|OUT))\b/) ) {
+ $headerizer->squawk( $file, $name, qq{"$arg" is const, but that $1 conflicts with const} );
+ }
+ }
+
+ return (@attrs, at mods);
+}
+
+sub asserts_from_args {
+ my @args = @_;
+ my @asserts;
+
+ for my $arg (@args) {
+ if ( $arg =~ m{(ARGIN|ARGOUT|ARGMOD|ARGFREE_NOTNULL|NOTNULL)\((.+)\)} ) {
+ my $var = $2;
+ if($var =~ /\(*\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*\)\s*\(/) {
+ # argument is a function pointer
+ $var = $1;
+ }
+ else {
+ # try to isolate the variable's name;
+ # strip off everything before the final space or asterisk.
+ $var =~ s{.+[* ]([^* ]+)$}{$1};
+ # strip off a trailing "[]", if any.
+ $var =~ s{\[\]$}{};
+ }
+ push( @asserts, "PARROT_ASSERT_ARG($var)" );
+ }
+ if( $arg eq 'PARROT_INTERP' ) {
+ push( @asserts, "PARROT_ASSERT_ARG(interp)" );
+ }
+ }
+
+ return (@asserts);
+}
+
+sub make_function_decls {
+ my @funcs = @_;
+
+ my @decls;
+ foreach my $func (@funcs) {
+ my $multiline = 0;
+
+ my $return = $func->{return_type};
+ my $alt_void = ' ';
+
+ # Splint can't handle /*@alt void@*/ on pointers, although this page
+ # http://www.mail-archive.com/lclint-interest@virginia.edu/msg00139.html
+ # seems to say that we can.
+ if ( $func->{is_ignorable} && ($return !~ /\*/) ) {
+ $alt_void = " /*\@alt void@*/\n";
+ }
+
+ my $decl = sprintf( "%s%s%s(", $return, $alt_void, $func->{name} );
+ $decl = "static $decl" if $func->{is_static};
+
+ my @args = @{ $func->{args} };
+ my @attrs = attrs_from_args( $func, @args );
+
+ for my $arg (@args) {
+ if ( $arg =~ m{SHIM\((.+)\)} ) {
+ $arg = $1;
+ if ( $func->{is_static} || ( $arg =~ /\*/ ) ) {
+ $arg = "SHIM($arg)";
+ }
+ else {
+ $arg = "NULLOK($arg)";
+ }
+ }
+ }
+
+ my $argline = join( ", ", @args );
+ if ( length( $decl . $argline ) <= 75 ) {
+ $decl = "$decl$argline)";
+ }
+ else {
+ if ( $args[0] =~ /^((SHIM|PARROT)_INTERP|Interp)\b/ ) {
+ $decl .= ( shift @args );
+ $decl .= "," if @args;
+ }
+ $argline = join( ",", map { "\n\t$_" } @args );
+ $decl = "$decl$argline)";
+ $multiline = 1;
+ }
+
+ my $attrs = join( "", map { "\n\t\t$_" } @attrs );
+ if ($attrs) {
+ $decl .= $attrs;
+ $multiline = 1;
+ }
+ my @macros = @{ $func->{macros} };
+ $multiline = 1 if @macros;
+
+ $decl .= $multiline ? ";\n" : ";";
+ $decl = join( "\n", @macros, $decl );
+ $decl =~ s/\t/ /g;
+ push( @decls, $decl );
+ }
+
+ foreach my $func (@funcs) {
+ my @args = @{ $func->{args} };
+ my @asserts = asserts_from_args( @args );
+
+ my $assert = "#define ASSERT_ARGS_" . $func->{name};
+ if(length($func->{name}) > 29) {
+ $assert .= " \\\n ";
+ }
+ $assert .= " __attribute__unused__ int _ASSERT_ARGS_CHECK = (";
+ if(@asserts) {
+ $assert .= "\\\n ";
+ $assert .= join(" \\\n , ", @asserts);
+ }
+ else {
+ $assert .= "0";
+ }
+ $assert .= ")";
+ push(@decls, $assert);
+ }
+
+ return @decls;
+}
+
+sub read_file {
+ my $filename = shift;
+
+ open my $fh, '<', $filename or die "couldn't read '$filename': $!";
+ my $text = do { local $/ = undef; <$fh> };
+ close $fh;
+
+ return $text;
+}
+
+sub write_file {
+ my $filename = shift;
+ my $text = shift;
+
+ open my $fh, '>', $filename or die "couldn't write '$filename': $!";
+ print {$fh} $text;
+ close $fh;
+}
+
+sub replace_headerized_declarations {
+ my $source_code = shift;
+ my $sourcefile = shift;
+ my $hfile = shift;
+ my @funcs = @_;
+
+ # Allow a way to not headerize statics
+ if ( $source_code =~ m{/\*\s*HEADERIZER NONE:\s*$sourcefile\s*\*/} ) {
+ return $source_code;
+ }
+
+ @funcs = sort api_first_then_alpha @funcs;
+
+ my @function_decls = make_function_decls(@funcs);
+
+ my $function_decls = join( "\n", @function_decls );
+ my $STARTMARKER = qr{/\* HEADERIZER BEGIN: $sourcefile \*/\n};
+ my $ENDMARKER = qr{/\* HEADERIZER END: $sourcefile \*/\n?};
+ my $DO_NOT_TOUCH = q{/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */};
+
+ $source_code =~
+ s{($STARTMARKER)(?:.*?)($ENDMARKER)}
+ {$1$DO_NOT_TOUCH\n\n$function_decls\n$DO_NOT_TOUCH\n$2}s
+ or die "Need begin/end HEADERIZER markers for $sourcefile in $hfile\n";
+
+ return $source_code;
+}
+
+sub api_first_then_alpha {
+ return ( ( $b->{is_api} || 0 ) <=> ( $a->{is_api} || 0 ) )
+ || ( lc $a->{name} cmp lc $b->{name} );
+}
+
+sub main {
+ my $macro_match;
+ GetOptions(
+ 'macro=s' => \$macro_match,
+ ) or exit(1);
+
+ die 'No files specified.' unless @ARGV;
+ my %ofiles;
+ ++$ofiles{$_} for @ARGV;
+ my @ofiles = sort keys %ofiles;
+ for (@ofiles) {
+ print "$_ is specified more than once.\n" if $ofiles{$_} > 1;
+ }
+ my %sourcefiles;
+ my %sourcefiles_with_statics;
+ my %api;
+
+ # Walk the object files and find corresponding source (either .c or .pmc)
+ for my $ofile (@ofiles) {
+ next if $ofile =~ m/^\Qsrc$PConfig{slash}ops\E/;
+
+ $ofile =~ s/\\/\//g;
+
+ my $is_yacc = ($ofile =~ /\.y$/);
+ if ( !$is_yacc ) {
+ my $sfile = $ofile;
+ $sfile =~ s/\Q$PConfig{o}\E$/.s/;
+ next if -f $sfile;
+ }
+
+ my $cfile = $ofile;
+ $cfile =~ s/\Q$PConfig{o}\E$/.c/ or $is_yacc
+ or die "$cfile doesn't look like an object file";
+
+ my $pmcfile = $ofile;
+ $pmcfile =~ s/\Q$PConfig{o}\E$/.pmc/;
+
+ my $from_pmc = -f $pmcfile && !$is_yacc;
+
+ my $sourcefile = $from_pmc ? $pmcfile : $cfile;
+
+ my $source_code = read_file( $sourcefile );
+ die qq{can't find HEADERIZER HFILE directive in "$sourcefile"}
+ unless $source_code =~
+ m{ /\* \s+ HEADERIZER\ HFILE: \s+ ([^*]+?) \s+ \*/ }sx;
+
+ my $hfile = $1;
+ if ( ( $hfile ne 'none' ) && ( not -f $hfile ) ) {
+ die qq{"$hfile" not found (referenced from "$sourcefile")};
+ }
+
+ my @decls;
+ if ( $macro_match ) {
+ @decls = $headerizer->extract_function_declarations( $source_code );
+ }
+ else {
+ @decls = extract_function_declarations_and_update_source( $sourcefile );
+ }
+
+ for my $decl (@decls) {
+ my $components = $headerizer->function_components_from_declaration( $sourcefile, $decl );
+ push( @{ $sourcefiles{$hfile}->{$sourcefile} }, $components ) unless $hfile eq 'none';
+ push( @{ $sourcefiles_with_statics{$sourcefile} }, $components ) if $components->{is_static};
+ if ( $macro_match ) {
+ if ( grep { $_ eq $macro_match } @{$components->{macros}} ) {
+ push( @{ $api{$sourcefile} }, $components );
+ }
+ }
+ }
+ } # for @cfiles
+
+ if ( $macro_match ) {
+ my $nfuncs = 0;
+ for my $cfile ( sort keys %api ) {
+ my @funcs = sort { $a->{name} cmp $b->{name} } @{$api{$cfile}};
+ print "$cfile\n";
+ for my $func ( @funcs ) {
+ print " $func->{name}\n";
+ ++$nfuncs;
+ }
+ }
+ my $s = $nfuncs == 1 ? '' : 's';
+ print "$nfuncs $macro_match function$s\n";
+ }
+ else { # Normal headerization and updating
+ # Update all the .h files
+ for my $hfile ( sort keys %sourcefiles ) {
+ my $sourcefiles = $sourcefiles{$hfile};
+
+ my $header = read_file($hfile);
+
+ for my $cfile ( sort keys %{$sourcefiles} ) {
+ my @funcs = @{ $sourcefiles->{$cfile} };
+ @funcs = grep { not $_->{is_static} } @funcs; # skip statics
+
+ $header = replace_headerized_declarations( $header, $cfile, $hfile, @funcs );
+ }
+
+ write_file( $hfile, $header );
+ }
+
+ # Update all the .c files in place
+ for my $cfile ( sort keys %sourcefiles_with_statics ) {
+ my @funcs = @{ $sourcefiles_with_statics{$cfile} };
+ @funcs = grep { $_->{is_static} } @funcs;
+
+ my $source = read_file($cfile);
+ $source = replace_headerized_declarations( $source, 'static', $cfile, @funcs );
+
+ write_file( $cfile, $source );
+ }
+ print "Headerization complete.\n";
+ }
+
+ my %warnings = %{$headerizer->{warnings}};
+ if ( keys %warnings ) {
+ my $nwarnings = 0;
+ my $nwarningfuncs = 0;
+ my $nwarningfiles = 0;
+ for my $file ( sort keys %warnings ) {
+ ++$nwarningfiles;
+ print "$file\n";
+ my $funcs = $warnings{$file};
+ for my $func ( sort keys %{$funcs} ) {
+ ++$nwarningfuncs;
+ for my $error ( @{ $funcs->{$func} } ) {
+ print " $func: $error\n";
+ ++$nwarnings;
+ }
+ }
+ }
+
+ print "$nwarnings warnings in $nwarningfuncs funcs in $nwarningfiles C files\n";
+ }
+
+ return;
+}
+
+# From earlier documentation:
+# * Generate docs from funcs
+# * Somehow handle static functions in the source file
+# * the .c files MUST have a /* HEADERIZER HFILE: foo/bar.h */ directive in them
+# * Support for multiple .c files pointing at the same .h file
+# * Does NOT remove all blocks in the .h file, so if a .c file
+# disappears, its block is "orphaned" and will remain there.
+
+# Local Variables:
+# mode: cperl
+# cperl-indent-level: 4
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:
Copied: branches/tt677_toolsdirs/tools/dev/ncidef2pasm.pl (from r48639, branches/tt677_toolsdirs/tools/util/ncidef2pasm.pl)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/tt677_toolsdirs/tools/dev/ncidef2pasm.pl Tue Aug 24 22:52:21 2010 (r48642, copy of r48639, branches/tt677_toolsdirs/tools/util/ncidef2pasm.pl)
@@ -0,0 +1,237 @@
+#! perl
+
+# Copyright (C) 2003-2007, Parrot Foundation.
+# $Id$
+
+=head1 NAME
+
+tools/util/ncidef2asm.pl - Turn an NCI library definition file into PASM
+
+=head1 SYNOPSIS
+
+ perl tools/util/ncidef2asm.pl path/to/from_file [ path/to/to_file ]
+
+=head1 DESCRIPTION
+
+This program takes an NCI library definition file and turns it into PASM.
+
+An NCI library definition file provides the information needed to
+generate a parrot wrapper for the named library (or libraries). Its
+format is simple, and looks like:
+
+ [package]
+ ncurses
+
+ [lib]
+ libform.so
+
+ [defs]
+ p new_field i i i i i i
+
+ [lib]
+ libncurses.so
+
+ [defs]
+ i is_term_resized i i
+
+Note that the assembly file is generated in the order you specify, so
+if there are library dependencies, make sure you have them in the
+correct order.
+
+=head2 package
+
+Declares the package that all subsequent sub PMCs will be put
+into. The name is a simple concatenation of the package name, double
+colon, and the routine name, with no preceding punctuation.
+
+=head2 lib
+
+The name of the library to be loaded. Should be as qualified as
+necessary for your platform--generally the full filename is required,
+though the directory generally isn't.
+
+You may load multiple libraries here, but only the last one loaded
+will be exposed to subsequent defs.
+
+=head2 defs
+
+This section holds the definitions of functions. Each function is
+assumed to be in the immediate preceding library. The definition of
+the function is:
+
+ return_type name [param [param [param ...]]]
+
+The param and return_type parameters use the NCI standard, which for
+reference is:
+
+=over 4
+
+=item p
+
+Parameter is a void pointer, taken from the PMC's data pointer. PMC is
+assumed to be an unmanagedstruct or child class.
+
+Taken from a P register
+
+=item c
+
+Parameter is a character.
+
+Taken from an I register
+
+=item s
+
+Parameter is a short
+
+Taken from an I register
+
+=item i
+
+Parameter is an int
+
+Taken from an I register
+
+=item l
+
+Parameter is a long
+
+Taken from an I register
+
+=item f
+
+Paramter is a float
+
+Taken from an N register.
+
+=item d
+
+Parameter is a double.
+
+Taken from an N register.
+
+=item t
+
+Paramter is a char *, presumably a C string
+
+Taken from an S register
+
+=item v
+
+Void. Only valid as a return type, noting that the function returns no data.
+
+=item I
+
+Interpreter pointer. The current interpreter pointer is passed in
+
+=item P
+
+PMC.
+
+=item 2
+
+Pointer to short.
+
+Taken from an I register.
+
+=item 3
+
+Pointer to int.
+
+Taken from an I register
+
+=item 4
+
+Pointer to long
+
+Taken from an I register
+
+=back
+
+=cut
+
+use strict;
+use warnings;
+
+my ( $from_file, $to_file ) = @ARGV;
+
+# If there is no destination file, strip off the extension of the
+# source file and add a .pasm to it
+if ( !defined $to_file ) {
+ $to_file = $from_file;
+ $to_file =~ s/\..*$//;
+ $to_file .= ".pasm";
+}
+
+open my $INPUT, '<', "$from_file" or die "Can't open up $from_file, error $!";
+open my $OUTPUT, '>', "$to_file" or die "Can't open up $to_file, error $!";
+
+# To start, save all the registers, just in case
+print $OUTPUT "saveall\n";
+
+my @libs;
+my ( $cur_package, $line, $cur_section );
+
+# Our dispatch table
+my (%dispatch) = (
+ package => \&package_line,
+ lib => \&lib_line,
+ defs => \&def_line,
+);
+
+while ( $line = <$INPUT> ) {
+
+ # Throw away trailing newlines, comments, and whitespace. If the
+ # line's empty, then off to the next line
+ chomp $line;
+ $line =~ s/#.*//;
+ $line =~ s/\s*$//;
+ next unless $line;
+
+ # Is it a section line? If so, extract the section and set it.
+ if ( $line =~ /\[(\w+)\]/ ) {
+ $cur_section = $1;
+ next;
+ }
+
+ # Everything else goes to the handler
+ $dispatch{$cur_section}->($line);
+
+}
+
+# Put the registers back and end
+print $OUTPUT "restoreall\n";
+print $OUTPUT "end\n";
+close $OUTPUT;
+
+sub package_line {
+ my $line = shift;
+
+ # Trim leading and trailing spaces
+ $line =~ s/^\s*//;
+ $line =~ s/\s*$//;
+
+ # Set the global current package
+ $cur_package = $line;
+
+}
+
+sub lib_line {
+ my $line = shift;
+ print $OUTPUT "loadlib P1, '$line'\n";
+}
+
+sub def_line {
+ my $line = shift;
+ my ( $return_type, $name, @params ) = split ' ', $line;
+ unshift @params, $return_type;
+ my $signature = join( "", @params );
+ print $OUTPUT "dlfunc P2, P1, '$name', '$signature'\n";
+ print $OUTPUT "store_global '${cur_package}::${name}', P2\n";
+}
+
+# Local Variables:
+# mode: cperl
+# cperl-indent-level: 4
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:
Copied: branches/tt677_toolsdirs/tools/dev/parrot-config.pir (from r48639, branches/tt677_toolsdirs/tools/util/parrot-config.pir)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/tt677_toolsdirs/tools/dev/parrot-config.pir Tue Aug 24 22:52:21 2010 (r48642, copy of r48639, branches/tt677_toolsdirs/tools/util/parrot-config.pir)
@@ -0,0 +1,103 @@
+#!/usr/bin/env parrot
+# $Id$
+
+=head1 NAME
+
+config.pir - Print a Parrot configuration item
+
+=head1 VERSION
+
+version 0.01
+
+=head1 SYNOPSIS
+
+ ./parrot parrot-config.pir VERSION
+ ./parrot parrot-config.pir ccflags
+ ./parrot parrot-config.pir --dump
+
+=head1 DESCRIPTION
+
+Print out configuration items.
+
+=head1 AUTHOR
+
+Leopold Toetsch E<lt>lt at toetsch.atE<gt>.
+
+=head1 COPYRIGHT
+
+Copyright (C) 2004-2009, Parrot Foundation.
+
+=cut
+
+.sub _main :main
+ .param pmc argv
+ .local int argc
+ argc = argv
+ if argc < 2 goto usage
+ .local pmc interp, conf_hash
+ .local string key
+ .include "iglobals.pasm"
+ interp = getinterp
+ conf_hash = interp[.IGLOBALS_CONFIG_HASH]
+ .local int i
+ i = 1
+loop:
+ key = argv[i]
+ if key == '--help' goto usage
+ if key == '--dump' goto dump
+ $I0 = defined conf_hash[key]
+ unless $I0 goto failkey
+ dec argc
+ if i < argc goto dumpsome
+ $S0 = conf_hash[key]
+ print $S0
+ inc i
+ if i < argc goto loop
+ print "\n"
+ end
+dumpsome:
+ key = argv[i]
+ $I0 = defined conf_hash[key]
+ unless $I0 goto failkey
+ print key
+ print " => '"
+ $S1 = conf_hash[key]
+ print $S1
+ say "'"
+ inc i
+ if i <= argc goto dumpsome
+ end
+failkey:
+ print " no such key: '"
+ print key
+ print "'\n"
+ end
+dump:
+ .local pmc iterator
+ iterator = iter conf_hash
+iter_loop:
+ unless iterator goto iter_end
+ shift $S0, iterator
+ print $S0
+ print " => '"
+ $S1 = conf_hash[$S0]
+ print $S1
+ say "'"
+ goto iter_loop
+iter_end:
+ end
+usage:
+ $S0 = argv[0]
+ $P0 = getinterp
+ .include 'stdio.pasm'
+ $P1 = $P0.'stdhandle'(.PIO_STDERR_FILENO)
+ $P1.'print'($S0)
+ $P1.'print'(" [ <config-key> [ <config-key> ... ] | --dump | --help ]\n")
+ exit 1
+.end
+
+# Local Variables:
+# mode: pir
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4 ft=pir:
Copied: branches/tt677_toolsdirs/tools/dev/perlcritic-cage.conf (from r48639, branches/tt677_toolsdirs/tools/util/perlcritic-cage.conf)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/tt677_toolsdirs/tools/dev/perlcritic-cage.conf Tue Aug 24 22:52:21 2010 (r48642, copy of r48639, branches/tt677_toolsdirs/tools/util/perlcritic-cage.conf)
@@ -0,0 +1,37 @@
+# A more stringent set of rules for cage cleaners
+
+[-CodeLayout::ProhibitParensWithBuiltins]
+[CodeLayout::ProhibitHardTabs]
+allow_leading_tabs = 0
+
+[-CodeLayout::RequireTidyCode]
+
+[-ControlStructures::ProhibitPostfixControls]
+[-ControlStructures::ProhibitUnlessBlocks]
+
+[-Documentation::PodSpelling]
+[-Documentation::RequirePodAtEnd]
+[-Documentation::RequirePodSections]
+
+[-ErrorHandling::RequireCarping]
+
+[-InputOutput::ProhibitBacktickOperators]
+[-InputOutput::ProhibitInteractiveTest]
+[-InputOutput::RequireCheckedSyscalls]
+functions = :builtins
+exclude_functions = print
+
+[-Miscellanea::RequireRcsKeywords]
+
+[-Modules::RequireVersionVar]
+
+[-RegularExpressions::ProhibitEscapedMetacharacters]
+[-RegularExpressions::RequireDotMatchAnything]
+[-RegularExpressions::RequireExtendedFormatting]
+[-RegularExpressions::RequireLineBoundaryMatching]
+
+[-ValuesAndExpressions::ProhibitConstantPragma]
+[-ValuesAndExpressions::ProhibitEmptyQuotes]
+[-ValuesAndExpressions::ProhibitMagicNumbers]
+
+[-Variables::ProhibitPunctuationVars]
Copied: branches/tt677_toolsdirs/tools/dev/perlcritic.conf (from r48639, branches/tt677_toolsdirs/tools/util/perlcritic.conf)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/tt677_toolsdirs/tools/dev/perlcritic.conf Tue Aug 24 22:52:21 2010 (r48642, copy of r48639, branches/tt677_toolsdirs/tools/util/perlcritic.conf)
@@ -0,0 +1,75 @@
+verbose = 3
+
+# not all the profiles listed here are installed by default, even if you have
+# Perl::Critic. Shhhh.
+profile-strictness = quiet
+
+[BuiltinFunctions::ProhibitStringySplit]
+add_themes = parrot
+
+[CodeLayout::ProhibitDuplicateCoda]
+add_themes = parrot
+
+[CodeLayout::ProhibitHardTabs]
+allow_leading_tabs = 0
+add_themes = parrot
+
+[CodeLayout::ProhibitTrailingWhitespace]
+add_themes = parrot
+
+[CodeLayout::RequireTidyCode]
+perltidyrc = tools/util/perltidy.conf
+add_themes = extra
+
+[CodeLayout::UseParrotCoda]
+add_themes = parrot
+
+[InputOutput::ProhibitBarewordFileHandles]
+add_themes = parrot
+
+[InputOutput::ProhibitTwoArgOpen]
+add_themes = parrot
+
+[NamingConventions::ProhibitAmbiguousNames]
+# remove abstract from the list of forbidden names
+forbid = bases close contract last left no record right second set
+add_themes = extra
+
+[Subroutines::ProhibitBuiltinHomonyms]
+add_themes = extra
+
+[Subroutines::ProhibitExplicitReturnUndef]
+add_themes = parrot
+
+[Subroutines::ProhibitSubroutinePrototypes]
+add_themes = parrot
+
+[Subroutines::RequireFinalReturn]
+add_themes = extra
+
+[TestingAndDebugging::MisplacedShebang]
+add_themes = parrot
+
+[TestingAndDebugging::ProhibitShebangWarningsArg]
+add_themes = parrot
+
+[TestingAndDebugging::RequirePortableShebang]
+add_themes = parrot
+
+[TestingAndDebugging::RequireUseStrict]
+add_themes = parrot
+
+[TestingAndDebugging::RequireUseWarnings]
+add_themes = parrot
+
+[ValuesAndExpressions::ProhibitInterpolationOfLiterals]
+add_themes = extra
+
+[Variables::ProhibitConditionalDeclarations]
+add_themes = parrot
+
+[Bangs::ProhibitFlagComments]
+add_themes = extra
+
+[Bangs::ProhibitRefProtoOrProto]
+add_themes = extra
Copied: branches/tt677_toolsdirs/tools/dev/perltidy.conf (from r48639, branches/tt677_toolsdirs/tools/util/perltidy.conf)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/tt677_toolsdirs/tools/dev/perltidy.conf Tue Aug 24 22:52:21 2010 (r48642, copy of r48639, branches/tt677_toolsdirs/tools/util/perltidy.conf)
@@ -0,0 +1,15 @@
+# A declarative version of PDD07 for perl.
+
+# Must apply...
+
+-l=100 # Source line width is limited to 100 characters.
+-i=4 # must be indented four columns (no tabs)
+-ola # Labels (including case labels) must be outdented two columns
+-ci=4 # Long lines, when split, must use at least one extra level of indentation on the continued line.
+-ce # Cuddled elses are forbidden: i.e. avoid } else { .
+
+# Nice to haves...
+
+# Freeze new lines; some really short lines look good the way they
+# are, this should stop perltidy from merging them together
+-fnl
Copied: branches/tt677_toolsdirs/tools/dev/pgegrep (from r48639, branches/tt677_toolsdirs/tools/util/pgegrep)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/tt677_toolsdirs/tools/dev/pgegrep Tue Aug 24 22:52:21 2010 (r48642, copy of r48639, branches/tt677_toolsdirs/tools/util/pgegrep)
@@ -0,0 +1,308 @@
+#! parrot
+
+=head1 NAME
+
+pgegrep - A simple grep using PGE for matching
+
+=head1 SYNOPSIS
+
+B<pgegrep> [I<OPTIONS>] B<PATTERN> [I<FILE...>]
+
+=head1 DESCRIPTION
+
+pgegrep aims to be a small and easy to use program in replacement of the
+standard grep utility. Regex support is whatever PGE will allow. It
+searches through files line by line and tests if the given pattern matches.
+
+=head1 OPTIONS
+
+=over 4
+
+=item -v
+
+=item --invert-match
+
+print lines not matching PATTERN
+
+=item -V
+
+=item --version
+
+print the version and exit
+
+=item --help
+
+show this help and exit
+
+=item -r
+
+=item --recursive
+
+recursively descend into directories
+
+=item -L
+
+=item --files-without-matches
+
+print a list of files that do not match PATTERN
+
+=item -l
+
+=item --files-with-matches
+
+print a list of files that do match PATTERN
+
+=item -a
+
+=item --text
+
+treat binary files as text.
+
+This uses a basic heuristic to discover if a file is binary or not. Files are
+read line by line, and it keeps processing "normally" until a control character
+is found, and then stops and goes onto the next file is that line matches.
+
+=item -n
+
+=item --line-number
+
+print the line number for each match
+
+=item -H
+
+=item --with-filename
+
+print the filename for each match
+
+=back
+
+=cut
+
+# Readability improved!
+.include 'hllmacros.pir'
+
+# for getstdin and friends
+.loadlib 'io_ops'
+
+.sub main :main
+ .param pmc argv # the script name, then our options.
+ .local string progname
+ progname = shift argv
+ load_bytecode 'Getopt/Obj.pbc'
+ load_bytecode 'PGE.pbc'
+ .local pmc getopts
+ getopts = new [ 'Getopt';'Obj' ]
+ getopts.'notOptStop'(1)
+ push getopts, 'with-filename|H'
+ push getopts, 'files-with-matches|l'
+ push getopts, 'files-without-matches|L'
+ push getopts, 'line-number|n'
+ push getopts, 'text|a'
+ push getopts, 'recursive|r'
+ push getopts, 'invert-match|v'
+ push getopts, 'version|V'
+ push getopts, 'help'
+ push_eh handler
+ .local pmc opts
+ opts = getopts.'get_options'(argv)
+ $I0 = defined opts['help']
+ .If($I0, {
+ showhelp()
+ })
+ $I0 = defined opts['version']
+ .If($I0, {
+ showversion()
+ })
+
+ .local int argc
+ argc = elements argv
+ .Unless(argc>1, { showhelp() }) # need rule and at least one file
+
+ .local string rule
+ .local pmc p6rule_compile, matchsub
+ rule = shift argv
+ p6rule_compile = compreg 'PGE::Perl6Regex'
+ matchsub = p6rule_compile(rule)
+ .If(null matchsub, { die 'Unable to compile regex' })
+
+ .local int i, filecount
+ .local string filename
+ .local pmc File, OS, files, handle
+ files = new 'ResizableStringArray'
+ files = argv
+ filecount = files
+ # define with-filename if there's more than one file
+ .If(filecount >= 2, { opts['with-filename'] = 1 })
+ $P0 = loadlib 'file'
+ File = new 'File'
+ $P0 = loadlib 'os'
+ OS = new 'OS'
+ # This must be here, or else it'll get filled with junk data we use stdin...
+ i = 0
+
+ .Unless(filecount, {
+ # no args, use stdin
+ stdindashhack:
+ handle = getstdin
+ filename = '(standard input)'
+ goto stdinhack
+ })
+ .For(, i < filecount, inc i, {
+ filename = files[i]
+ .If(filename == '-', {
+ goto stdindashhack
+ })
+ $I1 = File.'is_file'(filename)
+ .IfElse($I1, {
+ # Is a file
+ handle = open filename, 'r'
+ },{
+ # Not a file, hopefully a directory
+ $I1 = File.'is_dir'(filename)
+ $I0 = defined opts['recursive']
+ $I1 &= $I0
+ .Unless($I1, {
+ printerr "pgegrep: '"
+ printerr filename
+ printerr "': Operation not supported.\n"
+ goto nextfor_0
+ })
+ $P0 = OS.'readdir'(filename)
+ .Foreach($S0, $P0, {
+ .If($S0 != '.', {
+ .If($S0 != '..', {
+ $S1 = filename . '/'
+ $S0 = $S1 . $S0
+ $P1 = new 'ResizableStringArray'
+ $P1[0] = $S0
+ $I0 = i + 1
+ splice files, $P1, $I0, 0
+ }) })
+ })
+ filecount = files
+ goto nextfor_0
+ })
+ stdinhack:
+ checkfile(handle, filename, matchsub, opts)
+ close handle
+ nextfor_0:
+ })
+
+ end
+handler:
+ .local pmc exception, pmcmsg
+ .local string message
+ .get_results (exception)
+ pmcmsg = getattribute exception, 'message'
+ pop_eh
+ message = pmcmsg
+ message = "pgegrep: " . message
+ die message
+.end
+
+.sub checkfile
+ .param pmc handle
+ .param string filename
+ .param pmc matchsub
+ .param pmc opts
+
+ .local pmc match
+ .local string line
+ .local int lineno, linelen, matched
+ lineno = 1
+ matched = 0 # Only used for --files-without-matches
+ line = readline handle
+ linelen = length line
+
+ .local pmc p6rule_compile, cntrlchar
+ $S0 = '<+cntrl-[\t\r\n]>'
+ p6rule_compile = compreg 'PGE::Perl6Regex'
+ cntrlchar = p6rule_compile($S0)
+
+ .For(, linelen, {
+ line = readline handle
+ linelen = length line
+ inc lineno
+ }, {
+ match = matchsub(line)
+ $I1 = istrue match
+ match = cntrlchar(line)
+
+ $I2 = istrue match
+ $I0 = defined opts['files-without-matches']
+ .If($I0, {
+ .If($I1, { matched = 1 })
+ goto next
+ })
+ $I0 = defined opts['files-with-matches']
+ $I0 = $I0 && $I1
+ .If($I0, {
+ say filename
+ .return()
+ })
+
+ $I0 = defined opts['invert-match']
+ not $I0
+ $I1 = xor $I1, $I0
+ .Unless($I1, {
+ $I0 = defined opts['text']
+ $I0 = xor $I0, $I2
+ .If($I0, {
+ print 'Binary file '
+ print filename
+ say ' matches'
+ .return()
+ })
+ $I0 = defined opts['with-filename']
+ $I1 = defined opts['recursive']
+ $I0 = $I0 || $I1
+ .If($I0, {
+ print filename
+ print ':'
+ })
+ $I0 = defined opts['line-number']
+ .If($I0, {
+ print lineno
+ print ':'
+ })
+ print line
+ })
+ #---------
+ next:
+ })
+ $I0 = defined opts['files-without-matches']
+ .If($I0, { say filename })
+ .return()
+.end
+
+.sub showhelp
+ print <<'HELP'
+Usage: pgegrep [OPTIONS] PATTERN [FILE...]
+Search for the Perl 6 Rule PATTERN in each file.
+
+ -v --invert-match print lines not matching PATTERN
+ -V --version print the version and exit
+ --help show this help and exit
+ -r --recursive recursively descend into directories
+ -L --files-without-matches print a list of files that do not match PATTERN
+ -l --files-with-matches print a list of files that do match PATTERN
+ -a --text treat binary files as text
+ -n --line-number print the line number for each match
+ -H --with-filename print the filename for each match
+
+HELP
+ end
+.end
+
+.sub showversion
+ print <<'VERSION'
+pgegrep v0.0.1
+VERSION
+ end
+.end
+
+# Local Variables:
+# mode: pir
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4 ft=pir:
Copied: branches/tt677_toolsdirs/tools/dev/update_copyright.pl (from r48639, branches/tt677_toolsdirs/tools/util/update_copyright.pl)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/tt677_toolsdirs/tools/dev/update_copyright.pl Tue Aug 24 22:52:21 2010 (r48642, copy of r48639, branches/tt677_toolsdirs/tools/util/update_copyright.pl)
@@ -0,0 +1,63 @@
+#! perl
+# $Id$
+
+# Copyright (C) 2008, Parrot Foundation.
+
+use strict;
+use warnings;
+use Fatal qw( open close );
+
+=head1 NAME
+
+F<tools/util/update_copyright.pl>
+
+=head1 DESCRIPTION
+
+Given a list of files as command line arguments, update the copyright
+notice to go from the earliest year noted to the current year.
+
+Edits the files in place. You should update the copyright on a modified
+file before you commit it back to the repository.
+
+=cut
+
+use lib 'lib';
+use Parrot::Test;
+
+# Accept a little fuzz in the original copyright notice..
+my $copyright_re = qr/
+ Copyright \s+ \(C\) \s+
+ (\d\d\d\d)\s*(?:-\s*\d\d\d\d)? \s* ,? \s*
+ The \s+ Perl \s+ Foundation\.?
+/xi;
+
+my $year = (localtime())[5]+1900;
+
+# loop over all the files specified on the command line
+foreach my $file (@ARGV) {
+ my $contents = Parrot::Test::slurp_file( $file );
+ if ( $contents =~ $copyright_re) {
+ my $old_year = $1;
+ if ($old_year eq $year) {
+ warn "$file already up to date.\n";
+ next;
+ }
+ else {
+ $contents =~ s/$copyright_re/Copyright (C) $old_year-$year, Parrot Foundation./;
+ open my $ofh, '>', $file;
+ print {$ofh} $contents;
+ close $ofh;
+ }
+ }
+ else {
+ warn "$file doesn't have a valid copyright line.\n";
+ }
+}
+
+
+# Local Variables:
+# mode: cperl
+# cperl-indent-level: 4
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:
Deleted: branches/tt677_toolsdirs/tools/util/ncidef2pasm.pl
==============================================================================
--- branches/tt677_toolsdirs/tools/util/ncidef2pasm.pl Tue Aug 24 22:52:21 2010 (r48641)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,237 +0,0 @@
-#! perl
-
-# Copyright (C) 2003-2007, Parrot Foundation.
-# $Id$
-
-=head1 NAME
-
-tools/util/ncidef2asm.pl - Turn an NCI library definition file into PASM
-
-=head1 SYNOPSIS
-
- perl tools/util/ncidef2asm.pl path/to/from_file [ path/to/to_file ]
-
-=head1 DESCRIPTION
-
-This program takes an NCI library definition file and turns it into PASM.
-
-An NCI library definition file provides the information needed to
-generate a parrot wrapper for the named library (or libraries). Its
-format is simple, and looks like:
-
- [package]
- ncurses
-
- [lib]
- libform.so
-
- [defs]
- p new_field i i i i i i
-
- [lib]
- libncurses.so
-
- [defs]
- i is_term_resized i i
-
-Note that the assembly file is generated in the order you specify, so
-if there are library dependencies, make sure you have them in the
-correct order.
-
-=head2 package
-
-Declares the package that all subsequent sub PMCs will be put
-into. The name is a simple concatenation of the package name, double
-colon, and the routine name, with no preceding punctuation.
-
-=head2 lib
-
-The name of the library to be loaded. Should be as qualified as
-necessary for your platform--generally the full filename is required,
-though the directory generally isn't.
-
-You may load multiple libraries here, but only the last one loaded
-will be exposed to subsequent defs.
-
-=head2 defs
-
-This section holds the definitions of functions. Each function is
-assumed to be in the immediate preceding library. The definition of
-the function is:
-
- return_type name [param [param [param ...]]]
-
-The param and return_type parameters use the NCI standard, which for
-reference is:
-
-=over 4
-
-=item p
-
-Parameter is a void pointer, taken from the PMC's data pointer. PMC is
-assumed to be an unmanagedstruct or child class.
-
-Taken from a P register
-
-=item c
-
-Parameter is a character.
-
-Taken from an I register
-
-=item s
-
-Parameter is a short
-
-Taken from an I register
-
-=item i
-
-Parameter is an int
-
-Taken from an I register
-
-=item l
-
-Parameter is a long
-
-Taken from an I register
-
-=item f
-
-Paramter is a float
-
-Taken from an N register.
-
-=item d
-
-Parameter is a double.
-
-Taken from an N register.
-
-=item t
-
-Paramter is a char *, presumably a C string
-
-Taken from an S register
-
-=item v
-
-Void. Only valid as a return type, noting that the function returns no data.
-
-=item I
-
-Interpreter pointer. The current interpreter pointer is passed in
-
-=item P
-
-PMC.
-
-=item 2
-
-Pointer to short.
-
-Taken from an I register.
-
-=item 3
-
-Pointer to int.
-
-Taken from an I register
-
-=item 4
-
-Pointer to long
-
-Taken from an I register
-
-=back
-
-=cut
-
-use strict;
-use warnings;
-
-my ( $from_file, $to_file ) = @ARGV;
-
-# If there is no destination file, strip off the extension of the
-# source file and add a .pasm to it
-if ( !defined $to_file ) {
- $to_file = $from_file;
- $to_file =~ s/\..*$//;
- $to_file .= ".pasm";
-}
-
-open my $INPUT, '<', "$from_file" or die "Can't open up $from_file, error $!";
-open my $OUTPUT, '>', "$to_file" or die "Can't open up $to_file, error $!";
-
-# To start, save all the registers, just in case
-print $OUTPUT "saveall\n";
-
-my @libs;
-my ( $cur_package, $line, $cur_section );
-
-# Our dispatch table
-my (%dispatch) = (
- package => \&package_line,
- lib => \&lib_line,
- defs => \&def_line,
-);
-
-while ( $line = <$INPUT> ) {
-
- # Throw away trailing newlines, comments, and whitespace. If the
- # line's empty, then off to the next line
- chomp $line;
- $line =~ s/#.*//;
- $line =~ s/\s*$//;
- next unless $line;
-
- # Is it a section line? If so, extract the section and set it.
- if ( $line =~ /\[(\w+)\]/ ) {
- $cur_section = $1;
- next;
- }
-
- # Everything else goes to the handler
- $dispatch{$cur_section}->($line);
-
-}
-
-# Put the registers back and end
-print $OUTPUT "restoreall\n";
-print $OUTPUT "end\n";
-close $OUTPUT;
-
-sub package_line {
- my $line = shift;
-
- # Trim leading and trailing spaces
- $line =~ s/^\s*//;
- $line =~ s/\s*$//;
-
- # Set the global current package
- $cur_package = $line;
-
-}
-
-sub lib_line {
- my $line = shift;
- print $OUTPUT "loadlib P1, '$line'\n";
-}
-
-sub def_line {
- my $line = shift;
- my ( $return_type, $name, @params ) = split ' ', $line;
- unshift @params, $return_type;
- my $signature = join( "", @params );
- print $OUTPUT "dlfunc P2, P1, '$name', '$signature'\n";
- print $OUTPUT "store_global '${cur_package}::${name}', P2\n";
-}
-
-# Local Variables:
-# mode: cperl
-# cperl-indent-level: 4
-# fill-column: 100
-# End:
-# vim: expandtab shiftwidth=4:
Deleted: branches/tt677_toolsdirs/tools/util/parrot-config.pir
==============================================================================
--- branches/tt677_toolsdirs/tools/util/parrot-config.pir Tue Aug 24 22:52:21 2010 (r48641)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,103 +0,0 @@
-#!/usr/bin/env parrot
-# $Id$
-
-=head1 NAME
-
-config.pir - Print a Parrot configuration item
-
-=head1 VERSION
-
-version 0.01
-
-=head1 SYNOPSIS
-
- ./parrot parrot-config.pir VERSION
- ./parrot parrot-config.pir ccflags
- ./parrot parrot-config.pir --dump
-
-=head1 DESCRIPTION
-
-Print out configuration items.
-
-=head1 AUTHOR
-
-Leopold Toetsch E<lt>lt at toetsch.atE<gt>.
-
-=head1 COPYRIGHT
-
-Copyright (C) 2004-2009, Parrot Foundation.
-
-=cut
-
-.sub _main :main
- .param pmc argv
- .local int argc
- argc = argv
- if argc < 2 goto usage
- .local pmc interp, conf_hash
- .local string key
- .include "iglobals.pasm"
- interp = getinterp
- conf_hash = interp[.IGLOBALS_CONFIG_HASH]
- .local int i
- i = 1
-loop:
- key = argv[i]
- if key == '--help' goto usage
- if key == '--dump' goto dump
- $I0 = defined conf_hash[key]
- unless $I0 goto failkey
- dec argc
- if i < argc goto dumpsome
- $S0 = conf_hash[key]
- print $S0
- inc i
- if i < argc goto loop
- print "\n"
- end
-dumpsome:
- key = argv[i]
- $I0 = defined conf_hash[key]
- unless $I0 goto failkey
- print key
- print " => '"
- $S1 = conf_hash[key]
- print $S1
- say "'"
- inc i
- if i <= argc goto dumpsome
- end
-failkey:
- print " no such key: '"
- print key
- print "'\n"
- end
-dump:
- .local pmc iterator
- iterator = iter conf_hash
-iter_loop:
- unless iterator goto iter_end
- shift $S0, iterator
- print $S0
- print " => '"
- $S1 = conf_hash[$S0]
- print $S1
- say "'"
- goto iter_loop
-iter_end:
- end
-usage:
- $S0 = argv[0]
- $P0 = getinterp
- .include 'stdio.pasm'
- $P1 = $P0.'stdhandle'(.PIO_STDERR_FILENO)
- $P1.'print'($S0)
- $P1.'print'(" [ <config-key> [ <config-key> ... ] | --dump | --help ]\n")
- exit 1
-.end
-
-# Local Variables:
-# mode: pir
-# fill-column: 100
-# End:
-# vim: expandtab shiftwidth=4 ft=pir:
Deleted: branches/tt677_toolsdirs/tools/util/perlcritic-cage.conf
==============================================================================
--- branches/tt677_toolsdirs/tools/util/perlcritic-cage.conf Tue Aug 24 22:52:21 2010 (r48641)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,37 +0,0 @@
-# A more stringent set of rules for cage cleaners
-
-[-CodeLayout::ProhibitParensWithBuiltins]
-[CodeLayout::ProhibitHardTabs]
-allow_leading_tabs = 0
-
-[-CodeLayout::RequireTidyCode]
-
-[-ControlStructures::ProhibitPostfixControls]
-[-ControlStructures::ProhibitUnlessBlocks]
-
-[-Documentation::PodSpelling]
-[-Documentation::RequirePodAtEnd]
-[-Documentation::RequirePodSections]
-
-[-ErrorHandling::RequireCarping]
-
-[-InputOutput::ProhibitBacktickOperators]
-[-InputOutput::ProhibitInteractiveTest]
-[-InputOutput::RequireCheckedSyscalls]
-functions = :builtins
-exclude_functions = print
-
-[-Miscellanea::RequireRcsKeywords]
-
-[-Modules::RequireVersionVar]
-
-[-RegularExpressions::ProhibitEscapedMetacharacters]
-[-RegularExpressions::RequireDotMatchAnything]
-[-RegularExpressions::RequireExtendedFormatting]
-[-RegularExpressions::RequireLineBoundaryMatching]
-
-[-ValuesAndExpressions::ProhibitConstantPragma]
-[-ValuesAndExpressions::ProhibitEmptyQuotes]
-[-ValuesAndExpressions::ProhibitMagicNumbers]
-
-[-Variables::ProhibitPunctuationVars]
Deleted: branches/tt677_toolsdirs/tools/util/perlcritic.conf
==============================================================================
--- branches/tt677_toolsdirs/tools/util/perlcritic.conf Tue Aug 24 22:52:21 2010 (r48641)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,75 +0,0 @@
-verbose = 3
-
-# not all the profiles listed here are installed by default, even if you have
-# Perl::Critic. Shhhh.
-profile-strictness = quiet
-
-[BuiltinFunctions::ProhibitStringySplit]
-add_themes = parrot
-
-[CodeLayout::ProhibitDuplicateCoda]
-add_themes = parrot
-
-[CodeLayout::ProhibitHardTabs]
-allow_leading_tabs = 0
-add_themes = parrot
-
-[CodeLayout::ProhibitTrailingWhitespace]
-add_themes = parrot
-
-[CodeLayout::RequireTidyCode]
-perltidyrc = tools/util/perltidy.conf
-add_themes = extra
-
-[CodeLayout::UseParrotCoda]
-add_themes = parrot
-
-[InputOutput::ProhibitBarewordFileHandles]
-add_themes = parrot
-
-[InputOutput::ProhibitTwoArgOpen]
-add_themes = parrot
-
-[NamingConventions::ProhibitAmbiguousNames]
-# remove abstract from the list of forbidden names
-forbid = bases close contract last left no record right second set
-add_themes = extra
-
-[Subroutines::ProhibitBuiltinHomonyms]
-add_themes = extra
-
-[Subroutines::ProhibitExplicitReturnUndef]
-add_themes = parrot
-
-[Subroutines::ProhibitSubroutinePrototypes]
-add_themes = parrot
-
-[Subroutines::RequireFinalReturn]
-add_themes = extra
-
-[TestingAndDebugging::MisplacedShebang]
-add_themes = parrot
-
-[TestingAndDebugging::ProhibitShebangWarningsArg]
-add_themes = parrot
-
-[TestingAndDebugging::RequirePortableShebang]
-add_themes = parrot
-
-[TestingAndDebugging::RequireUseStrict]
-add_themes = parrot
-
-[TestingAndDebugging::RequireUseWarnings]
-add_themes = parrot
-
-[ValuesAndExpressions::ProhibitInterpolationOfLiterals]
-add_themes = extra
-
-[Variables::ProhibitConditionalDeclarations]
-add_themes = parrot
-
-[Bangs::ProhibitFlagComments]
-add_themes = extra
-
-[Bangs::ProhibitRefProtoOrProto]
-add_themes = extra
Deleted: branches/tt677_toolsdirs/tools/util/perltidy.conf
==============================================================================
--- branches/tt677_toolsdirs/tools/util/perltidy.conf Tue Aug 24 22:52:21 2010 (r48641)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,15 +0,0 @@
-# A declarative version of PDD07 for perl.
-
-# Must apply...
-
--l=100 # Source line width is limited to 100 characters.
--i=4 # must be indented four columns (no tabs)
--ola # Labels (including case labels) must be outdented two columns
--ci=4 # Long lines, when split, must use at least one extra level of indentation on the continued line.
--ce # Cuddled elses are forbidden: i.e. avoid } else { .
-
-# Nice to haves...
-
-# Freeze new lines; some really short lines look good the way they
-# are, this should stop perltidy from merging them together
--fnl
Deleted: branches/tt677_toolsdirs/tools/util/pgegrep
==============================================================================
--- branches/tt677_toolsdirs/tools/util/pgegrep Tue Aug 24 22:52:21 2010 (r48641)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,308 +0,0 @@
-#! parrot
-
-=head1 NAME
-
-pgegrep - A simple grep using PGE for matching
-
-=head1 SYNOPSIS
-
-B<pgegrep> [I<OPTIONS>] B<PATTERN> [I<FILE...>]
-
-=head1 DESCRIPTION
-
-pgegrep aims to be a small and easy to use program in replacement of the
-standard grep utility. Regex support is whatever PGE will allow. It
-searches through files line by line and tests if the given pattern matches.
-
-=head1 OPTIONS
-
-=over 4
-
-=item -v
-
-=item --invert-match
-
-print lines not matching PATTERN
-
-=item -V
-
-=item --version
-
-print the version and exit
-
-=item --help
-
-show this help and exit
-
-=item -r
-
-=item --recursive
-
-recursively descend into directories
-
-=item -L
-
-=item --files-without-matches
-
-print a list of files that do not match PATTERN
-
-=item -l
-
-=item --files-with-matches
-
-print a list of files that do match PATTERN
-
-=item -a
-
-=item --text
-
-treat binary files as text.
-
-This uses a basic heuristic to discover if a file is binary or not. Files are
-read line by line, and it keeps processing "normally" until a control character
-is found, and then stops and goes onto the next file is that line matches.
-
-=item -n
-
-=item --line-number
-
-print the line number for each match
-
-=item -H
-
-=item --with-filename
-
-print the filename for each match
-
-=back
-
-=cut
-
-# Readability improved!
-.include 'hllmacros.pir'
-
-# for getstdin and friends
-.loadlib 'io_ops'
-
-.sub main :main
- .param pmc argv # the script name, then our options.
- .local string progname
- progname = shift argv
- load_bytecode 'Getopt/Obj.pbc'
- load_bytecode 'PGE.pbc'
- .local pmc getopts
- getopts = new [ 'Getopt';'Obj' ]
- getopts.'notOptStop'(1)
- push getopts, 'with-filename|H'
- push getopts, 'files-with-matches|l'
- push getopts, 'files-without-matches|L'
- push getopts, 'line-number|n'
- push getopts, 'text|a'
- push getopts, 'recursive|r'
- push getopts, 'invert-match|v'
- push getopts, 'version|V'
- push getopts, 'help'
- push_eh handler
- .local pmc opts
- opts = getopts.'get_options'(argv)
- $I0 = defined opts['help']
- .If($I0, {
- showhelp()
- })
- $I0 = defined opts['version']
- .If($I0, {
- showversion()
- })
-
- .local int argc
- argc = elements argv
- .Unless(argc>1, { showhelp() }) # need rule and at least one file
-
- .local string rule
- .local pmc p6rule_compile, matchsub
- rule = shift argv
- p6rule_compile = compreg 'PGE::Perl6Regex'
- matchsub = p6rule_compile(rule)
- .If(null matchsub, { die 'Unable to compile regex' })
-
- .local int i, filecount
- .local string filename
- .local pmc File, OS, files, handle
- files = new 'ResizableStringArray'
- files = argv
- filecount = files
- # define with-filename if there's more than one file
- .If(filecount >= 2, { opts['with-filename'] = 1 })
- $P0 = loadlib 'file'
- File = new 'File'
- $P0 = loadlib 'os'
- OS = new 'OS'
- # This must be here, or else it'll get filled with junk data we use stdin...
- i = 0
-
- .Unless(filecount, {
- # no args, use stdin
- stdindashhack:
- handle = getstdin
- filename = '(standard input)'
- goto stdinhack
- })
- .For(, i < filecount, inc i, {
- filename = files[i]
- .If(filename == '-', {
- goto stdindashhack
- })
- $I1 = File.'is_file'(filename)
- .IfElse($I1, {
- # Is a file
- handle = open filename, 'r'
- },{
- # Not a file, hopefully a directory
- $I1 = File.'is_dir'(filename)
- $I0 = defined opts['recursive']
- $I1 &= $I0
- .Unless($I1, {
- printerr "pgegrep: '"
- printerr filename
- printerr "': Operation not supported.\n"
- goto nextfor_0
- })
- $P0 = OS.'readdir'(filename)
- .Foreach($S0, $P0, {
- .If($S0 != '.', {
- .If($S0 != '..', {
- $S1 = filename . '/'
- $S0 = $S1 . $S0
- $P1 = new 'ResizableStringArray'
- $P1[0] = $S0
- $I0 = i + 1
- splice files, $P1, $I0, 0
- }) })
- })
- filecount = files
- goto nextfor_0
- })
- stdinhack:
- checkfile(handle, filename, matchsub, opts)
- close handle
- nextfor_0:
- })
-
- end
-handler:
- .local pmc exception, pmcmsg
- .local string message
- .get_results (exception)
- pmcmsg = getattribute exception, 'message'
- pop_eh
- message = pmcmsg
- message = "pgegrep: " . message
- die message
-.end
-
-.sub checkfile
- .param pmc handle
- .param string filename
- .param pmc matchsub
- .param pmc opts
-
- .local pmc match
- .local string line
- .local int lineno, linelen, matched
- lineno = 1
- matched = 0 # Only used for --files-without-matches
- line = readline handle
- linelen = length line
-
- .local pmc p6rule_compile, cntrlchar
- $S0 = '<+cntrl-[\t\r\n]>'
- p6rule_compile = compreg 'PGE::Perl6Regex'
- cntrlchar = p6rule_compile($S0)
-
- .For(, linelen, {
- line = readline handle
- linelen = length line
- inc lineno
- }, {
- match = matchsub(line)
- $I1 = istrue match
- match = cntrlchar(line)
-
- $I2 = istrue match
- $I0 = defined opts['files-without-matches']
- .If($I0, {
- .If($I1, { matched = 1 })
- goto next
- })
- $I0 = defined opts['files-with-matches']
- $I0 = $I0 && $I1
- .If($I0, {
- say filename
- .return()
- })
-
- $I0 = defined opts['invert-match']
- not $I0
- $I1 = xor $I1, $I0
- .Unless($I1, {
- $I0 = defined opts['text']
- $I0 = xor $I0, $I2
- .If($I0, {
- print 'Binary file '
- print filename
- say ' matches'
- .return()
- })
- $I0 = defined opts['with-filename']
- $I1 = defined opts['recursive']
- $I0 = $I0 || $I1
- .If($I0, {
- print filename
- print ':'
- })
- $I0 = defined opts['line-number']
- .If($I0, {
- print lineno
- print ':'
- })
- print line
- })
- #---------
- next:
- })
- $I0 = defined opts['files-without-matches']
- .If($I0, { say filename })
- .return()
-.end
-
-.sub showhelp
- print <<'HELP'
-Usage: pgegrep [OPTIONS] PATTERN [FILE...]
-Search for the Perl 6 Rule PATTERN in each file.
-
- -v --invert-match print lines not matching PATTERN
- -V --version print the version and exit
- --help show this help and exit
- -r --recursive recursively descend into directories
- -L --files-without-matches print a list of files that do not match PATTERN
- -l --files-with-matches print a list of files that do match PATTERN
- -a --text treat binary files as text
- -n --line-number print the line number for each match
- -H --with-filename print the filename for each match
-
-HELP
- end
-.end
-
-.sub showversion
- print <<'VERSION'
-pgegrep v0.0.1
-VERSION
- end
-.end
-
-# Local Variables:
-# mode: pir
-# fill-column: 100
-# End:
-# vim: expandtab shiftwidth=4 ft=pir:
Deleted: branches/tt677_toolsdirs/tools/util/update_copyright.pl
==============================================================================
--- branches/tt677_toolsdirs/tools/util/update_copyright.pl Tue Aug 24 22:52:21 2010 (r48641)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,63 +0,0 @@
-#! perl
-# $Id$
-
-# Copyright (C) 2008, Parrot Foundation.
-
-use strict;
-use warnings;
-use Fatal qw( open close );
-
-=head1 NAME
-
-F<tools/util/update_copyright.pl>
-
-=head1 DESCRIPTION
-
-Given a list of files as command line arguments, update the copyright
-notice to go from the earliest year noted to the current year.
-
-Edits the files in place. You should update the copyright on a modified
-file before you commit it back to the repository.
-
-=cut
-
-use lib 'lib';
-use Parrot::Test;
-
-# Accept a little fuzz in the original copyright notice..
-my $copyright_re = qr/
- Copyright \s+ \(C\) \s+
- (\d\d\d\d)\s*(?:-\s*\d\d\d\d)? \s* ,? \s*
- The \s+ Perl \s+ Foundation\.?
-/xi;
-
-my $year = (localtime())[5]+1900;
-
-# loop over all the files specified on the command line
-foreach my $file (@ARGV) {
- my $contents = Parrot::Test::slurp_file( $file );
- if ( $contents =~ $copyright_re) {
- my $old_year = $1;
- if ($old_year eq $year) {
- warn "$file already up to date.\n";
- next;
- }
- else {
- $contents =~ s/$copyright_re/Copyright (C) $old_year-$year, Parrot Foundation./;
- open my $ofh, '>', $file;
- print {$ofh} $contents;
- close $ofh;
- }
- }
- else {
- warn "$file doesn't have a valid copyright line.\n";
- }
-}
-
-
-# Local Variables:
-# mode: cperl
-# cperl-indent-level: 4
-# fill-column: 100
-# End:
-# vim: expandtab shiftwidth=4:
More information about the parrot-commits
mailing list