| 1 | # /=====================================================================\ # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # | LaTeXML::Common::Glue | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # | Representation of Stretchy dimensions | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # |=====================================================================| # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # | Part of LaTeXML: | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # | Public domain software, produced as part of work done by the | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # | United States Government & not subject to copyright in the US. | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # |---------------------------------------------------------------------| # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # | Bruce Miller <bruce.miller@nist.gov> #_# | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # | http://dlmf.nist.gov/LaTeXML/ (o o) | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | # \=========================================================ooo==U==ooo=/ # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | package LaTeXML::Common::Glue; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 4 | ▶ | use LaTeXML::Global; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 4 | ▶ | use base qw(LaTeXML::Common::Dimension); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 4 | ▶ | use base qw(Exporter); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 4 | our @EXPORT = (qw(&Glue)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | #====================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | # Exported constructor. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | sub Glue { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | my ($scaledpoints, $plus, $pfill, $minus, $mfill) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Glue: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | return LaTeXML::Common::Glue->new($scaledpoints, $plus, $pfill, $minus, $mfill); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | #====================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 4 | my %fillcode = (fil => 1, fill => 2, filll => 3); # [CONSTANT] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 4 | my @FILL = ('', 'fil', 'fill', 'filll'); # [CONSTANT] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 4 | my $num_re = qr/\d*\.?\d*/; # [CONSTANT] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 4 | my $unit_re = qr/[a-zA-Z][a-zA-Z]/; # [CONSTANT] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 4 | my $fill_re = qr/fil|fill|filll|[a-zA-Z][a-zA-Z]/; # [CONSTANT] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 4 | my $plus_re = qr/\s+plus\s*($num_re)($fill_re)/; # [CONSTANT] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 4 | my $minus_re = qr/\s+minus\s*($num_re)($fill_re)/; # [CONSTANT] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 4 | our $GLUE_re = qr/(\+?\-?$num_re)($unit_re)($plus_re)?($minus_re)?/; # [CONSTANT] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | my ($class, $sp, $plus, $pfill, $minus, $mfill) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=21 SCAR=61.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | $sp = ToString($sp) if ref $sp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | $plus = ToString($plus) if ref $plus; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | $pfill = ToString($pfill) if ref $pfill; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | $minus = ToString($minus) if ref $minus; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | $mfill = ToString($mfill) if ref $mfill; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | if ((!defined $plus) && (!defined $pfill) && (!defined $minus) && (!defined $mfill)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
defined $plus or defined $pfill or defined $minus or defined $mfill
defined $plus or defined $pfill or defined $minus
defined $plus or defined $pfill
MC/DC0%0/4
defined $plus or defined $pfill or defined $minus or defined $mfill
defined $plus
defined $pfill
defined $minus
defined $mfill
Truth table0%0/5
A or B or C or D
A= defined $plusB= defined $pfillC= defined $minusD= defined $mfill
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | if ($sp =~ /^(\d*\.?\d*)$/) { } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | elsif ($sp =~ /^$GLUE_re$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | my ($f, $u, $p, $pu, $m, $mu) = ($1, $2, $4, $5, $7, $8); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | $sp = $f * $STATE->convertUnit($u); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | if (!$pu) { } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | elsif ($fillcode{$pu}) { $plus = $p; $pfill = $pu; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | else { $plus = $p * $STATE->convertUnit($pu); $pfill = 0; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | if (!$mu) { } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | elsif ($fillcode{$mu}) { $minus = $m; $mfill = $mu; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | else { $minus = $m * $STATE->convertUnit($mu); $mfill = 0; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | return bless [$sp || "0", $plus || "0", $pfill || 0, $minus || "0", $mfill || 0], $class; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/10
$sp || '0'
$plus || '0'
$pfill || 0
$minus || '0'
$mfill || 0
MC/DC0%0/1
$sp || '0'
$sp
MC/DC0%0/1
$plus || '0'
$plus
MC/DC0%0/1
$pfill || 0
$pfill
MC/DC0%0/1
$minus || '0'
$minus
MC/DC0%0/1
$mfill || 0
$mfill
Truth table0%0/2
A
A= $sp
Truth table0%0/2
A
A= $plus
Truth table0%0/2
A
A= $pfill
Truth table0%0/2
A
A= $minus
Truth table0%0/2
A
A= $mfill
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | #sub getStretch { $_[0]->[1]; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | #sub getShrink { $_[0]->[2]; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | sub toString { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
toString: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | my ($sp, $plus, $pfill, $minus, $mfill) = @$self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | my $string = LaTeXML::Common::Dimension::pointformat($sp); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | $string .= ' plus ' . ($pfill | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | ? $plus . $FILL[$pfill] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | : LaTeXML::Common::Dimension::pointformat($plus)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | if $plus != 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | $string .= ' minus ' . ($mfill | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | ? $minus . $FILL[$mfill] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | : LaTeXML::Common::Dimension::pointformat($minus)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | if $minus != 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | return $string; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | sub toAttribute { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
toAttribute: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | my ($sp, $plus, $pfill, $minus, $mfill) = @$self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | my $string = LaTeXML::Common::Dimension::attributeformat($sp); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | $string .= ' plus ' . ($pfill | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | ? $plus . $FILL[$pfill] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | : LaTeXML::Common::Dimension::attributeformat($plus)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | if $plus != 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | $string .= ' minus ' . ($mfill | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | ? $minus . $FILL[$mfill] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | : LaTeXML::Common::Dimension::attributeformat($minus)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | if $minus != 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | return $string; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | sub negate { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
negate: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | my ($pts, $p, $pf, $m, $mf) = @$self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | return (ref $self)->new(-$pts, -$p, $pf, -$m, $mf); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | sub add { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | my ($self, $other) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | my ($pts, $p, $pf, $m, $mf) = @$self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | if (ref $other eq 'LaTeXML::Common::Glue') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | my ($pts2, $p2, $pf2, $m2, $mf2) = @$other; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | $pts += $pts2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | if ($pf == $pf2) { $p += $p2; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | elsif ($pf < $pf2) { $p = $p2; $pf = $pf2; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | if ($mf == $mf2) { $m += $m2; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | elsif ($mf < $mf2) { $m = $m2; $mf = $mf2; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | return (ref $self)->new($pts, $p, $pf, $m, $mf); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | return (ref $self)->new($pts + $other->valueOf, $p, $pf, $m, $mf); } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | sub multiply { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | my ($self, $other) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
multiply: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | my ($pts, $p, $pf, $m, $mf) = @$self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | $other = $other->valueOf if ref $other; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | return (ref $self)->new($pts * $other, $p * $other, $pf, $m * $other, $mf); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | sub divide { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | my ($self, $other) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
divide: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | my ($pts, $p, $pf, $m, $mf) = @$self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | $other = $other->valueOf if ref $other; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | return (ref $self)->new($pts / $other, $p / $other, $pf, $m / $other, $mf); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | sub divideround { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | my ($self, $other) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
divideround: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | my ($pts, $p, $pf, $m, $mf) = @$self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | $other = $other->valueOf if ref $other; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | return (ref $self)->new($pts / $other, $p / $other, $pf, $m / $other, $mf); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | sub stringify { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stringify: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | return "Glue[" . join(',', @$self) . "]"; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | #====================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||