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 7     7   40 use strict;
  7         12  
  7         179  
4 7     7   32 use warnings;
  7         12  
  7         149  
5 7     7   31 use RPerl::Config; # get Carp, English, $RPerl::INCLUDE_PATH without 'use RPerl;'
  7         12  
  7         879  
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 7     7   1659 use RPerl::Inline;
  7         25  
  7         279  
15 7     7   48 use rperltypessizes; # get type_integer_native_ccflag() & type_number_native_ccflag() w/out loading the entire RPerl type system via 'use rperltypes;'
  7         12  
  7         1725  
16              
17             # [[[ SUBROUTINES ]]]
18             sub cpp_load {
19             # { my void::method $RETURN_TYPE };
20 22     22 0 53 my $need_load_cpp = 0;
21              
22 22 100 66     100 if ( ( exists $main::{'RPerl__HelperFunctions__MODE_ID'} )
23 22         144 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 15 50       134 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 7         21 $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 22 50 33     210 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 7         37 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 7         52 $RPerl::Inline::ARGS{ccflagsex} = $RPerl::Inline::CCFLAGSEX . $RPerl::TYPES_CCFLAG . rperltypessizes::type_integer_native_ccflag() . rperltypessizes::type_number_native_ccflag();
58 7         31 $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 7 50   7   62 eval $eval_string or croak( $OS_ERROR . "\n" . $EVAL_ERROR );
  7     7   17  
  7     7   294  
  7         56  
  7         2986  
  7         103510  
  7         100  
  7         509  
64 7 50       40 if ($EVAL_ERROR) { croak($EVAL_ERROR); }
  0         0  
65              
66             #RPerl::diag("[[[ END 'use Inline' STAGE for 'RPerl/HelperFunctions.cpp' ]]]\n" x 1);
67 7         96 $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;