mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
merge revision(s) 40525,40526,40528,40530: [Backport #8345]
proc.c: remove unnecessary static function * proc.c (proc_lambda): remove and use rb_block_lambda directly instead. * include/ruby/intern.h (rb_block_lambda): add declaration instead of deprecated rb_f_lambda. * proc.c (mproc, mlambda): use frozen core methods instead of plain global methods, so that methods cannot be overridden. [ruby-core:54687] [Bug #8345] * vm.c (Init_VM): define proc and lambda on the frozen core object. * defs/id.def (predefined): add "idProc". * proc.c (mnew, mproc, mlambda): use predefined IDs. * vm.c (Init_VM): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@41649 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7e88248f7d
commit
f8665e42f0
8 changed files with 42 additions and 19 deletions
13
ChangeLog
13
ChangeLog
|
|
@ -1,3 +1,16 @@
|
|||
Wed Jun 26 16:36:39 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* defs/id.def (predefined): add "idProc".
|
||||
|
||||
* proc.c (mnew, mproc, mlambda): use predefined IDs.
|
||||
|
||||
* vm.c (Init_VM): ditto.
|
||||
|
||||
Wed Jun 26 16:36:39 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* include/ruby/intern.h (rb_block_lambda): add declaration instead of
|
||||
deprecated rb_f_lambda.
|
||||
|
||||
Wed Jun 26 16:31:49 2013 Shugo Maeda <shugo@ruby-lang.org>
|
||||
|
||||
* lib/net/imap.rb (capability_response): should ignore trailing
|
||||
|
|
|
|||
1
id.c
1
id.c
|
|
@ -35,6 +35,7 @@ Init_id(void)
|
|||
REGISTER_SYMID(idEach, "each");
|
||||
REGISTER_SYMID(idLength, "length");
|
||||
REGISTER_SYMID(idSize, "size");
|
||||
REGISTER_SYMID(idProc, "proc");
|
||||
REGISTER_SYMID(idLambda, "lambda");
|
||||
REGISTER_SYMID(idIntern, "intern");
|
||||
REGISTER_SYMID(idGets, "gets");
|
||||
|
|
|
|||
|
|
@ -350,7 +350,7 @@ VALUE rb_require_safe(VALUE, int);
|
|||
void rb_obj_call_init(VALUE, int, VALUE*);
|
||||
VALUE rb_class_new_instance(int, VALUE*, VALUE);
|
||||
VALUE rb_block_proc(void);
|
||||
VALUE rb_f_lambda(void);
|
||||
VALUE rb_block_lambda(void);
|
||||
VALUE rb_proc_new(VALUE (*)(ANYARGS/* VALUE yieldarg[, VALUE procarg] */), VALUE);
|
||||
VALUE rb_obj_is_proc(VALUE);
|
||||
VALUE rb_proc_call(VALUE, VALUE);
|
||||
|
|
|
|||
28
proc.c
28
proc.c
|
|
@ -465,6 +465,14 @@ rb_block_proc(void)
|
|||
return proc_new(rb_cProc, FALSE);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* lambda { |...| block } -> a_proc
|
||||
*
|
||||
* Equivalent to <code>Proc.new</code>, except the resulting Proc objects
|
||||
* check the number of parameters passed when called.
|
||||
*/
|
||||
|
||||
VALUE
|
||||
rb_block_lambda(void)
|
||||
{
|
||||
|
|
@ -478,20 +486,6 @@ rb_f_lambda(void)
|
|||
return rb_block_lambda();
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* lambda { |...| block } -> a_proc
|
||||
*
|
||||
* Equivalent to <code>Proc.new</code>, except the resulting Proc objects
|
||||
* check the number of parameters passed when called.
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
proc_lambda(void)
|
||||
{
|
||||
return rb_block_lambda();
|
||||
}
|
||||
|
||||
/* Document-method: ===
|
||||
*
|
||||
* call-seq:
|
||||
|
|
@ -1798,13 +1792,13 @@ method_inspect(VALUE method)
|
|||
static VALUE
|
||||
mproc(VALUE method)
|
||||
{
|
||||
return rb_funcall(Qnil, rb_intern("proc"), 0);
|
||||
return rb_funcall2(rb_mRubyVMFrozenCore, idProc, 0, 0);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
mlambda(VALUE method)
|
||||
{
|
||||
return rb_funcall(Qnil, rb_intern("lambda"), 0);
|
||||
return rb_funcall(rb_mRubyVMFrozenCore, idLambda, 0, 0);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
|
|
@ -2151,7 +2145,7 @@ Init_Proc(void)
|
|||
|
||||
/* utility functions */
|
||||
rb_define_global_function("proc", rb_block_proc, 0);
|
||||
rb_define_global_function("lambda", proc_lambda, 0);
|
||||
rb_define_global_function("lambda", rb_block_lambda, 0);
|
||||
|
||||
/* Method */
|
||||
rb_cMethod = rb_define_class("Method", rb_cObject);
|
||||
|
|
|
|||
|
|
@ -98,6 +98,7 @@ enum ruby_method_ids {
|
|||
tGets,
|
||||
tSucc,
|
||||
tEach,
|
||||
tProc,
|
||||
tLambda,
|
||||
tSend,
|
||||
t__send__,
|
||||
|
|
@ -120,6 +121,7 @@ enum ruby_method_ids {
|
|||
TOKEN2ID(Gets),
|
||||
TOKEN2ID(Succ),
|
||||
TOKEN2ID(Each),
|
||||
TOKEN2ID(Proc),
|
||||
TOKEN2ID(Lambda),
|
||||
TOKEN2ID(Send),
|
||||
TOKEN2ID(__send__),
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
require 'test/unit'
|
||||
require_relative 'envutil'
|
||||
|
||||
class TestProc < Test::Unit::TestCase
|
||||
def setup
|
||||
|
|
@ -818,4 +819,14 @@ class TestProc < Test::Unit::TestCase
|
|||
assert_equal('zot', o.method(:foo).to_proc.() {'zot'}, bug3792)
|
||||
}
|
||||
end
|
||||
|
||||
def test_overriden_lambda
|
||||
bug8345 = '[ruby-core:54687] [Bug #8345]'
|
||||
assert_normal_exit('def lambda; end; method(:puts).to_proc', bug8345)
|
||||
end
|
||||
|
||||
def test_overriden_proc
|
||||
bug8345 = '[ruby-core:54688] [Bug #8345]'
|
||||
assert_normal_exit('def proc; end; ->{}.curry', bug8345)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#define RUBY_VERSION "1.9.3"
|
||||
#define RUBY_PATCHLEVEL 440
|
||||
#define RUBY_PATCHLEVEL 441
|
||||
|
||||
#define RUBY_RELEASE_DATE "2013-06-26"
|
||||
#define RUBY_RELEASE_YEAR 2013
|
||||
|
|
|
|||
2
vm.c
2
vm.c
|
|
@ -2109,6 +2109,8 @@ Init_VM(void)
|
|||
rb_define_method_id(klass, id_core_define_method, m_core_define_method, 3);
|
||||
rb_define_method_id(klass, id_core_define_singleton_method, m_core_define_singleton_method, 3);
|
||||
rb_define_method_id(klass, id_core_set_postexe, m_core_set_postexe, 1);
|
||||
rb_define_method_id(klass, idProc, rb_block_proc, 0);
|
||||
rb_define_method_id(klass, idLambda, rb_block_lambda, 0);
|
||||
rb_obj_freeze(fcore);
|
||||
rb_gc_register_mark_object(fcore);
|
||||
rb_mRubyVMFrozenCore = fcore;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue