зеркало из https://github.com/github/ruby.git
* include/ruby/intern.h, proc.c: revert rb_proc_call() and
create rb_proc_call_with_block() instaed. * include/ruby/ruby.h, eval_jump.c, thread.c, vm_insnhelper.c: rb_blockptr should not be exposed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17081 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
8b7a284b65
Коммит
ed4139e39b
|
@ -1,3 +1,11 @@
|
|||
Wed Jun 11 01:28:12 2008 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* include/ruby/intern.h, proc.c: revert rb_proc_call() and
|
||||
create rb_proc_call_with_block() instaed.
|
||||
|
||||
* include/ruby/ruby.h, eval_jump.c, thread.c, vm_insnhelper.c:
|
||||
rb_blockptr should not be exposed.
|
||||
|
||||
Tue Jun 10 21:07:19 2008 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
|
||||
|
||||
* test/ruby/test_float.rb: add tests. [ruby-dev:35009]
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
void
|
||||
rb_call_end_proc(VALUE data)
|
||||
{
|
||||
rb_proc_call(data, rb_ary_new(), 0);
|
||||
rb_proc_call(data, rb_ary_new());
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -272,7 +272,8 @@ VALUE rb_class_new_instance(int, VALUE*, VALUE);
|
|||
VALUE rb_block_proc(void);
|
||||
VALUE rb_f_lambda(void);
|
||||
VALUE rb_proc_new(VALUE (*)(ANYARGS/* VALUE yieldarg[, VALUE procarg] */), VALUE);
|
||||
VALUE rb_proc_call(VALUE, VALUE, rb_blockptr);
|
||||
VALUE rb_proc_call(VALUE, VALUE);
|
||||
VALUE rb_proc_call_with_block(VALUE, int argc, VALUE *argv, VALUE);
|
||||
int rb_proc_arity(VALUE);
|
||||
VALUE rb_binding_new(void);
|
||||
VALUE rb_obj_method(VALUE, VALUE);
|
||||
|
|
|
@ -824,8 +824,6 @@ PRINTF_ARGS(void rb_sys_warning(const char*, ...), 1, 2);
|
|||
PRINTF_ARGS(void rb_warn(const char*, ...), 1, 2);
|
||||
PRINTF_ARGS(void rb_compile_warn(const char *, int, const char*, ...), 3, 4);
|
||||
|
||||
typedef struct rb_block_struct *rb_blockptr;
|
||||
|
||||
typedef VALUE rb_block_call_func(VALUE, VALUE, int, VALUE*);
|
||||
|
||||
VALUE rb_each(VALUE);
|
||||
|
|
30
proc.c
30
proc.c
|
@ -507,12 +507,26 @@ proc_call(int argc, VALUE *argv, VALUE procval)
|
|||
}
|
||||
|
||||
VALUE
|
||||
rb_proc_call(VALUE self, VALUE args, rb_blockptr blockptr)
|
||||
rb_proc_call(VALUE self, VALUE args)
|
||||
{
|
||||
rb_proc_t *proc;
|
||||
GetProcPtr(self, proc);
|
||||
return vm_invoke_proc(GET_THREAD(), proc, proc->block.self,
|
||||
RARRAY_LEN(args), RARRAY_PTR(args), blockptr);
|
||||
RARRAY_LEN(args), RARRAY_PTR(args), 0);
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_proc_call_with_block(VALUE self, int argc, VALUE *argv, VALUE pass_procval)
|
||||
{
|
||||
rb_proc_t *proc, *pass_proc = 0;
|
||||
GetProcPtr(self, proc);
|
||||
|
||||
if (!NIL_P(pass_procval)) {
|
||||
GetProcPtr(pass_procval, pass_proc);
|
||||
}
|
||||
|
||||
return vm_invoke_proc(GET_THREAD(), proc, proc->block.self,
|
||||
argc, argv, &pass_proc->block);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1584,7 +1598,7 @@ proc_binding(VALUE self)
|
|||
return bindval;
|
||||
}
|
||||
|
||||
static VALUE curry(VALUE dummy, VALUE args, int argc, VALUE *argv, rb_blockptr blockptr);
|
||||
static VALUE curry(VALUE dummy, VALUE args, int argc, VALUE *argv, VALUE passed_proc);
|
||||
|
||||
static VALUE
|
||||
make_curry_proc(VALUE proc, VALUE passed, VALUE arity)
|
||||
|
@ -1600,7 +1614,7 @@ make_curry_proc(VALUE proc, VALUE passed, VALUE arity)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
curry(VALUE dummy, VALUE args, int argc, VALUE *argv, rb_blockptr blockptr)
|
||||
curry(VALUE dummy, VALUE args, int argc, VALUE *argv, VALUE passed_proc)
|
||||
{
|
||||
VALUE proc, passed, arity;
|
||||
proc = RARRAY_PTR(args)[0];
|
||||
|
@ -1609,15 +1623,17 @@ curry(VALUE dummy, VALUE args, int argc, VALUE *argv, rb_blockptr blockptr)
|
|||
|
||||
passed = rb_ary_plus(passed, rb_ary_new4(argc, argv));
|
||||
rb_ary_freeze(passed);
|
||||
|
||||
if(RARRAY_LEN(passed) < FIX2INT(arity)) {
|
||||
if (blockptr) {
|
||||
if (!NIL_P(passed_proc)) {
|
||||
rb_warn("given block not used");
|
||||
}
|
||||
arity = make_curry_proc(proc, passed, arity);
|
||||
return arity;
|
||||
}
|
||||
arity = rb_proc_call(proc, passed, blockptr);
|
||||
return arity;
|
||||
else {
|
||||
return rb_proc_call_with_block(proc, RARRAY_LEN(passed), RARRAY_PTR(passed), passed_proc);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
15
thread.c
15
thread.c
|
@ -3079,6 +3079,7 @@ call_trace_proc(VALUE args, int tracing)
|
|||
struct call_trace_func_args *p = (struct call_trace_func_args *)args;
|
||||
VALUE eventname = rb_str_new2(get_event_name(p->event));
|
||||
VALUE filename = rb_str_new2(rb_sourcefile());
|
||||
VALUE argv[6];
|
||||
int line = rb_sourceline();
|
||||
ID id = 0;
|
||||
VALUE klass = 0;
|
||||
|
@ -3101,11 +3102,15 @@ call_trace_proc(VALUE args, int tracing)
|
|||
klass = rb_iv_get(klass, "__attached__");
|
||||
}
|
||||
}
|
||||
return rb_proc_call(p->proc, rb_ary_new3(6,
|
||||
eventname, filename, INT2FIX(line),
|
||||
id ? ID2SYM(id) : Qnil,
|
||||
p->self ? rb_binding_new() : Qnil,
|
||||
klass ? klass : Qnil), 0);
|
||||
|
||||
argv[0] = eventname;
|
||||
argv[1] = filename;
|
||||
argv[2] = INT2FIX(line);
|
||||
argv[3] = id ? ID2SYM(id) : Qnil;
|
||||
argv[4] = p->self ? rb_binding_new() : Qnil;
|
||||
argv[5] = klass ? klass : Qnil;
|
||||
|
||||
return rb_proc_call_with_block(p->proc, 6, argv, Qnil);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#define RUBY_VERSION "1.9.0"
|
||||
#define RUBY_RELEASE_DATE "2008-06-10"
|
||||
#define RUBY_RELEASE_DATE "2008-06-11"
|
||||
#define RUBY_VERSION_CODE 190
|
||||
#define RUBY_RELEASE_CODE 20080610
|
||||
#define RUBY_RELEASE_CODE 20080611
|
||||
#define RUBY_PATCHLEVEL 0
|
||||
|
||||
#define RUBY_VERSION_MAJOR 1
|
||||
|
@ -9,7 +9,7 @@
|
|||
#define RUBY_VERSION_TEENY 0
|
||||
#define RUBY_RELEASE_YEAR 2008
|
||||
#define RUBY_RELEASE_MONTH 6
|
||||
#define RUBY_RELEASE_DAY 10
|
||||
#define RUBY_RELEASE_DAY 11
|
||||
|
||||
#ifdef RUBY_EXTERN
|
||||
RUBY_EXTERN const char ruby_version[];
|
||||
|
|
|
@ -655,8 +655,7 @@ vm_yield_with_cfunc(rb_thread_t *th, const rb_block_t *block,
|
|||
const rb_block_t *blockptr)
|
||||
{
|
||||
NODE *ifunc = (NODE *) block->iseq;
|
||||
VALUE val;
|
||||
VALUE arg;
|
||||
VALUE val, arg, blockarg;
|
||||
int lambda = block_proc_is_lambda(block->proc);
|
||||
|
||||
if (lambda) {
|
||||
|
@ -669,11 +668,18 @@ vm_yield_with_cfunc(rb_thread_t *th, const rb_block_t *block,
|
|||
arg = argv[0];
|
||||
}
|
||||
|
||||
if (blockptr) {
|
||||
blockarg = vm_make_proc(th, th->cfp, blockptr);
|
||||
}
|
||||
else {
|
||||
blockarg = Qnil;
|
||||
}
|
||||
|
||||
vm_push_frame(th, 0, FRAME_MAGIC_IFUNC,
|
||||
self, (VALUE)block->dfp,
|
||||
0, th->cfp->sp, block->lfp, 1);
|
||||
|
||||
val = (*ifunc->nd_cfnc) (arg, ifunc->nd_tval, argc, argv, blockptr);
|
||||
val = (*ifunc->nd_cfnc) (arg, ifunc->nd_tval, argc, argv, blockarg);
|
||||
|
||||
th->cfp++;
|
||||
return val;
|
||||
|
|
Загрузка…
Ссылка в новой задаче