diff options
-rw-r--r-- | ChangeLog | 20 | ||||
-rwxr-xr-x | bin/erb | 2 | ||||
-rw-r--r-- | ext/.document | 1 | ||||
-rw-r--r-- | ext/enumerator/enumerator.c | 103 | ||||
-rw-r--r-- | ext/tk/lib/tk/canvas.rb | 2 | ||||
-rw-r--r-- | ext/tk/lib/tk/menu.rb | 2 |
6 files changed, 126 insertions, 4 deletions
@@ -1,6 +1,20 @@ +Mon Oct 24 07:57:56 2005 Yukihiro Matsumoto <matz@ruby-lang.org> + + * ext/tk/lib/tk/canvas.rb (TkCanvasItemConfig::__item_val2ruby_optkeys): + typo fixed. [ruby-talk:162187] + + * ext/tk/lib/tk/menu.rb (TkMenuEntryConfig::__item_val2ruby_optkeys): + ditto. [ruby-core:06359] + +Sun Oct 23 21:50:15 2005 Yukihiro Matsumoto <matz@ruby-lang.org> + + * ext/enumerator/enumerator.c: applied documentation patch from + James Edward Gray II <james@grayproductions.net>. + [ruby-core:06348] + Sun Oct 23 07:11:11 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp> - * ext/tcltklib/extconf.rb: improbe messages [ruby-core:06325]. + * ext/tcltklib/extconf.rb: improve messages [ruby-core:06325]. * ext/tk/lib/tk.rb, ext/tk/lib/tk/canvas.rb, ext/tk/lib/tk/entry.rb, ext/tk/lib/tk/frame.rb, ext/tk/lib/tk/image.rb, @@ -41,6 +55,10 @@ Fri Oct 21 19:21:56 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp> * rubysig.h (CHECK_INTS): fixed typo. (I believe bit-or is improper) +Fri Oct 21 17:49:32 2005 Yukihiro Matsumoto <matz@ruby-lang.org> + + * bin/erb (ERB::Main::run): typo fixed. [ruby-core:06337] + Fri Oct 21 15:27:17 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp> * bignum.c (bignew_1): convertion from `int' to `char' discards @@ -60,7 +60,7 @@ class ERB $DEBUG = true when '-r' # require require ARGV.req_arg - when '-S' # sacurity level + when '-S' # security level arg = ARGV.req_arg raise "invalid safe_level #{arg.dump}" unless arg =~ /^[0-4]$/ safe_level = arg.to_i diff --git a/ext/.document b/ext/.document index f4c8de2f3b..0f5b1fb1b7 100644 --- a/ext/.document +++ b/ext/.document @@ -1,5 +1,6 @@ # Add files to this as they become documented +enumerator/enumerator.c iconv/iconv.c stringio/stringio.c strscan/strscan.c diff --git a/ext/enumerator/enumerator.c b/ext/enumerator/enumerator.c index 74785569e7..1c6e1d1ace 100644 --- a/ext/enumerator/enumerator.c +++ b/ext/enumerator/enumerator.c @@ -15,10 +15,34 @@ #include "ruby.h" #include "node.h" +/* + * Document-class: Enumerable::Enumerator + * + * A class which provides a method `each' to be used as an Enumerable + * object. + */ static VALUE rb_cEnumerator; static ID sym_each, sym_each_with_index, sym_each_slice, sym_each_cons; static ID id_new, id_enum_obj, id_enum_method, id_enum_args; +/* + * call-seq: + * obj.to_enum(method = :each, *args) + * obj.enum_for(method = :each, *args) + * + * Returns Enumerable::Enumerator.new(self, method, *args). + * + * e.g.: + * str = "xyz" + * + * enum = str.enum_for(:each_byte) + * a = enum.map {|b| '%02x' % b } #=> ["78", "79", "7a"] + * + * # protects an array from being modified + * a = [1, 2, 3] + * some_method(a.to_enum) + * + */ static VALUE obj_to_enum(obj, enum_args) VALUE obj, enum_args; @@ -28,6 +52,13 @@ obj_to_enum(obj, enum_args) return rb_apply(rb_cEnumerator, id_new, enum_args); } +/* + * call-seq: + * enum_with_index + * + * Returns Enumerable::Enumerator.new(self, :each_with_index). + * + */ static VALUE enumerator_enum_with_index(obj) VALUE obj; @@ -53,6 +84,21 @@ each_slice_i(val, memo) return Qnil; } +/* + * call-seq: + * e.each_slice(n) {...} + * + * Iterates the given block for each slice of <n> elements. + * + * e.g.: + * (1..10).each_slice(3) {|a| p a} + * # outputs below + * [1, 2, 3] + * [4, 5, 6] + * [7, 8, 9] + * [10] + * + */ static VALUE enum_each_slice(obj, n) VALUE obj, n; @@ -73,6 +119,13 @@ enum_each_slice(obj, n) return Qnil; } +/* + * call-seq: + * e.enum_slice(n) + * + * Returns Enumerable::Enumerator.new(self, :each_slice, n). + * + */ static VALUE enumerator_enum_slice(obj, n) VALUE obj, n; @@ -98,6 +151,26 @@ each_cons_i(val, memo) return Qnil; } +/* + * call-seq: + * each_cons(n) {...} + * + * Iterates the given block for each array of consecutive <n> + * elements. + * + * e.g.: + * (1..10).each_cons(3) {|a| p a} + * # outputs below + * [1, 2, 3] + * [2, 3, 4] + * [3, 4, 5] + * [4, 5, 6] + * [5, 6, 7] + * [6, 7, 8] + * [7, 8, 9] + * [8, 9, 10] + * + */ static VALUE enum_each_cons(obj, n) VALUE obj, n; @@ -113,6 +186,13 @@ enum_each_cons(obj, n) return Qnil; } +/* + * call-seq: + * e.enum_cons(n) + * + * Returns Enumerable::Enumerator.new(self, :each_cons, n). + * + */ static VALUE enumerator_enum_cons(obj, n) VALUE obj, n; @@ -120,6 +200,21 @@ enumerator_enum_cons(obj, n) return rb_funcall(rb_cEnumerator, id_new, 3, obj, sym_each_cons, n); } +/* + * call-seq: + * Enumerable::Enumerator.new(obj, method = :each, *args) + * + * Creates a new Enumerable::Enumerator object, which is to be + * used as an Enumerable object using the given object's given + * method with the given arguments. + * + * e.g.: + * str = "xyz" + * + * enum = Enumerable::Enumerator.new(str, :each_byte) + * a = enum.map {|b| '%02x' % b } #=> ["78", "79", "7a"] + * + */ static VALUE enumerator_initialize(argc, argv, obj) int argc; @@ -147,6 +242,14 @@ enumerator_iter(memo) return rb_apply(memo->u1.value, memo->u2.id, memo->u3.value); } +/* + * call-seq: + * enum.each {...} + * + * Iterates the given block using the object and the method specified + * in the first place. + * + */ static VALUE enumerator_each(obj) VALUE obj; diff --git a/ext/tk/lib/tk/canvas.rb b/ext/tk/lib/tk/canvas.rb index 94b43ebc39..02b4a8cb20 100644 --- a/ext/tk/lib/tk/canvas.rb +++ b/ext/tk/lib/tk/canvas.rb @@ -28,7 +28,7 @@ module TkCanvasItemConfig def __item_val2ruby_optkeys(id) # { key=>proc, ... } super(id).update('window'=>proc{|i, v| window(v)}) end - private :__val2ruby_optkeys + private :__item_val2ruby_optkeys def __item_pathname(tagOrId) if tagOrId.kind_of?(TkcItem) || tagOrId.kind_of?(TkcTag) diff --git a/ext/tk/lib/tk/menu.rb b/ext/tk/lib/tk/menu.rb index e366816d57..be8ec2ddee 100644 --- a/ext/tk/lib/tk/menu.rb +++ b/ext/tk/lib/tk/menu.rb @@ -31,7 +31,7 @@ module TkMenuEntryConfig def __item_val2ruby_optkeys(id) # { key=>proc, ... } super(id).update('menu'=>proc{|i, v| window(v)}) end - private :__val2ruby_optkeys + private :__item_val2ruby_optkeys alias entrycget itemcget alias entryconfigure itemconfigure |