From f8665e42f01f5caff4cb90e1ba0893a8518d521f Mon Sep 17 00:00:00 2001 From: usa Date: Wed, 26 Jun 2013 07:51:04 +0000 Subject: 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 --- proc.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) (limited to 'proc.c') diff --git a/proc.c b/proc.c index 943a49a96a..fdd148ebe9 100644 --- a/proc.c +++ b/proc.c @@ -465,6 +465,14 @@ rb_block_proc(void) return proc_new(rb_cProc, FALSE); } +/* + * call-seq: + * lambda { |...| block } -> a_proc + * + * Equivalent to Proc.new, 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 Proc.new, 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); -- cgit v1.2.3