| 1 | #!/usr/bin/env perl | ||||||||||
| 2 | # Copyright (c) 2014, 2015 Yon <anaseto@bardinflor.perso.aquilenet.fr> | ||||||||||
| 3 | # | ||||||||||
| 4 | # Permission to use, copy, modify, and distribute this software for any | ||||||||||
| 5 | # purpose with or without fee is hereby granted, provided that the above | ||||||||||
| 6 | # copyright notice and this permission notice appear in all copies. | ||||||||||
| 7 | # | ||||||||||
| 8 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||||||||||
| 9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||||||||||
| 10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||||||||||
| 11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||||||||||
| 12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||||||||||
| 13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||||||||||
| 14 | # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||||||||||
| 15 | # | ||||||||||
| 16 | # Eval of perl code to compile new user defined macros | ||||||||||
| 17 | # | ||||||||||
| 18 | package Text::Frundis::PerlEval; | ||||||||||
| 19 | |||||||||||
| 20 | 3 | ▶ | use utf8; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | 3 | ▶ | use v5.12; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 22 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 23 | 3 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 24 | 3 | ▶ | use open qw(:std :utf8); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 25 | |||||||||||
| 26 | 3 | ▶ | use Text::Frundis::Object qw(@Arg); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 27 | 3 | ▶ | use Text::Frundis::Processing; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 28 | |||||||||||
| 29 | 3 | our @Arg; | |||||||||
| 30 | |||||||||||
| 31 | 63 | ▶ | sub _compile_perl_code { # [[[ | ||||||||
|
Subroutine
_compile_perl_code: called CC=3 SCAR=11.0
| |||||||||||
| 32 | 63 | my $self = shift; | |||||||||
| 33 | 63 | my ($macro, $text, $type) = @_; | |||||||||
| 34 | 63 | ▶ | my $key = $type eq "macro" ? "macros" : "filters"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 35 | 63 | local $@; | |||||||||
| 36 | { | ||||||||||
| 37 | 63 | ▶ | local $SIG{'__WARN__'} = sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||
| 38 | 0 | Text::Frundis::Processing::diag_error("perl_eval:$type:$_[0]"); | |||||||||
| 39 | 63 | }; | |||||||||
| 40 | 63 | ▶ | $self->{$key}{$macro}{code} = eval qq(sub { $text }); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 41 | } | ||||||||||
| 42 | 63 | ▶ | if ($@) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 43 | 0 | Text::Frundis::Processing::diag_fatal("perl_eval:$type:$@"); | |||||||||
| 44 | } | ||||||||||
| 45 | } # ]]] | ||||||||||
| 46 | |||||||||||
| 47 | 3 | 1; | |||||||||
| 48 | |||||||||||
| 49 | # vim:foldmarker=[[[,]]]:foldmethod=marker:sw=4:sts=4:expandtab | ||||||||||