Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
.gist/.perl/.elems/.Numeric/.Int for Uni
  • Loading branch information
jnthn committed Apr 24, 2015
1 parent 7c89551 commit c7da6ce
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/core/Uni.pm
Expand Up @@ -46,7 +46,10 @@ my class Uni does Positional[uint32] does Stringy is repr('VMArray') is array_ty
nqp::strfromcodes(self)
}

method codes(Uni:D:) { nqp::elems(self) }
method codes(Uni:D:) { nqp::elems(self) }
method elems(Uni:D:) { nqp::elems(self) }
method Numeric(Uni:D:) { nqp::elems(self) }
method Int(Uni:D:) { nqp::elems(self) }

multi method EXISTS-POS(Uni:D: int \pos) {
nqp::p6bool(
Expand Down Expand Up @@ -74,6 +77,15 @@ my class Uni does Positional[uint32] does Stringy is repr('VMArray') is array_ty
) if nqp::isge_i($pos,nqp::elems(self)) || nqp::islt_i($pos,0);
nqp::atpos_i(self,$pos);
}

multi method gist(Uni:D:) {
self.^name ~ ':0x<' ~ self.list.fmt('%04x', ' ') ~ '>'
}

multi method perl(Uni:D:) {
'Uni.new(' ~ self.list.fmt('0x%04x', ', ') ~ ')' ~
(self.WHAT === Uni ?? '' !! '.' ~ self.^name);
}
}

my class NFD is Uni {
Expand Down

0 comments on commit c7da6ce

Please sign in to comment.