Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
implement uc builtin in setting, with inline PIR. Reviews welcome!
  • Loading branch information
moritz committed Mar 17, 2009
1 parent 72f522d commit 39b1290
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 25 deletions.
26 changes: 1 addition & 25 deletions src/builtins/any-str.pir
Expand Up @@ -23,7 +23,7 @@ the size of that file down and to emphasize their generic,
.namespace []
.sub 'onload' :anon :init :load
$P0 = get_hll_namespace ['Any']
'!EXPORT'('capitalize,chomp,chars,:d,:e,:f,index,lc,rindex,ord,substr,trim,uc', 'from'=>$P0)
'!EXPORT'('capitalize,chomp,chars,:d,:e,:f,index,lc,rindex,ord,substr,trim', 'from'=>$P0)
.end
Expand Down Expand Up @@ -982,30 +982,6 @@ Partial implementation. The :g modifier on regexps doesn't work, for example.
.return ($I0)
.end


=item uc

our Str multi Str::uc ( Str $string )

Returns the input string after converting each character to its uppercase
form, if lowercase. This is not a Unicode "titlecase" operation, but a
full "uppercase".

=cut

.sub 'uc' :method :multi(_)
.local string tmps
.local pmc retv

tmps = self
upcase tmps

retv = new 'Str'
retv = tmps

.return(retv)
.end

# Local Variables:
# mode: pir
# fill-column: 100
Expand Down
10 changes: 10 additions & 0 deletions src/setting/Any-str.pm
Expand Up @@ -70,6 +70,16 @@ class Any is also {
}
}
}

multi method uc() is export {
return Q:PIR {
$S0 = self
upcase $S0
$P0 = new 'Str'
$P0 = $S0
%r = $P0
}
}
our Str multi method ucfirst is export {
self gt '' ?? self.substr(0,1).uc ~ self.substr(1) !! ""
Expand Down

0 comments on commit 39b1290

Please sign in to comment.