aboutsummaryrefslogtreecommitdiffstats
path: root/enumerator.c
Commit message (Collapse)AuthorAgeFilesLines
* [DOC] Improve docs for Enumerator.produce, Enumerator.newMarcus Stollsteimer2019-12-241-14/+12
|
* Fix typos of previous docs PRzverok2019-12-231-1/+1
| | | | | | In #2612 I made two typos (extra ,, and copy-pasted same line of code instead of showing two different ones), fixing them.
* Some fixes in Enumerator::Lazy docsMarcus Stollsteimer2019-12-221-23/+24
| | | | | | * fix list in #flat_map * fix wrong indentation in #filter_map and #with_index * other small fixes
* Added rb_warn_deprecatedNobuyoshi Nakada2019-12-191-1/+1
|
* Fix Enumerator::Lazy#with_indexJeremy Evans2019-12-111-65/+56
| | | | | | | | | | | | | | | | * Make it correctly handle lambdas * Make it iterate over the block if block is given The original implementation was flawed, based on lazy_set_method instead of lazy_add_method. Note that there is no implicit map when passing a block, the return value of the block passed to with_index is ignored, just as it is for Enumerator#with_index. Also like Enumerator#with_index, when called with a block, the return value is an enumerator without the index. Fixes [Bug #16414]
* Make Enumerator::Chain#each treat lambdas as lambdaJeremy Evans2019-12-031-8/+1
| | | | | | | | Previously, lambdas were converted to procs because of how rb_block_call works. Switch to rb_funcall_with_block, which handles procs as procs and lambdas as lambdas. Fixes [Bug #15613]
* Deprecate taint/trust and related methods, and make the methods no-opsJeremy Evans2019-11-181-3/+0
| | | | | | This removes the related tests, and puts the related specs behind version guards. This affects all code in lib, including some libraries that may want to support older versions of Ruby.
* Right size the Enumerator internal lazy_use_super_method hashLourens Naudé2019-10-291-1/+1
|
* Improve Enumerator.produce docszverok2019-10-271-0/+15
| | | | | * Add to NEWS; * Add examples of while-alike cycles with practical tasks.
* Documentation improvements for Ruby corezverok2019-10-261-1/+7
| | | | | | | | | | | * Top-level `return`; * Documentation for comments syntax; * `rescue` inside blocks; * Enhance `Object#to_enum` docs; * Make `chomp:` option more obvious for `String#each_line` and `#lines`; * Enhance `Proc#>>` and `#<<` docs; * Enhance `Processs` class docs.
* Add rb_enumeratorize_with_size_kw and related macrosJeremy Evans2019-09-301-7/+19
| | | | | | | | | | Currently, there is not a way to create a sized enumerator in C with a different set of arguments than provided by Ruby, and correctly handle keyword arguments. This function allows that. The need for this is fairly uncommon, but it occurs at least in Enumerator.produce, which takes arugments from Ruby but calls rb_enumeratorize_with_size with a different set of arguments.
* Fix more keyword separation issuesJeremy Evans2019-09-261-2/+2
| | | | | | | | | | | | | | | | | | | | | This fixes instance_exec and similar methods. It also fixes Enumerator::Yielder#yield, rb_yield_block, and a couple of cases with Proc#{<<,>>}. This support requires the addition of rb_yield_values_kw, similar to rb_yield_values2, for passing the keyword flag. Unlike earlier attempts at this, this does not modify the rb_block_call_func type or add a separate function type. The functions of type rb_block_call_func are called by Ruby with a separate VM frame, and we can get the keyword flag information from the VM frame flags, so it doesn't need to be passed as a function argument. These changes require the following VM functions accept a keyword flag: * vm_yield_with_cref * vm_yield * vm_yield_with_block
* Fix keyword argument separation issues in Enumerator::Generator#eachJeremy Evans2019-09-261-1/+1
| | | | This requires adding rb_proc_call_kw to pass the keyword flag.
* Handle keyword argument separation for Enumerator#sizeJeremy Evans2019-09-201-1/+1
| | | | | | | | | When Object#to_enum is passed a block, the block is called to get a size with the arguments given to to_enum. This calls the block with the same keyword flag as to_enum is called with. This requires adding rb_check_funcall_kw and rb_check_funcall_default_kw to handle keyword flags.
* Consolidate empty keyword handlingJeremy Evans2019-09-131-8/+2
| | | | | | | | | | | | | | | | | | | | | | Remove rb_add_empty_keyword, and instead of calling that every place you need to add empty keyword hashes, run that code in a single static function in vm_eval.c. Add 4 defines to include/ruby/ruby.h, these are to be used as int kw_splat values when calling the various rb_*_kw functions: RB_NO_KEYWORDS :: Do not pass keywords RB_PASS_KEYWORDS :: Pass final argument (which should be hash) as keywords RB_PASS_EMPTY_KEYWORDS :: Add an empty hash to arguments and pass as keywords RB_PASS_CALLED_KEYWORDS :: Passes same keyword type as current method was called with (for method delegation) rb_empty_keyword_given_p needs to stay. It is required if argument delegation is done but delayed to a later point, which Enumerator does. Use RB_PASS_CALLED_KEYWORDS in rb_call_super to correctly delegate keyword arguments to super method.
* Document and test Enumerator.produceAkinori MUSHA2019-09-121-0/+22
| | | | Co-authored-by: Victor Shepelev <zverok.offline@gmail.com>
* Implement Enumerator.produce [Feature #14781]Akinori MUSHA2019-09-121-1/+156
|
* Fix keyword argument separation warnings for enumeratorsJeremy Evans2019-09-061-9/+21
| | | | | | | | | | This makes objects created via #to_enum and related methods pass keyword arguments as keywords. To implement this, add a kw_splat member of struct enumerator and struct iter_method_arg, and add rb_block_call_kw, which is the same as rb_block_call_kw with a flag for whether the last argument is keyword options.
* Describe #eager in the Enumerator::Lazy sectionAkinori MUSHA2019-09-041-6/+25
|
* Implement Enumerator::Lazy#eager [Feature #15901]Akinori MUSHA2019-09-041-0/+21
|
* Fix Enumerator::Lazy#{to_enum,enum_for} where method is defined in LazyJeremy Evans2019-09-031-1/+68
| | | | | | | | | | | | | | | | | | | Previously, passing to_enum/enum_for a method that was defined in Lazy itself returned wrong results: [1,2,3].to_enum(:map).to_a # => [1, 2, 3] [1,2,3].lazy.to_enum(:map).to_a # => [] I'm not sure why methods that are designed to be lazy do not work with to_enum/enum_for. However, one possible way to work around this bug is to have to_enum/enum_for use the implementation found in Enumerable/Enumerator, which is what this commit does. While this commit works around the problem, it is a band-aid, not a real fix. It doesn't handle aliases of Enumerable::Lazy methods, for instance. A better fix would be appreciated.
* Make Enumerator::Lazy#with_index be lazyJeremy Evans2019-09-031-0/+66
| | | | | | | | | | Previously, Enumerator::Lazy#with_index was not defined, so it picked up the default implementation from Enumerator, which was not lazy. Based on earlier patch from nobu. Fixes [Bug #7877]
* Revert "Make Enumerator::Lazy#with_index be lazy"Jeremy Evans2019-09-011-66/+0
| | | | | | This reverts commit 83498854eb5a824f1f83c31fac18c9279f9ee10d. This didn't pass rubyspec.
* Make Enumerator::Lazy#with_index be lazyJeremy Evans2019-09-011-0/+66
| | | | | | | | | | Previously, Enumerator::Lazy#with_index was not defined, so it picked up the default implementation from Enumerator, which was not lazy. Based on earlier patch from nobu. Fixes [Bug #7877]
* rb_proc_new / rb_fiber_new now free from ANYARGS卜部昌平2019-08-271-1/+1
| | | | | | | After 5e86b005c0f2ef30df2f9906c7e2f3abefe286a2, I now think ANYARGS is dangerous and should be extinct. This commit deletes ANYARGS from rb_proc_new / rb_fiber_new, and applies RB_BLOCK_CALL_FUNC_ARGLIST wherever necessary.
* rb_rescue / rb_rescue2 now free from ANYARGS卜部昌平2019-08-271-1/+1
| | | | | | After 5e86b005c0f2ef30df2f9906c7e2f3abefe286a2, I now think ANYARGS is dangerous and should be extinct. This commit deletes ANYARGS from rb_rescue / rb_rescue2, which revealed many arity / type mismatches.
* #define RB_BLOCK_CALL_FUNC_STRICT 1卜部昌平2019-08-271-3/+3
| | | | | | After 5e86b005c0f2ef30df2f9906c7e2f3abefe286a2, I now think ANYARGS is dangerous and should be extinct. Let's start from making rb_block_call_func_t strict, and apply RB_BLOCK_CALL_FUNC_ARGLIST liberally.
* Minor documentation fixes [ci skip]Jeremy Evans2019-08-241-4/+4
| | | | | | From zverok (Victor Shepelev) Fixes [Misc #16126]
* * expand tabs.git2019-08-131-4/+4
|
* Add compaction callbacks for EnumeratorAaron Patterson2019-08-131-15/+65
| | | | This commit gives Enumerator compaction support
* Use predefined idTo_procNobuyoshi Nakada2019-08-011-3/+2
|
* Remove duplicate functionsNobuyoshi Nakada2019-06-211-33/+2
|
* * expand tabs.git2019-06-211-1/+1
|
* Enumerator::Lazy should support filter_mapShugo Maeda2019-06-211-0/+31
| | | | Fixes [Bug #15949]
* Fix an example [ci skip]Nobuyoshi Nakada2019-06-211-1/+1
|
* Fix call-seq of lazy.filter_map [ci skip]Kazuhiro NISHIYAMA2019-06-211-3/+2
|
* * expand tabs.git2019-06-211-3/+3
|
* Lazy filter_mapNobuyoshi Nakada2019-06-211-0/+35
|
* [DOC] Improve documentation for Enumerator::LazyMarcus Stollsteimer2019-05-181-12/+12
|
* Static symbols can't be moved (they are not RValue)Aaron Patterson2019-05-141-11/+12
| | | | | | | | | This is my mistake, I thought they were regular objects, but apparently they are not. We don't need to pin them. Revert "Symbols can move so only cache IDs" This reverts commit 672ee5f6ed5a6840a3be9150b6721a5ee8f8766b.
* Symbols can move so only cache IDsAaron Patterson2019-05-141-12/+11
| | | | IDs can't move, we need to use them to look up the symbol objects later.
* Add `or nil` to call-seq of `Enumerator::ArithmeticSequence#begin`Kazuhiro NISHIYAMA2019-04-271-1/+1
| | | | | | | | | | | ``` % ruby -ve 'p (nil..).first' ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin18] nil % ruby -ve 'p (nil..).begin' ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin18] nil ```
* enumerator.c: force hash values fixablenobu2019-04-081-1/+1
| | | | | | | * enumerator.c (arith_seq_hash): force hash values fixable on LLP64 environment. [ruby-core:92190] [Bug #15755] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67466 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* enumerator.c: make arith_seq_first support nil beginmrkn2019-04-041-0/+3
| | | | | | | | | * enumerator.c: (arith_seq_first): support nil begin. * test/ruby/test_arithmetic_sequence.rb (test_first): add assertions for beginless and endless arithmetic sequences. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67435 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add Enumerator::Lazy docs.hsbt2019-03-201-26/+221
| | | | | | | | | | | | | * explanation of the class concept, with examples; * docs for all class methods (most of them just say "Like Enumerable#<methodname>, but chains operation to be lazy-evaluated.", but I believe they are useful this way because now have proper call-sequences and link to corresponding Enumerable's explanations) * simplified example for ::new to emphasize the main concept * Enumerable#lazy docs are slightly lightened and linked to this class for more in-depth explanations. [Misc #15529][ruby-core:91046] Co-authored-by: zverok <zverok.offline@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67320 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Implement Enumerator::Yielder#to_procknu2019-03-111-2/+25
| | | | | | | | | | | | | | | A Yielder object can now be directly passed to another method as a block argument. ```ruby enum = Enumerator.new { |y| Dir.glob("*.rb") { |file| File.open(file) { |f| f.each_line(&y) } } } ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67211 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * expand tabs.svn2019-01-301-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66948 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* enumerator.c: fix arith_seq_first for Infinitymrkn2019-01-301-10/+115
| | | | | | | | | | | | | | * enumerator.c (arith_seq_first): fix for Float::INFINITY. * test/ruby/test_arithmetic_sequence.rb: add tests. * numeric.c (ruby_float_step_size): export for internal use. * internal.h: add prototype declaration of ruby_float_step_size. [ruby-core:90937][Bug #15518] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66947 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* enumerator.c: fix inspect with the last empty hashnobu2018-12-241-1/+1
| | | | | | [ruby-core:90685] [Bug #15455] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66519 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* range.c: reject ArithmeticSequence in rb_range_valuesmrkn2018-12-211-1/+1
| | | | | | | Reject ArithmeticSequence in rb_range_values so that methods like Array#[] raises TypeError for ArithmeticSequence as an index. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66478 b2dd03c8-39d4-4d8f-98ff-823fe69b080e