Граф коммитов

290 Коммитов

Автор SHA1 Сообщение Дата
nobu b0dd250dc9 use RB_TYPE_P() instead of comparison of TYPE()
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35763 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-23 07:13:21 +00:00
nagachika 4007da1792 * enumerator.c (lazy_take_func, lazy_take): multiple calls of
force/to_a method to Enumerator::Lazy#take should return same
  results. [ruby-dev:45634] [Bug #6428]

* test/ruby/test_lazy_enumerator.rb (test_take_recycle): add test for
  above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35638 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-13 15:24:40 +00:00
nobu b30aa26707 initialize IDs in advance.
* enumerator.c (Init_Enumerator): initialize IDs in advance.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35219 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-03 01:24:51 +00:00
nobu 63e8110bfc * enumerator.c (inspect_enumerator): suppress uninitialized
instance variable warnings.  [ruby-dev:45449][Bug #6214]
  patched by no6v (Nobuhiro IMAI).


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35218 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-03 01:18:31 +00:00
shugo b9f67c4149 * enumerator.c (inspect_enumerator): show method arguments of
lazy enumerators correctly.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35136 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-26 10:52:02 +00:00
shugo 0c9f66eb40 * enumerator (lazy_initialize): set the instance variable "receiver"
to include the receiver to the return value of inspect on a lazy
  enumerator directly created by Enumerator::Lazy.new.

* enumerator (RETURN_LAZY): don't set the instance variable "receiver".

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-24 15:53:38 +00:00
shugo 6b885f6e74 * enumerator (enumerator_inspect): include the original receiver and
method name of Enumerator::Lazy in the result of inspect.
  [ruby-core:43345] [Bug #6159]

* enumerator (InitVM_Enumerator): don't use rb_define_alias for
  some methods such as collect in order to make rb_frame_this_func()
  return the correct method names.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35124 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-24 15:17:31 +00:00
shugo ded27bf5dc * enumerator.c (lazy_flat_map_func): convert the block value to
Array if it doesn't respond to each.  [ruby-core:43334]
  [Bug #6155]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35092 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-19 08:22:29 +00:00
shugo 831898bd99 * enumerator.c (enumerable_lazy): add an example of take and first
to the documentation.  [ruby-core:43344] [Bug #6158]
  add the description of the behavior when a block is given to zip
  or cycle.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35090 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-19 06:41:02 +00:00
kazu 30c0db4a85 follow r35040
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35075 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-16 22:05:31 +00:00
shugo 29f73009ca * enumerator.c (lazy_take): don't enumerate an extra value.
[ruby-dev:45370] [Bug #6152]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35050 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-16 02:22:20 +00:00
nobu a1f4163dd3 * enumerator.c (lazy_zip_func): variadic argument needs explicit cast
on the platforms where VALUE is longer than int.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35049 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-15 21:30:12 +00:00
nobu 641e9e7bce * enumerator.c (lazy_init_iterator): no need to check overflow twice.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35048 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-15 21:29:32 +00:00
drbrain 5e72676688 * enumerator.c (lazy_init_iterator): Fix type error (int vs long).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35046 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-15 20:53:23 +00:00
shugo 2baeb78294 * enum.c (rb_enum_values_pack): rename from enum_values_pack, and
remove static.

* enumerator.c (lazy_init_iterator, lazy_init_yielder,
  lazy_select_func, lazy_reject_func, lazy_grep_func): handle
  multiple values correctly.

* enumerator.c (lazy_grep): change the behavior when a block is
  given, to be consistent with Enumerable#grep.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35043 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-15 14:20:27 +00:00
shugo d135138f9b * enumerator.c (lazy_zip): rescue StopIteration returned by
Enumerator#next.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35042 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-15 10:14:22 +00:00
shugo 032861ade7 * enumerator.c (lazy_zip, lazy_cycle): Enumerator::Lazy#{zip,cycle}
should be eager when a block is given, to be consistent with
  Enumerable#{zip,cycle}.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35041 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-15 09:25:03 +00:00
shugo ff1f6107f9 * enumerator.c (InitVM_Enumerator): renamed Enumerable::Lazy to
Enumerator::Lazy.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35040 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-15 08:47:09 +00:00
shugo 4a1db362f0 * enumerator.c (enumerator_lazy): added cycle to the documentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35039 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-15 07:38:11 +00:00
nobu fbdce66908 * enumerator.c (lazy_cycle): check argument number overflow before
creating temporary array.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35036 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-15 06:19:42 +00:00
shugo d18dc74698 * enumerator.c (lazy_cycle): add Enumerable::Lazy#cycle.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35028 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-15 02:00:30 +00:00
marcandre 7316302483 * include/ruby/intern.h: Add rb_check_arity, rb_error_arity [#6085]
* array.c: Use rb_check_arity / rb_error_arity

* class.c: ditto

* enumerator.c: ditto

* eval.c: ditto

* file.c: ditto

* hash.c: ditto

* numeric.c: ditto

* proc.c: ditto

* process.c: ditto

* random.c: ditto

* re.c: ditto

* signal.c: ditto

* string.c: ditto

* struct.c: ditto

* transcode.c: ditto

* vm_eval.c: ditto

* vm_insnhelper.c: ditto & implementation of rb_error_arity

* test/ruby/test_arity.rb: tests for above

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-14 21:10:34 +00:00
shugo 552adf8c5b * enumerator.c (enumerable_lazy): fix the documentation of
Enumerable#lazy.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35021 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-14 16:00:30 +00:00
shugo c8860b504e * enumerator.c (lazy_init_iterator): break when Qundef is returned
to make obj.drop(3).take(2) work properly.

* enumerator.c (lazy_take_while): add Enumerable::Lazy#take_while.

* enumerator.c (lazy_drop): add Enumerable::Lazy#drop.

* enumerator.c (lazy_drop_while): add Enumerable::Lazy#drop_while.

* enumerator.c (InitVM_Enumerator): add Enumerable::Lazy#force as an
  alias of to_a.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35019 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-14 13:04:18 +00:00
shugo 0b35e9e5dd * enumerator.c (lazy_take): add Enumerable::Lazy#take.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35018 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-14 10:29:25 +00:00
shugo 0d94434eca * enumerator.c: use long for array indices.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35017 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-14 09:41:44 +00:00
shugo 449c8a2ba3 * enumerator.c: moved the comment of StopIteration.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35016 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-14 09:26:27 +00:00
nobu cb1d290886 * enumerator.c (lazy_grep_func): should use === instead of =~, as
well as Enumerable#grep

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35008 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-14 01:44:37 +00:00
nobu 8f30190dfe InitVM_Enumerator
* enumerator.c (InitVM_Enumerator): split from Init_Enumerator.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35007 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-14 01:35:12 +00:00
nobu 8cdfe403d3 Init_Enumerator
* enumerator.c (Init_Enumerator): initialize method IDs first.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35006 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-14 01:35:09 +00:00
shugo 6b4525912b * enumerator.c (lazy_zip_func): use each for non-Array objects.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35004 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-13 23:16:37 +00:00
shugo 22434473c7 * enumerator.c (lazy_zip): add Enumerable::Lazy#flat_map.
* enumerator.c (lazy_lazy): just returns self.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35003 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-13 23:08:15 +00:00
shugo f0f777bc4a * enumerator.c (enumerable_lazy): added the documenation of Enumerable#lazy.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34989 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-12 15:12:07 +00:00
ktsj 0934e6c014 * enumerator.c: remove trailing space.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34961 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-10 13:33:16 +00:00
shugo a21d0f72c2 * enumerator.c (lazy_flat_map): add Enumerable::Lazy#flat_map.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34956 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-09 05:34:41 +00:00
nobu e7d4e659a0 * enumerator.c (lazy_initialize, enumerable_lazy): no additional
arguments.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-08 15:35:05 +00:00
nobu 0b2c4f43d2 * enumerator.c: add Enumerable#lazy. based on the patch by
Innokenty Mikhailov at <https://github.com/ruby/ruby/pull/101>
  [ruby-core:37164] [Feature #4890]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34951 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-08 15:30:28 +00:00
nobu e160610200 * enumerator.c (enumerator_each, generator_each): pass arguments to
the block with yielder.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34950 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-08 15:26:01 +00:00
matz 3052f75db4 * enumerator.c (enumerator_rewind): update the documentation.
fixed: #6053

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34712 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-20 17:59:43 +00:00
drbrain a63b86e2a8 * enumerator.c: Document use of Enumerator.new for creating a lazy
enumeration for filtering/chaining.  [ruby-trunk - Feature #707]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34586 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-13 21:19:11 +00:00
nobu 8e6e8e6288 * use RB_TYPE_P which is optimized for constant types, instead of
comparison with TYPE.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-29 11:07:45 +00:00
drbrain d137810d3a * enumerator.c: Remove "enumeration sequenced by".
[Ruby 1.9 - Bug #4757]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32466 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-09 00:25:27 +00:00
akr e7996eb3cc * internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.

* iseq.h: declare rb_iseq_t dependent internal functions here.

* vm_core.h: declare rb_thread_t dependent internal functions here.

* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
  enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
  iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
  proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
  thread.c, time.c, transcode.c, variable.c, vm.c,
  tool/compile_prelude.rb: don't declare internal functions declared
  in above headers.  include above headers if required.

  Note that rb_thread_mark() was declared as
  void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
  void rb_thread_mark(void *ptr) in vm.c.  Now it is declared as
  the later in internal.h.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 22:43:38 +00:00
ryan ffe4aff8b3 More clarification for enumerator_feed
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31897 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-01 21:16:05 +00:00
ryan f4273e88a8 Extra formatting and clarification of enumerator_feed [#4757]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31879 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-31 23:19:50 +00:00
drbrain 6cfb4b614a * enumerator.c: Improve documentation. Patch by Dave Copeland.
[Ruby 1.9 - Bug #4757]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31704 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-22 23:33:21 +00:00
nobu 25b9eb5e57 * include/ruby/ruby.h (rb_data_type_t): restructured. [ruby-dev:41862]
add parent member.

* error.c (rb_typeddata_inherited_p): new function.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28676 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-07-18 07:31:54 +00:00
nobu 45f6fbf339 * removed trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28085 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-29 18:51:39 +00:00
marcandre 7729de4d91 * array.c: Documentation: change => in call-seq to ->.
Harmonize "#=>" in examples. [ruby-core:30206]

* bignum.c: ditto

* class.c: ditto

* compar.c: ditto

* cont.c: ditto

* dir.c: ditto

* encoding.c: ditto

* enum.c: ditto

* enumerator.c: ditto

* error.c: ditto

* eval.c: ditto

* file.c: ditto

* gc.c: ditto

* io.c: ditto

* load.c: ditto

* marshal.c: ditto

* math.c: ditto

* numeric.c: ditto

* object.c: ditto

* pack.c: ditto

* proc.c: ditto

* process.c: ditto

* random.c: ditto

* range.c: ditto

* re.c: ditto

* ruby.c: ditto

* signal.c: ditto

* sprintf.c: ditto

* string.c: ditto

* struct.c: ditto

* thread.c: ditto

* time.c: ditto

* transcode.c: ditto

* variable.c: ditto

* vm_eval.c: ditto

* vm_method.c: ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27865 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-17 21:07:33 +00:00
marcandre 1dee5e34a3 * error.c: RDoc for subclasses of Exception. [ruby-core:28394]
* cont.c: ditto

* enumerator.c: ditto

* io.c: ditto

* math.c: ditto

* numeric.c: ditto

* proc.c: ditto

* re.c: ditto

* thread.c: ditto

* transcode.c: ditto. Thanks to Run Paint for some of the documentation.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27671 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-08 04:50:09 +00:00
akr 309077c9ae * enumerator.c (inspect_enumerator): don't raise for uninitialized
enumerator.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-04-12 13:49:44 +00:00
matz 78a59da8bc * enumerator.c: move implementation of each_slice, each_cons,
each_with_object to enum.c.

* enum.c (each_slice_i): convert multiple values from yield into
  an array.

* enum.c (each_cons_i): ditto.

* enum.c (each_with_object_i): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26546 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-02-03 01:29:44 +00:00
mame ae8dc9b722 * vm_eval.c (rb_iterate): pass current block when the argument bl_proc
is NULL.  This behavior can be used to make enumerator faster
  [ruby-dev:39874]

* enumerator.c (enumerator_each): pass current block directly instead
  of trampoline block (enumerator_each_i).

* io.c (argf_each_line, argf_each_byte, argf_each_char): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26128 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-12-20 12:31:26 +00:00
mame 61ec623860 * enumerator.c (yielder_yield_push): Yielder#<< should return self.
[ruby-dev:39660]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25721 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-11-11 16:32:34 +00:00
akr b9e0294eda fix typos.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-11-03 17:46:28 +00:00
matz 0580ba0611 * array.c (rb_ary_to_ary): do not use #respond_to? to detect
to_ary.  Just call.  [ruby-core:23738]

* eval.c (rb_check_funcall): new function with method existence
  check.  returns Qundef when the method does not exist.

* enumerator.c (enumerator_rewind): just call method, using
  rb_check_funcall().  [ruby-core:23738]

* error.c (exc_equal): ditto.

* object.c (convert_type): ditto.

* error.c (rb_name_err_mesg_new): export function.

* eval.c (make_exception): ditto.

* io.c (pop_last_hash): return early when the last argument is nil.

* io.c (rb_io_puts): treat T_STRING specially for small
  optimization. 

* vm_eval.c (raise_method_missing): skip method call if possible
  using rb_method_basic_definition_p().

* vm_eval.c (method_missing): ditto.

* test/ruby/test_rubyoptions.rb (TestRubyOptions#test_debug): test
  suites changed to ignore exceptions caused by just-call policy.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25556 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-29 04:55:10 +00:00
nobu 40e50764f4 * enumerator.c (enumerator_block_call): extracted.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25164 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-29 15:37:28 +00:00
nobu 9c1e2b4fb7 * enumerator.c (enumerator_data_type): typed.
(yielder_data_type, generator_data_type): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24805 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-09 02:46:00 +00:00
matz c9775b0382 * enumerator.c (next_i): typo fixed (reached at end -> reached an
end).  pointed out by James Edward Gray II at LoneStar RubyConf.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24685 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-27 22:28:15 +00:00
akr c89714924c fix rdoc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24623 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-22 03:40:35 +00:00
akr b2a83ef6f2 rdoc update.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24622 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-22 03:19:53 +00:00
akr 461bd62fec * enumerator.c (ary2sv): add dup argument.
(enumerator_next): call ary2sv with dup=0.
  (enumerator_peek): call ary2sv with dup=1 to return duplicated array.
  (enumerator_peek_values_m): new function to return duplicated array.
  (Init_Enumerator): use enumerator_peek_values_m as
  Enumerator#peek_value.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24619 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-21 15:51:35 +00:00
akr 7609494ffd rdoc update.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24618 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-21 15:18:57 +00:00
akr 3a855da47b * enumerator.c (get_next_values): extracted from
enumerator_next_values.
  (enumerator_next_values): use get_next_values.
  (enumerator_peek_values): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24615 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-21 13:39:35 +00:00
akr ce46bc6345 rdoc update.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24590 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-19 20:26:38 +00:00
akr 0c0f754400 * enumerator.c (next_init): don't clear feedvalue.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24588 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-19 17:32:56 +00:00
akr 3b4949ffa8 * enumerator.c: implement Enumerator#{next_values,peek_values,feed}
and StopIteration#result.  [ruby-dev:39109]
  (struct enumerator): replace no_next by stop_exc.
  new field feedvalue.
  (enumerator_mark): mark feedvalue and stop_exc.
  (enumerator_init): initialize feedvalue and stop_exc.
  (enumerator_init_copy): initialize feedvalue.
  (next_ii): send yield arguments as an array.  return feedvalue.
  (next_i): generate StopIteration exception here.  set result.
  (next_init): initialize feedvalue.
  (enumerator_next_values): new method Enumerator#next_values.
  (ary2sv): new function.
  (enumerator_peek_values): new method Enumerator#peek_values.
  (enumerator_feed): new method Enumerator#feed.
  (yielder_yield): return the yield value.
  (generator_each): return the iterator value.
  (stop_result): new method StopIteration#result.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24587 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-19 16:36:00 +00:00
akr 2772c80ce0 * enumerator.c (enumerator_peek): new method Enumerator#peek.
(enumerator_next): don't rewind at end.
  [ruby-dev:38932]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24578 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-18 12:02:53 +00:00
nobu e07cb859cc * suppressed shorten-64-to-32 warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-18 08:05:32 +00:00
mame cb46d98caa * enumerator.c (yielder_yield_i): use rb_proc_new instead of
rb_iterate.  [ruby-dev:38518]
 
* README.EXT: rb_iterate is obsolete since 1.9; use rb_block_call
  instead.
 
* README.EXT.ja: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24094 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-13 16:07:43 +00:00
nobu 6494314d2a * enumerator.c (inspect_enumerator): should use long.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23497 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-05-20 09:34:34 +00:00
knu 385223daa2 Trivial change in comment.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23265 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-04-22 16:32:43 +00:00
knu 6712cca3b5 * enumerator.c (Enumerator#{each_,}{with_index,with_object}): Fix
a bug where any parameter but the first one is dropped even if
  multiple values are yielded with. [Bug #1198]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22992 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-03-17 09:07:18 +00:00
knu 3a701d7281 Slightly fix rdoc of with_index.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22170 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-09 05:52:09 +00:00
mame 3e11901f1c * enumerator.c (enumerator_with_index): receives one argument which
represents a start offset.  [ruby-dev:37921]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22134 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-08 14:42:01 +00:00
knu 2654904a1a * enumerator.c: Introduce id_each to save rb_itern() and SYM2ID()
calls.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21975 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-02 11:50:49 +00:00
knu 820c409ce9 * enumerator.c (enumerator_rewind): If the enclosed object
responds to a "rewind" method, call it; cf. [ruby-dev:37268]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20607 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-10 03:58:56 +00:00
knu 1ed799937b * enumerator.c (enumerator_next): Fix a typo: s/rewinded/rewound/.
* lib/prime.rb (Prime::OldCompatibility#each): Ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20604 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-10 03:49:48 +00:00
knu ea465ecda7 * enumerator.c (inspect_enumerator): Implement #inspect.
[ruby-dev:37248]-[ruby-dev:37263]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20481 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-04 02:44:38 +00:00
ko1 8cd252ac6f * common.mk: clean up
- remove blockinlining.$(OBJEXT) to built
  - make ENCODING_H_INCLDUES variable (include/ruby/encoding.h)
  - make VM_CORE_H_INCLUDES variable (vm_core.h)
  - simplify rules.
  - make depends rule to output depend status using gcc -MM.
* include/ruby/mvm.h, include/ruby/vm.h: rename mvm.h to vm.h.
* include/ruby.h: ditto.
* load.c: add inclusion explicitly.
* enumerator.c, object.c, parse.y, thread.c, vm_dump.c:
  remove useless inclusion.
* eval_intern.h: cleanup inclusion.
* vm_core.h: rb_thread_t should be defined in this file.
* vm_evalbody.c, vm_exec.c: rename vm_evalbody.c to vm_exec.c.
* vm.h, vm_exec.h: rename vm.h to vm_exec.h.
* insnhelper.h, vm_insnhelper.h: rename insnhelper.h to vm_insnhelper.h.
* vm.c, vm_insnhelper.c, vm_insnhelper.h:
  - rename vm_eval() to vm_exec_core().
  - rename vm_eval_body() to vm_exec().
  - cleanup include order.
* vm_method.c: fix comment.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19466 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-23 00:20:28 +00:00
knu 3e8c3897ab * enumerator.c: Activate Enumerator#with_object and add
Enumerable#each_with_object.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18864 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-26 05:45:18 +00:00
knu cb32985d03 * enumerator.c (enumerator_initialize),
test/ruby/test_enumerator.rb: Add an ability to generate an
  enumerator from a block. [experimental] [ruby-dev:35903]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18863 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-26 05:42:12 +00:00
knu 7b8e762afa * enumerator.c (Init_Enumerator): Rename Enumerable::Enumerator to
just Enumerator.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18564 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-13 06:25:53 +00:00
nobu 56e28fcf98 * enumerator.c (enumerator_with_object): suppress a warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18149 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-21 20:26:25 +00:00
matz b8b6c4894a * enumerator.c (enum_each_cons): typo in RDoc fixed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17493 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-20 19:41:29 +00:00
knu a938a52126 * enumerator.c (enumerator_with_object, Init_Enumerator):
Temporarily back out with_memo, for which we need a better name.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17353 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-16 00:49:25 +00:00
ko1 72ba13aa8e * array.c, bignum.c, cont.c, dir.c, dln.c, encoding.c, enumerator.c,
enumerator.c (enumerator_allocate), eval_jump.c, file.c, hash.c,
  io.c, load.c, pack.c, proc.c, random.c, re.c, ruby.c, st.c,
  string.c, thread.c, thread_pthread.c, time.c, util.c, variable.c,
  vm.c, gc.c:
  allocated memory objects by xmalloc (ruby_xmalloc) should be
  freed by xfree (ruby_xfree).
* ext/curses/curses.c, ext/dbm/dbm.c, ext/digest/digest.c,
  ext/gdbm/gdbm.c, ext/json/ext/parser/parser.c,
  ext/json/ext/parser/unicode.c, ext/openssl/ossl_cipher.c,
  ext/openssl/ossl_hmac.c, ext/openssl/ossl_pkey_ec.c,
  ext/sdbm/init.c, ext/strscan/strscan.c, ext/zlib/zlib.c:
  ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17017 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-08 10:01:40 +00:00
knu 9812a3a498 * enumerator.c (enumerator_with_index, enumerator_with_memo): Fix
grammo in rdoc.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16802 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-04 06:46:54 +00:00
knu a96cf7a7a5 * enumerator.c (enumerator_with_memo): New method: with_memo().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16795 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-03 12:43:45 +00:00
knu 7e7cbad17e * enumerator.c (enumerator_init_copy): Take care of
initialize_copy as well as initialize.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16790 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-03 10:34:45 +00:00
knu 10ffed17c9 * 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/trunk@16767 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-03 03:58:30 +00:00
knu 71b059e070 * enumerator.c (struct enumerator, enumerator_init)
(enumerator_init_copy, enumerator_each): Eliminate iter.
  (enumerator_ptr): Do not hardcode the class name.
  (enumerator_with_index): Delay variable initialization after
  RETURN_ENUMERATOR().


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16614 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-26 08:49:08 +00:00
knu efa115e451 * enumerator.c (Init_Enumerator): Override
Enumerable::Enumerator#each_with_index with #with_index.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16558 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-23 07:47:54 +00:00
knu 74430e8679 * 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.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16402 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-13 06:10:56 +00:00
nobu 89c408704b * enumerator.c (enumerator_each, enumerator_with_index): suppress
warnings.

* pack.c (pack_unpack): ditto.

* process.c (rb_syswait): ditto.

* re.c (rb_reg_prepare_enc, rb_reg_prepare_re,
  rb_reg_adjust_startpos): ditto.

* regparse.c (onig_name_to_group_numbers): ditto.

* missing/vsnprintf.c (BSD_vfprintf): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-22 13:49:43 +00:00
knu 80467678dd * 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/trunk@16146 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-22 10:36:31 +00:00
matz 59b08c22b5 * 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/trunk@16121 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-21 07:07:39 +00:00
knu d657d4feb3 * enumerator.c, include/ruby/ruby.h: Export rb_cEnumerator.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16107 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-20 12:01:27 +00:00
knu 3537b97bc1 * 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/trunk@16106 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-20 11:58:44 +00:00
akr 861219ce4a fix doc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15734 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-09 01:04:46 +00:00
mame c8048c5f07 * enumerator.c: fix documents.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15326 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-29 13:30:15 +00:00
matz 929faf7906 * enum.c (enum_zip): honor length of the receiver, not the
shortest length.  [ruby-core:14738]

* enum.c (enum_zip): returns array not enumerator for no block
  form.  [ruby-core:14738]

* enumerator.c (next_ii): do not ignore multiple values yielded.

* array.c (rb_ary_zip): faster version without creating generators.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-08 09:50:01 +00:00
nobu e791259e00 * enumerator.c (enumerator_iter_i): adjusted for rb_block_call_func.
* include/ruby/ruby.h (rb_block_call_func): function to be called back
  as block.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14416 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-21 07:33:31 +00:00
matz 1ee46d76c4 * enumerator.c (enumerator_init_copy): typo fixed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14407 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-21 06:18:25 +00:00
matz 8fa21bc05f * enumerator.c (enumerator_init_copy): prohibit cloning of
generators since Fibers cannot be copied.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14404 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-21 05:59:20 +00:00
matz bb1719875c * enumerator.c (enumerator_next): should call next_init() if fiber
is dead already. [ruby-dev:32459]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14374 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-20 23:33:32 +00:00
matz f00338f430 * insnhelper.ci (vm_yield_with_cfunc): call cfunc with
(argv[0], data, argc, argv) to pass all arguments.

* eval.c (loop_i): adapted to new calling convention.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14319 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-19 06:37:41 +00:00
matz 2bbffcd6a4 * insns.def (concatarray, splatarray): use to_a instead of
to_splat.

* insnhelper.ci (caller_setup_args): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14063 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-01 05:20:06 +00:00
ko1 6fafbfd63e * insnhelper.ci (vm_yield_with_cfunc): fix to passing argc on third
parameter of IFUNC.  [ruby-dev:32329]
* enumerator.c: fix to pass exact number of argument.
* eval.c (rb_yield_values2): added.
* include/ruby/ruby.h: ditto.
* bootstraptest/test_knownbug.rb: move a fixed test.
* bootstraptest/test_block.rb: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14062 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-01 04:30:19 +00:00
matz a68451d610 * enum.c (enum_butfirst): add a new method to iterates over
elements but first n.  RDoc need to be updated.

* enumerator.c (Init_Enumerator): remove unnecessary symbol
  initialization.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13793 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-30 01:06:10 +00:00
matz 98d6d636e3 * enumerator.c (enumerator_next): message changed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13279 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-26 16:33:45 +00:00
ko1 977d66ec99 * cont.c: separate Continuation and Fiber from core.
* ext/continuation/*, ext/fiber/*: ditto.
* include/ruby/ruby.h: remove rb_cFiber.
* include/ruby/intern.h: add the rb_fiber_new() declaration.
* enumerator.c (next_init): fix to use rb_fiber_new().
* test/ruby/test_enumerator.rb: remove next? tests.
* test/ruby/test_continuation.rb: add a require 'continuation'.
* test/ruby/test_fiber.rb: add a require 'fiber'.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-25 02:03:44 +00:00
matz 901343a761 * enumerator.c (enumerator_next): stop pre-fetching.
* enumerator.c (Init_Enumerator): remove next? method.

* eval.c (rb_f_loop): now handles StopIteration exception.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13245 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-24 10:48:43 +00:00
nobu e1b18be016 * enumerator.c (sym_call): initialize first.
* enumerator.c (enum_iter): typedefed.

* enumerator.c (next_i): suppress a warning.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13238 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-23 07:57:03 +00:00
ko1 c5e4cd0638 * cont.c: add Fiber#resume and Fiber.yield.
and Fiber::Core class to realize Coroutine.
* include/ruby/intern.h: declare rb_fiber_yield(), rb_fiber_resume(),
* enumerator.c: use above api.
* test/ruby/test_fiber.rb: fix and add tests for above changes.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13130 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-21 18:51:39 +00:00
ko1 ad56f8c611 * enumerator.c (next_i): fix to return with Fiber#yield at
the end of each block.  [ruby-dev:31470]
* enumerator.c (enumerator_next_p): call init_next if not
  initialized.  [ruby-dev:31514]
* test/ruby/test_enumerator.rb: add tests for Enumerator.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13120 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-20 18:58:32 +00:00
matz c186fdb90b * enumerator.c (enumerator_next_p): should check correctly even when
e.next has not been called before.

* enumerator.c (enumerator_next): raise StopIteration (name taken
  from Python) instead of IndexError.

* enum.c (enum_zip): catch StopIteration exception.

* enumerator.c (enumerator_with_index): return Enumerator if no
  block is given.

* test/ruby/test_iterator.rb (TestIterator::test_enumerator): add
  test for enumerators.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12905 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-08 07:07:03 +00:00
matz ecb93c3fdf * enum.c (enum_zip): zip no longer converts arguments into
arrays, uses enumerators.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12892 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-06 16:53:36 +00:00
matz 57b0b6c7b1 * cont.c (rb_fiber_yield): change argument ordering. export.
* cont.c (rb_fiber_current): export

* include/ruby/intern.h: export several functions from cont.c.

* enumerator.c (enumerator_next): new method to implement external
  iterator (generator) using fiber.

* enumerator.c (enumerator_next_p): new method to check whether
  any element is left in the generator sequence.

* enumerator.c (enumerator_rewind): a new method to rewind the
  generator sequence.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12891 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-06 16:41:17 +00:00
nobu 2b592580bf * include/ruby: moved public headers.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12501 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-10 03:06:15 +00:00
matz 369b098721 * enumerator.c (enumerator_init_copy): need to copy internal
structure on clone and dup.  [ruby-dev:30192]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11574 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-01-25 22:52:38 +00:00
matz 833551800d * enumerator.c (enum_each_cons): move RETURN_ENUMERATOR() after
argument check.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11230 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-10-27 08:31:10 +00:00
matz d4b775fe45 * enumerator.c: remove by_slice and by_cons.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11228 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-10-26 06:24:32 +00:00
matz 805e130d20 * enumerator.c (enumerator_by_slice): new method added.
* enumerator.c (enumerator_by_cons): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11219 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-10-25 00:21:54 +00:00
matz f1e4b10a84 * enumerator.c (enum_each_slice, enum_each_cons): returns
Enumerable::Enumerator if no block is given.  [ruby-dev:29246]

* enumerator.c: remove methods: enum_with_index, enum_slice,
  enum_cons.  [ruby-dev:29246]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11218 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-10-25 00:21:22 +00:00
matz 9317700a5d * eval.c (splat_value): use "to_splat" instead of "to_ary" to
prepare splat values as an array.

* array.c (Init_Array): define to_splat.

* range.c (range_to_splat): new method.

* enumerator.c (enumerator_to_splat): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11069 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-10-02 17:39:57 +00:00
matz 2156870525 * ruby.h (struct RArray): embed small arrays.
(RARRAY_LEN): defined for accessing array members.
  (RARRAY_PTR): ditto.

* array.c: use RARRAY_LEN and RARRAY_PTR.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10833 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-09-02 14:42:08 +00:00
matz 9b383bd6cf * sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).

* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
  basename and pid.  [ruby-talk:196272]
* parse.y (do_block): remove -> style block.

* parse.y (parser_yylex): remove tLAMBDA_ARG.

* eval.c (rb_call0): binding for the return event hook should have
  consistent scope.  [ruby-core:07928]

* eval.c (proc_invoke): return behavior should depend whether it
  is surrounded by a lambda or a mere block.

* eval.c (formal_assign): handles post splat arguments.

* eval.c (rb_call0): ditto.

* st.c (strhash): use FNV-1a hash.

* parse.y (parser_yylex): removed experimental ';;' terminator.

* eval.c (rb_node_arity): should be aware of post splat arguments.

* eval.c (rb_proc_arity): ditto.

* parse.y (f_args): syntax rule enhanced to support arguments
  after the splat.

* parse.y (block_param): ditto for block parameters.

* parse.y (f_post_arg): mandatory formal arguments after the splat
  argument.

* parse.y (new_args_gen): generate nodes for mandatory formal
  arguments after the splat argument.

* eval.c (rb_eval): dispatch mandatory formal arguments after the
  splat argument.

* parse.y (args): allow more than one splat in the argument list.

* parse.y (method_call): allow aref [] to accept all kind of
  method argument, including assocs, splat, and block argument.

* eval.c (SETUP_ARGS0): prepare block argument as well.

* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]

* eval.c (error_line): print receivers true/false/nil specially.

* eval.c (rb_proc_yield): handles parameters in yield semantics.

* eval.c (nil_yield): gives LocalJumpError to denote no block
  error.

* io.c (rb_io_getc): now takes one-character string.

* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
  hashing algorithm.

* string.c (rb_str_aref): str[0] now returns 1 character string,
  instead of a fixnum.	[Ruby2]

* parse.y (parser_yylex): ?c now returns 1 character string,
  instead of a fixnum.	[Ruby2]

* string.c (rb_str_aset): no longer support fixnum insertion.

* eval.c (umethod_bind): should not update original class.
  [ruby-dev:28636]

* eval.c (ev_const_get): should support constant access from
  within instance_eval().  [ruby-dev:28327]

* time.c (time_timeval): should round for usec floating
  number.  [ruby-core:07896]

* time.c (time_add): ditto.

* dir.c (sys_warning): should not call a vararg function
  rb_sys_warning() indirectly.	[ruby-core:07886]

* numeric.c (flo_divmod): the first element of Float#divmod should
  be an integer. [ruby-dev:28589]

* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.

* re.c (rb_reg_initialize): should not allow modifying literal
  regexps.  frozen check moved from rb_reg_initialize_m as well.

* re.c (rb_reg_initialize): should not modify untainted objects in
  safe levels higher than 3.

* re.c (rb_memcmp): type change from char* to const void*.

* dir.c (dir_close): should not close untainted dir stream.

* dir.c (GetDIR): add tainted/frozen check for each dir operation.

* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
  typo fixed.  a patch from Florian Gross <florg at florg.net>.

* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
  event_hooks.	no guarantee for arbitrary hook deletion.
  [ruby-dev:28632]

* util.c (ruby_strtod): differ addition to minimize error.
  [ruby-dev:28619]

* util.c (ruby_strtod): should not raise ERANGE when the input
  string does not have any digits.  [ruby-dev:28629]

* eval.c (proc_invoke): should restore old ruby_frame->block.
  thanks to ts <decoux at moulon.inra.fr>.  [ruby-core:07833]
  also fix [ruby-dev:28614] as well.

* signal.c (trap): sig should be less then NSIG.  Coverity found
  this bug.  a patch from Kevin Tew <tewk at tewk.com>.
  [ruby-core:07823]

* math.c (math_log2): add new method inspired by
  [ruby-talk:191237].

* math.c (math_log): add optional base argument to Math::log().
  [ruby-talk:191308]

* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
  uninitialized array element.	a patch from Pat Eyler
  <rubypate at gmail.com>.  [ruby-core:07809]

* array.c (rb_ary_fill): initialize local variables first.  a
  patch from Pat Eyler <rubypate at gmail.com>.	 [ruby-core:07810]

* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
  type_tag.  a patch from Pat Eyler <rubypate at gmail.com>.
  [ruby-core:07808]

* ext/socket/socket.c (make_hostent_internal): accept ai_family
  check from Sam Roberts <sroberts at uniserve.com>.
  [ruby-core:07691]

* util.c (ruby_strtod): should not cut off 18 digits for no
  reason.  [ruby-core:07796]

* array.c (rb_ary_fill): internalize local variable "beg" to
  pacify Coverity.  [ruby-core:07770]

* pack.c (pack_unpack): now supports CRLF newlines.  a patch from
  <tommy at tmtm.org>.	[ruby-dev:28601]

* applied code clean-up patch from Stefan Huehner
  <stefan at huehner.org>.  [ruby-core:07764]

* lib/jcode.rb (String::tr_s): should have translated non
  squeezing character sequence (i.e. a character) as well.  thanks
  to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]

* ext/socket/socket.c: document update patch from Sam Roberts
  <sroberts at uniserve.com>.  [ruby-core:07701]

* lib/mathn.rb (Integer): need not to remove gcd2.  a patch from
  NARUSE, Yui <naruse at airemix.com>.	[ruby-dev:28570]

* parse.y (arg): too much NEW_LIST()

* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.

* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
  [ruby-dev:28585]

* parse.y (arg): use NODE_ARGSCAT for placeholder.

* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
  mathew <meta at pobox.com>.  [ruby-core:07738]

* variable.c (rb_const_set): raise error when no target klass is
  supplied.  [ruby-dev:28582]

* prec.c (prec_prec_f): documentation patch from
  <gerardo.santana at gmail.com>.  [ruby-core:07689]

* bignum.c (rb_big_pow): second operand may be too big even if
  it's a Fixnum.  [ruby-talk:187984]

* README.EXT: update symbol description.  [ruby-talk:188104]

* COPYING: explicitly note GPLv2.  [ruby-talk:187922]

* parse.y: remove some obsolete syntax rules (unparenthesized
  method calls in argument list).

* eval.c (rb_call0): insecure calling should be checked for non
  NODE_SCOPE method invocations too.

* eval.c (rb_alias): should preserve the current safe level as
  well as method definition.

* process.c (rb_f_sleep): remove RDoc description about SIGALRM
  which is not valid on the current implementation. [ruby-dev:28464]

 Thu Mar 23 21:40:47 2006  K.Kosako  <sndgk393 AT ybb.ne.jp>

* eval.c (method_missing): should support argument splat in
  super.  a bug in combination of super, splat and
  method_missing.  [ruby-talk:185438]

* configure.in: Solaris SunPro compiler -rapth patch from
  <kuwa at labs.fujitsu.com>.  [ruby-dev:28443]

* configure.in: remove enable_rpath=no for Solaris.
  [ruby-dev:28440]

* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
  of converting  OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
  String object.

* ruby.1: a clarification patch from David Lutterkort
  <dlutter at redhat.com>.  [ruby-core:7508]

* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
  directories.	a patch from Eric Hodel <drbrain at segment7.net>.
  [ruby-core:07423]

* eval.c (rb_clear_cache_by_class): clearing wrong cache.

* ext/extmk.rb: use :remove_destination to install extension libraries
  to avoid SEGV.  [ruby-dev:28417]

* eval.c (rb_thread_fd_writable): should not re-schedule output
  from KILLED thread (must be error printing).

* array.c (rb_ary_flatten_bang): allow specifying recursion
  level.  [ruby-talk:182170]

* array.c (rb_ary_flatten): ditto.

* gc.c (add_heap): a heap_slots may overflow.  a patch from Stefan
  Weil <weil at mail.berlios.de>.

* eval.c (rb_call): use separate cache for fcall/vcall
  invocation.

* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
  functions.

* eval.c (rb_mod_local): a new method to specify newly added
  visibility "local".

* eval.c (search_method): search for local methods which are
  visible only from the current class.

* class.c (rb_class_local_methods): a method to list local methods.

* object.c (Init_Object): add BasicObject class as a top level
  BlankSlate class.

* ruby.h (SYM2ID): should not cast to signed long.
  [ruby-core:07414]

* class.c (rb_include_module): allow module duplication.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 21:20:17 +00:00
nobu 8e1d0d7cc3 * enumerator.c (enumerator_with_index): removed suspicious return
statement.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10069 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-03-31 05:25:00 +00:00
matz d4cecea858 * enumerator.c (enumerator_each): return self if no block is
given.  [yarv-dev:882]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9934 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-02-14 12:36:11 +00:00
matz 5675cdbd41 * eval.c: unify ruby_class (for method definition) and ruby_cbase
(for constant reference).

* eval.c (rb_call0): use TMP_ALLOC() instead of allocating
  a temporary array object.

* eval.c (eval): need not to protect $SAFE value.
  [ruby-core:07177]

* error.c (Init_Exception): change NameError to direct subclass of
  Exception so that default rescue do not handle it silently.

* struct.c (rb_struct_select): update RDoc description.
  [ruby-core:7254]

* numeric.c (int_upto): return an enumerator if no block is
  attached to the method.

* numeric.c (int_downto): ditto.

* numeric.c (int_dotimes): ditto.

* enum.c (enum_first): new method Enumerable#first to take first n
  element from an enumerable.

* enum.c (enum_group_by): new method Enumerable#group_by that
  groups enumerable values according to their block values.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9880 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-02-03 09:15:42 +00:00
nobu ea2b0febf0 * enumerator.c (enumerator_allocate): allow subclassing.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9475 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-10-27 11:35:24 +00:00
nobu 9c871d5a5a * enumerator.c, eval.c, gc.c, parse.y, regparse.c, sjis.c, time.c:
made internal symbols static.  [ruby-dev:27435]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9412 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-10-18 17:35:18 +00:00
ocean ca32aea6a2 * dir.c: changed `foo (*bar)_((boo))' to `foo (*bar)(boo)`.
* enumerator.c, eval.c, gc.c, intern.h, io.c, process.c, ruby.c,
  ruby.h, signal.c: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9157 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 08:30:16 +00:00
ocean 08c1738c51 * bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
  gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
  node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
  rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
  util.c, util.h, variable.c: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 06:32:32 +00:00
ocean dda5dc00cf * array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
   other platforms. And  `foo _((boo))' stuff is still there)
   [ruby-dev:26975]

* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
  enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
  io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
  prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
  regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
  sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
  version.c: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 10:44:21 +00:00
nobu c83d6db61b * enumerator.c (Init_Enumerator): provided features should have
extensions.

* eval.c (rb_feature_p): returns type of the feature instead of
  extension.

* eval.c (search_required): ruby library should be prior to statically
  linked extentions.  fixed: [ruby-dev:26711]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8913 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-08-04 15:09:03 +00:00
nobu 99ce5395af * enumerator.c (Init_Enumerator): wrong argument specs.
[ruby-core:05481]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8781 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-07-16 14:43:34 +00:00
nobu fd0f36a4a8 * enumerator.c (Init_Enumerator): use an internal directly.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8772 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-07-15 14:20:19 +00:00
nobu d725e6666a * enum.c (enumeratorize): create new enumerator for current method if
no block is given.

* enumerator.c: moved from ext/enumerator.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8764 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-07-14 15:15:22 +00:00