File Coverage

blib/lib/RPerl/HelperFunctions_cpp.pm
Criterion Covered Total %
statement 34 37 91.8
branch 8 12 66.6
condition 4 9 44.4
subroutine 9 9 100.0
pod 0 1 0.0
total 55 68 80.8


line stmt bran cond sub pod time code
1             # [[[ HEADER ]]]
2             package RPerl::HelperFunctions_cpp;
3 9     9   1161 use strict;
  9         25  
  9         257  
4 9     9   50 use warnings;
  9         20  
  9         230  
5 9     9   52 use RPerl::Config; # get Carp, English, $RPerl::INCLUDE_PATH without 'use RPerl;'
  9         20  
  9         1436  
6              
7             #use RPerl; # DEV NOTE: need to use HelperFunctions in RPerl::DataStructure::Array for type checking SvIOKp() etc; remove dependency on RPerl void::method type so HelperFunctions can be loaded by RPerl type system
8             our $VERSION = 0.007_000;
9              
10             # [[[ CRITICS ]]]
11             ## no critic qw(ProhibitStringyEval) # SYSTEM DEFAULT 1: allow eval()
12              
13             # [[[ INCLUDES ]]]
14 9     9   3262 use RPerl::Inline;
  9         23  
  9         251  
15 9     9   3039 use rperltypessizes; # get type_integer_native_ccflag() & type_number_native_ccflag() w/out loading the entire RPerl type system via 'use rperltypes;'
  9         23  
  9         1962  
16              
17             # [[[ SUBROUTINES ]]]
18             #our void::method $cpp_load = sub { # DEV NOTE: remove dependency on RPerl
19             sub cpp_load {
20 28     28 0 88 my $need_load_cpp = 0;
21              
22 28 100 66     169 if ( ( exists $main::{'RPerl__HelperFunctions__MODE_ID'} )
23 28         246 and ( defined &{ $main::{'RPerl__HelperFunctions__MODE_ID'} } ) )
24             {
25             # RPerl::diag("in HelperFunctions_cpp::cpp_load, RPerl__HelperFunctions__MODE_ID() exists & defined\n");
26             # RPerl::diag(q{in HelperFunctions_cpp::cpp_load, have RPerl__HelperFunctions__MODE_ID() retval = '} . main::RPerl__HelperFunctions__MODE_ID() . "'\n");
27 19 50       243 if ( $RPerl::MODES->{ main::RPerl__HelperFunctions__MODE_ID() }->{ops} ne 'CPP' )
28             {
29 0         0 $need_load_cpp = 1;
30             }
31             }
32             else {
33             # RPerl::diag("in HelperFunctions_cpp::cpp_load, RPerl__HelperFunctions__MODE_ID() does not exist or undefined\n");
34 9         25 $need_load_cpp = 1;
35             }
36              
37             # DEV NOTE, CORRELATION #rp040: fix recursive dependencies of String.pm & HelperFunctions_cpp.pm, as triggered by ingy's Inline::create_config_file() system() call
38 28 50 33     385 if ((exists $ARGV[0]) and (defined $ARGV[0]) and ((substr $ARGV[0], -7, 7) eq '_Inline')) {
    100 33        
39             # RPerl::diag("in HelperFunctions_cpp::cpp_load, Inline recursion detected, SKIPPING\n");
40 0         0 1;
41             }
42             elsif ($need_load_cpp) {
43             # RPerl::diag("in HelperFunctions_cpp::cpp_load, need load CPP code\n");
44              
45             #BEGIN { RPerl::diag("[[[ BEGIN 'use Inline' STAGE for 'RPerl/HelperFunctions.cpp' ]]]\n" x 1); }
46 9         49 my $eval_string = <<"EOF";
47             package main;
48             use RPerl::Inline;
49             BEGIN { RPerl::diag("[[[ BEGIN 'use Inline' STAGE for 'RPerl/HelperFunctions.cpp' ]]]\n" x 1); }
50             # DEV NOTE, CORRELATION #rp040: fix recursive dependencies of String.pm & HelperFunctions_cpp.pm, as triggered by ingy's Inline::create_config_file() system() call
51             #BEGIN { \$DB::single = 1; }
52             use Inline (CPP => '$RPerl::INCLUDE_PATH' . '/RPerl/HelperFunctions.cpp', \%RPerl::Inline::ARGS);
53             RPerl::diag("[[[ END 'use Inline' STAGE for 'RPerl/HelperFunctions.cpp' ]]]\n" x 1);
54             1;
55             EOF
56              
57 9         65 $RPerl::Inline::ARGS{ccflagsex} = $RPerl::Inline::CCFLAGSEX . $RPerl::TYPES_CCFLAG . rperltypessizes::type_integer_native_ccflag() . rperltypessizes::type_number_native_ccflag();
58 9         50 $RPerl::Inline::ARGS{cppflags} = $RPerl::TYPES_CCFLAG . rperltypessizes::type_integer_native_ccflag() . rperltypessizes::type_number_native_ccflag();
59              
60             # RPerl::diag("in HelperFunctions_cpp::cpp_load(), CPP not yet loaded, have \%RPerl::Inline::ARGS =\n" . Dumper(\%RPerl::Inline::ARGS) . "\n");
61             # RPerl::diag("in HelperFunctions_cpp::cpp_load(), CPP not yet loaded, about to call eval() on \$eval_string =\n<<< BEGIN EVAL STRING>>>\n" . $eval_string . "<<< END EVAL STRING >>>\n");
62              
63 9 50   9   80 eval $eval_string or croak( $OS_ERROR . "\n" . $EVAL_ERROR );
  9     9   406  
  9     9   404  
  9         278  
  9         5062  
  9         127710  
  9         124  
  9         718  
64 9 50       56 if ($EVAL_ERROR) { croak($EVAL_ERROR); }
  0         0  
65              
66             #RPerl::diag("[[[ END 'use Inline' STAGE for 'RPerl/HelperFunctions.cpp' ]]]\n" x 1);
67 9         136 $RPerl::HelperFunctions_cpp::LOADING = 0;
68             }
69              
70             # else { RPerl::diag("in HelperFunctions_cpp::cpp_load(), CPP already loaded, DOING NOTHING\n"); }
71             }
72              
73             1;