File Coverage

blib/lib/RPerl/DataType/GMPInteger_cpp.pm
Criterion Covered Total %
statement 19 19 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod n/a
total 26 26 100.0


line stmt bran cond sub pod time code
1             # [[[ HEADER ]]]
2             package RPerl::DataType::GMPInteger_cpp;
3 1     1   1800 use strict;
  1         3  
  1         29  
4 1     1   6 use warnings;
  1         2  
  1         27  
5 1     1   6 use RPerl::AfterSubclass;
  1         2  
  1         188  
6             our $VERSION = 0.002_000;
7              
8             # [[[ CRITICS ]]]
9             ## no critic qw(ProhibitStringyEval) # SYSTEM DEFAULT 1: allow eval()
10              
11             # [[[ INCLUDES ]]]
12 1     1   10 use RPerl::Inline;
  1         3  
  1         232  
13              
14             # [[[ SUBROUTINES ]]]
15             our void::method $cpp_load = sub {
16             my $need_load_cpp = 0;
17             if ( ( exists $main::{'RPerl__DataType__GMPInteger__MODE_ID'} )
18             and ( defined &{ $main::{'RPerl__DataType__GMPInteger__MODE_ID'} } ) )
19             {
20             # RPerl::diag("in GMPInteger_cpp::cpp_load, RPerl__DataType__GMPInteger__MODE_ID() exists & defined\n");
21             # RPerl::diag(q{in GMPInteger_cpp::cpp_load, have RPerl__DataType__GMPInteger__MODE_ID() retval = '} . main::RPerl__DataType__GMPInteger__MODE_ID() . "'\n");
22             if ( $RPerl::MODES->{main::RPerl__DataType__GMPInteger__MODE_ID()}->{ops} ne 'CPP' ) {
23             $need_load_cpp = 1;
24             }
25             }
26             else {
27             # RPerl::diag("in GMPInteger_cpp::cpp_load, RPerl__DataType__GMPInteger__MODE_ID() does not exist or undefined\n");
28             $need_load_cpp = 1;
29             }
30              
31             if ($need_load_cpp) {
32              
33             # RPerl::diag("in GMPInteger_cpp::cpp_load, need load CPP code\n");
34              
35             my $eval_string = <<"EOF";
36             package main;
37             use RPerl::Inline;
38             BEGIN { RPerl::diag("[[[ BEGIN 'use Inline' STAGE for 'RPerl/DataType/GMPInteger.cpp' ]]]\n" x 0); }
39             use Inline (CPP => '$RPerl::INCLUDE_PATH' . '/RPerl/DataType/GMPInteger.cpp', \%RPerl::Inline::ARGS);
40             RPerl::diag("[[[ END 'use Inline' STAGE for 'RPerl/DataType/GMPInteger.cpp' ]]]\n" x 0);
41             1;
42             EOF
43              
44             $RPerl::Inline::ARGS{ccflagsex} = $RPerl::Inline::CCFLAGSEX . $RPerl::TYPES_CCFLAG . rperltypessizes::type_integer_native_ccflag() . rperltypessizes::type_number_native_ccflag();
45             $RPerl::Inline::ARGS{cppflags} = $RPerl::TYPES_CCFLAG . rperltypessizes::type_integer_native_ccflag() . rperltypessizes::type_number_native_ccflag();
46             $RPerl::Inline::ARGS{libs} = '-lgmpxx -lgmp'; # enable GMP support
47             $RPerl::Inline::ARGS{auto_include} = [ @{ $RPerl::Inline::ARGS{auto_include} }, '#include <gmpxx.h>', '#include <gmp.h>' ]; # enable GMP support
48            
49             # RPerl::diag("in GMPInteger_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");
50             # RPerl::diag("in GMPInteger_cpp::cpp_load(), CPP not yet loaded, have \%RPerl::Inline::ARGS =\n" . Dumper(\%RPerl::Inline::ARGS) . "\n");
51             # RPerl::diag("in GMPInteger_cpp::cpp_load(), CPP not yet loaded, have \$RPerl::TYPES_CCFLAG = '" . $RPerl::TYPES_CCFLAG . "'\n");
52              
53 1     1   13 eval $eval_string or croak( $OS_ERROR . "\n" . $EVAL_ERROR );
  1     1   3  
  1     1   45  
  1         9  
  1         11  
  1         3  
  1         16  
54             if ($EVAL_ERROR) { croak($EVAL_ERROR); }
55             }
56              
57             # else { RPerl::diag("in GMPInteger_cpp::cpp_load(), CPP already loaded, DOING NOTHING\n"); }
58             };
59              
60             1; # end of package