mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* eval.c (rb_call_super): inheritance line adjustment moved from
rb_call(). [ruby-core:01113] * eval.c (rb_eval): use rb_call_super() to follow DRY principle. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3901 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
63ae7e1c13
commit
c5fc4bca6d
9 changed files with 62 additions and 50 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
Tue Jun 3 09:59:27 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* eval.c (rb_call_super): inheritance line adjustment moved from
|
||||||
|
rb_call(). [ruby-core:01113]
|
||||||
|
|
||||||
|
* eval.c (rb_eval): use rb_call_super() to follow DRY principle.
|
||||||
|
|
||||||
Mon Jun 2 02:20:52 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
|
Mon Jun 2 02:20:52 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* array.c (push_values_at): Array#values_at should work with
|
* array.c (push_values_at): Array#values_at should work with
|
||||||
|
|
45
eval.c
45
eval.c
|
@ -3021,12 +3021,8 @@ rb_eval(self, n)
|
||||||
END_CALLARGS;
|
END_CALLARGS;
|
||||||
}
|
}
|
||||||
|
|
||||||
PUSH_ITER(ruby_iter->iter?ITER_PRE:ITER_NOT);
|
|
||||||
SET_CURRENT_SOURCE();
|
SET_CURRENT_SOURCE();
|
||||||
result = rb_call(RCLASS(ruby_frame->last_class)->super,
|
result = rb_call_super(argc, argv);
|
||||||
ruby_frame->self, ruby_frame->orig_func,
|
|
||||||
argc, argv, 3);
|
|
||||||
POP_ITER();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -5041,7 +5037,6 @@ rb_call(klass, recv, mid, argc, argv, scope)
|
||||||
int noex;
|
int noex;
|
||||||
ID id = mid;
|
ID id = mid;
|
||||||
struct cache_entry *ent;
|
struct cache_entry *ent;
|
||||||
VALUE k = klass;
|
|
||||||
|
|
||||||
if (!klass) {
|
if (!klass) {
|
||||||
rb_raise(rb_eNotImpError, "method `%s' called on terminated object (0x%lx)",
|
rb_raise(rb_eNotImpError, "method `%s' called on terminated object (0x%lx)",
|
||||||
|
@ -5052,7 +5047,7 @@ rb_call(klass, recv, mid, argc, argv, scope)
|
||||||
if (ent->mid == mid && ent->klass == klass) {
|
if (ent->mid == mid && ent->klass == klass) {
|
||||||
if (!ent->method)
|
if (!ent->method)
|
||||||
return rb_undefined(recv, mid, argc, argv, scope==2?CSTAT_VCALL:0);
|
return rb_undefined(recv, mid, argc, argv, scope==2?CSTAT_VCALL:0);
|
||||||
k = ent->origin;
|
klass = ent->origin;
|
||||||
id = ent->mid0;
|
id = ent->mid0;
|
||||||
noex = ent->noex;
|
noex = ent->noex;
|
||||||
body = ent->method;
|
body = ent->method;
|
||||||
|
@ -5063,19 +5058,6 @@ rb_call(klass, recv, mid, argc, argv, scope)
|
||||||
}
|
}
|
||||||
return rb_undefined(recv, mid, argc, argv, scope==2?CSTAT_VCALL:0);
|
return rb_undefined(recv, mid, argc, argv, scope==2?CSTAT_VCALL:0);
|
||||||
}
|
}
|
||||||
if (BUILTIN_TYPE(k) == T_MODULE) {
|
|
||||||
while (!(BUILTIN_TYPE(klass) == T_ICLASS && RBASIC(klass)->klass == k)) {
|
|
||||||
klass = RCLASS(klass)->super;
|
|
||||||
if (!klass) {
|
|
||||||
rb_raise(rb_eTypeError, "%s is not included in %s",
|
|
||||||
rb_class2name(k),
|
|
||||||
rb_class2name(CLASS_OF(recv)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
klass = k;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mid != missing) {
|
if (mid != missing) {
|
||||||
/* receiver specified form for private method */
|
/* receiver specified form for private method */
|
||||||
|
@ -5187,7 +5169,7 @@ rb_call_super(argc, argv)
|
||||||
int argc;
|
int argc;
|
||||||
const VALUE *argv;
|
const VALUE *argv;
|
||||||
{
|
{
|
||||||
VALUE result;
|
VALUE result, self, klass, k;
|
||||||
|
|
||||||
if (ruby_frame->last_class == 0) {
|
if (ruby_frame->last_class == 0) {
|
||||||
rb_name_error(ruby_frame->last_func,
|
rb_name_error(ruby_frame->last_func,
|
||||||
|
@ -5195,10 +5177,25 @@ rb_call_super(argc, argv)
|
||||||
rb_id2name(ruby_frame->last_func));
|
rb_id2name(ruby_frame->last_func));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self = ruby_frame->self;
|
||||||
|
klass = CLASS_OF(self);
|
||||||
|
k = ruby_frame->last_class;
|
||||||
|
if (BUILTIN_TYPE(k) == T_MODULE) {
|
||||||
|
while (!(BUILTIN_TYPE(klass) == T_ICLASS && RBASIC(klass)->klass == k)) {
|
||||||
|
klass = RCLASS(klass)->super;
|
||||||
|
if (!klass) {
|
||||||
|
rb_raise(rb_eTypeError, "%s is not included in %s",
|
||||||
|
rb_class2name(k),
|
||||||
|
rb_class2name(CLASS_OF(self)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
klass = k;
|
||||||
|
}
|
||||||
|
|
||||||
PUSH_ITER(ruby_iter->iter?ITER_PRE:ITER_NOT);
|
PUSH_ITER(ruby_iter->iter?ITER_PRE:ITER_NOT);
|
||||||
result = rb_call(RCLASS(ruby_frame->last_class)->super,
|
result = rb_call(RCLASS(klass)->super, self, ruby_frame->last_func, argc, argv, 3);
|
||||||
ruby_frame->self, ruby_frame->last_func,
|
|
||||||
argc, argv, 3);
|
|
||||||
POP_ITER();
|
POP_ITER();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -441,11 +441,11 @@ module TkComm
|
||||||
private :install_bind, :tk_event_sequence,
|
private :install_bind, :tk_event_sequence,
|
||||||
:_bind_core, :_bind, :_bind_append, :_bind_remove, :_bindinfo
|
:_bind_core, :_bind, :_bind_append, :_bind_remove, :_bindinfo
|
||||||
|
|
||||||
def bind(tagOrClass, context, cmd=Proc.new, args=nil)
|
def bind(tagOrClass, context, cmd=Block.new, args=nil)
|
||||||
_bind(["bind", tagOrClass], context, cmd, args)
|
_bind(["bind", tagOrClass], context, cmd, args)
|
||||||
end
|
end
|
||||||
|
|
||||||
def bind_append(tagOrClass, context, cmd=Proc.new, args=nil)
|
def bind_append(tagOrClass, context, cmd=Block.new, args=nil)
|
||||||
_bind_append(["bind", tagOrClass], context, cmd, args)
|
_bind_append(["bind", tagOrClass], context, cmd, args)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -457,11 +457,11 @@ module TkComm
|
||||||
_bindinfo(['bind', tagOrClass], context)
|
_bindinfo(['bind', tagOrClass], context)
|
||||||
end
|
end
|
||||||
|
|
||||||
def bind_all(context, cmd=Proc.new, args=nil)
|
def bind_all(context, cmd=Block.new, args=nil)
|
||||||
_bind(['bind', 'all'], context, cmd, args)
|
_bind(['bind', 'all'], context, cmd, args)
|
||||||
end
|
end
|
||||||
|
|
||||||
def bind_append_all(context, cmd=Proc.new, args=nil)
|
def bind_append_all(context, cmd=Block.new, args=nil)
|
||||||
_bind_append(['bind', 'all'], context, cmd, args)
|
_bind_append(['bind', 'all'], context, cmd, args)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -513,7 +513,7 @@ module TkCore
|
||||||
fail TkCallbackContinue, "Tk callback returns 'continue' status"
|
fail TkCallbackContinue, "Tk callback returns 'continue' status"
|
||||||
end
|
end
|
||||||
|
|
||||||
def after(ms, cmd=Proc.new)
|
def after(ms, cmd=Block.new)
|
||||||
myid = _curr_cmd_id
|
myid = _curr_cmd_id
|
||||||
cmdid = install_cmd(cmd)
|
cmdid = install_cmd(cmd)
|
||||||
tk_call("after",ms,cmdid)
|
tk_call("after",ms,cmdid)
|
||||||
|
@ -531,7 +531,7 @@ module TkCore
|
||||||
# end
|
# end
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_idle(cmd=Proc.new)
|
def after_idle(cmd=Block.new)
|
||||||
myid = _curr_cmd_id
|
myid = _curr_cmd_id
|
||||||
cmdid = install_cmd(cmd)
|
cmdid = install_cmd(cmd)
|
||||||
tk_call('after','idle',cmdid)
|
tk_call('after','idle',cmdid)
|
||||||
|
@ -871,10 +871,10 @@ module Tk
|
||||||
end
|
end
|
||||||
|
|
||||||
module Scrollable
|
module Scrollable
|
||||||
def xscrollcommand(cmd=Proc.new)
|
def xscrollcommand(cmd=Block.new)
|
||||||
configure_cmd 'xscrollcommand', cmd
|
configure_cmd 'xscrollcommand', cmd
|
||||||
end
|
end
|
||||||
def yscrollcommand(cmd=Proc.new)
|
def yscrollcommand(cmd=Block.new)
|
||||||
configure_cmd 'yscrollcommand', cmd
|
configure_cmd 'yscrollcommand', cmd
|
||||||
end
|
end
|
||||||
def xview(*index)
|
def xview(*index)
|
||||||
|
@ -1103,11 +1103,11 @@ else
|
||||||
end
|
end
|
||||||
|
|
||||||
module TkBindCore
|
module TkBindCore
|
||||||
def bind(context, cmd=Proc.new, args=nil)
|
def bind(context, cmd=Block.new, args=nil)
|
||||||
Tk.bind(to_eval, context, cmd, args)
|
Tk.bind(to_eval, context, cmd, args)
|
||||||
end
|
end
|
||||||
|
|
||||||
def bind_append(context, cmd=Proc.new, args=nil)
|
def bind_append(context, cmd=Block.new, args=nil)
|
||||||
Tk.bind_append(to_eval, context, cmd, args)
|
Tk.bind_append(to_eval, context, cmd, args)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -2161,7 +2161,7 @@ module TkOption
|
||||||
proc_str = TkOption.get(self::CARRIER, id.id2name, '')
|
proc_str = TkOption.get(self::CARRIER, id.id2name, '')
|
||||||
proc_str = '{' + proc_str + '}' unless /\A\{.*\}\Z/ =~ proc_str
|
proc_str = '{' + proc_str + '}' unless /\A\{.*\}\Z/ =~ proc_str
|
||||||
proc_str = __check_proc_string__(proc_str)
|
proc_str = __check_proc_string__(proc_str)
|
||||||
res_proc = eval 'Proc.new' + proc_str
|
res_proc = eval 'Block.new' + proc_str
|
||||||
self::METHOD_TBL[id] = res_proc
|
self::METHOD_TBL[id] = res_proc
|
||||||
end
|
end
|
||||||
proc{
|
proc{
|
||||||
|
@ -2840,7 +2840,7 @@ class TkWindow<TkObject
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def command(cmd=Proc.new)
|
def command(cmd=Block.new)
|
||||||
configure_cmd 'command', cmd
|
configure_cmd 'command', cmd
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -3458,10 +3458,10 @@ class TkMenu<TkWindow
|
||||||
def postcascade(index)
|
def postcascade(index)
|
||||||
tk_send 'postcascade', index
|
tk_send 'postcascade', index
|
||||||
end
|
end
|
||||||
def postcommand(cmd=Proc.new)
|
def postcommand(cmd=Block.new)
|
||||||
configure_cmd 'postcommand', cmd
|
configure_cmd 'postcommand', cmd
|
||||||
end
|
end
|
||||||
def tearoffcommand(cmd=Proc.new)
|
def tearoffcommand(cmd=Block.new)
|
||||||
configure_cmd 'tearoffcommand', cmd
|
configure_cmd 'tearoffcommand', cmd
|
||||||
end
|
end
|
||||||
def menutype(index)
|
def menutype(index)
|
||||||
|
|
|
@ -81,11 +81,11 @@ class TkCanvas<TkWindow
|
||||||
list(tk_send('bbox', tagid(tagOrId), *tags.collect{|t| tagid(t)}))
|
list(tk_send('bbox', tagid(tagOrId), *tags.collect{|t| tagid(t)}))
|
||||||
end
|
end
|
||||||
|
|
||||||
def itembind(tag, context, cmd=Proc.new, args=nil)
|
def itembind(tag, context, cmd=Block.new, args=nil)
|
||||||
_bind([path, "bind", tagid(tag)], context, cmd, args)
|
_bind([path, "bind", tagid(tag)], context, cmd, args)
|
||||||
end
|
end
|
||||||
|
|
||||||
def itembind_append(tag, context, cmd=Proc.new, args=nil)
|
def itembind_append(tag, context, cmd=Block.new, args=nil)
|
||||||
_bind_append([path, "bind", tagid(tag)], context, cmd, args)
|
_bind_append([path, "bind", tagid(tag)], context, cmd, args)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -346,7 +346,7 @@ module TkcTagAccess
|
||||||
@c.bbox(@id)
|
@c.bbox(@id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def bind(seq, cmd=Proc.new, args=nil)
|
def bind(seq, cmd=Block.new, args=nil)
|
||||||
@c.itembind @id, seq, cmd, args
|
@c.itembind @id, seq, cmd, args
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ class TkEntry<TkLabel
|
||||||
attr :widget
|
attr :widget
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(cmd = Proc.new, args=nil)
|
def initialize(cmd = Block.new, args=nil)
|
||||||
if args
|
if args
|
||||||
@id = install_cmd(proc{|*arg|
|
@id = install_cmd(proc{|*arg|
|
||||||
TkUtil.eval_cmd cmd, *arg
|
TkUtil.eval_cmd cmd, *arg
|
||||||
|
|
|
@ -172,11 +172,11 @@ class TkText<TkTextWin
|
||||||
tk_send 'tag', 'add', tag, index1, index2
|
tk_send 'tag', 'add', tag, index1, index2
|
||||||
end
|
end
|
||||||
|
|
||||||
def tag_bind(tag, seq, cmd=Proc.new, args=nil)
|
def tag_bind(tag, seq, cmd=Block.new, args=nil)
|
||||||
_bind(['tag', 'bind', tag], seq, cmd, args)
|
_bind(['tag', 'bind', tag], seq, cmd, args)
|
||||||
end
|
end
|
||||||
|
|
||||||
def tag_bind_append(tag, seq, cmd=Proc.new, args=nil)
|
def tag_bind_append(tag, seq, cmd=Block.new, args=nil)
|
||||||
_bind_append(['tag', 'bind', tag], seq, cmd, args)
|
_bind_append(['tag', 'bind', tag], seq, cmd, args)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -419,7 +419,7 @@ class TkText<TkTextWin
|
||||||
|
|
||||||
def dump(type_info, *index, &block)
|
def dump(type_info, *index, &block)
|
||||||
args = type_info.collect{|inf| '-' + inf}
|
args = type_info.collect{|inf| '-' + inf}
|
||||||
args << '-command' << Proc.new(&block) if iterator?
|
args << '-command' << block if block
|
||||||
str = tk_send('dump', *(args + index))
|
str = tk_send('dump', *(args + index))
|
||||||
result = []
|
result = []
|
||||||
sel = nil
|
sel = nil
|
||||||
|
@ -663,11 +663,11 @@ class TkTextTag<TkObject
|
||||||
@t.tag_configinfo @id, key
|
@t.tag_configinfo @id, key
|
||||||
end
|
end
|
||||||
|
|
||||||
def bind(seq, cmd=Proc.new, args=nil)
|
def bind(seq, cmd=Block.new, args=nil)
|
||||||
_bind([@t.path, 'tag', 'bind', @id], seq, cmd, args)
|
_bind([@t.path, 'tag', 'bind', @id], seq, cmd, args)
|
||||||
end
|
end
|
||||||
|
|
||||||
def bind_append(seq, cmd=Proc.new, args=nil)
|
def bind_append(seq, cmd=Block.new, args=nil)
|
||||||
_bind_append([@t.path, 'tag', 'bind', @id], seq, cmd, args)
|
_bind_append([@t.path, 'tag', 'bind', @id], seq, cmd, args)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -263,7 +263,7 @@ Object
|
||||||
If this mailbox exists, an array containing objects of
|
If this mailbox exists, an array containing objects of
|
||||||
((<Net::IMAP::MailboxACLItem>)) will be returned.
|
((<Net::IMAP::MailboxACLItem>)) will be returned.
|
||||||
|
|
||||||
: add_response_handler(handler = Proc.new)
|
: add_response_handler(handler = Block.new)
|
||||||
Adds a response handler.
|
Adds a response handler.
|
||||||
|
|
||||||
ex).
|
ex).
|
||||||
|
@ -1047,7 +1047,7 @@ module Net
|
||||||
return sort_internal("UID SORT", sort_keys, search_keys, charset)
|
return sort_internal("UID SORT", sort_keys, search_keys, charset)
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_response_handler(handler = Proc.new)
|
def add_response_handler(handler = Block.new)
|
||||||
@response_handlers.push(handler)
|
@response_handlers.push(handler)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -480,6 +480,14 @@ module Net
|
||||||
buf = preprocess(c)
|
buf = preprocess(c)
|
||||||
rest = ''
|
rest = ''
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
# Not Telnetmode.
|
||||||
|
#
|
||||||
|
# We cannot use preprocess() on this data, because that
|
||||||
|
# method makes some Telnetmode-specific assumptions.
|
||||||
|
buf = c
|
||||||
|
buf.gsub!(/#{EOL}/no, "\n") unless @options["Binmode"]
|
||||||
|
rest = ''
|
||||||
end
|
end
|
||||||
@log.print(buf) if @options.has_key?("Output_log")
|
@log.print(buf) if @options.has_key?("Output_log")
|
||||||
line += buf
|
line += buf
|
||||||
|
|
|
@ -167,7 +167,7 @@ Individual switch class.
|
||||||
=end #'#"#`#
|
=end #'#"#`#
|
||||||
def initialize(pattern = nil, conv = nil,
|
def initialize(pattern = nil, conv = nil,
|
||||||
short = nil, long = nil, arg = nil,
|
short = nil, long = nil, arg = nil,
|
||||||
desc = ([] if short or long), block = Proc.new)
|
desc = ([] if short or long), block = Block.new)
|
||||||
@pattern, @conv, @short, @long, @arg, @desc, @block =
|
@pattern, @conv, @short, @long, @arg, @desc, @block =
|
||||||
pattern, conv, short, long, arg, desc, block
|
pattern, conv, short, long, arg, desc, block
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue