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

274 Коммитов

Автор SHA1 Сообщение Дата
akr 80870e14a7 [DOC]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48782 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12 03:15:56 +00:00
akr 2b9191e557 * internal.h: Gather declarations in non-header files.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-18 15:13:05 +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
nobu 723cee93c4 enum.c: nil if no iteration
* enum.c (enum_inject): return nil if no iteration, instead of
  Qundef.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47928 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-15 06:27:30 +00:00
nobu efaed8c80d enum.c: use Qundef
* enum.c (enum_inject): use Qundef for no initial values.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47926 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-15 05:25:36 +00:00
akr 5a601ec591 * enum.c: min(n) drops elements bigger than the n-th maximum element.
(struct nmin_data): New field to record the n-th maximumelement, limit
  (nmin_filter): Update limit field.
  (nmin_i): Drop too big eleents.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47923 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-14 22:24:34 +00:00
akr 2f83b32f71 update doc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47910 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-13 22:36:17 +00:00
akr 450307e383 * enum.c (nmin_run): max(n) and max_by(n) returns an array in
descending order.
  [ruby-core:65452] Suggested by David Grayson.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47907 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-13 16:30:07 +00:00
akr 5a77a4e71b Update doc. and warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47864 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-10 09:42:47 +00:00
akr 1292c5ec58 * enum.c (enum_chunk): Deprecate the state management.
(enum_slice_before): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47653 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-20 15:01:44 +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
knu f76e390ed6 Move enum.one? documentation before the relevant method.
* enum.c (enum_one): Move enum.one? documentation before the
  relevant method.  Submitted by @vipulnsward. [Fixes GH-687]
  https://github.com/ruby/ruby/pull/687

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47086 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-06 11:45:47 +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 e23d173679 revert r46859 and r46860
revert "enum.c: optimize any? object allocations for Array and Hash"

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46865 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-18 13:16:37 +00:00
nobu 0d0fc55122 enum.c: optimize any? object allocations for Array and Hash
* enum.c (enum_any): optimize object allocations for Array and
  Hash when `each` is not redefined, always false if empty and the
  case without a block.  [fix GH-617]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46859 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-18 02:10:37 +00:00
zzak b09c01eff0 * enum.c: [DOC] Use #find in example to clarify alias by @rachellogie
Patch submitted via documenting-ruby/ruby#34 [ci skip]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46095 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-25 01:20:30 +00:00
nobu 8d236c317f enum.c: suppress warnings
* enum.c (sliceafter_ii): suppress unused-value warnings.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45990 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-18 03:15:34 +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
akr 693703c391 [DOC]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45829 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-05 14:12:03 +00:00
nobu 118838ad3a enum.c: fix condition to recycle block argument
* enum.c (dont_recycle_block_arg): fix condition to recycle block
  argument.  lambda with rest can get internal array directly.
  [ruby-core:62060] [Bug #9749]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-16 14:47:38 +00:00
nobu 20675167d7 enum.c: make each_slice and each_cons more efficient
* enum.c (enum_each_slice, enum_each_cons): make more efficient by
  allocating less and recycling block argument arrays if possible.
  [Fixes GH-596]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45589 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-15 03:49:55 +00:00
nobu 3be926db2a revert [Bug #9605]
* enum.c: revert r45284, r45286, r45292.  it conflicts with
  existing behaviors.  [Bug #9605]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-12 08:16:47 +00:00
nobu e4c06f3c22 enum.c: suppress warnings
* enum.c (each_val_i): svalue is no longer used.
  [ruby-core:61340] [Bug #9605]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45292 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-08 05:49:12 +00:00
nobu c052c80cda enum.c: yield multiple values
* enum.c (find_i): yield multiple values instead of a packed
  array, so that lambda block can work.  with tests by Alex
  Rothenberg.  [ruby-core:61340] [Bug #9605]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45286 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-07 22:36:32 +00:00
akr f526784e1e * enum.c: Enumerable#{min,min_by,max,max_by} extended to take an
optional argument.
  (nmin_cmp): New function.
  (nmin_block_cmp): Ditto
  (nmin_filter): Ditto.
  (nmin_i): Ditto.
  (nmin_run): Ditto.
  (enum_min): Call nmin_run if the optional argument is given.
  (nmin_max): Ditto.
  (nmin_min_by): Ditto.
  (nmin_max_by): Ditto.

* range.c: Range#{min,max} extended to take an optional argument.
  (range_min): Call range_first if the optional argument is given.
  (range_max): Call rb_call_super if the optional argument is given.

[ruby-core:57111] [Feature #8887]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44958 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-14 15:45:11 +00:00
hsbt 993e57d175 * enum.c: document that it is OK to take more than available by @mvidner [fix GH-525] [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44901 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-10 05:39:26 +00:00
zzak f72e5b8bd3 * enum.c: [DOC] Add simple example of Enumerable#zip [ci skip]
Patch by @nruth on documenting-ruby/ruby#22
  https://github.com/documenting-ruby/ruby/pull/22


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-21 07:45:55 +00:00
marcandre 9471f4187f * array.c: Have to_h raise on elements that are not key-value pairs [#9239]
* enum.c: ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-23 03:42:29 +00:00
marcandre e91ccb6c67 * array.c: More doc examples for Array#{map|collect}{!} using both forms
* enum.c: ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44140 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-11 19:55:56 +00:00
nobu 58553ca184 ruby/ruby.h, enum.c, vm_eval.c: constify argv
* include/ruby/ruby.h (RB_BLOCK_CALL_FUNC_ARGLIST): constify argv.
* enum.c (rb_enum_values_pack): ditto.
* vm_eval.c (rb_block_call, rb_check_block_call): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43911 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-29 08:02:51 +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 32145ebfd6 array.c, enum.c, range.c: rb_block_call_func compatible
* array.c (take_i), range.c (first_i): make rb_block_call_func
  compatible.

* enum.c (collect_all, DEFINE_ENUMFUNCS): add blockarg.

* enum.c ({min,max,minmax,chunk,slicebefore}_ii): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43908 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-29 07:45:00 +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
marcandre dc215dcd9f * array.c: Add Array#to_h [Feature #7292]
* enum.c: Add Enumerable#to_h

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43401 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-23 15:10:48 +00:00
zzak b8d053030e * enum.c: [DOC] Enumerable#to_a accepts arguments [GH-388]
Patch by @kachick https://github.com/ruby/ruby/pull/388


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42999 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-20 15:49:42 +00:00
ko1 ad0ef29da7 * array.c (rb_ary_splice): use RARRAY_PTR_USE() without WB because
there are not new relations.
* enum.c (enum_sort_by): ditto.
* struct.c (setup_struct): use RARRAY_RAWPTR().
* vm_eval.c (yield_under): ditto.
* ext/pathname/pathname.c (path_entries): use RARRAY_AREF().
* ext/pathname/pathname.c (path_s_glob): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42688 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-26 05:47:27 +00:00
nobu c169b51389 internal.h: STATIC_ASSERT
* internal.h (STATIC_ASSERT): move from enum.c.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41895 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-10 11:47:54 +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 bd15d4ca78 * internal.h (numberof): Gathered from various files.
* array.c, math.c, thread_pthread.c, iseq.c, enum.c, string.c, io.c,
  load.c, compile.c, struct.c, eval.c, gc.c, parse.y, process.c,
  error.c, ruby.c: Remove the definitions of numberof.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41142 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07 10:01:19 +00:00
ko1 83aba04862 * include/ruby/ruby.h: constify RBasic::klass and add
RBASIC_CLASS(obj) macro which returns a class of `obj'.
  This change is a part of RGENGC branch [ruby-trunk - Feature #8339].
* object.c: add new function rb_obj_reveal().
  This function reveal interal (hidden) object by rb_obj_hide().
  Note that do not change class before and after hiding.
  Only permitted example is:
  klass = RBASIC_CLASS(obj);
  rb_obj_hide(obj);
  ....
  rb_obj_reveal(obj, klass);
  TODO: API design. rb_obj_reveal() should be replaced with others.
  TODO: modify constified variables using cast may be harmful for
  compiler's analysis and optimizaton.
  Any idea to prohibt inserting RBasic::klass directly?
  If rename RBasic::klass and force to use RBASIC_CLASS(obj),
  then all codes such as `RBASIC(obj)->klass' will be
  compilation error. Is it acceptable? (We have similar
  experience at Ruby 1.9,
  for example "RARRAY(ary)->ptr" to "RARRAY_PTR(ary)".
* internal.h: add some macros.
* RBASIC_CLEAR_CLASS(obj) clear RBasic::klass to make it internal
  object.
* RBASIC_SET_CLASS(obj, cls) set RBasic::klass.
* RBASIC_SET_CLASS_RAW(obj, cls) same as RBASIC_SET_CLASS
  without write barrier (planned).
* RCLASS_SET_SUPER(a, b) set super class of a.
* array.c, class.c, compile.c, encoding.c, enum.c, error.c, eval.c,
  file.c, gc.c, hash.c, io.c, iseq.c, marshal.c, object.c,
  parse.y, proc.c, process.c, random.c, ruby.c, sprintf.c,
  string.c, thread.c, transcode.c, vm.c, vm_eval.c, win32/file.c:
  Use above macros and functions to access RBasic::klass.
* ext/coverage/coverage.c, ext/readline/readline.c,
  ext/socket/ancdata.c, ext/socket/init.c,
* ext/zlib/zlib.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 10:49:11 +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
eregon bd14f5bf94 * enum.c (Enumerable#chunk): fix grammar of error message
for symbols beginning with an underscore [Bug #8351]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40539 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-01 10:04:21 +00:00
nobu 9f87297c21 enum.c: avoid inadvertent symbol creation
* enum.c (enum_inject): avoid inadvertent symbol creation.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40097 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-04 06:46:53 +00:00
zzak d2c218d559 * enum.c (Enumerable#chunk: Improved examples, grammar, and formatting
Patch by Dan Bernier and Rich Bruchal of newhaven.rb
  [Github documenting-ruby/ruby#8]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39370 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-22 02:11:26 +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 96af5360a4 * enum.c (enum_zip): Fix error message
* array.c (take_items): Same, for Array#zip
  [Bug #7706]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38927 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-24 07:51:05 +00:00
ko1 f6f388a5bd * array.c, enum.c, insns.def, io.c, numeric.c, parse.y, process.c,
range.c: use prepared IDs.
  A patch from charliesome (Charlie Somerville).
  [Bug #7495]
* common.mk: add dependency to id.h.
* common.mk: replace ID_H_INCLUDES with id.h.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38143 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-02 09:57:47 +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
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
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