diff --git a/.gitignore b/.gitignore index a1abf85..36901fd 100644 --- a/.gitignore +++ b/.gitignore @@ -55,8 +55,8 @@ inc/ nytprof.out pod2htm*.tmp pm_to_blib -Build-Hopen-* -Build-Hopen-*.tar.gz +Data-Hopen-* +Data-Hopen-*.tar.gz *.bak # Other diff --git a/MANIFEST b/MANIFEST index b37062e..6cb0bdf 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1,13 +1,11 @@ bin/hopen Changes lib/Data/Hopen.pm -lib/Data/Hopen/Arrrgs.pm lib/Data/Hopen/Base.pm lib/Data/Hopen/G.pod lib/Data/Hopen/G/CollectOp.pm lib/Data/Hopen/G/DAG.pm lib/Data/Hopen/G/Entity.pm -lib/Data/Hopen/G/FilesOp.pm lib/Data/Hopen/G/Goal.pm lib/Data/Hopen/G/GraphBuilder.pm lib/Data/Hopen/G/Link.pm @@ -19,8 +17,6 @@ lib/Data/Hopen/Scope/Environment.pm lib/Data/Hopen/Scope/Hash.pm lib/Data/Hopen/Scope/Inputs.pm lib/Data/Hopen/Scope/Overrides.pm -lib/Data/Hopen/Tool.pm -lib/Data/Hopen/Toolchain.pm lib/Data/Hopen/Util/Data.pm lib/Data/Hopen/Util/Filename.pm lib/Data/Hopen/Util/NameSet.pm diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP index 519663e..43813bf 100644 --- a/MANIFEST.SKIP +++ b/MANIFEST.SKIP @@ -1,11 +1,11 @@ -# MIscellaneous +# Miscellaneous ^\.editorconfig ^\.[^\\\/]*\.yml \bfoo\b.* t/.*\.out$ lua$ TEMPLATE -Data-Hopen-* +Data-Hopen-.* TODO \brunhopen$ \.stackdump$ diff --git a/Makefile.PL b/Makefile.PL index bc6e5bb..92737cb 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -214,7 +214,7 @@ my %opts = ( 'Hash::Ordered' => '0.011', 'Import::Into' => '0', 'IO::Handle' => '0', - 'Getargs::Mixed' => '1.03', # no Changes file - take the latest + 'Getargs::Mixed' => '1.04', # For -undef_ok option 'Getopt::Long' => '2.5', # For long option bugfix 'Graph' => '0.9704', # For latest multiedged support 'List::MoreUtils' => '0.428', diff --git a/lib/Data/Hopen.pm b/lib/Data/Hopen.pm index 26eb35b..c64d86e 100644 --- a/lib/Data/Hopen.pm +++ b/lib/Data/Hopen.pm @@ -10,7 +10,7 @@ our (@EXPORT, @EXPORT_OK, %EXPORT_TAGS); BEGIN { # TODO move more of these to a separate utility package? # Probably keep hnew, hlog, $VERBOSE, and $QUIET here. - @EXPORT = qw(hnew hlog); + @EXPORT = qw(hnew hlog getparameters); @EXPORT_OK = qw(loadfrom $VERBOSE $QUIET UNSPECIFIED NOTHING isMYH MYH); %EXPORT_TAGS = ( default => [@EXPORT], @@ -19,9 +19,10 @@ BEGIN { } use Data::Hopen::Util::NameSet; +use Getargs::Mixed; use Storable (); -our $VERSION = '0.000009'; # TRIAL +our $VERSION = '0.000010'; # Docs {{{1 @@ -205,6 +206,20 @@ sub isMYH { return ($name =~ /\b\Q@{[MYH]}\E$/) } #isMYH() +=head2 getparameters + +An alias of the C function from L, but with +C<-undef_ok> set. + +=cut + +my $GM = Getargs::Mixed->new(-undef_ok => true); + +sub getparameters { + unshift @_, $GM; + goto &Getargs::Mixed::parameters; +} #getparameters() + =head1 CONSTANTS =head2 UNSPECIFIED diff --git a/lib/Data/Hopen/Arrrgs.pm b/lib/Data/Hopen/Arrrgs.pm deleted file mode 100755 index 75d63c6..0000000 --- a/lib/Data/Hopen/Arrrgs.pm +++ /dev/null @@ -1,281 +0,0 @@ -package Data::Hopen::Arrrgs; # A tweaked version of Getopt::Mixed - -use 5.008; -use strict; -use warnings; - -use Carp; - -require Exporter; - -our @ISA = qw(Exporter); - -our @EXPORT = qw( parameters ); - -our $VERSION = '0.000009'; # TRIAL - -=head1 NAME - -Data::Hopen::Arrrgs - Perl extension allowing subs to handle mixed parameter lists - -=head1 SYNOPSIS - -This is a tweaked version of L. See -L. - - use Data::Hopen::Arrrgs; - - sub foo { - my %args = parameters([ qw( x y z ) ], @_); - - # Do stuff with @args{qw(x y z)} - } - - # OR if you have object-oriented syntax - sub bar { - my ($self, %args) = parameters('self', [ qw( x y z ) ], @_); - - # Do stuff with @args{qw(x y z)} - } - - # OR if you have mixed OO and function syntax - sub baz { - my ($self, %args) = parameters('My::Class', [ qw( x y z ) ], @_); - - # Do stuff with @args{qw(x y z)} - } - - # Calling foo: - foo($x, $y, $z); - foo($x, -z => $z, -y => $y); - foo(-z => $z, -x => $x, -y => $y); - - # ERRORS! calling foo: - foo(-z => $z, $x, $y); ### <-- ERROR! - foo(x => $x, y => $y, z => $z); ### <-- ERROR! - foo($x, -y => $y, $z); ### <-- ERROR! - foo($x, $y, $z, -x => $blah); ### <-- ERROR! - - # Calling bar: - $obj->bar($x, $y, $z); - $obj->bar($x, -z => $z, -y => $y); - My::Class->bar(-z => $z, -x => $x, -y => $y); # etc... - - # Calling baz is slight dangerous! UNIVERSAL::isa($x, 'My::Class') better not - # be true in the last case or problems may arrise! - $obj->baz($x, $y, $z); - My::Class->baz($x, -z => $z, -y => $y); - baz($x, -z => $z, -y => $y); # etc... - -=head1 DESCRIPTION - -This allows for the handling mixed argument lists to subroutines. It is meant -to be flexible and lightweight. It doesn't do any "type-checking", it simply -turns your parameter lists into hash according to a simple specification. - -The only function in this module is C and it handles all the work -of figuring out which parameters have been sent and which have not. When it -detects an error, it will die with L. - -=head2 ARGUMENTS - -The C function takes either two or three arguments. If the first -argument is a string, it takes three arguments. If the first argument is -an array reference, it takes just two. - -=head3 INVOCANT - -If the first parameter is a string, it should either be a package name or the -special string C<"self">. Passing C<"self"> in this argument will cause the -C function to require an invocant on the method--that is, it must -be called like this: - - $obj->foo($a, $b, $c); # OR - foo $obj ($a, $b, $c); # often seen as new My::Class (...) - -where C<$obj> is either a blessed reference, package name, or a scalar -containing a package name. - -If, instead, the first parameter is a string, but not equal to C<"self">. The -string is considered to be a package name. In this case, C tries to -guess how the method is being called. This has a lot of potential caveats, so -B! Essentially, C will check to see if the first argument is -a subclass of the given package name (i.e., according to -L. If so, it will I (pronounced -Ass-You-Me) that the argument is the invocant. Otherwise, it will I -that the argument is the first parameter. In this case, the returned list will -contain the given package name as the first element before the list of pairs -even though no invocant was actually used. - -=head3 SPECIFICATION - -The array reference argument to C contains a list of variable names -that the caller accepts. The parameter list is ordered so that if the user -passes positional parameters, the same order the parameters are placed, will be -the order used to set the variables in the returned hash. The list may contain -a single semicolon, which tells C that all parameters up to that -point are required and all following are optional. If no semicolon exists, then -C will consider all to be required and die when one of the required -parameters is missing. - -Finally, the list may end with a '*' which will cause C to collect -any extra unexpected named or positional parameters. Extra named parameters -will be inserted into the returned arguments list. Extra positional parameters -will be placed in array reference and assigned to the '*' key of the returned -arguments list. If '*' is not specified and extra arguments are found -C will die. - -=head3 ARGUMENTS - -The final argument to C is always the list of arguments passed to -the caller. - -=head2 RESULTS - -The result returned from the C function depends on whether there -are two arguments or three. If C is called with two arguments, -then a list of pairs (a hash) is returned. If C is called with -three arguments, then an invocant is prepended to the list of pairs first. -If the first argument is not C<"self">, then the invocant will be set to the -first argument if C doesn't detect any invocant. - -=head2 ARGUMENT PARSING - -The way C handles arguments is relatively flexible. However, the -format must always specify all positional parameters first, if any, followed by -all positional parameters. The C function switches from positional -to named parameters when it encounters the first string preceded with a hypen -('-'). This may have the unfortunate side effect of causing normal parameters to -be misinterpreted as named parameters. If this may be the case with your usage, -I suggest finding another solution--or modifying this module to suit. A safe -solution to this is to always use named parameters--at which point you might -as well not use this module anyway. - -=cut - -sub parameters { - my ($invocant, $spec); - if (ref $_[0] eq 'ARRAY') { - $spec = shift; - } elsif (ref $_[0]) { - croak "Getopt::Mixed doesn't handle a ",ref $_[0]," as a parameter."; - } else { - $invocant = shift; - $spec = shift; - } - - croak "Getopt::Mixed specification contains more than one semicolon." - if grep /;/, @$spec > 1; - - # Extract invocant - my $self; - if (defined $invocant) { - if ($invocant eq 'self') { - $self = shift; - } else { - if (UNIVERSAL::isa($_[0], $invocant)) { - $self = shift; - } else { - $self = $invocant; - } - } - } - - # This works because I break-out when I modify $spec - my @required; - for (0 .. $#$spec) { - last if $$spec[$_] eq '*'; - if ($$spec[$_] eq ';') { - splice(@$spec, $_, 1); - - last; - } elsif ($$spec[$_] =~ /;/) { - my @els = split /;/, $$spec[$_]; - shift @els if $els[0] eq ''; - - croak "Getopt::Mixed specification contains more than one semicolon." - if @els > 2; - - push @required, $els[0] unless $$spec[$_] =~ /^;/; - splice(@$spec, $_, 1, @els); - - last; - } - - push @required, $$spec[$_]; - } - - - my %result; - - # Scan for positional parameters - while (@_ > 0) { - last if defined $_[0] and $_[0] =~ /^-/; # stop if named - if ($$spec[0] eq '*') { - push @{$result{'*'}}, shift; - } else { - $result{shift @$spec} = shift; - } - } - - # Scan for named parameters - my %named = @_; - while (my ($k, $v) = each %named) { - confess "Illegal switch back to positional arguments." - if $k !~ /^-/; - - my $name = substr $k, 1; - - confess "Illegal argument: $name specified twice." - if exists $result{$name}; - confess "Illegal argument: $name unknown." - unless (@$spec > 0 and @$spec[-1] eq '*') or grep { $name eq $_ } @$spec; - - $result{$name} = $v; - } - - my @missing = grep { !exists $result{$_} } @required; - if (@missing) { - confess "Missing these required arguments: ",join(', ',@missing); - } - - return defined $self ? ($self, %result) : %result; -} - -=head2 EXPORT - -Always exports C by default. If you do not want this, use: - - use Data::Hopen::Arrrgs (); - # OR - require Data::Hopen::Arrrgs; - - # ... - my %args = Data::Hopen::Arrrgs::parameters([ qw( x y z ) ], @_); - -=head1 SEE ALSO - -Other similar modules to this one that I'm aware of include: -L, L, and L. - -=head1 BUGS - -This is probably backwards compatible to Perl 5.6 and even earlier but no -attempt has been made to test this theory. - -I suspect this is rather slower than it could be. I hacked this together in an -afternoon without a whole lot of planning. - -=head1 AUTHOR - -Andrew Sterling Hanenkamp, Ehanenkamp@users.sourceforge.netE. Contact -me at this address for support. - -=head1 COPYRIGHT AND LICENSE - -Copyright 2003 by Andrew Sterling Hanenkamp - -This library is free software; you can redistribute it and/or modify -it under the same terms as Perl itself. - -=cut diff --git a/lib/Data/Hopen/Base.pm b/lib/Data/Hopen/Base.pm index fe385e0..f65d26c 100755 --- a/lib/Data/Hopen/Base.pm +++ b/lib/Data/Hopen/Base.pm @@ -8,7 +8,7 @@ package Data::Hopen::Base; use parent 'Exporter'; use Import::Into; -our $VERSION = '0.000009'; # TRIAL +our $VERSION = '0.000010'; # Pragmas use 5.014; diff --git a/lib/Data/Hopen/G.pod b/lib/Data/Hopen/G.pod index bd9579a..57b9059 100644 --- a/lib/Data/Hopen/G.pod +++ b/lib/Data/Hopen/G.pod @@ -20,8 +20,8 @@ Classes are (all under C): PassthroughOp - no-op concrete operation DAG - the graph -Specific use cases of the graph are not under C<...::G>. For example, -tools used in the hopen build system are under L. +Specific use cases of the graph are not under C<...::G>, such as +tools used in the hopen build system (L). =head1 ELEMENTS diff --git a/lib/Data/Hopen/G/CollectOp.pm b/lib/Data/Hopen/G/CollectOp.pm index 8d9b0fe..97cf470 100755 --- a/lib/Data/Hopen/G/CollectOp.pm +++ b/lib/Data/Hopen/G/CollectOp.pm @@ -1,17 +1,16 @@ # Data::Hopen::G::CollectOp - pull values from scope(s) package Data::Hopen::G::CollectOp; -use Data::Hopen qw(:default UNSPECIFIED); use Data::Hopen::Base; -our $VERSION = '0.000009'; # TRIAL +our $VERSION = '0.000010'; use parent 'Data::Hopen::G::Op'; use Class::Tiny { levels => 'local', }; +use Data::Hopen qw(:default UNSPECIFIED); use Data::Hopen::Util::Data qw(clone forward_opts); -use Data::Hopen::Arrrgs; use Storable (); # Docs {{{1 @@ -52,7 +51,7 @@ See L for more details. =cut sub _run { - my ($self, %args) = parameters('self', [qw(*)], @_); + my ($self, %args) = getparameters('self', [qw(*)], @_); hlog { Running => __PACKAGE__ , $self->name }; return $self->passthrough(-nocontext => 1, -levels => $self->levels); # -nocontext because Runnable::run() already hooked in the context diff --git a/lib/Data/Hopen/G/DAG.pm b/lib/Data/Hopen/G/DAG.pm index 222b964..9e3cc98 100755 --- a/lib/Data/Hopen/G/DAG.pm +++ b/lib/Data/Hopen/G/DAG.pm @@ -1,9 +1,8 @@ # Data::Hopen::G::DAG - hopen build graph package Data::Hopen::G::DAG; use Data::Hopen::Base; -use Data::Hopen qw(hlog $QUIET); -our $VERSION = '0.000009'; # TRIAL +our $VERSION = '0.000010'; use parent 'Data::Hopen::G::Op'; use Class::Tiny { @@ -26,12 +25,12 @@ use Class::Tiny { # TODO? also support fini to run operations after _graph runs? }; +use Data::Hopen qw(hlog getparameters $QUIET); use Data::Hopen::G::Goal; use Data::Hopen::G::Link; use Data::Hopen::G::Node; use Data::Hopen::G::CollectOp; use Data::Hopen::Util::Data qw(forward_opts); -use Data::Hopen::Arrrgs; use Graph; use Storable (); @@ -109,7 +108,7 @@ Other options are as L. # The implementation of run(). $self->scope has already been linked to the context. sub _run { - my ($self, %args) = parameters('self', [qw(; phase generator)], @_); + my ($self, %args) = getparameters('self', [qw(; phase generator)], @_); my $retval = {}; # --- Get the initialization ops --- diff --git a/lib/Data/Hopen/G/Entity.pm b/lib/Data/Hopen/G/Entity.pm index 5703ec3..e25cfd4 100755 --- a/lib/Data/Hopen/G/Entity.pm +++ b/lib/Data/Hopen/G/Entity.pm @@ -3,7 +3,7 @@ package Data::Hopen::G::Entity; use Data::Hopen; use Data::Hopen::Base; -our $VERSION = '0.000009'; # TRIAL +our $VERSION = '0.000010'; sub name; diff --git a/lib/Data/Hopen/G/FilesOp.pm b/lib/Data/Hopen/G/FilesOp.pm deleted file mode 100755 index 1381ed4..0000000 --- a/lib/Data/Hopen/G/FilesOp.pm +++ /dev/null @@ -1,49 +0,0 @@ -# Data::Hopen::G::FilesOp - Op that outputs a list of files. -package Data::Hopen::G::FilesOp; -use Data::Hopen; -use Data::Hopen::Base; - -our $VERSION = '0.000009'; # TRIAL - -use parent 'Data::Hopen::G::Op'; -use Class::Tiny { - files => sub { [] }, -}; - -# Docs {{{1 - -=head1 NAME - -Data::Hopen::G::FilesOp - Op that holds a list of files. - -=head1 SYNOPSIS - - my $node = Data::Hopen::G::FilesOp(files=>['foo.c'], name=>'foo node'); - -Used by L. - -=head1 FUNCTIONS - -=cut - -# }}}1 - -=head2 run - -Output a C record holding the given names. See -L. - -=cut - -sub _run { - my $self = shift or croak 'Need an instance'; - - return { work => [ { - from => [], how => undef, - to => $self->files - } ] }; -} #run() - -1; -__END__ -# vi: set fdm=marker: # diff --git a/lib/Data/Hopen/G/Goal.pm b/lib/Data/Hopen/G/Goal.pm index 7c927a5..047cbf5 100755 --- a/lib/Data/Hopen/G/Goal.pm +++ b/lib/Data/Hopen/G/Goal.pm @@ -1,14 +1,13 @@ # Data::Hopen::G::Goal - A named build goal package Data::Hopen::G::Goal; -use Data::Hopen; use Data::Hopen::Base; -our $VERSION = '0.000009'; # TRIAL +our $VERSION = '0.000010'; use parent 'Data::Hopen::G::Op'; #use Class::Tiny qw(_passthrough); -use Data::Hopen::Arrrgs; +use Data::Hopen; use Data::Hopen::Util::Data qw(forward_opts); # Docs {{{1 @@ -35,7 +34,7 @@ Wraps a L's run function. # }}}1 sub _run { - my ($self, %args) = parameters('self', [qw(; phase generator)], @_); + my ($self, %args) = getparameters('self', [qw(; phase generator)], @_); hlog { Goal => $self->name }; return $self->passthrough(-nocontext=>1, -levels => 'local', forward_opts(\%args, {'-'=>1}, qw[phase generator])); diff --git a/lib/Data/Hopen/G/GraphBuilder.pm b/lib/Data/Hopen/G/GraphBuilder.pm index 16d6952..81f3fc2 100755 --- a/lib/Data/Hopen/G/GraphBuilder.pm +++ b/lib/Data/Hopen/G/GraphBuilder.pm @@ -6,7 +6,7 @@ use Exporter 'import'; our @EXPORT; BEGIN { @EXPORT=qw(make_GraphBuilder); } -our $VERSION = '0.000009'; # TRIAL +our $VERSION = '0.000010'; use Class::Tiny { name => sub { 'ANON' }, # Name is optional; it's here so the diff --git a/lib/Data/Hopen/G/Link.pm b/lib/Data/Hopen/G/Link.pm index 4916549..9eb3b40 100755 --- a/lib/Data/Hopen/G/Link.pm +++ b/lib/Data/Hopen/G/Link.pm @@ -1,17 +1,16 @@ # Data::Hopen::G::Link - base class for hopen edges package Data::Hopen::G::Link; -use Data::Hopen qw(:default UNSPECIFIED); use Data::Hopen::Base; -our $VERSION = '0.000009'; # TRIAL +our $VERSION = '0.000010'; use parent 'Data::Hopen::G::Runnable'; use Class::Tiny { greedy => 0 }; +use Data::Hopen qw(:default UNSPECIFIED); use Data::Hopen::Util::Data qw(clone); -use Data::Hopen::Arrrgs; =head1 NAME @@ -36,7 +35,7 @@ The output is C<{}> if no inputs are provided. =cut sub _run { - my ($self, %args) = parameters('self', [qw(; phase generator)], @_); + my ($self, %args) = getparameters('self', [qw(; phase generator)], @_); return $self->passthrough(-nocontext => 1); } #run() diff --git a/lib/Data/Hopen/G/Node.pm b/lib/Data/Hopen/G/Node.pm index 51d92d3..58098fa 100755 --- a/lib/Data/Hopen/G/Node.pm +++ b/lib/Data/Hopen/G/Node.pm @@ -3,7 +3,7 @@ package Data::Hopen::G::Node; use Data::Hopen; use Data::Hopen::Base; -our $VERSION = '0.000009'; # TRIAL +our $VERSION = '0.000010'; sub outputs; diff --git a/lib/Data/Hopen/G/Op.pm b/lib/Data/Hopen/G/Op.pm index f76d456..25f45b7 100644 --- a/lib/Data/Hopen/G/Op.pm +++ b/lib/Data/Hopen/G/Op.pm @@ -3,7 +3,7 @@ package Data::Hopen::G::Op; use Data::Hopen; use Data::Hopen::Base; -our $VERSION = '0.000009'; # TRIAL +our $VERSION = '0.000010'; use parent 'Data::Hopen::G::Node'; use Class::Tiny; diff --git a/lib/Data/Hopen/G/Runnable.pm b/lib/Data/Hopen/G/Runnable.pm index 7e18518..df99611 100755 --- a/lib/Data/Hopen/G/Runnable.pm +++ b/lib/Data/Hopen/G/Runnable.pm @@ -1,14 +1,13 @@ # Data::Hopen::G::Runnable - parent class for anything runnable in a hopen graph package Data::Hopen::G::Runnable; use Data::Hopen::Base; -use Data::Hopen; -our $VERSION = '0.000009'; # TRIAL +our $VERSION = '0.000010'; +use Data::Hopen; use Data::Hopen::Scope::Hash; use Data::Hopen::Util::Data qw(forward_opts); use Data::Hopen::Util::NameSet; -use Data::Hopen::Arrrgs; use Hash::Merge; # Docs {{{1 @@ -95,7 +94,7 @@ scope. =cut sub run { - my ($self, %args) = parameters('self', [qw(; context phase generator nocontext)], @_); + my ($self, %args) = getparameters('self', [qw(; context phase generator nocontext)], @_); my $context_scope = $args{context}; # which may be undef - that's OK croak "Can't combine -context and -nocontext" if $args{context} && $args{nocontext}; @@ -123,7 +122,7 @@ context, and must return a new hashref. =cut sub _run { - my ($self, %args) = parameters('self', [qw(; phase generator)], @_); + my ($self, %args) = getparameters('self', [qw(; phase generator)], @_); ... } @@ -142,7 +141,7 @@ Other valid options include L<-levels|Data::Hopen::Scope/$levels>. =cut sub passthrough { - my ($self, %args) = parameters('self', ['*'], @_); + my ($self, %args) = getparameters('self', ['*'], @_); my $outer_scope = $args{context}; # which may be undef - that's OK croak "Can't combine -context and -nocontext" if $args{context} && $args{nocontext}; diff --git a/lib/Data/Hopen/Scope.pm b/lib/Data/Hopen/Scope.pm index 072ae5a..32eb742 100755 --- a/lib/Data/Hopen/Scope.pm +++ b/lib/Data/Hopen/Scope.pm @@ -3,7 +3,7 @@ package Data::Hopen::Scope; use Data::Hopen::Base; use Exporter 'import'; -our $VERSION = '0.000009'; # TRIAL +our $VERSION = '0.000010'; # Class definition use Class::Tiny { @@ -24,8 +24,8 @@ sub FIRST_ONLY { $_first_only } use constant _LOCAL => 'local'; # What we use +use Data::Hopen qw(getparameters); use Config; -use Data::Hopen::Arrrgs; use POSIX (); use Data::Hopen::Util::Data qw(clone forward_opts); use Set::Scalar; @@ -186,7 +186,7 @@ Dies if given a falsy name, notably, C<'0'>. =cut sub find { - my ($self, %args) = parameters('self', [qw(name ; set levels)], @_); + my ($self, %args) = getparameters('self', [qw(name ; set levels)], @_); croak 'Need a name' unless $args{name}; # Therefore, '0' is not a valid name my $levels = $args{levels}; @@ -217,7 +217,7 @@ TODO? Support a C<$set> parameter? =cut sub names { - my ($self, %args) = parameters('self', [qw(; levels)], @_); + my ($self, %args) = getparameters('self', [qw(; levels)], @_); my $retval = Set::Scalar->new; $self->_fill_names($retval, $args{levels}); return $retval; @@ -226,7 +226,7 @@ sub names { # Implementation of names() sub _fill_names { #say Dumper(\@_); - my ($self, %args) = parameters('self', [qw(retval levels)], @_); + my ($self, %args) = getparameters('self', [qw(retval levels)], @_); $self->_names_here($args{retval}); # Insert this scope's names @@ -252,7 +252,7 @@ TODO? Support a C<$set> parameter? =cut sub as_hashref { - my ($self, %args) = parameters('self', [qw(; levels deep)], @_); + my ($self, %args) = getparameters('self', [qw(; levels deep)], @_); my $hrRetval = {}; $self->_fill_hashref($hrRetval, $args{deep}, $args{levels}); return $hrRetval; @@ -261,7 +261,7 @@ sub as_hashref { # Implementation of as_hashref. Mutates the provided $hrRetval. # TODO move this to subclasses. sub _fill_hashref { - my ($self, %args) = parameters('self', [qw(retval levels deep)], @_); + my ($self, %args) = getparameters('self', [qw(retval levels deep)], @_); my $hrRetval = $args{retval}; # Innermost wins, so copy ours first. @@ -288,7 +288,7 @@ C<$new_outer> may be C or a valid C. =cut sub outerize { - my ($self, %args) = parameters('self', [qw(outer)], @_); + my ($self, %args) = getparameters('self', [qw(outer)], @_); croak 'Need a Scope' unless (!defined($args{outer})) or diff --git a/lib/Data/Hopen/Scope/Environment.pm b/lib/Data/Hopen/Scope/Environment.pm index 34d9ebd..acf0877 100755 --- a/lib/Data/Hopen/Scope/Environment.pm +++ b/lib/Data/Hopen/Scope/Environment.pm @@ -1,13 +1,12 @@ # Data::Hopen::Scope::Environment - a hopen Scope for %ENV package Data::Hopen::Scope::Environment; use Data::Hopen::Base; -use Data::Hopen qw(hlog); -our $VERSION = '0.000009'; # TRIAL +our $VERSION = '0.000010'; use parent 'Data::Hopen::Scope'; -use Data::Hopen::Arrrgs; +use Data::Hopen qw(hlog getparameters); use Set::Scalar; # Docs {{{1 @@ -50,7 +49,7 @@ failure. =cut sub _find_here { - my ($self, %args) = parameters('self', [qw(name ; set)], @_); + my ($self, %args) = getparameters('self', [qw(name ; set)], @_); _set0 $args{set} or croak 'I only support set 0'; my $val = $ENV{$args{name}}; return undef unless defined $val; @@ -81,7 +80,7 @@ Add the names in C<%ENV> to the given L. =cut sub _names_here { - my ($self, %args) = parameters('self', [qw(retval ; set)], @_); + my ($self, %args) = getparameters('self', [qw(retval ; set)], @_); _set0 $args{set} or croak 'I only support set 0'; $args{retval}->insert(keys %ENV); hlog { __PACKAGE__ . '::_names_here', Dumper $args{retval} }; diff --git a/lib/Data/Hopen/Scope/Hash.pm b/lib/Data/Hopen/Scope/Hash.pm index 8ae3d94..1e3f4e1 100755 --- a/lib/Data/Hopen/Scope/Hash.pm +++ b/lib/Data/Hopen/Scope/Hash.pm @@ -2,15 +2,15 @@ package Data::Hopen::Scope::Hash; use Data::Hopen::Base; -our $VERSION = '0.000009'; # TRIAL +our $VERSION = '0.000010'; use parent 'Data::Hopen::Scope'; use Class::Tiny { _content => sub { +{} }, # Our storage }; +use Data::Hopen qw(getparameters); #use Data::Hopen::Util::Data qw(clone); -use Data::Hopen::Arrrgs; use Set::Scalar; #use Sub::ScopeFinalizer qw(scope_finalizer); @@ -133,7 +133,7 @@ No return value. =cut sub _names_here { - my ($self, %args) = parameters('self', [qw(retval ; set)], @_); + my ($self, %args) = getparameters('self', [qw(retval ; set)], @_); _set0 $args{set} or croak 'I only support set 0'; $args{retval}->insert(keys %{$self->_content}); } #_names_here() @@ -149,7 +149,7 @@ Returns the value, or C if not found. =cut sub _find_here { - my ($self, %args) = parameters('self', [qw(name ; set)], @_); + my ($self, %args) = getparameters('self', [qw(name ; set)], @_); _set0 $args{set} or croak 'I only support set 0'; my $val = $self->_content->{$args{name}}; diff --git a/lib/Data/Hopen/Scope/Inputs.pm b/lib/Data/Hopen/Scope/Inputs.pm index 95bab82..5e64db2 100644 --- a/lib/Data/Hopen/Scope/Inputs.pm +++ b/lib/Data/Hopen/Scope/Inputs.pm @@ -3,7 +3,7 @@ package Data::Hopen::Scope::Inputs; use Data::Hopen; use Data::Hopen::Base; -our $VERSION = '0.000009'; # TRIAL +our $VERSION = '0.000010'; # TODO if a class use parent 'Data::Hopen::Scope'; diff --git a/lib/Data/Hopen/Scope/Overrides.pm b/lib/Data/Hopen/Scope/Overrides.pm index d3c5fe5..f15a76f 100755 --- a/lib/Data/Hopen/Scope/Overrides.pm +++ b/lib/Data/Hopen/Scope/Overrides.pm @@ -3,7 +3,7 @@ package Data::Hopen::Scope::Overrides; use Data::Hopen; use Data::Hopen::Base; -our $VERSION = '0.000009'; # TRIAL +our $VERSION = '0.000010'; # TODO if using exporter use parent 'Exporter'; diff --git a/lib/Data/Hopen/TEMPLATE.pm b/lib/Data/Hopen/TEMPLATE.pm index 85ee13a..3b41670 100755 --- a/lib/Data/Hopen/TEMPLATE.pm +++ b/lib/Data/Hopen/TEMPLATE.pm @@ -3,7 +3,7 @@ package Data::Hopen::TEMPLATE; use Data::Hopen; use Data::Hopen::Base; -our $VERSION = '0.000009'; # TRIAL +our $VERSION = '0.000010'; # TODO if using exporter use parent 'Exporter'; diff --git a/lib/Data/Hopen/Tool.pm b/lib/Data/Hopen/Tool.pm deleted file mode 100755 index 3ea3c01..0000000 --- a/lib/Data/Hopen/Tool.pm +++ /dev/null @@ -1,39 +0,0 @@ -# Data::Hopen::Tool - base class for a hopen tool. -package Data::Hopen::Tool; -use Data::Hopen; -use Data::Hopen::Base; - -our $VERSION = '0.000009'; # TRIAL - -use parent 'Data::Hopen::G::Op'; -use Class::Tiny; - -# Docs {{{1 - -=head1 NAME - -Data::Hopen::Tool - Base class for packages that know how to process files - -=head1 SYNOPSIS - -A tool knows how to generate a command or other text that will cause -a build system to perform a particular action on a file belonging to a -particular language. - -A tool is a L, so may interact with the current -generator (L). Moreover, the generator will -get a chance to visit the op after it is processed. - -Maybe TODO: - - Each Generator must specify a list of Content-Types (media types) - it can consume. Each Tool must specify a specific content-type - it produces. Mismatches are an error unless overriden on the - hopen command line. - -=cut - -# }}}1 - -1; -__END__ -# vi: set fdm=marker: # diff --git a/lib/Data/Hopen/Toolchain.pm b/lib/Data/Hopen/Toolchain.pm deleted file mode 100755 index d3b0a63..0000000 --- a/lib/Data/Hopen/Toolchain.pm +++ /dev/null @@ -1,92 +0,0 @@ -# Data::Hopen::Toolchain - SUPERSEDED base class for hopen toolchains -package Data::Hopen::Toolchain; -use Data::Hopen; -use Data::Hopen::Base; - -our $VERSION = '0.000009'; # TRIAL - -use Class::Tiny qw(proj_dir dest_dir), { - architecture => '', -}; - -# Docs {{{1 - -=head1 NAME - -Data::Hopen::Toolchain - SUPERSEDED base class for hopen toolchains - -=head1 SYNOPSIS - -TODO - - change this to "Tool" instead of "Toolchain" - - permit loading any number of tools - - The Generator specifies a default list of tools rather than a - single default toolchain. - - add G::ToolOp to invoke tools. A ToolOp will take a language - and an opcode and invoke a corresponding Tool. E.g., a GNU C - Tool will generate command-line options for gcc-style command lines. - - Only one Tool may be loaded for each (language, opcode) pair. - Otherwise the build would be ambiguous. - - In Conventions, define the formats for languages and opcodes. - -Maybe TODO: - - Each Generator must specify a list of Content-Types (media types) - it can consume. Each Tool must specify a specific content-type - it produces. Mismatches are an error unless overriden on the - hopen command line. - -The code that generates command lines to invoke specific toolchains lives under -C. Those modules must implement the interface defined -here. - -=head1 ATTRIBUTES - -=head2 proj_dir - -A L instance specifying the root directory of the project - -=head2 dest_dir - -A L instance specifying where the generated output -should be written. - -=head1 FUNCTIONS - -A toolchain (C subclass) is a Visitor. - -TODO Figure out if the toolchain has access to L -instances. - -=cut - -# }}}1 - -=head2 visit_goal - -Do whatever the toolchain wants to do with a L. -By default, no-op. - -=cut - -sub visit_goal { } - -=head2 visit_op - -Do whatever the toolchain wants to do with a L that -is not a Goal (see L). By default, no-op. - -=cut - -sub visit_op { } - -=head2 finalize - -Do whatever the toolchain wants to do to finish up. - -=cut - -sub finalize { } - -false; # SUPERSEDED --- will be removed. -__END__ -# vi: set fdm=marker: # diff --git a/lib/Data/Hopen/Util/Data.pm b/lib/Data/Hopen/Util/Data.pm index ef4cafd..3e3dec7 100755 --- a/lib/Data/Hopen/Util/Data.pm +++ b/lib/Data/Hopen/Util/Data.pm @@ -3,7 +3,7 @@ package Data::Hopen::Util::Data; use Data::Hopen; use Data::Hopen::Base; -our $VERSION = '0.000009'; # TRIAL +our $VERSION = '0.000010'; use parent 'Exporter'; our (@EXPORT, @EXPORT_OK, %EXPORT_TAGS); @@ -137,7 +137,7 @@ If truthy, lower-case the key names in the output =item '-' If present, add C<-> to the beginning of each name in the output. -This is useful with L. +This is useful with L. =back diff --git a/lib/Data/Hopen/Util/Filename.pm b/lib/Data/Hopen/Util/Filename.pm index c83372c..5b02769 100755 --- a/lib/Data/Hopen/Util/Filename.pm +++ b/lib/Data/Hopen/Util/Filename.pm @@ -1,9 +1,8 @@ # Data::Hopen::Util::Filename - functions for manipulating filenames package Data::Hopen::Util::Filename; -use Data::Hopen; use Data::Hopen::Base; -our $VERSION = '0.000009'; # TRIAL +our $VERSION = '0.000010'; use parent 'Exporter'; our (@EXPORT, @EXPORT_OK, %EXPORT_TAGS); @@ -18,7 +17,7 @@ BEGIN { use Class::Method::Modifiers qw(fresh); use Config; -use Data::Hopen::Arrrgs; +use Data::Hopen; # Docs {{{1 @@ -67,7 +66,7 @@ BEGIN { [qw(lib _a lib_ext .a)]) { fresh $lrFunction->[0] => sub { - my (undef, %args) = parameters(__PACKAGE__, [qw(filename; strip)], @_); + my (undef, %args) = getparameters(__PACKAGE__, [qw(filename; strip)], @_); # __PACKAGE__ => Permit OO interface $args{filename} =~ s/\.[^.]*$// if $args{strip}; return $args{filename} . diff --git a/lib/Data/Hopen/Util/NameSet.pm b/lib/Data/Hopen/Util/NameSet.pm index 044748b..a2e5f06 100755 --- a/lib/Data/Hopen/Util/NameSet.pm +++ b/lib/Data/Hopen/Util/NameSet.pm @@ -2,7 +2,7 @@ package Data::Hopen::Util::NameSet; use Data::Hopen::Base; -our $VERSION = '0.000009'; # TRIAL +our $VERSION = '0.000010'; # Docs {{{1