Skip to content

Commit

Permalink
unival() is the same for all backends but the jvm
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Jan 5, 2019
1 parent b20ff80 commit 27332f0
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions src/core/Cool.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -389,16 +389,6 @@ multi sub unimatch(|) { die 'unimatch NYI on jvm backend' }
#?endif

#?if js
proto sub unival(|) {*}
multi sub unival(Str:D $str) { $str ?? unival($str.ord) !! Nil }
multi sub unival(Int:D $code) {
state $nuprop = nqp::unipropcode("Numeric_Value_Numerator");
state $deprop = nqp::unipropcode("Numeric_Value_Denominator");
my $nu = nqp::getuniprop_str($code, $nuprop);
my $de = nqp::getuniprop_str($code, $deprop);
!$de || $de eq '1' ?? $nu.Int !! $nu / $de;
}

proto sub univals(|) {*}
multi sub univals(Str:D $str) { $str.ords.map: { unival($_) } }

Expand All @@ -412,6 +402,12 @@ multi sub uniprops(|) { die 'uniprops NYI on jvm backend' }
multi sub unimatch(|) { die 'unimatch NYI on js backend' }
#?endif

#?if !jvm
proto sub unival($, *%) {*}
multi sub unival(Str:D $str) { $str ?? $str.ord.unival !! Nil }
multi sub unival(Int:D $code) { $code.unival }
#?endif

#?if moar
proto sub uniprop($, |) {*}
multi sub uniprop(Str:D $str, |c) { $str ?? uniprop($str.ord, |c) !! Nil }
Expand Down Expand Up @@ -547,10 +543,6 @@ multi sub uniprops(Str:D $str, Stringy:D $propname = "General_Category") {
$str.ords.map: { uniprop($_, $propname) }
}

proto sub unival($, *%) {*}
multi sub unival(Str:D $str) { $str ?? $str.ord.unival !! Nil }
multi sub unival(Int:D $code) { $code.unival }

proto sub univals($, *%) {*}
multi sub univals(Str:D $str) { $str.ords.map: { .unival } }

Expand Down

0 comments on commit 27332f0

Please sign in to comment.