mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* proc.c: refactoring (remove K&R style, move Binding stuffs from
Init_Proc() to Init_Binding()). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11634 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
27172b8e6f
commit
0d70d88643
2 changed files with 29 additions and 45 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Tue Feb 6 03:13:33 2007 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
|
* proc.c: refactoring (remove K&R style, move Binding stuffs from
|
||||||
|
Init_Proc() to Init_Binding()).
|
||||||
|
|
||||||
Tue Feb 6 01:07:14 2007 Koichi Sasada <ko1@atdot.net>
|
Tue Feb 6 01:07:14 2007 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
* intern.h: prepare rb_last_status_get() and rb_last_status_set().
|
* intern.h: prepare rb_last_status_get() and rb_last_status_set().
|
||||||
|
|
67
proc.c
67
proc.c
|
@ -157,7 +157,8 @@ proc_dup(VALUE self)
|
||||||
return procval;
|
return procval;
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE yarv_proc_dup(VALUE self)
|
static VALUE
|
||||||
|
yarv_proc_dup(VALUE self)
|
||||||
{
|
{
|
||||||
return proc_dup(self);
|
return proc_dup(self);
|
||||||
}
|
}
|
||||||
|
@ -715,8 +716,7 @@ mnew(VALUE klass, VALUE obj, ID id, VALUE mklass)
|
||||||
|
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
method_eq(method, other)
|
method_eq(VALUE method, VALUE other)
|
||||||
VALUE method, other;
|
|
||||||
{
|
{
|
||||||
struct METHOD *m1, *m2;
|
struct METHOD *m1, *m2;
|
||||||
|
|
||||||
|
@ -744,8 +744,7 @@ method_eq(method, other)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
method_hash(method)
|
method_hash(VALUE method)
|
||||||
VALUE method;
|
|
||||||
{
|
{
|
||||||
struct METHOD *m;
|
struct METHOD *m;
|
||||||
long hash;
|
long hash;
|
||||||
|
@ -769,8 +768,7 @@ method_hash(method)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
method_unbind(obj)
|
method_unbind(VALUE obj)
|
||||||
VALUE obj;
|
|
||||||
{
|
{
|
||||||
VALUE method;
|
VALUE method;
|
||||||
struct METHOD *orig, *data;
|
struct METHOD *orig, *data;
|
||||||
|
@ -867,9 +865,7 @@ method_owner(VALUE obj)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
rb_obj_method(obj, vid)
|
rb_obj_method(VALUE obj, VALUE vid)
|
||||||
VALUE obj;
|
|
||||||
VALUE vid;
|
|
||||||
{
|
{
|
||||||
return mnew(CLASS_OF(obj), obj, rb_to_id(vid), rb_cMethod);
|
return mnew(CLASS_OF(obj), obj, rb_to_id(vid), rb_cMethod);
|
||||||
}
|
}
|
||||||
|
@ -907,9 +903,7 @@ rb_obj_method(obj, vid)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
rb_mod_method(mod, vid)
|
rb_mod_method(VALUE mod, VALUE vid)
|
||||||
VALUE mod;
|
|
||||||
VALUE vid;
|
|
||||||
{
|
{
|
||||||
return mnew(mod, Qundef, rb_to_id(vid), rb_cUnboundMethod);
|
return mnew(mod, Qundef, rb_to_id(vid), rb_cUnboundMethod);
|
||||||
}
|
}
|
||||||
|
@ -951,8 +945,6 @@ rb_mod_method(mod, vid)
|
||||||
* #<B:0x401b39e8>
|
* #<B:0x401b39e8>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VALUE yarv_proc_dup(VALUE self);
|
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
rb_mod_define_method(int argc, VALUE *argv, VALUE mod)
|
rb_mod_define_method(int argc, VALUE *argv, VALUE mod)
|
||||||
{
|
{
|
||||||
|
@ -1022,8 +1014,7 @@ rb_mod_define_method(int argc, VALUE *argv, VALUE mod)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
method_clone(self)
|
method_clone(VALUE self)
|
||||||
VALUE self;
|
|
||||||
{
|
{
|
||||||
VALUE clone;
|
VALUE clone;
|
||||||
struct METHOD *orig, *data;
|
struct METHOD *orig, *data;
|
||||||
|
@ -1175,8 +1166,7 @@ rb_method_call(int argc, VALUE *argv, VALUE method)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
umethod_bind(method, recv)
|
umethod_bind(VALUE method, VALUE recv)
|
||||||
VALUE method, recv;
|
|
||||||
{
|
{
|
||||||
struct METHOD *data, *bound;
|
struct METHOD *data, *bound;
|
||||||
|
|
||||||
|
@ -1192,8 +1182,7 @@ umethod_bind(method, recv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
method =
|
method = Data_Make_Struct(rb_cMethod, struct METHOD, bm_mark, free, bound);
|
||||||
Data_Make_Struct(rb_cMethod, struct METHOD, bm_mark, free, bound);
|
|
||||||
*bound = *data;
|
*bound = *data;
|
||||||
bound->recv = recv;
|
bound->recv = recv;
|
||||||
bound->rklass = CLASS_OF(recv);
|
bound->rklass = CLASS_OF(recv);
|
||||||
|
@ -1278,16 +1267,14 @@ rb_node_arity(NODE * body)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
method_arity_m(method)
|
method_arity_m(VALUE method)
|
||||||
VALUE method;
|
|
||||||
{
|
{
|
||||||
int n = method_arity(method);
|
int n = method_arity(method);
|
||||||
return INT2FIX(n);
|
return INT2FIX(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
method_arity(method)
|
method_arity(VALUE method)
|
||||||
VALUE method;
|
|
||||||
{
|
{
|
||||||
struct METHOD *data;
|
struct METHOD *data;
|
||||||
|
|
||||||
|
@ -1296,18 +1283,14 @@ method_arity(method)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
rb_mod_method_arity(mod, id)
|
rb_mod_method_arity(VALUE mod, ID id)
|
||||||
VALUE mod;
|
|
||||||
ID id;
|
|
||||||
{
|
{
|
||||||
NODE *node = rb_method_node(mod, id);
|
NODE *node = rb_method_node(mod, id);
|
||||||
return rb_node_arity(node);
|
return rb_node_arity(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
rb_obj_method_arity(obj, id)
|
rb_obj_method_arity(VALUE obj, ID id)
|
||||||
VALUE obj;
|
|
||||||
ID id;
|
|
||||||
{
|
{
|
||||||
return rb_mod_method_arity(CLASS_OF(obj), id);
|
return rb_mod_method_arity(CLASS_OF(obj), id);
|
||||||
}
|
}
|
||||||
|
@ -1478,7 +1461,7 @@ localjump_reason(VALUE exc)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
Init_Proc()
|
Init_Proc(void)
|
||||||
{
|
{
|
||||||
/* Env */
|
/* Env */
|
||||||
rb_cVM = rb_define_class("VM", rb_cObject); /* TODO: should be moved to suitable place */
|
rb_cVM = rb_define_class("VM", rb_cObject); /* TODO: should be moved to suitable place */
|
||||||
|
@ -1501,19 +1484,10 @@ Init_Proc()
|
||||||
rb_define_method(rb_cProc, "hash", proc_hash, 0);
|
rb_define_method(rb_cProc, "hash", proc_hash, 0);
|
||||||
rb_define_method(rb_cProc, "to_s", proc_to_s, 0);
|
rb_define_method(rb_cProc, "to_s", proc_to_s, 0);
|
||||||
|
|
||||||
/* Binding */
|
/* Exceptions */
|
||||||
rb_cBinding = rb_define_class("Binding", rb_cObject);
|
|
||||||
rb_undef_alloc_func(rb_cBinding);
|
|
||||||
rb_undef_method(CLASS_OF(rb_cBinding), "new");
|
|
||||||
rb_define_method(rb_cBinding, "clone", binding_clone, 0);
|
|
||||||
rb_define_method(rb_cBinding, "dup", binding_dup, 0);
|
|
||||||
rb_define_global_function("binding", rb_f_binding, 0);
|
|
||||||
|
|
||||||
rb_eLocalJumpError = rb_define_class("LocalJumpError", rb_eStandardError);
|
rb_eLocalJumpError = rb_define_class("LocalJumpError", rb_eStandardError);
|
||||||
rb_define_method(rb_eLocalJumpError, "exit_value", localjump_xvalue, 0);
|
rb_define_method(rb_eLocalJumpError, "exit_value", localjump_xvalue, 0);
|
||||||
rb_define_method(rb_eLocalJumpError, "reason", localjump_reason, 0);
|
rb_define_method(rb_eLocalJumpError, "reason", localjump_reason, 0);
|
||||||
|
|
||||||
/* Exceptions */
|
|
||||||
exception_error = rb_exc_new2(rb_eFatal, "exception reentered");
|
exception_error = rb_exc_new2(rb_eFatal, "exception reentered");
|
||||||
rb_register_mark_object(exception_error);
|
rb_register_mark_object(exception_error);
|
||||||
|
|
||||||
|
@ -1603,8 +1577,13 @@ Init_Proc()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
Init_Binding()
|
Init_Binding(void)
|
||||||
{
|
{
|
||||||
|
rb_cBinding = rb_define_class("Binding", rb_cObject);
|
||||||
|
rb_undef_alloc_func(rb_cBinding);
|
||||||
|
rb_undef_method(CLASS_OF(rb_cBinding), "new");
|
||||||
|
rb_define_method(rb_cBinding, "clone", binding_clone, 0);
|
||||||
|
rb_define_method(rb_cBinding, "dup", binding_dup, 0);
|
||||||
|
rb_define_global_function("binding", rb_f_binding, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue