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

373 Коммитов

Автор SHA1 Сообщение Дата
normal 4c0c299964 use predefined ids in a few more places
Saves a little space on x86:

   text	   data	    bss	    dec	    hex	filename
3684110	  11968	  34240	3730318	 38eb8e	ruby.before
3684086	  11968	  34240	3730294	 38eb76	ruby.after

* enumerator.c: include id.h, define aliases
  (Init_Enumeerator): remove unnecessary rb_intern calls
* gc.c (should_be_callable): use idCall
* vm.c (Init_VM): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61704 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-09 02:45:03 +00:00
nobu 20685cdc85 Get rid of shadowing local variables
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60204 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-18 04:35:25 +00:00
nobu 51982c8139 enumerator.c: fix nested maps
* enumerator.c (lazy_map_proc, lazy_grep_iter_proc): marks values
  returned by blocks are not packed in the case of nested maps, so
  that the result will be same as non-lazy version.  based on the
  patch by akihikodaki (Akihiko Odaki) at [ruby-core:81638],
  without GCC extension.  [Bug#13648]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59056 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-10 10:26:32 +00:00
akr 7c7444bcd3 Enumerator::Lazy#chunk_while defined.
* enumerator.c (InitVM_Enumerator): Enumerator::Lazy#chunk_while
  defined.  [Fix GH-1186]
  https://github.com/ruby/ruby/pull/1186



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56607 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-05 15:46:48 +00:00
nobu 856afbef61 enumerator.c: lazy enum improvement
* enumerator.c (lazy_init_yielder): directly call stored functions.
  [Feature #6183]
* enumerator.c (lazy_add_method): create lazy enumerator which
  uses lazy_init_yielder().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56185 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-19 01:36:56 +00:00
nobu c463366dfd rb_funcallv
* *.c: rename rb_funcall2 to rb_funcallv, except for extensions
  which are/will be/may be gems.  [Fix GH-1406]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55773 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-29 11:57:14 +00:00
nobu 6882b35460 enumerator.c: Enumerator::Lazy#uniq
* enumerator.c (lazy_uniq): new method Enumerator::Lazy#uniq.
  [Feature #11090]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55710 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-20 08:44:08 +00:00
nobu 5987e6a50b enumerator.c: use ALLOCV
* enumerator.c (lazy_init_iterator): use ALLOCV instead of tmp
  array.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53132 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-15 15:32:28 +00:00
ko1 2f5b8f0529 * *.c (*_memsize): do not check ptr.
NULL checking is finished Before call of memsize functions.
  See r52979.




git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-09 00:38:32 +00:00
nobu 7d0b7fb4cf enumerator.c: lazy_grep_v
* enumerator.c (lazy_grep_v): add Enumerator::Lazy#grep_v as well
  as Enumerable, to enumerate lazily.
  [ruby-core:71845] [Feature #11773]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52943 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-08 07:23:43 +00:00
nobu 4191a6b90d preserve encodings in error messages
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51962 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-28 02:40:46 +00:00
ko1 08f3cfb585 * internal.h: use T_IMEMO to represent `struct MEMO' value.
memo->v1 and memo->v2 is WB protected values.
  So use MEMO_V1/V2_SET() macros to set these values.
  memo->u3 is ambiguous (sometimes a VALUE, sometimes an integer
  value), so use gc_mark_maybe() in gc.c to mark it.
  Rename NEW_MEMO() to MEMO_NEW().
  Move MEMO_FOR and NEW_MEMO_FOF macros from node.h.
  Export a rb_imemo_new() function for ext/ripper.
* node.h: remove NODE_MEMO.
* enum.c: catch up these change.
* enumerator.c: ditto.
* load.c: ditto.
* ext/objspace/objspace.c (count_nodes): ditto.
* gc.c (gc_mark_children): mark imemo_memo type.
* parse.y (new_args_gen): use T_IMEMO.
  (I'm not sure it is working correctly...)



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49942 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-11 23:13:01 +00:00
ko1 97e21517a3 * internal.h: define struct MEMO.
* enum.c: use MEMO.
* enumerator.c: ditto.
* load.c: ditto.
* node.h: return (struct MEMO *) pointer.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49928 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-11 00:20:45 +00:00
nobu e580a631be use 0 for reserved
use 0 for rb_data_type_t::reserved instead of NULL, since its type
may be changed in the future and possibly not a pointer type.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-01 06:38:04 +00:00
akr 7cd76ab0c5 * internal.h: Include ruby.h and ruby/encoding.h to be
includable without prior inclusion.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-15 11:49:06 +00:00
akr cc659d2f1b * enum.c (enum_slice_when): New method: Enumerable#slice_when.
(slicewhen_i): New function.
  (slicewhen_ii): New function.

* enumerator.c (InitVM_Enumerator): New method:
  Enumerator::Lazy#slice_when.

  [ruby-core:62499] [Feature #9826]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47652 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-20 06:52:29 +00:00
nobu 95d1b61a14 symbols instead of IDs
* encoding.c (rb_enc_get_index): deal with symbols instead of IDs
  to get rid of inadvertent pin-downs.

* enum.c (chunk_ii): ditto.

* enumerator.c (append_method): ditto.

* iseq.c (iseq_load): ditto.

* marshal.c (w_symbol, r_symlink, r_symreal, r_symbol): ditto.

* signal.c (trap_handler): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46988 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-28 08:15:42 +00:00
nobu 876bfc6b4e Init functions don't need ID caches
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46663 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-03 03:38:10 +00:00
nobu e99ee55abc constify parameters
* include/ruby/intern.h: constify `argv` parameters.

* include/ruby/ruby.h: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46459 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-18 06:16:39 +00:00
zzak a563664e06 * enumerator.c: [DOC] Fix example to show Enumerator#peek behavior
Patch by Erik Hollembeak [Bug #9814] [ci skip]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46099 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-25 03:00:17 +00:00
nobu abfa2b6c7e enumerator.c: adjust style [ci skip]
* enumerator.c (yielder_yield_push): Insert a break after the
  method return value.  [fix GH-617]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46071 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-24 06:05:35 +00:00
akr ddd155842f * enum.c: Enumerable#slice_after implemented.
* enumerator.c: Enumerator::Lazy#slice_after implemented.

  Requested by Tsuyoshi Sawada.  [ruby-core:58123] [Feature #9071]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45981 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-18 00:06:05 +00:00
ko1 57e557908a * enumerator.c (enumerator_block_call): use PARRAY_CONST_PTR()
instead of RARRAY_PTR().
* io.c (rb_io_s_popen): ditto.
* numeric.c (num_step_size): ditto.
* vm_eval.c (rb_apply): ditto.
* vm_eval.c (rb_eval_cmd): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45353 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-17 04:20:16 +00:00
nobu 520f0fec95 enumerator.c: should not store local variable address
* enumerator.c (enumerator_with_index): should not store local variable
  address to memoise the arguments.  it is invalidated after the return.
  [ruby-core:58692] [Bug #9178]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43929 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-30 07:25:17 +00:00
nobu 7566c49068 ruby/ruby.h: RB_BLOCK_CALL_FUNC_ARGLIST
* include/ruby/ruby.h (RB_BLOCK_CALL_FUNC_ARGLIST): for declaration
  argument list of rb_block_call_func.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43910 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-29 07:59:14 +00:00
nobu 9f45081627 ruby/ruby.h: add blockarg to rb_block_call_func
* include/ruby/ruby.h (rb_block_call_func): add blockarg.  block
  function can take block argument, e.g., proc {|&blockarg| ...}.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43907 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-29 02:26:48 +00:00
glass eb86296497 * enumerator.c (append_method): use RARRAY_CONST_PTR().
* enumerator.c (lazy_init_iterator): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43578 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-08 01:52:07 +00:00
ko1 c5e08b764e * add RUBY_TYPED_FREE_IMMEDIATELY to data types which only use
safe functions during garbage collection such as xfree().
  On default, T_DATA objects are freed at same points as fianlizers.
  This approach protects issues such as reported by [ruby-dev:35578].
  However, freeing T_DATA objects immediately helps heap usage.
  Most of T_DATA (in other words, most of dfree functions) are safe.
  However, we turned off RUBY_TYPED_FREE_IMMEDIATELY by default
  for safety.
* cont.c: ditto.
* dir.c: ditto.
* encoding.c: ditto.
* enumerator.c: ditto.
* error.c: ditto.
* file.c: ditto.
* gc.c: ditto.
* io.c: ditto.
* iseq.c: ditto.
* marshal.c: ditto.
* parse.y: ditto.
* proc.c: ditto.
* process.c: ditto.
* random.c: ditto.
* thread.c: ditto.
* time.c: ditto.
* transcode.c: ditto.
* variable.c: ditto.
* vm.c: ditto.
* vm_backtrace.c: ditto.
* vm_trace.c: ditto.
* ext/bigdecimal/bigdecimal.c: ditto.
* ext/objspace/objspace.c: ditto.
* ext/stringio/stringio.c: ditto.
* ext/strscan/strscan.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43466 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-29 11:16:54 +00:00
ko1 dc626dbab3 * include/ruby/ruby.h: rename RARRAY_RAWPTR() to RARRAY_CONST_PTR().
RARRAY_RAWPTR(ary) returns (const VALUE *) type pointer and
  usecase of this macro is not acquire raw pointer, but acquire
  read-only pointer. So we rename to better name.
  RSTRUCT_RAWPTR() is also renamed to RSTRUCT_CONST_PTR()
  (I expect that nobody use it).
* array.c, compile.c, cont.c, enumerator.c, gc.c, proc.c, random.c,
  string.c, struct.c, thread.c, vm_eval.c, vm_insnhelper.c:
  catch up this change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43043 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-25 08:24:34 +00:00
zzak df3e4b8306 * enumerator.c: [DOC] Enumerator#each arguments documentation [GH-388]
Patch by @kachick  https://github.com/ruby/ruby/pull/388


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43000 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-20 15:51:17 +00:00
nobu 1af4196cdf enumerator.c: rb_check_funcall
* enumerator.c (enumerator_size): use rb_check_funcall() instead of
  respond_to? and call.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42707 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-27 07:56:52 +00:00
nobu 9b4b5ad27c enumerator.c: add comment
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42706 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-27 07:56:17 +00:00
nobu a5f18c1f9d enumerator.c: check arg size
* enumerator.c (enumerator_each): ensure argument array size is int.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42705 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-27 07:51:27 +00:00
marcandre ca7f52a32a * enumerator.c: Allow Enumerator size argument to be any callable.
Patch by Avdi Grimm. [bug #8641] [ruby-core:56032] [fix GH-362]

* test/ruby/test_enumerator.rb: Test for above

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42698 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-27 02:50:08 +00:00
nobu 8d644d6a6e enumerator.c: fix non-single argument
* enumerator.c (lazy_zip_func): fix non-single argument.  fix
  out-of-bound access and pack multiple yielded values.
  [ruby-core:56383] [Bug #8735]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42450 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-08 15:10:37 +00:00
zzak b649592c4a * enumerator.c: [DOC] Remove reference to Enumerator::Lazy#cycle
Patch by @kachick [Fixes GH-372]
  https://github.com/ruby/ruby/pull/372


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42379 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-04 21:15:08 +00:00
knu 075752a836 Add a frozenness check to Enumerator::Generator#initialize.
* enumerator.c (generator_init): Ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42234 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-29 12:06:42 +00:00
knu 8cb0de91c4 Add a frozenness check to Enumerator#initialize.
* enumerator.c (enumerator_init): Add a frozenness check to
  prevent a frozen Enumerator object from being reinitialized with
  a different enumerable object.  This is the least we should do,
  and more fixes will follow. [Fixes GH-368] Patch by Kenichi
  Kamiya.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42233 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-29 12:06:39 +00:00
nobu da0c4e5e11 enumerator.c: lazyenum_size
* enumerator.c (lazyenum_size): adjust arguments.

* enumerator.c (enumerable_lazy): use lazyenum_size() instead of
  enum_size().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41688 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-28 04:26:21 +00:00
nobu 0f73dde5da enumerator.c: adjust indent
* enumerator.c (rb_enumeratorize_with_size): adjust indent.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41669 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-27 07:51:55 +00:00
nobu e5178a2550 enumerator.c: use rb_enumerator_size_func
* enumerator.c (rb_enumeratorize_with_size): use strict definition
  rb_enumerator_size_func.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41661 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-26 14:22:23 +00:00
nobu 5e2f227d21 intern.h: define rb_enumerator_size_func
* include/ruby/intern.h (rb_enumerator_size_func): define strict
  function declaration for rb_enumeratorize_with_size().


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41656 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-26 13:43:22 +00:00
akr e12df5ef40 Update doc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40883 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-21 13:54:31 +00:00
nobu 8a28e97ae9 enumerator.c: use VALUE
* enumerator.c (inspect_enumerator): use VALUE instead of mere char*
  by using rb_sprintf() and rb_id2str().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40805 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-18 02:05:17 +00:00
nobu 6b6ca88925 enumerator.c: append_method
* enumerator.c (append_method): extract from inspect_enumerator().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40804 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-18 02:03:07 +00:00
nobu 15b88811d6 enumerator.c: fix style
* enumerator.c (enumerator_initialize): no cuddle up else.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40803 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-18 01:58:00 +00:00
ko1 aacd771046 * *.c, parse.y, insns.def: use RARRAY_AREF/ASET macro
instead of using RARRAY_PTR().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 09:56:22 +00:00
zzak 9ef4e13459 * array.c: Document synonymous methods, by windwiny [GH-277]
* bignum.c: ditto
* complex.c: ditto
* dir.c: ditto
* encoding.c: ditto
* enumerator.c: ditto
* numeric.c: ditto
* proc.c: ditto
* re.c: ditto
* string.c: ditto


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-12 02:59:07 +00:00
naruse 5f257cf403 * enumerator.c (enumerator_with_index): try to convert given offset to
integer. fix bug introduced in r39594.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39722 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-11 09:47:15 +00:00
kazu dbec401c11 use INT2FIX(0) instead of INT2NUM(0).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39604 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-05 16:31:19 +00:00
drbrain 6c77ae07a5 * enumerator.c (enumerator_with_index): Restore handling of a nil memo
from r39594.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39596 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-05 03:25:55 +00:00
nobu 4a429c11e1 enumerator.c: allow Bignum for with_index
* enumerator.c (enumerator_with_index_i): allow Bignum as offset, to
  get rid of conversion exception and integer overflow.
  [ruby-dev:47131] [Bug #8010]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39594 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-05 01:20:20 +00:00
marcandre 673e1b9276 * enumerator.c: rdoc fix
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39438 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-23 17:38:12 +00:00
nobu 4b81b403eb enumerator.c: suppress warnings
* enumerator.c (lazy_zip_arrays_func, lazy_zip_func, lazy_take_func),
  (lazy_drop_func, lazy_drop_while_func): suppress uninitialized
  instance vriable warnings.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39329 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-20 03:15:32 +00:00
marcandre 757bbe8737 * enumerator.c: Remove rdoc that is obsolete because of lazy
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39066 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-05 05:52:39 +00:00
marcandre 1677cbce9d * enumerator.c: Use to_enum for Enumerable methods returning Enumerators.
This makes Lazy#cycle no longer needed, so it was removed.
  Make Enumerator#chunk and slice_before return lazy Enumerators.
  [Bug #7715]

* internal.h: Remove ref to rb_enum_cycle_size; no longer needed

* enum.c: Make enum_cycle_size static.

* test/ruby/test_lazy_enumerator.rb: Test for above

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39058 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-05 03:49:59 +00:00
marcandre 44cd5f21e9 * enumerator.c: Finalize and document Lazy.new. [Bug #7248]
Add Lazy#to_enum and simplify Lazy#size.

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

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39057 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-05 03:49:41 +00:00
marcandre 5af821c6e9 * enumerator.c: Fix and improve rdoc for to_enum
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39056 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-05 03:49:22 +00:00
marcandre aab2f788d7 * enumerator.c (lazy_zip): raise error for bad arguments
[Bug #7706]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38926 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-24 07:50:33 +00:00
marcandre 1af390b1ea * enumerator.c: Optimize Lazy#zip when passed only arrays
[Bug #7706]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38925 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-24 07:05:42 +00:00
marcandre 41d6ba8765 * enumerator.c: Fix state handling for Lazy#zip
[bug #7696] [bug #7691]

* test/ruby/test_lazy_enumerator.rb: test for above

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38923 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-24 06:24:22 +00:00
marcandre 9d94a1a5a1 * enumerator.c: Fix state handling for Lazy#drop
[bug #7696] [bug #7691]

* test/ruby/test_lazy_enumerator.rb: test for above

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38922 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-24 06:23:42 +00:00
marcandre bcbeb5d008 * enumerator.c: Fix state handling for Lazy#drop_while
[bug #7696] [bug #7691]

* test/ruby/test_lazy_enumerator.rb: test for above

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38921 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-24 06:23:07 +00:00
marcandre de0e887635 * enumerator.c: Fix state handling for Lazy#take
[bug #7696]

* test/ruby/test_lazy_enumerator.rb: test for above

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38920 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-24 06:22:34 +00:00
shugo 7dd52f895f * enumerator.c (lazy_flat_map_func): flat_map should call each only
when the value of a block returns a forcable object.
  [ruby-core:51401] [Bug #7690]

* enumerator.c (lazy_flat_map): add documentation.

* test/ruby/test_lazy_enumerator.rb: related test.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38812 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-14 08:36:15 +00:00
marcandre 8ca504214d * enumerator.c: Require block for Lazy#{take|drop}_while [Bug #7692]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38811 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-14 07:42:43 +00:00
marcandre 62e67609b6 * enumerator.c: Fix size for Enumerator::Lazy#flat_map
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38808 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-14 01:19:12 +00:00
marcandre 19c530d8c1 * enumerator.c: Fix rdoc typo (thanks to Yutaka HARA)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38793 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-13 00:19:10 +00:00
nobu e878df745c use RB_TYPE_P
* enumerator.c (enumerator_initialize), eval.c (rb_using_refinement),
  (add_activated_refinement), numeric.c (num_interval_step_size),
  parse.y (arg, match_op_gen, cond0), range.c (range_bsearch),
  vm_insnhelper.c (vm_get_iclass): use RB_TYPE_P() to optimize.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38653 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-29 12:22:01 +00:00
nobu 66fd9d44d8 adjust style.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38128 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-01 15:25:28 +00:00
marcandre a68cc24a9e * include/ruby/intern.h: Restore rb_enumeratorize as it was before r37497
and introduce rb_enumeratorize_with_size instead. [#7302]

* enumerator.c: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37543 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-07 19:46:16 +00:00
nobu db54dc7215 enum.c: prefix
* enum.c (rb_enum_cycle_size): prefix with rb.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37531 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06 22:52:52 +00:00
nobu 7f00f853d4 adjust style
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37530 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06 22:50:30 +00:00
marcandre 0814c4ac64 * enumerator.c: Support for lazy.cycle.size
[Feature #6636]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37525 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06 17:16:58 +00:00
marcandre 7a31096255 * enumerator.c: Add support for lazy.drop.size
[Feature #6636]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37524 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06 17:16:44 +00:00
marcandre 9aafa954aa * enumerator.c: Support for lazy.take.size
[Feature #6636]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37523 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06 17:16:29 +00:00
marcandre 5dbbfc3b34 * enumerator.c: Support for lazy.{map|flat_map|...}.size
[Feature #6636]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37522 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06 17:16:13 +00:00
marcandre c8426ce840 * enumerator.c: Support for lazy.size
[Feature #6636]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37521 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06 17:15:59 +00:00
marcandre 57d596cdb4 * enumerator.c: Support #size for enumerators created from enumerators
[Feature #6636]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06 17:10:35 +00:00
marcandre acfd34a6a9 * enumerator.c (obj_to_enum): Have #to_enum accept a block
[Feature #6636]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37498 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06 17:10:20 +00:00
marcandre 610eeffa46 * enumerator: New method #size; constructor accepts size
[Feature #6636]

* include/ruby/intern.h: RETURN_SIZED_ENUMERATOR for support of
  sized enumerators

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37497 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06 17:10:06 +00:00
marcandre c73b6bd7eb * enumerator.c (enumerator_initialize): Warn when using deprecated form
[Feature #6636]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37495 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06 17:09:43 +00:00
nobu 2073258a7d obj_init_copy
* object.c (rb_obj_init_copy): should check if trusted too.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35922 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-05 11:13:18 +00:00
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