File Coverage

blib/lib/RPerl/Inline.pm
Criterion Covered Total %
statement 13 15 86.6
branch n/a
condition n/a
subroutine 5 5 100.0
pod n/a
total 18 20 90.0


line stmt bran cond sub pod time code
1             # [[[ HEADER ]]]
2             package RPerl::Inline;
3 9     9   56 use strict;
  9         19  
  9         219  
4 9     9   43 use warnings;
  9         17  
  9         371  
5             our $VERSION = 0.005_000;
6              
7             #use RPerl; # ERROR: Too late to run INIT block at ...
8             #use Config;
9 9     9   48 use RPerl::Config; # for $RPerl::DEBUG
  9         16  
  9         1089  
10 9     9   3531 use Alien::PCRE2; # for regex support
  9         196382  
  9         93  
11 9     9   1076400 use Alien::JPCRE2; # for regex support
  0            
  0            
12             use File::Spec; # for splitpath() and catpath()
13              
14             # for regex support, look up include & lib dirs
15             my $pcre2_dir = Alien::PCRE2->dist_dir();
16             my $jpcre2_dir = Alien::JPCRE2->dist_dir();
17             #print {*STDERR} "\n\n", q{<<< DEBUG >>> in RPerl::Inline, have $pcre2_dir = '}, $pcre2_dir, q{'}, "\n\n";
18             #print {*STDERR} "\n\n", q{<<< DEBUG >>> in RPerl::Inline, have $jpcre2_dir = '}, $jpcre2_dir, q{'}, "\n\n";
19              
20             # two 'our' vars below utilized from Compiler.pm
21             our $pcre2_include_dir = File::Spec->catpath(q{}, $pcre2_dir, q{include});
22             our $jpcre2_include_dir = File::Spec->catpath(q{}, $jpcre2_dir, q{include});
23             my $pcre2_lib_dir = File::Spec->catpath(q{}, $pcre2_dir, q{lib});
24             #my $jpcre2_lib_dir = File::Spec->catpath(q{}, $jpcre2_dir, q{lib}); # NOT USED
25             #print {*STDERR} "\n\n", q{<<< DEBUG >>> in RPerl::Inline, have $pcre2_include_dir = '}, $pcre2_include_dir, q{'}, "\n\n";
26             #print {*STDERR} "\n\n", q{<<< DEBUG >>> in RPerl::Inline, have $jpcre2_include_dir = '}, $jpcre2_include_dir, q{'}, "\n\n";
27              
28             # long form
29             #use Inline CPP => config => classes =>
30             #sub {
31             # my $class = shift;
32             # my @class_split = split('__', $class);
33             # my $class_join = join('::', @class_split);
34             # return($class_join);
35             #};
36              
37             # short form
38             #use Inline CPP => config => classes => sub { join('::', split('__', shift)); };
39              
40             # DEV NOTE, CORRELATION #rp011: replace -std=c++0x w/ -std=c++11 for std::string::pop_back()
41             # DEV NOTE: move ccflags outside %ARGS, make individual modules compose ccflags with possible cppflags right before calling Inline
42             #our $CCFLAGSEX = '-DNO_XSLOCKS -Wno-deprecated -std=c++0x -Wno-reserved-user-defined-literal -Wno-literal-suffix';
43             #our $CCFLAGSEX = '-DNO_XSLOCKS -Wno-deprecated -std=c++11 -Wno-reserved-user-defined-literal -Wno-literal-suffix';
44             # DEV NOTE: add -Wno-unused-variable to suppress warnings in GCC v4.9
45             my $is_msvc_compiler = ($Config::Config{cc} =~ /cl/);
46              
47             our $CCFLAGSEX = $is_msvc_compiler ? '-DNO_XSLOCKS'
48             : '-Wno-unused-variable -DNO_XSLOCKS -Wno-deprecated -std=c++11 -Wno-reserved-user-defined-literal -Wno-literal-suffix';
49              
50             # for regex support
51             $CCFLAGSEX .= ' -L"' . $pcre2_lib_dir . '"';
52              
53             our %ARGS = (
54             typemaps => "$RPerl::INCLUDE_PATH/typemap.rperl",
55             # disable default '-O2 -g' (or similar) from Perl core & Makemaker
56             ($is_msvc_compiler
57             ? ()
58             : (optimize => '-O3 -fomit-frame-pointer -march=native -g')
59             ),
60              
61             # NEED UPGRADE: strip C++ incompat CFLAGS
62             # ccflags => $Config{ccflags} . ' -DNO_XSLOCKS -Wno-deprecated -std=c++0x -Wno-reserved-user-defined-literal -Wno-literal-suffix',
63             # force_build => 1, # debug use only
64             inc => '-I' . $RPerl::INCLUDE_PATH . ' -Ilib -I' . $pcre2_include_dir . ' -I' . $jpcre2_include_dir,
65             build_noisy => ( $ENV{RPERL_DEBUG} or $RPerl::DEBUG ), # suppress or display actual g++ compiler commands
66             clean_after_build => 0, # used by Inline::C(PP) to cache build, also used by Inline::Filters to save Filters*.c files for use in gdb debugging
67             warnings => (((not defined $ENV{RPERL_WARNINGS}) or $ENV{RPERL_WARNINGS}) and $RPerl::WARNINGS), # suppress or display Inline warnings
68             filters => 'Preprocess',
69             auto_include => # DEV NOTE: include non-RPerl files using AUTO_INCLUDE so they are not parsed by the 'Preprocess' filter
70             [
71             # DEV NOTE, CORRELATION #rp024: sync include files in both RPerl/Inline.pm and rperlstandalone.h
72             '#include <memory>', # smart pointers for memory management
73             '#include <iostream>',
74             '#include <string>',
75             '#include <sstream>',
76             '#include <limits>',
77             '#undef seed', # fix conflict between Perl's source/internal.h & libstdc++-dev's algorithm.h; 'error: macro "seed" passed 1 arguments, but takes just 0'
78             '#include <algorithm>',
79             '#include <vector>',
80             '#include <math.h>',
81             '#include <unordered_map>', # DEV NOTE: unordered_map may require '-std=c++0x' in CCFLAGS above
82             '#undef do_open', # for regex support, fix conflict between jpcre2.hpp subdep locale_facets_nonio.h & other uknown file, 'error: macro "do_open" requires 7 arguments, but only 2 given'
83             '#undef do_close', # for regex support, fix conflict between jpcre2.hpp subdep locale_facets_nonio.h & other uknown file, 'error: macro "do_close" requires 2 arguments, but only 1 given'
84             '#include "jpcre2.hpp"', # for regex support
85             # DEV NOTE, CORRELATION #rp300: must link against all bit width libs to allow automatic selection
86             'typedef jpcre2::select<char> jp;', # for regex support, automatically selects correct character bit width based on system, 8 or 16 or 32
87             ],
88             classes => sub { join('::', split('__', shift)); }
89             );
90              
91             1;