Skip to content

Commit

Permalink
Learning RPerl, Typo Fix; OO Classes Cont'd, Part 1
Browse files Browse the repository at this point in the history
  • Loading branch information
wbraswell committed Feb 23, 2017
1 parent 11634d8 commit 65b0584
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 65 deletions.
16 changes: 10 additions & 6 deletions docs/todo.txt
Expand Up @@ -5,7 +5,15 @@ DONE

DOING
Monolithic Modules, Fix Deps Warning & Create Tests

Parse::Eyapp regex fix & CPAN upload
implement 10 ops in CPPOPS_CPPTYPES
CODE GENERATION, CPPOPS_CPPTYPES MODE
ForEach.pm
finish .pl body generation
subroutines, final operation must be return operator
WHAT ELSE?!?

update pluto URL to official github repo, delete mirror repo
update tests to emit more useful failure info, for CPAN testers debugging
update CPPOPS_DUALTYPES reference files
remove explicit properties inheritance, Generator.pm & Grammar.eyp
Expand Down Expand Up @@ -59,11 +67,7 @@ DOING
split author tests (checking Changes file, etc) into xt/ directory,
split deps in Makefile.PL, possibly utilize AUTHOR_TESTING in travis-perl/helpers

CODE GENERATION, CPPOPS_CPPTYPES MODE
ForEach.pm
finish .pl body generation
subroutines, final operation must be return operator
WHAT ELSE?!?


