1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
Commit graph

13 commits

Author SHA1 Message Date
knu
2bc5bfdc67 * enumerator.c (enumerator_init_copy): Take care of
initialize_copy as well as initialize.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16791 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-03 10:55:17 +00:00
knu
b5af8dbe17 * enumerator.c (enumerator_allocate, enumerator_ptr): Properly
detect if the object is initialized and raise error when
  appropriate.
  (enumerator_initialize): Fix a typo in rdoc. [ruby-core:17052]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16768 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-03 04:00:30 +00:00
knu
065f538086 * array.c (rb_ary_slice_bang): Be consistent with Array#slice()
and String#slice!().  Just return nil when a negative length or
  out of boundary index is given instead of raising an exception
  via internal functions.
  (rb_ary_slice_bang): should not use rb_ary_subseq() which shares
  internal pointer.  splice modifies the receiver right after
  subseq.  [ruby-dev:34005]
  (rb_ary_slice_bang): should adjust length before making
  sub-array.

* enumerator.c (Init_Enumerator): Override
  Enumerable::Enumerator#each_with_index with #with_index.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16582 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-24 20:07:54 +00:00
knu
1e81e55093 * enumerator.c (proc_call): Remove an unused static function.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16557 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-23 07:47:05 +00:00
knu
d007e7d20f * array.c (rb_ary_count): Override Enumerable#count for better
performance.
  (rb_ary_nitems): Undo the backport.  Use #count {} instead.

* enumerator.c (enumerator_iter_i): Remove an unused function.
  (enumerator_with_index, enumerator_each): Remove unused
  variables.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16417 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-14 10:26:48 +00:00
knu
8cf1995901 * enumerator.c: Update rdoc.
(enumerator_initialize): Discourage the use.
  (enum_each_slice, enum_each_cons, enumerator_each)
  (enumerator_with_index): Add a note about a call without a block.

* NEWS: Intentionally omit enum_slice and enum_cons, which are
  removed in 1.9.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16403 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-13 06:13:05 +00:00
knu
185e2676af * enumerator.c (enumerator_initialize): Remove an undocumented
feature (passing a block to the constructor) that's broken.
  This is not what I intended.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16147 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-22 10:39:19 +00:00
knu
0a436cd938 * enumerator.c (enumerator_init): preserve the method name in ID.
* enumerator.c (enumerator_each): need not to call rb_to_id().

* enumerator.c (enumerator_with_index): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-21 09:41:40 +00:00
knu
cc58638faa * enumerator.c: Resolve the method every time an enumeration
method is run, not once when the enumerator is initialized as it
  was before, so that method_missing() and method (re)definition
  afterwards are both in effect; pointed out in: [ruby-core:16441]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16108 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-20 12:02:59 +00:00
knu
4c4fad2749 * ruby.h (rb_block_call_func): Fix prototype.
* enumerator.c (enumerator_iter_i, enumerator_each_i): Ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16005 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-14 07:43:40 +00:00
usa
4f56ca8218 * enumerator.c (enumerator_mark, enumerator_iter_i, enumerator_each_i,
enumerator_allocate): add prototype.

	* enumerator.c (enumerator_each_i): declare unused two arguments.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16002 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-14 05:18:02 +00:00
knu
badb865567 * enumerator.c (rb_eStopIteration), eval.c (rb_f_loop), ruby.h:
Add a new exception class StopIteration, which breaks Kernel#loop
  iteration when raised; backported from 1.9.

* enumerator.c (enumerator_next, enumerator_rewind): Implement
  #next and #rewind using the "generator" library.

* lib/generator.rb: Implement Enumerable::Enumerator#next and
  #rewind.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@15954 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-10 10:52:50 +00:00
knu
fd8c8d09f4 * enumerator.c, inits.c (rb_call_inits), ruby.h, intern.h,
ext/enumerator, common.mk (OBJS, enumerator.$(OBJEXT)): Make the
  enumerator module built-in,

* enumerator.c: New method: Enumerable::Enumerator#with_index.

* enum.c (enum_each_with_index): Enumerable#each_with_index now
  returns an enumerator instead of raising an exception if no
  block is given.  Enumerable#enum_with_index, formerly defined in
  the enumerator module, is kept as an alias to each_with_index
  for backward compatibility.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@15934 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-09 11:13:04 +00:00