summaryrefslogtreecommitdiff
path: root/proc.c
AgeCommit message (Collapse)Author
2019-08-30Add rb_iseq_locationJeremy Evans
This wraps iseq_location and should fix the leaked global test.
2019-08-30Use more accurate source location in keyword argument separation warningsJeremy Evans
This shows locations in places it didn't before, such as for proc calls, and fixes the location for super calls. This requires making iseq_location non-static and MJIT exported, which I hope will not cause problems.
2019-08-30Separate keyword arguments from positional argumentsYusuke Endoh
And, allow non-symbol keys as a keyword arugment Notes: Merged: https://github.com/ruby/ruby/pull/2395
2019-08-30[DOC] Return obj may be different from 1st argument [ci skip]Kazuhiro NISHIYAMA
2019-08-30proc.c: Add UnboundMethod#bind_callYusuke Endoh
`umethod.bind_call(obj, ...)` is semantically equivalent to `umethod.bind(obj).call(...)`. This idiom is used in some libraries to call a method that is overridden. The added method does the same without allocation of intermediate Method object. [Feature #15955] ``` class Foo def add_1(x) x + 1 end end class Bar < Foo def add_1(x) # override x + 2 end end obj = Bar.new p obj.add_1(1) #=> 3 p Foo.instance_method(:add_1).bind(obj).call(1) #=> 2 p Foo.instance_method(:add_1).bind_call(obj, 1) #=> 2 ```
2019-08-29move docs around [ci skip]卜部昌平
To properly generate documents.
2019-08-29drop-in type check for rb_define_global_function卜部昌平
We can check the function pointer passed to rb_define_global_function like we do so in rb_define_method. It turns out that almost anybody is misunderstanding the API.
2019-08-27rb_proc_new / rb_fiber_new now free from ANYARGS卜部昌平
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.
2019-08-27decouple compile.c usage of imemo_ifunc卜部昌平
After 5e86b005c0f2ef30df2f9906c7e2f3abefe286a2, I now think ANYARGS is dangerous and should be extinct. This commit deletes ANYARGS from struct vm_ifunc, but in doing so we also have to decouple the usage of this struct in compile.c, which (I think) is an abuse of ANYARGS.
2019-08-16Add details about parameters to define_method doc (#2165)OKURA Masafumi
When we use `define_method` and `define_singleton_method`, if we supply block parameters to a block then a generated method has corresponding parameters. However, the doc doesn't mention it, so this info has been added.
2019-08-14* expand tabs.git
2019-08-14change Proc#to_s format ('@...' -> ' ...') (#2362)Koichi Sasada
Now Proc#to_s returns "#<Proc:0x00000237a0f5f170@t.rb:1>". However, it is convenient to select a file name by (double-)clicking on some terminals by separating ' ' instead of '@' like "#<Proc:0x00000237a0f5f170 t.rb:1>" [Feature #16101]
2019-08-12Rename rb_gc_mark_no_pin -> rb_gc_mark_movableAaron Patterson
Renaming this function. "No pin" leaks some implementation details. We just want users to know that if they mark this object, the reference may move and they'll need to update the reference accordingly.
2019-07-14fix typos.Tanaka Akira
2019-07-14Method#inspect with source location.Koichi Sasada
Method#inspect shows with source location. [Feature #14145]
2019-07-14Describe lambda-ness of Proc more.Tanaka Akira
2019-06-12* expand tabs.git
2019-06-11Add compaction support for more types.Aaron Patterson
This commit adds compaction support for: * Fibers * Continuations * Autoload Constants
2019-06-03Unpin objects that `proc` referencesAaron Patterson
This commit adds compaction support to method and proc objects. It just unpins references and implements the "compact" callback and updates references.
2019-04-27Add class ref to `UnboundMethod#owner` docokuramasafumi
It refers to `Method#receiver` in the doc, but there's no class reference in current doc. Some tools automatically make it a link so it's useful. Closes: https://github.com/ruby/ruby/pull/2156
2019-04-22Adds a reference to `TracePoint` to `binding` docsKazuhiro NISHIYAMA
This change adds an explicit reference to `TracePoint` in the documentation for `binding`. Currently it only refers to the now deprecated `Kernel#set_trace_func`. This reference is left alone for continuity in the documentation. [Fix GH-2079] Co-authored-by: Brandon Weaver <baweaver@squareup.com>
2019-04-13* expand tabs.svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67520 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-13Proc.new: change deprecation warning for clarity (issue #15539)marcandre
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67519 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-08range.c: force hash values fixablenobu
* range.c (method_hash): force hash values fixable on LLP64 environment. [ruby-core:92191] [Bug #15756] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67467 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-28[DOC] fix markups [ci skip]nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-06proc.c: call respond_to_missing? with a symbolnobu
[ruby-core:91683] [Bug #15640] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67185 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-28* expand tabs.svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66936 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-28Add refinements support to method/instance_method.nobu
[Fix GH-2034] From: manga_osyo <manga.osyo@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66935 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-10proc.c: proc without blocknobu
* proc.c (proc_new): promoted lambda/proc/Proc.new with no block in a method called with a block to a warning/error. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66772 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-10proc.c: check if callablenobu
* proc.c: check the argument at composition, expect a Proc, Method, or callable object. [ruby-core:90591] [Bug #15428] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66769 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-14proc.c: [DOC] fix typosstomar
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66402 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-14* remove trailing spaces. [ci skip]svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66399 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-14tweak syntax of Proc documentation [ci skip]duerst
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66398 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-13proc.c: [DOC] fix typosstomar
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66385 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-13[DOC] Fix typos [ci skip]kazu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66383 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-12Enhance Proc docs [Misc #14610]duerst
From: Victor Shepelev <zverok.offline@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66355 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-06Prefer rb_check_arity when 0 or 1 argumentsnobu
Especially over checking argc then calling rb_scan_args just to raise an ArgumentError. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66238 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-26* expand tabs.svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66004 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-26Support targetting TracePoint [Feature #15289]ko1
* vm_trace.c (rb_tracepoint_enable_for_target): support targetting TracePoint. [Feature #15289] Tragetting TracePoint is only enabled on specified method, proc and so on, example: `tp.enable(target: code)`. `code` should be consisted of InstructionSeuqnece (iseq) (RubyVM::InstructionSeuqnece.of(code) should not return nil) If code is a tree of iseq, TracePoint is enabled on all of iseqs in a tree. Enabled tragetting TracePoints can not enabled again with and without target. * vm_core.h (rb_iseq_t): introduce `rb_iseq_t::local_hooks` to store local hooks. `rb_iseq_t::aux::trace_events` is renamed to `global_trace_events` to contrast with `local_hooks`. * vm_core.h (rb_hook_list_t): add `rb_hook_list_t::running` to represent how many Threads/Fibers are used this list. If this field is 0, nobody using this hooks and we can delete it. This is why we can remove code from cont.c. * vm_core.h (rb_vm_t): because of above change, we can eliminate `rb_vm_t::trace_running` field. Also renamed from `rb_vm_t::event_hooks` to `global_hooks`. * vm_core.h, vm.c (ruby_vm_event_enabled_global_flags): renamed from `ruby_vm_event_enabled_flags. * vm_core.h, vm.c (ruby_vm_event_local_num): added to count enabled targetting TracePoints. * vm_core.h, vm_trace.c (rb_exec_event_hooks): accepts hook list. * vm_core.h (rb_vm_global_hooks): added for convinience. * method.h (rb_method_bmethod_t): added to maintain Proc and `rb_hook_list_t` for bmethod (defined by define_method). * prelude.rb (TracePoint#enable): extracet a keyword parameter (because it is easy than writing in C). It calls `TracePoint#__enable` internal method written in C. * vm_insnhelper.c (vm_trace): check also iseq->local_hooks. * vm.c (invoke_bmethod): check def->body.bmethod.hooks. * vm.c (hook_before_rewind): check iseq->local_hooks and def->body.bmethod.hooks before rewind by exception. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66003 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-23proc.c: [DOC] refine proc-compistion examples [ci skip]nobu
* proc.c: [DOC] refine proc-compistion examples by using same Proc/Method and different composition orders. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65935 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-22Proc#<< and Proc#>>nobu
[Feature #6284] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65914 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-22proc.c: Support any callable when composing Procsnobu
* proc.c (proc_compose): support any object with a call method rather than supporting only procs. [Feature #6284] * proc.c (compose): use the function call on the given object rather than rb_proc_call_with_block in order to support any object. * test/ruby/test_proc.rb: Add test cases for composing Procs with callable objects. * test/ruby/test_method.rb: Add test cases for composing Methods with callable objects. From: Paul Mucur <paul@altmetric.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65913 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-22proc.c: Implement Method#* for Method compositionnobu
* proc.c (rb_method_compose): Implement Method#* for Method composition, which delegates to Proc#*. * test/ruby/test_method.rb: Add test cases for Method composition. From: Paul Mucur <mudge@mudge.name> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65912 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-22proc.c: Implement Proc#* for Proc compositionnobu
* proc.c (proc_compose): Implement Proc#* for Proc composition, enabling composition of Procs and Methods. [Feature #6284] * test/ruby/test_proc.rb: Add test cases for Proc composition. From: Paul Mucur <mudge@mudge.name> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65911 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-26proc.c: [DOC] improve docs for {Method,Proc}#===stomar
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65379 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-26proc.c: [DOC] fix grammar in doc for Method#to_sstomar
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65378 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-21Improve docs of Proc / Methodaycabta
* proc.c: Add descriptions and code examples. [ruby-core:85600] [Bug #14483] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65283 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-13Prefer `rb_fstring_lit` over `rb_fstring_cstr`nobu
The former states explicitly that the argument must be a literal, and can optimize away `strlen` on all compilers. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65059 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-10revisit `RARRAY_PTR()`.ko1
* array.c (yield_indexed_values): use RARRAY_AREF/ASET instead of using RARRAY_PTR(). * enum.c (nmin_filter): ditto. * proc.c (rb_sym_to_proc): ditto. * enum.c (rb_nmin_run): use RARRAY_PTR_USE() instead of RARRAY_PTR(). It is safe because they don't make new referecen from an array. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-25Remove obsolete comment from Module#define_method documentationtenderlove
Since 2.5, Module#define_method is public. (feature #14133) Co-Authored-By: Miguel Landaeta <miguel@miguel.cc> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64057 b2dd03c8-39d4-4d8f-98ff-823fe69b080e