blib/lib/Unicode/Property/XS.pm

filter: Statementstmt 79.7% 55 / 69 Branchbran 43.7% 7 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 87.5% 7 / 8 Podpod n/a totaltotal 74.1% 69 / 93 CC 11 SCAR 23.2
CC
11
Cov
73%
import
16.0
_report_error
2.0
BEGIN
1.0
CRAP 10.2
↑ Summary XS.xs »
1 package Unicode::Property::XS;
2  
3 1 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use vars qw( $VERSION );
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 #require Exporter;
9 #our @ISA = qw(Exporter);
10 # use Exporter::Lite;
11 #our (@ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
12 1 our $Prefix;
13 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 $VERSION = '0.81';
15 }
16  
17 # This allows declaration use Unicode::Property::XS ':all';
18  
19  
20 1 our @general = (
21 'L', 'LC', 'Lu', 'Ll',
22 'Lt', 'Lm', 'Lo', 'M',
23 'Mn', 'Mc', 'Me', 'N',
24 'Nd', 'Nl', 'No', 'P',
25 'Pc', 'Pd', 'Ps', 'Pe',
26 'Pi', 'Pf', 'Po', 'S',
27 'Sm', 'Sc', 'Sk', 'So',
28 'Z', 'Zs', 'Zl', 'Zp',
29 'C', 'Cc', 'Cf', 'Cs',
30 'Co', 'Cn' );
31 1 our @bidirectional = (
32 'BidiL', 'BidiLRE', 'BidiLRO', 'BidiR',
33 'BidiAL', 'BidiRLE', 'BidiRLO', 'BidiPDF',
34 'BidiEN', 'BidiES', 'BidiET', 'BidiAN',
35 'BidiCS', 'BidiNSM', 'BidiBN', 'BidiB',
36 'BidiS', 'BidiWS', 'BidiON' );
37 1 our @scripts = (
38 'Arabic', 'Armenian', 'Balinese', 'Bengali',
39 'Bopomofo', 'Braille', 'Buginese', 'Buhid',
40 'CanadianAboriginal', 'Cherokee', 'Coptic', 'Cuneiform',
41 'Cypriot', 'Cyrillic', 'Deseret', 'Devanagari',
42 'Ethiopic', 'Georgian', 'Glagolitic', 'Gothic',
43 'Greek', 'Gujarati', 'Gurmukhi', 'Han',
44 'Hangul', 'Hanunoo', 'Hebrew', 'Hiragana',
45 'Inherited', 'Kannada', 'Katakana', 'Kharoshthi',
46 'Khmer', 'Lao', 'Latin', 'Limbu',
47 'LinearB', 'Malayalam', 'Mongolian', 'Myanmar',
48 'NewTaiLue', 'Nko', 'Ogham', 'OldItalic',
49 'OldPersian', 'Oriya', 'Osmanya', 'PhagsPa',
50 'Phoenician', 'Runic', 'Shavian', 'Sinhala',
51 'SylotiNagri', 'Syriac', 'Tagalog', 'Tagbanwa',
52 'TaiLe', 'Tamil', 'Telugu', 'Thaana',
53 'Thai', 'Tibetan', 'Tifinagh', 'Ugaritic',
54 'Yi' );
55 1 our @extended = (
56 'ASCIIHexDigit', 'BidiControl', 'Dash', 'Deprecated',
57 'Diacritic', 'Extender', 'HexDigit', 'Hyphen',
58 'Ideographic', 'IDSBinaryOperator', 'IDSTrinaryOperator', 'JoinControl',
59 'LogicalOrderException', 'NoncharacterCodePoint', 'OtherAlphabetic', 'OtherDefaultIgnorableCodePoint',
60 'OtherGraphemeExtend', 'OtherIDStart', 'OtherIDContinue', 'OtherLowercase',
61 'OtherMath', 'OtherUppercase', 'PatternSyntax', 'PatternWhiteSpace',
62 'QuotationMark', 'Radical', 'SoftDotted', 'STerm',
63 'TerminalPunctuation', 'UnifiedIdeograph', 'VariationSelector', 'WhiteSpace' );
64 1 our @derived = (
65 'Alphabetic', 'Lowercase', 'Uppercase', 'Math',
66 'IDStart', 'IDContinue', 'Any', 'Assigned',
67 'Unassigned', 'ASCII', 'Common' );
68 1 our @EastAsianWidth = (
69 'EaF', 'EaH', 'EaA', 'EaNa',
70 'EaW', 'EaN', 'EaFullwidth0', 'EaFullwidth1',
71 'EaHalfwidth0', 'EaHalfwidth1' );
72  
73 1 our %EXPORT_TAGS = (
74 'all' => [ 'Legal',
75 @general,@bidirectional,@scripts,@extended,
76 @derived,@EastAsianWidth ],
77  
78 'general' => [ @general ],
79 'bidirectional' => [ @bidirectional ],
80 'scripts' => [ @scripts ],
81 'extended' => [ @extended ],
82 'derived' => [ @derived ],
83 'EastAsianWidth' => [ @EastAsianWidth ],
84 );
85  
86  
87 # ucs_InEastAsianFullwidth
88 # ucs_InEastAsianHalfwidth
89 # ucs_InEastAsianAmbiguous
90 # ucs_InEastAsianNarrow
91 # ucs_InEastAsianWide
92 # ucs_InEastAsianNeutral
93 # ucs_InFullwidth
94 # ucs_InHalfwidth
95 # for ucs_InFullwidth see context $Unicode::EastAsianWidth::EastAsian
96 # for ucs_InHalfwidth see context $Unicode::EastAsianWidth::EastAsian
97  
98 1 our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
99  
100 1 our @EXPORT = qw();
101  
102 1 ▶sub import {
Subroutine import: called CC=11 SCAR=27.7
103 1 my ($pkg, @imports) = @_;
104 1 my($caller, $file, $line) = caller;
105  
106 1 ▶ $Prefix = defined($Prefix) ? $Prefix : 'ucs_' ;
Branch: 1 branch
BranchTrueFalseTotal
defined $Unicode::Property::XS::Prefix ? : 0 1 1
107 1 $Prefix =~ s/[^A-Za-z0-9_]//g ; # strip possible weird chars in prefix
108  
109 # my @tags;
110 1 my @items;
111  
112 # adapted from Exporter::Lite
113 1 ▶ if ( !@imports ) { # Default import.
Branch: 1 branch
BranchTrueFalseTotal
unless (@imports) 0 1 1
114 0 @imports = @EXPORT;
115 }
116 1 my %ok = map { s/^&//; $_ => 1; } @EXPORT_OK, @EXPORT;
117 1 my %ok_tag = map { $_ => 1; } keys %EXPORT_TAGS;
118 1 my $add;
119  
120 ITEM:
121 1 foreach my $item (@imports) {
122 1 ▶ $add = $item =~ s/^!// ? 1 : 2;
Branch: 1 branch
BranchTrueFalseTotal
$item =~ s/^!// ? : 0 1 1
123  
124 1 ▶ if ($item eq ':DEFAULT') {
Branch: 1 branch
BranchTrueFalseTotal
if ($item eq ":DEFAULT") 0 1 1
125 0 map { $ok{$_}=$add; } @EXPORT ;
126 0 next ITEM;
127 }
128  
129 1 ▶ if ($item =~ /^:(.*)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($item =~ /^:(.*)/) { } 1 0 1
130 1 ▶ if (!$ok_tag{$1}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ok_tag{$1}) 0 1 1
131 0 _report_error($1);
132 0 next ITEM;
133 };
134 1 map { $ok{$_}=$add; } @{ $EXPORT_TAGS{$1} } ;
135 }
136 else {
137 0 ▶ if (!$ok{$item}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ok{$item}) 0 0 0
138 0 _report_error($item);
139 0 next ITEM;
140 };
141 0 $ok{$item}=$add;
142 }
143 };
144  
145 1 foreach my $item (keys %ok) {
146 176 ▶ next if $ok{ $item } != 2 ;
Branch: 1 branch
BranchTrueFalseTotal
if $ok{$item} != 2 0 176 176
147  
148 1 ▶ do { no strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
149 176 *{ $caller.'::'.$Prefix.$item } = \&{ $item };
150 };
151 };
152  
153 };
154  
155 0 ▶sub _report_error {
Subroutine _report_error: not called CC=1 SCAR=6.9
156 0 my $item = shift;
157 0 do { require Carp; Carp::croak("Can't export symbol: $item") };
158 };
159  
160 1 require XSLoader;
161 1 XSLoader::load('Unicode::Property::XS', $VERSION);
162  
163 # Preloaded methods go here.
164  
165 1 1;
166 __END__
↑ Summary XS.xs »