File Coverage

blib/lib/RPerl/HelperFunctions_cpp.pm
Criterion Covered Total %
statement 10 12 83.3
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 14 16 87.5


line stmt bran cond sub pod time code
1             # [[[ HEADER ]]]
2             package RPerl::HelperFunctions_cpp;
3 9     9   58 use strict;
  9         20  
  9         244  
4 9     9   48 use warnings;
  9         20  
  9         217  
5 9     9   49 use RPerl::Config; # get Carp, English, $RPerl::INCLUDE_PATH without 'use RPerl;'
  9         20  
  9         1514  
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   4058 use RPerl::Inline;
  0            
  0            
15             use rperltypessizes; # get type_integer_native_ccflag() & type_number_native_ccflag() w/out loading the entire RPerl type system via 'use rperltypes;'
16              
17             # [[[ SUBROUTINES ]]]
18             #our void::method $cpp_load = sub { # DEV NOTE: remove dependency on RPerl
19             sub cpp_load {
20             my $need_load_cpp = 0;
21              
22             if ( ( exists $main::{'RPerl__HelperFunctions__MODE_ID'} )
23             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             if ( $RPerl::MODES->{ main::RPerl__HelperFunctions__MODE_ID() }->{ops} ne 'CPP' )
28             {
29             $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             $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             if ((exists $ARGV[0]) and (defined $ARGV[0]) and ((substr $ARGV[0], -7, 7) eq '_Inline')) {
39             # RPerl::diag("in HelperFunctions_cpp::cpp_load, Inline recursion detected, SKIPPING\n");
40             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             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             $RPerl::Inline::ARGS{ccflagsex} = $RPerl::Inline::CCFLAGSEX . $RPerl::TYPES_CCFLAG . rperltypessizes::type_integer_native_ccflag() . rperltypessizes::type_number_native_ccflag();
58             $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             eval $eval_string or croak( $OS_ERROR . "\n" . $EVAL_ERROR );
64             if ($EVAL_ERROR) { croak($EVAL_ERROR); }
65              
66             #RPerl::diag("[[[ END 'use Inline' STAGE for 'RPerl/HelperFunctions.cpp' ]]]\n" x 1);
67             $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;