INSTALLERS
Linux DEB
Expand Down
11 changes: 11 additions & 0 deletions lib/RPerl/CompileUnit/Module/Class.pm
Expand Up @@ -838,6 +838,17 @@ sub activate_subroutine {
if ($EVAL_ERROR) { croak($EVAL_ERROR); }
}
else {




# START HERE: why is sun() getting redefined and trigger ECOPR00 below???
# START HERE: why is sun() getting redefined and trigger ECOPR00 below???
# START HERE: why is sun() getting redefined and trigger ECOPR00 below???




# RPerl::diag( "in Class::activate_subroutine(), $subroutine_name is a non-method subroutine\n" );
if ( eval( 'defined(&main::' . $subroutine_name . ')' ) ) {
croak
Expand Down
4 changes: 2 additions & 2 deletions lib/RPerl/Learning.pm
Expand Up @@ -3,7 +3,7 @@ use RPerl;
package RPerl::Learning;
use strict;
use warnings;
our $VERSION = 0.180_000;
our $VERSION = 0.181_000;

# [[[ OO INHERITANCE ]]]
# NEED FIX: why does the following 'use parent' command cause $VERSION to become undefined???
Expand Down Expand Up @@ -699,7 +699,7 @@ L<http://shop.oreilly.com/product/0636920049517.do>

=item * Do you love learning about new languages and compilers?

=item * Do you miss you favorite old language Perl, and you're looking for a legitimate reason to go back?
=item * Do you miss your favorite old language Perl, and you're looking for a legitimate reason to go back?

=item * Are you a scientist and you just want your code to run really fast without the headaches of C or C++?

Expand Down
12 changes: 5 additions & 7 deletions t/09_interpret_execute.t
Expand Up @@ -9,7 +9,7 @@ BEGIN { $ENV{RPERL_WARNINGS} = 0; }
use strict;
use warnings;
use RPerl::AfterSubclass;
our $VERSION = 0.007_100;
our $VERSION = 0.008_000;

# [[[ CRITICS ]]]
## no critic qw(ProhibitUselessNoCritic ProhibitMagicNumbers RequireCheckedSyscalls) # USER DEFAULT 1: allow numeric values & print operator
Expand Down Expand Up @@ -81,7 +81,6 @@ find(
}

if ( ( $file =~ m/Good/ms ) or ( $file =~ m/good/ms ) or ( $file =~ m/NotBad/ms ) or ( $file =~ m/not_bad/ms ) ) {

open my filehandleref $FILE_HANDLE, '<', $file
or croak 'ERROR, Cannot open file ' . $file . ' for reading,' . $OS_ERROR . ', croaking';
while (<$FILE_HANDLE>) {
Expand Down Expand Up @@ -142,8 +141,8 @@ if ( $ENV{RPERL_VERBOSE} ) {

my integer $i = 0;

# NEED ANSWER: keep IPC::Run3 code, or revert back to original IPC::Open3 code???
foreach my $test_file ( sort keys %{$test_files} ) {

$i++;
if ( $ENV{RPERL_VERBOSE} ) {
Test::More::diag( 'Test File #' . $i . ' of ' . $number_of_test_files . ': ' . $test_file );
Expand Down Expand Up @@ -306,7 +305,7 @@ foreach my $test_file ( sort keys %{$test_files} ) {
}

sub preprocess_execute_error {
(my string_hashref $test_files, my string $file) = @_;
(my string_hashref $test_files, my string $file) = @ARG;
open my filehandleref $FILE_HANDLE, '<', $file
or croak 'ERROR, Cannot open file ' . $file . ' for reading,' . $OS_ERROR . ', croaking';
while (<$FILE_HANDLE>) {
Expand All @@ -319,7 +318,7 @@ sub preprocess_execute_error {
}

sub missing_errors_count {
(my string_hashref $test_files, my string $test_file, my string $stdout_generated, my string $stderr_generated) = @_;
(my string_hashref $test_files, my string $test_file, my string $stdout_generated, my string $stderr_generated) = @ARG;
my $missing_errors = [];
if ( defined $test_files->{$test_file}->{errors} ) {
foreach my $error ( @{ $test_files->{$test_file}->{errors} } ) {
Expand All @@ -334,7 +333,7 @@ sub missing_errors_count {
}

sub success_match {
(my string $test_file, my string_arrayref $test_file_successes, my string $stdout_generated_lines) = @_;
(my string $test_file, my string_arrayref $test_file_successes, my string $stdout_generated_lines) = @ARG;
# $RPerl::DEBUG = 0;
# $RPerl::VERBOSE = 0;

Expand All @@ -350,7 +349,6 @@ FOREACH_STDOUT_LINE: foreach my string $stdout_generated_line ( @{$stdout_genera

# each stdout line is only allowed to match one success string
if ( $stdout_generated_line =~ /\Q$success\E/xms ) {

# RPerl::diag( 'in 09_interpret_execute.t success_match(), MATCH' . "\n" );
shift @{ $test_file_successes };
if ( ( scalar @{ $test_file_successes } ) == 0 ) { last FOREACH_STDOUT_LINE; }
Expand Down
5 changes: 2 additions & 3 deletions t/12_parse.t
Expand Up @@ -9,7 +9,7 @@ BEGIN { $ENV{RPERL_WARNINGS} = 0; }
use strict;
use warnings;
use RPerl::AfterSubclass;
our $VERSION = 0.011_000;
our $VERSION = 0.012_000;

# [[[ CRITICS ]]]
## no critic qw(ProhibitUselessNoCritic ProhibitMagicNumbers RequireCheckedSyscalls) # USER DEFAULT 1: allow numeric values & print operator
Expand Down Expand Up @@ -191,5 +191,4 @@ for my $test_file ( sort keys %{$test_files} ) {
#RPerl::diag( 'in 12_parse.t, have $number_of_tests_run =' . $number_of_tests_run . "\n" );

done_testing();
#done_testing($number_of_tests_run);

#done_testing($number_of_tests_run);
91 changes: 44 additions & 47 deletions t/13_generate.t
Expand Up @@ -107,56 +107,55 @@ find(
(defined $ARGV[0]) ? $ARGV[0] : PATH_TESTS() # accept optional command-line argument
);

# locate all *.*OPS_*TYPES pre-compiled files in PATH_PRECOMPILED directory or ARGV command-line argument directory
find(
sub {
my $file = $File::Find::name;
# RPerl::diag('in 13_generate.t, find1, have $file = ' . $file . "\n");
# if ( $file !~ m/[.]pm$/xms ) { # TEMP DEBUGGING, ONLY FIND *.pm, NOT *.pl
# if ( $file !~ m/.*Module\/.*$/xms ) { # TEMP DEBUGGING, ONLY FIND FILES IN A CERTAIN DIRECTORY
# if ( $file =~ m/^(.*foo_bar_arith.*)[.].*OPS.*$/xms ) { # TEMP DEBUGGING, ONLY FIND CERTAIN FILES
if ( $file =~ m/^(.+)[.]\w+OPS_\w+TYPES$/gxms ) { # find all pre-compiled files
my string $file_base = $1;
# RPerl::diag('in 13_generate.t, have pre-compiled $file = ' . $file . "\n");
# RPerl::diag('in 13_generate.t, have pre-compiled $file_base = ' . $file_base . "\n");
if (($file_base =~ m/^(.*)[.]cpp$/gxms) or ($file_base =~ m/^(.*)[.]h$/gxms) or ($file_base =~ m/^(.*)[.]pmc$/gxms)) {
my string $file_prefix = $1;
# RPerl::diag('in 13_generate.t, find1, have pre-compiled $file_prefix = ' . $file_prefix . "\n");

# restore saved path, because File::Find changes directories while searching for files
my string $file_program = $file_prefix . '.pl';
my string $file_module = $file_prefix . '.pm';
# RPerl::diag('in 13_generate.t, find1, have $file_program = ' . $file_program . "\n");
# RPerl::diag('in 13_generate.t, find1, have $file_module = ' . $file_module . "\n");
my $file_program_full_path = File::Spec->catpath( $volume, $directories, $file_program );
my $file_module_full_path = File::Spec->catpath( $volume, $directories, $file_module );
# RPerl::diag('in 13_generate.t, find1, have $file_program_full_path = ' . $file_program_full_path . "\n");
# RPerl::diag('in 13_generate.t, find1, have $file_module_full_path = ' . $file_module_full_path . "\n");

if ((-e $file_program_full_path) and (-f $file_program_full_path) and (-T $file_program_full_path)) {
# RPerl::diag('in 13_generate.t, find1, have all reference code for *.pl file, pre-compiled $file_prefix = ' . $file_prefix . "\n");
$test_files->{$file_prefix . '.pl'} = undef;
}
elsif ((-e $file_module_full_path) and (-f $file_module_full_path) and (-T $file_module_full_path)) {
# RPerl::diag('in 13_generate.t, find1, have all reference code for *.pm file, pre-compiled $file_prefix = ' . $file_prefix . "\n");
$test_files->{$file_prefix . '.pm'} = undef;
}
else {
RPerl::warning( 'WARNING WTE13GE01, TEST GROUP 13, CODE GENERATOR: Missing non-compiled source code reference file ' . q{'} . $file_prefix . '.pl' . q{'} . ' or ' . q{'} . $file_prefix . '.pm' . q{'} . ', not performing difference check' . "\n" );
}
# locate all *.*OPS_*TYPES pre-compiled files in PATH_PRECOMPILED directory or ARGV command-line argument directory
find(
sub {
my $file = $File::Find::name;
# RPerl::diag('in 13_generate.t, find1, have $file = ' . $file . "\n");
# if ( $file !~ m/[.]pm$/xms ) { # TEMP DEBUGGING, ONLY FIND *.pm, NOT *.pl
# if ( $file !~ m/.*Module\/.*$/xms ) { # TEMP DEBUGGING, ONLY FIND FILES IN A CERTAIN DIRECTORY
# if ( $file =~ m/^(.*foo_bar_arith.*)[.].*OPS.*$/xms ) { # TEMP DEBUGGING, ONLY FIND CERTAIN FILES
if ( $file =~ m/^(.+)[.]\w+OPS_\w+TYPES$/gxms ) { # find all pre-compiled files
my string $file_base = $1;
# RPerl::diag('in 13_generate.t, have pre-compiled $file = ' . $file . "\n");
# RPerl::diag('in 13_generate.t, have pre-compiled $file_base = ' . $file_base . "\n");
if (($file_base =~ m/^(.*)[.]cpp$/gxms) or ($file_base =~ m/^(.*)[.]h$/gxms) or ($file_base =~ m/^(.*)[.]pmc$/gxms)) {
my string $file_prefix = $1;
# RPerl::diag('in 13_generate.t, find1, have pre-compiled $file_prefix = ' . $file_prefix . "\n");

# restore saved path, because File::Find changes directories while searching for files
my string $file_program = $file_prefix . '.pl';
my string $file_module = $file_prefix . '.pm';
# RPerl::diag('in 13_generate.t, find1, have $file_program = ' . $file_program . "\n");
# RPerl::diag('in 13_generate.t, find1, have $file_module = ' . $file_module . "\n");
my $file_program_full_path = File::Spec->catpath( $volume, $directories, $file_program );
my $file_module_full_path = File::Spec->catpath( $volume, $directories, $file_module );
# RPerl::diag('in 13_generate.t, find1, have $file_program_full_path = ' . $file_program_full_path . "\n");
# RPerl::diag('in 13_generate.t, find1, have $file_module_full_path = ' . $file_module_full_path . "\n");

if ((-e $file_program_full_path) and (-f $file_program_full_path) and (-T $file_program_full_path)) {
# RPerl::diag('in 13_generate.t, find1, have all reference code for *.pl file, pre-compiled $file_prefix = ' . $file_prefix . "\n");
$test_files->{$file_prefix . '.pl'} = undef;
}
elsif ((-e $file_module_full_path) and (-f $file_module_full_path) and (-T $file_module_full_path)) {
# RPerl::diag('in 13_generate.t, find1, have all reference code for *.pm file, pre-compiled $file_prefix = ' . $file_prefix . "\n");
$test_files->{$file_prefix . '.pm'} = undef;
}
else {
RPerl::warning( 'WARNING WTE13GE02, TEST GROUP 13, CODE GENERATOR: Unrecognized pre-compiled source code reference file base ' . q{'} . $file_base . q{'} . ', not performing difference check' . "\n" );
RPerl::warning( 'WARNING WTE13GE01, TEST GROUP 13, CODE GENERATOR: Missing non-compiled source code reference file ' . q{'} . $file_prefix . '.pl' . q{'} . ' or ' . q{'} . $file_prefix . '.pm' . q{'} . ', not performing difference check' . "\n" );
}
}
else { # not a pre-compiled file
# RPerl::diag('in 13_generate.t, have NOT pre-compiled $file = ' . $file . "\n");
return;
else {
RPerl::warning( 'WARNING WTE13GE02, TEST GROUP 13, CODE GENERATOR: Unrecognized pre-compiled source code reference file base ' . q{'} . $file_base . q{'} . ', not performing difference check' . "\n" );
}
},
# PATH_PRECOMPILED()
(defined $ARGV[0]) ? $ARGV[0] : PATH_PRECOMPILED() # accept optional command-line argument
);
}
else { # not a pre-compiled file
# RPerl::diag('in 13_generate.t, have NOT pre-compiled $file = ' . $file . "\n");
return;
}
},
(defined $ARGV[0]) ? $ARGV[0] : PATH_PRECOMPILED() # accept optional command-line argument
);

#=cut

Expand Down Expand Up @@ -216,7 +215,6 @@ for my $mode_id ( 2 , 0 ) { # CPPOPS_CPPTYPES, PERLOPS_PERLTYPES; DEV NOTE: r
# RPerl::diag( 'in 13_generate.t, top of secondary runloop, have $number_of_test_files = ' . $number_of_test_files . "\n" );

$modes = {
# dependencies => 'OFF', # unnecessary, handled by explicitly calling find_dependencies() below, only used for RPerl system deps; also find_parents()
dependencies => 'ON',
ops => $ops,
types => $types,
Expand Down Expand Up @@ -276,7 +274,6 @@ for my $mode_id ( 2 , 0 ) { # CPPOPS_CPPTYPES, PERLOPS_PERLTYPES; DEV NOTE: r
# find RPerl system deps such as 'use rperlsse;', 'use rperlgmp;', etc.;
# ignore return value, here we only care about $modes->{_enable_sse}, $modes->{_enable_gmp}, etc.;
# find_dependencies( $test_file, 0, $modes ); # second argument set to 0 for false value of $find_subdependencies_recurse
# find_dependencies( $test_file, 1, $modes );

$output_file_name_groups_tmp = generate_output_file_names( [$test_file], [], 1, $modes );
$output_file_name_group = $output_file_name_groups_tmp->[0];
Expand Down

0 comments on commit 65b0584

Please sign in to comment.