Skip to content

Commit

Permalink
implement Symbol#succ
Browse files Browse the repository at this point in the history
  • Loading branch information
Watson1978 committed Jun 23, 2012
1 parent 64299cd commit c9e48eb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
1 change: 1 addition & 0 deletions include/ruby/intern.h
Expand Up @@ -562,6 +562,7 @@ VALUE rb_str_intern(VALUE);
VALUE rb_sym_to_s(VALUE);
VALUE rb_str_length(VALUE);
VALUE rb_str_match(VALUE, VALUE);
VALUE rb_str_succ(VALUE);

// Return a string object appropriate for bstr_ calls. This does nothing for
// data/binary RubyStrings.
Expand Down
6 changes: 0 additions & 6 deletions spec/frozen/tags/macruby/core/symbol/succ_tags.txt

This file was deleted.

6 changes: 6 additions & 0 deletions string.c
Expand Up @@ -5127,6 +5127,12 @@ rstr_succ(VALUE str, SEL sel)
return newstr;
}

VALUE
rb_str_succ(VALUE str)
{
return rstr_succ(str, 0);
}

/*
* call-seq:
* str.succ! => str
Expand Down
16 changes: 16 additions & 0 deletions symbol.c
Expand Up @@ -323,6 +323,20 @@ Init_PreSymbol(void)
}
}

/*
* call-seq:
*
* sym.succ
*
* Same as <code>sym.to_s.succ.intern</code>.
*/

static VALUE
rsym_succ(VALUE sym, SEL sel)
{
return rb_str_intern(rb_str_succ(rb_sym_to_s(sym)));
}

/*
* call-seq:
*
Expand Down Expand Up @@ -818,6 +832,8 @@ Init_Symbol(void)
rb_objc_define_method(rb_cSymbol, "downcase", rsym_downcase, 0);
rb_objc_define_method(rb_cSymbol, "swapcase", rsym_swapcase, 0);
rb_objc_define_method(rb_cSymbol, "capitalize", rsym_capitalize, 0);
rb_objc_define_method(rb_cSymbol, "succ", rsym_succ, 0);
rb_objc_define_method(rb_cSymbol, "next", rsym_succ, 0);

// Cocoa primitives.
rb_objc_install_method2((Class)rb_cSymbol, "copy",
Expand Down

0 comments on commit c9e48eb

Please sign in to comment.