[svn:parrot] r43549 - branches/one_make/tools/build
jkeenan at svn.parrot.org
jkeenan at svn.parrot.org
Sat Jan 23 03:37:33 UTC 2010
Author: jkeenan
Date: Sat Jan 23 03:37:32 2010
New Revision: 43549
URL: https://trac.parrot.org/parrot/changeset/43549
Log:
Add some barebones documentation of subroutines.
Modified:
branches/one_make/tools/build/h2inc.pl
Modified: branches/one_make/tools/build/h2inc.pl
==============================================================================
--- branches/one_make/tools/build/h2inc.pl Sat Jan 23 03:36:51 2010 (r43548)
+++ branches/one_make/tools/build/h2inc.pl Sat Jan 23 03:37:32 2010 (r43549)
@@ -49,6 +49,26 @@
EOF
close $out_fh;
+=head1 SUBROUTINES
+
+=head2 C<const_to_parrot()>
+
+=over 4
+
+=item * Arguments
+
+ $gen = join "\n", const_to_parrot(@defs);
+
+List.
+
+=item * Return Value
+
+String.
+
+=back
+
+=cut
+
sub const_to_parrot {
my $keylen = (sort { $a <=> $b } map { length($_->[0]) } @_ )[-1] ;
@@ -57,6 +77,24 @@
map {sprintf ".macro_const %-${keylen}s %${vallen}s", $_->[0], $_->[1]} @_;
}
+=head2 C<const_to_perl()>
+
+=over 4
+
+=item * Arguments
+
+ $gen = join "\n", const_to_perl(@defs);
+
+List.
+
+=item * Return Value
+
+String.
+
+=back
+
+=cut
+
sub const_to_perl {
my $keylen = (sort { $a <=> $b } map { length($_->[0]) } @_ )[-1] ;
@@ -64,18 +102,75 @@
map {sprintf "use constant %-${keylen}s => %s;", $_->[0], $_->[1]} @_;
}
+=head2 C<transform_name()>
+
+=over 4
+
+=item * Arguments
+
+ transform_name( sub { $prefix . $_[0] }, @_ );
+
+List of two or more elements, the first element of which is a subroutine
+reference.
+
+=item * Return Value
+
+List which is a mapping of the transformations executed by the first argument
+upon the remaining arguments.
+
+=back
+
+=cut
+
sub transform_name {
my $action = shift;
return map { [ $action->( $_->[0] ), $_->[1] ] } @_;
}
+=head2 C<prepend_prefix()>
+
+=over 4
+
+=item * Arguments
+
+ @defs = prepend_prefix $d->{prefix}, @{ $d->{defs} };
+
+List of two or more elements, the first element of which is a string.
+
+=item * Return Value
+
+List.
+
+=back
+
+=cut
+
sub prepend_prefix {
my $prefix = shift;
transform_name( sub { $prefix . $_[0] }, @_ );
}
+=head2 C<perform_directive()>
+
+=over 4
+
+=item * Arguments
+
+ @defs = perform_directive($directive);
+
+Single hash reference (which is the return value from a successful run of
+C<parse_file()>.
+
+=item * Return Value
+
+List.
+
+=back
+
+=cut
+
sub perform_directive {
my ($d) = @_;
@@ -86,6 +181,25 @@
@defs;
}
+=head2 C<parse_file()>
+
+=over 4
+
+=item * Arguments
+
+ $directive = parse_file($in_file, $in_fh, $out_file);
+
+List of 3 elements: string holding name of incoming file; read handle to that
+file; string holding name of outgoing file.
+
+=item * Return Value
+
+If successful, returns a hash reference.
+
+=back
+
+=cut
+
sub parse_file {
my ( $in_file, $fh, $out_file) = @_;
More information about the parrot-commits
mailing list