Skip to content

Commit

Permalink
* eval.c (rb_call_super): inheritance line adjustment moved from
Browse files Browse the repository at this point in the history
  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
  • Loading branch information
matz committed Jun 3, 2003
1 parent 63ae7e1 commit c5fc4bc
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 50 deletions.
7 changes: 7 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -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>

* array.c (push_values_at): Array#values_at should work with
Expand Down
45 changes: 21 additions & 24 deletions eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -3021,12 +3021,8 @@ rb_eval(self, n)
END_CALLARGS;
}

PUSH_ITER(ruby_iter->iter?ITER_PRE:ITER_NOT);
SET_CURRENT_SOURCE();
result = rb_call(RCLASS(ruby_frame->last_class)->super,
ruby_frame->self, ruby_frame->orig_func,
argc, argv, 3);
POP_ITER();
result = rb_call_super(argc, argv);
}
break;

Expand Down Expand Up @@ -5041,7 +5037,6 @@ rb_call(klass, recv, mid, argc, argv, scope)
int noex;
ID id = mid;
struct cache_entry *ent;
VALUE k = klass;

if (!klass) {
rb_raise(rb_eNotImpError, "method `%s' called on terminated object (0x%lx)",
Expand All @@ -5052,7 +5047,7 @@ rb_call(klass, recv, mid, argc, argv, scope)
if (ent->mid == mid && ent->klass == klass) {
if (!ent->method)
return rb_undefined(recv, mid, argc, argv, scope==2?CSTAT_VCALL:0);
k = ent->origin;
klass = ent->origin;
id = ent->mid0;
noex = ent->noex;
body = ent->method;
Expand All @@ -5063,19 +5058,6 @@ rb_call(klass, recv, mid, argc, argv, scope)
}
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) {
/* receiver specified form for private method */
Expand Down Expand Up @@ -5187,18 +5169,33 @@ rb_call_super(argc, argv)
int argc;
const VALUE *argv;
{
VALUE result;
VALUE result, self, klass, k;

if (ruby_frame->last_class == 0) {
rb_name_error(ruby_frame->last_func,
"superclass method `%s' must be enabled by rb_enable_super()",
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);
result = rb_call(RCLASS(ruby_frame->last_class)->super,
ruby_frame->self, ruby_frame->last_func,
argc, argv, 3);
result = rb_call(RCLASS(klass)->super, self, ruby_frame->last_func, argc, argv, 3);
POP_ITER();

return result;
Expand Down
28 changes: 14 additions & 14 deletions ext/tk/lib/tk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -441,11 +441,11 @@ def _bindinfo(what, context=nil)
private :install_bind, :tk_event_sequence,
:_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)
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)
end

Expand All @@ -457,11 +457,11 @@ def bindinfo(tagOrClass, context=nil)
_bindinfo(['bind', tagOrClass], context)
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)
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)
end

Expand Down Expand Up @@ -513,7 +513,7 @@ def callback_continue
fail TkCallbackContinue, "Tk callback returns 'continue' status"
end

def after(ms, cmd=Proc.new)
def after(ms, cmd=Block.new)
myid = _curr_cmd_id
cmdid = install_cmd(cmd)
tk_call("after",ms,cmdid)
Expand All @@ -531,7 +531,7 @@ def after(ms, cmd=Proc.new)
# end
end

def after_idle(cmd=Proc.new)
def after_idle(cmd=Block.new)
myid = _curr_cmd_id
cmdid = install_cmd(cmd)
tk_call('after','idle',cmdid)
Expand Down Expand Up @@ -871,10 +871,10 @@ def Tk.fromUTF8(str,encoding)
end

module Scrollable
def xscrollcommand(cmd=Proc.new)
def xscrollcommand(cmd=Block.new)
configure_cmd 'xscrollcommand', cmd
end
def yscrollcommand(cmd=Proc.new)
def yscrollcommand(cmd=Block.new)
configure_cmd 'yscrollcommand', cmd
end
def xview(*index)
Expand Down Expand Up @@ -1103,11 +1103,11 @@ def encoding_system=(enc)
end

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)
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)
end

