зеркало из https://github.com/github/ruby.git
* eval.c (rb_call0): call_cfunc() should be protected.
* eval.c (rb_add_event_hook): use K&R style. * eval.c (rb_remove_event_hook): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8164 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
1aeb9b93c2
Коммит
9606ff514f
|
@ -1,3 +1,11 @@
|
||||||
|
Wed Mar 16 22:57:43 2005 Shugo Maeda <shugo@ruby-lang.org>
|
||||||
|
|
||||||
|
* eval.c (rb_call0): call_cfunc() should be protected.
|
||||||
|
|
||||||
|
* eval.c (rb_add_event_hook): use K&R style.
|
||||||
|
|
||||||
|
* eval.c (rb_remove_event_hook): ditto.
|
||||||
|
|
||||||
Wed Mar 16 22:03:15 2005 Shugo Maeda <shugo@ruby-lang.org>
|
Wed Mar 16 22:03:15 2005 Shugo Maeda <shugo@ruby-lang.org>
|
||||||
|
|
||||||
* eval.c (rb_add_event_hook): new function to add a hook function for
|
* eval.c (rb_add_event_hook): new function to add a hook function for
|
||||||
|
|
35
eval.c
35
eval.c
|
@ -2434,7 +2434,9 @@ rb_obj_is_proc(proc)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
rb_add_event_hook(rb_event_hook_func_t func, rb_event_t events)
|
rb_add_event_hook(func, events)
|
||||||
|
rb_event_hook_func_t func;
|
||||||
|
rb_event_t events;
|
||||||
{
|
{
|
||||||
rb_event_hook_t *hook;
|
rb_event_hook_t *hook;
|
||||||
|
|
||||||
|
@ -2446,7 +2448,8 @@ rb_add_event_hook(rb_event_hook_func_t func, rb_event_t events)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
rb_remove_event_hook(rb_event_hook_func_t func)
|
rb_remove_event_hook(func)
|
||||||
|
rb_event_hook_func_t func;
|
||||||
{
|
{
|
||||||
rb_event_hook_t *prev, *hook;
|
rb_event_hook_t *prev, *hook;
|
||||||
|
|
||||||
|
@ -5626,7 +5629,6 @@ rb_call0(klass, recv, id, oid, argc, argv, body, nosuper)
|
||||||
int itr;
|
int itr;
|
||||||
static int tick;
|
static int tick;
|
||||||
volatile VALUE args;
|
volatile VALUE args;
|
||||||
volatile int trace_status = 0; /* 0:none 1:cfunc 2:rfunc */
|
|
||||||
TMP_PROTECT;
|
TMP_PROTECT;
|
||||||
|
|
||||||
switch (ruby_iter->iter) {
|
switch (ruby_iter->iter) {
|
||||||
|
@ -5668,11 +5670,23 @@ rb_call0(klass, recv, id, oid, argc, argv, body, nosuper)
|
||||||
len, rb_class2name(klass), rb_id2name(id));
|
len, rb_class2name(klass), rb_id2name(id));
|
||||||
}
|
}
|
||||||
if (event_hooks) {
|
if (event_hooks) {
|
||||||
|
int state;
|
||||||
|
|
||||||
EXEC_EVENT_HOOK(RUBY_EVENT_C_CALL, ruby_current_node,
|
EXEC_EVENT_HOOK(RUBY_EVENT_C_CALL, ruby_current_node,
|
||||||
recv, id, klass);
|
recv, id, klass);
|
||||||
trace_status = 1; /* cfunc */
|
PUSH_TAG(PROT_FUNC);
|
||||||
|
if ((state = EXEC_TAG()) == 0) {
|
||||||
|
result = call_cfunc(body->nd_cfnc, recv, len, argc, argv);
|
||||||
|
}
|
||||||
|
POP_TAG();
|
||||||
|
ruby_current_node = ruby_frame->node;
|
||||||
|
EXEC_EVENT_HOOK(RUBY_EVENT_C_RETURN, ruby_current_node,
|
||||||
|
recv, id, klass);
|
||||||
|
if (state) JUMP_TAG(state);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
result = call_cfunc(body->nd_cfnc, recv, len, argc, argv);
|
||||||
}
|
}
|
||||||
result = call_cfunc(body->nd_cfnc, recv, len, argc, argv);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -5704,6 +5718,7 @@ rb_call0(klass, recv, id, oid, argc, argv, body, nosuper)
|
||||||
int state;
|
int state;
|
||||||
VALUE *local_vars; /* OK */
|
VALUE *local_vars; /* OK */
|
||||||
NODE *saved_cref = 0;
|
NODE *saved_cref = 0;
|
||||||
|
int hook_return = 0;
|
||||||
|
|
||||||
PUSH_SCOPE();
|
PUSH_SCOPE();
|
||||||
|
|
||||||
|
@ -5799,7 +5814,7 @@ rb_call0(klass, recv, id, oid, argc, argv, body, nosuper)
|
||||||
|
|
||||||
if (event_hooks) {
|
if (event_hooks) {
|
||||||
EXEC_EVENT_HOOK(RUBY_EVENT_CALL, b2, recv, id, klass);
|
EXEC_EVENT_HOOK(RUBY_EVENT_CALL, b2, recv, id, klass);
|
||||||
trace_status = 2; /* rfunc */
|
hook_return = 1;
|
||||||
}
|
}
|
||||||
result = rb_eval(recv, body);
|
result = rb_eval(recv, body);
|
||||||
}
|
}
|
||||||
|
@ -5812,14 +5827,8 @@ rb_call0(klass, recv, id, oid, argc, argv, body, nosuper)
|
||||||
POP_CLASS();
|
POP_CLASS();
|
||||||
POP_SCOPE();
|
POP_SCOPE();
|
||||||
ruby_cref = saved_cref;
|
ruby_cref = saved_cref;
|
||||||
switch (trace_status) {
|
if (hook_return) {
|
||||||
case 0: break; /* none */
|
|
||||||
case 1: /* cfunc */
|
|
||||||
EXEC_EVENT_HOOK(RUBY_EVENT_C_RETURN, body, recv, id, klass);
|
|
||||||
break;
|
|
||||||
case 2: /* rfunc */
|
|
||||||
EXEC_EVENT_HOOK(RUBY_EVENT_RETURN, body, recv, id, klass);
|
EXEC_EVENT_HOOK(RUBY_EVENT_RETURN, body, recv, id, klass);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case 0:
|
case 0:
|
||||||
|
|
4
node.h
4
node.h
|
@ -379,8 +379,8 @@ typedef unsigned int rb_event_t;
|
||||||
#define RUBY_EVENT_ALL 0xff
|
#define RUBY_EVENT_ALL 0xff
|
||||||
|
|
||||||
typedef void (*rb_event_hook_func_t)_((rb_event_t,NODE*,VALUE,ID,VALUE));
|
typedef void (*rb_event_hook_func_t)_((rb_event_t,NODE*,VALUE,ID,VALUE));
|
||||||
void rb_add_event_hook(rb_event_hook_func_t,rb_event_t);
|
void rb_add_event_hook _((rb_event_hook_func_t,rb_event_t));
|
||||||
int rb_remove_event_hook(rb_event_hook_func_t);
|
int rb_remove_event_hook _((rb_event_hook_func_t));
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
} /* extern "C" { */
|
} /* extern "C" { */
|
||||||
|
|
Загрузка…
Ссылка в новой задаче