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

89 Коммитов

Автор SHA1 Сообщение Дата
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