Expand Down Expand Up @@ -2161,7 +2161,7 @@ def method_missing(id, *args)
proc_str = TkOption.get(self::CARRIER, id.id2name, '')
proc_str = '{' + proc_str + '}' unless /\A\{.*\}\Z/ =~ 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
end
proc{
Expand Down Expand Up @@ -2840,7 +2840,7 @@ def raise(above=None)
self
end

def command(cmd=Proc.new)
def command(cmd=Block.new)
configure_cmd 'command', cmd
end

Expand Down Expand Up @@ -3458,10 +3458,10 @@ def post(x, y)
def postcascade(index)
tk_send 'postcascade', index
end
def postcommand(cmd=Proc.new)
def postcommand(cmd=Block.new)
configure_cmd 'postcommand', cmd
end
def tearoffcommand(cmd=Proc.new)
def tearoffcommand(cmd=Block.new)
configure_cmd 'tearoffcommand', cmd
end
def menutype(index)
Expand Down
6 changes: 3 additions & 3 deletions ext/tk/lib/tkcanvas.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ def bbox(tagOrId, *tags)
list(tk_send('bbox', tagid(tagOrId), *tags.collect{|t| tagid(t)}))
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)
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)
end

Expand Down Expand Up @@ -346,7 +346,7 @@ def bbox
@c.bbox(@id)
end

def bind(seq, cmd=Proc.new, args=nil)
def bind(seq, cmd=Block.new, args=nil)
@c.itembind @id, seq, cmd, args
end

Expand Down
2 changes: 1 addition & 1 deletion ext/tk/lib/tkentry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def initialize(d,i,s,v,pp,ss,vv,ww)
attr :widget
end

def initialize(cmd = Proc.new, args=nil)
def initialize(cmd = Block.new, args=nil)
if args
@id = install_cmd(proc{|*arg|
TkUtil.eval_cmd cmd, *arg
Expand Down
10 changes: 5 additions & 5 deletions ext/tk/lib/tktext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,11 @@ def tag_add(tag, index1, index2=None)
tk_send 'tag', 'add', tag, index1, index2
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)
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)
end

Expand Down Expand Up @@ -419,7 +419,7 @@ def rsearch(pat,start,stop=None)

def dump(type_info, *index, &block)
args = type_info.collect{|inf| '-' + inf}
args << '-command' << Proc.new(&block) if iterator?
args << '-command' << block if block
str = tk_send('dump', *(args + index))
result = []
sel = nil
Expand Down Expand Up @@ -663,11 +663,11 @@ def configinfo(key=nil)
@t.tag_configinfo @id, key
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)
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)
end

Expand Down
4 changes: 2 additions & 2 deletions lib/net/imap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@
If this mailbox exists, an array containing objects of
((<Net::IMAP::MailboxACLItem>)) will be returned.
: add_response_handler(handler = Proc.new)
: add_response_handler(handler = Block.new)
Adds a response handler.
ex).
Expand Down Expand Up @@ -1047,7 +1047,7 @@ def uid_sort(sort_keys, search_keys, charset)
return sort_internal("UID SORT", sort_keys, search_keys, charset)
end

def add_response_handler(handler = Proc.new)
def add_response_handler(handler = Block.new)
@response_handlers.push(handler)
end

Expand Down
8 changes: 8 additions & 0 deletions lib/net/telnet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,14 @@ def waitfor(options)
buf = preprocess(c)
rest = ''
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
@log.print(buf) if @options.has_key?("Output_log")
line += buf
Expand Down
2 changes: 1 addition & 1 deletion lib/optparse.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def self.pattern
=end #'#"#`#
def initialize(pattern = nil, conv = 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
end
Expand Down

0 comments on commit c5fc4bc

Please sign in to comment.