| 1 | # [[[ HEADER ]]] | ||
| 2 | package Perl::HelperFunctions_cpp; | ||
| 3 | 5 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 5 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 5 | ▶ | use Perl::Config; # get Carp, English, $Perl::INCLUDE_PATH without 'use Perl::Types;' |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | #use Perl::Types; # DEV NOTE: need to use HelperFunctions in Perl::Structure::Array for type checking SvIOKp() etc; remove dependency on Perl::Types void 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 | 0 | ▶ | use Perl::Inline; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 15 | use perltypessizes; # get type_integer_native_ccflag() & type_number_native_ccflag() w/out loading the entire Perl type system via 'use perltypes;' | ||
| 16 | |||
| 17 | # [[[ SUBROUTINES ]]] | ||
| 18 | sub cpp_load { | ||
| 19 | # { my void $RETURN_TYPE }; | ||
| 20 | my $need_load_cpp = 0; | ||
| 21 | |||
| 22 | if ( ( exists $main::{'Perl__HelperFunctions__MODE_ID'} ) | ||
| 23 | and ( defined &{ $main::{'Perl__HelperFunctions__MODE_ID'} } ) ) | ||
| 24 | { | ||
| 25 | # Perl::diag("in HelperFunctions_cpp::cpp_load, Perl__HelperFunctions__MODE_ID() exists & defined\n"); | ||
| 26 | # Perl::diag(q{in HelperFunctions_cpp::cpp_load, have Perl__HelperFunctions__MODE_ID() retval = '} . main::Perl__HelperFunctions__MODE_ID() . "'\n"); | ||
| 27 | if ( $Perl::MODES->{ main::Perl__HelperFunctions__MODE_ID() }->{ops} ne 'CPP' ) | ||
| 28 | { | ||
| 29 | $need_load_cpp = 1; | ||
| 30 | } | ||
| 31 | } | ||
| 32 | else { | ||
| 33 | # Perl::diag("in HelperFunctions_cpp::cpp_load, Perl__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 | # Perl::diag("in HelperFunctions_cpp::cpp_load, Inline recursion detected, SKIPPING\n"); | ||
| 40 | 1; | ||
| 41 | } | ||
| 42 | elsif ($need_load_cpp) { | ||
| 43 | # Perl::diag("in HelperFunctions_cpp::cpp_load, need load CPP code\n"); | ||
| 44 | |||
| 45 | #BEGIN { Perl::diag("[[[ BEGIN 'use Inline' STAGE for 'Perl/HelperFunctions.cpp' ]]]\n" x 1); } | ||
| 46 | my $eval_string = <<"EOF"; | ||
| 47 | package main; | ||
| 48 | use Perl::Inline; | ||
| 49 | BEGIN { Perl::diag("[[[ BEGIN 'use Inline' STAGE for 'Perl/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 => '$Perl::INCLUDE_PATH' . '/Perl/HelperFunctions.cpp', \%Perl::Inline::ARGS); | ||
| 53 | Perl::diag("[[[ END 'use Inline' STAGE for 'Perl/HelperFunctions.cpp' ]]]\n" x 1); | ||
| 54 | 1; | ||
| 55 | EOF | ||
| 56 | |||
| 57 | $Perl::Inline::ARGS{ccflagsex} = $Perl::Inline::CCFLAGSEX . $Perl::TYPES_CCFLAG . perltypessizes::type_integer_native_ccflag() . perltypessizes::type_number_native_ccflag(); | ||
| 58 | $Perl::Inline::ARGS{cppflags} = $Perl::TYPES_CCFLAG . perltypessizes::type_integer_native_ccflag() . perltypessizes::type_number_native_ccflag(); | ||
| 59 | |||
| 60 | # Perl::diag("in HelperFunctions_cpp::cpp_load(), CPP not yet loaded, have \%Perl::Inline::ARGS =\n" . Dumper(\%Perl::Inline::ARGS) . "\n"); | ||
| 61 | # Perl::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 | #Perl::diag("[[[ END 'use Inline' STAGE for 'Perl/HelperFunctions.cpp' ]]]\n" x 1); | ||
| 67 | $Perl::HelperFunctions_cpp::LOADING = 0; | ||
| 68 | } | ||
| 69 | |||
| 70 | # else { Perl::diag("in HelperFunctions_cpp::cpp_load(), CPP already loaded, DOING NOTHING\n"); } | ||
| 71 | } | ||
| 72 | |||
| 73 | 1; | ||