1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* commit miss; and tcltklib fix too.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2920 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2002-10-02 06:02:17 +00:00
parent 8c0cbb7350
commit ab6b478615
8 changed files with 59 additions and 24 deletions

View file

@ -264,7 +264,7 @@ module TkComm
end end
def uninstall_cmd(id) def uninstall_cmd(id)
id = $1 if /rb_out (c\d+)/ =~ id id = $1 if /rb_out (c\d+)/ =~ id
Tk_CMDTBL[id] = nil Tk_CMDTBL.delete(id)
end end
private :install_cmd, :uninstall_cmd private :install_cmd, :uninstall_cmd
@ -282,7 +282,7 @@ module TkComm
end end
def uninstall_win() def uninstall_win()
Tk_WINDOWS[@path] = nil Tk_WINDOWS.delete(@path)
end end
class Event class Event
@ -2188,7 +2188,7 @@ module TkOption
METHOD_TBL = {} METHOD_TBL = {}
ADD_METHOD = #{add} ADD_METHOD = #{add}
SAFE_MODE = #{safe} SAFE_MODE = #{safe}
%w(#{func_str}).each{|f| METHOD_TBL[f.intern] = nil } %w(#{func_str}).each{|f| METHOD_TBL.delete(f.intern) }
end end
EOD EOD

View file

@ -64,7 +64,7 @@ class TkAfter
def set_next_callback(args) def set_next_callback(args)
if @running == false || @proc_max == 0 || @do_loop == 0 if @running == false || @proc_max == 0 || @do_loop == 0
Tk_CBTBL[@id] = nil ;# for GC Tk_CBTBL.delete(@id) ;# for GC
@running = false @running = false
return return
end end
@ -72,7 +72,7 @@ class TkAfter
if @do_loop < 0 || (@do_loop -= 1) > 0 if @do_loop < 0 || (@do_loop -= 1) > 0
@current_pos = 0 @current_pos = 0
else else
Tk_CBTBL[@id] = nil ;# for GC Tk_CBTBL.delete(@id) ;# for GC
@running = false @running = false
return return
end end
@ -272,7 +272,7 @@ class TkAfter
@running = false @running = false
tk_call 'after', 'cancel', @after_id if @after_id tk_call 'after', 'cancel', @after_id if @after_id
@after_id = nil @after_id = nil
Tk_CBTBL[@id] = nil ;# for GC Tk_CBTBL.delete(@id) ;# for GC
self self
end end
alias stop cancel alias stop cancel

View file

@ -504,7 +504,7 @@ class TkcTag<TkObject
def delete def delete
@c.delete @id @c.delete @id
CTagID_TBL[@cpath][@id] = nil if CTagID_TBL[@cpath] CTagID_TBL[@cpath].delete(@id) if CTagID_TBL[@cpath]
end end
alias remove delete alias remove delete
alias destroy delete alias destroy delete
@ -688,7 +688,7 @@ class TkcItem<TkObject
def delete def delete
@c.delete @id @c.delete @id
CItemID_TBL[@path][@id] = nil if CItemID_TBL[@path] CItemID_TBL[@path].delete(@id) if CItemID_TBL[@path]
end end
alias remove delete alias remove delete
alias destroy delete alias destroy delete
@ -763,7 +763,7 @@ class TkImage<TkObject
end end
def delete def delete
Tk_IMGTBL[@id] = nil if @id Tk_IMGTBL.delete(@id) if @id
tk_call('image', 'delete', @path) tk_call('image', 'delete', @path)
end end
def height def height

View file

@ -564,7 +564,7 @@ class TkFont
end end
def delete_core_tk4x def delete_core_tk4x
Tk_FontNameTBL[@id] = nil Tk_FontNameTBL.delete(@id)
Tk_FontUseTBL.delete_if{|key,value| value == self} Tk_FontUseTBL.delete_if{|key,value| value == self}
end end
@ -581,7 +581,7 @@ class TkFont
tk_call('font', 'delete', @compoundfont) tk_call('font', 'delete', @compoundfont)
rescue rescue
end end
Tk_FontNameTBL[@id] = nil Tk_FontNameTBL.delete(@id)
Tk_FontUseTBL.delete_if{|key,value| value == self} Tk_FontUseTBL.delete_if{|key,value| value == self}
end end
@ -610,7 +610,7 @@ class TkFont
tk_call(w, 'configure', '-font', @latinfont) tk_call(w, 'configure', '-font', @latinfont)
end end
rescue rescue
Tk_FontUseTBL[w] = nil Tk_FontUseTBL.delete(w)
end end
end end
} }
@ -644,7 +644,7 @@ class TkFont
tk_call(w, 'configure', '-kanjifont', @kanjifont) tk_call(w, 'configure', '-kanjifont', @kanjifont)
end end
rescue rescue
Tk_FontUseTBL[w] = nil Tk_FontUseTBL.delete(w)
end end
end end
} }

View file

@ -685,7 +685,7 @@ class TkTextTag<TkObject
def destroy def destroy
tk_call @t.path, 'tag', 'delete', @id tk_call @t.path, 'tag', 'delete', @id
TTagID_TBL[@tpath][@id] = nil if CTagID_TBL[@tpath] TTagID_TBL[@tpath].delete(@id) if CTagID_TBL[@tpath]
end end
end end

View file

@ -54,11 +54,11 @@ class TkVirtualEvent<TkObject
def delete(*sequences) def delete(*sequences)
if sequences == [] if sequences == []
tk_call('event', 'delete', "<#{@id}>") tk_call('event', 'delete', "<#{@id}>")
TkVirtualEventTBL[@id] = nil TkVirtualEventTBL.delete(@id)
else else
tk_call('event', 'delete', "<#{@id}>", tk_call('event', 'delete', "<#{@id}>",
*(sequences.collect{|seq| "<#{tk_event_sequence(seq)}>"}) ) *(sequences.collect{|seq| "<#{tk_event_sequence(seq)}>"}) )
TkVirtualEventTBL[@id] = nil if info == [] TkVirtualEventTBL.delete(@id) if info == []
end end
self self
end end

33
gc.c
View file

@ -848,12 +848,12 @@ gc_sweep()
{ {
RVALUE *p, *pend, *final_list; RVALUE *p, *pend, *final_list;
int freed = 0; int freed = 0;
int i, used = heaps_used; int i, j;
if (ruby_in_compile && ruby_parser_stack_on_heap()) { if (ruby_in_compile && ruby_parser_stack_on_heap()) {
/* should not reclaim nodes during compilation /* should not reclaim nodes during compilation
if yacc's semantic stack is not allocated on machine stack */ if yacc's semantic stack is not allocated on machine stack */
for (i = 0; i < used; i++) { for (i = 0; i < heaps_used; i++) {
p = heaps[i]; pend = p + heaps_limits[i]; p = heaps[i]; pend = p + heaps_limits[i];
while (p < pend) { while (p < pend) {
if (!(p->as.basic.flags&FL_MARK) && BUILTIN_TYPE(p) == T_NODE) if (!(p->as.basic.flags&FL_MARK) && BUILTIN_TYPE(p) == T_NODE)
@ -869,8 +869,10 @@ gc_sweep()
freelist = 0; freelist = 0;
final_list = deferred_final_list; final_list = deferred_final_list;
deferred_final_list = 0; deferred_final_list = 0;
for (i = 0; i < used; i++) { for (i = 0; i < heaps_used; i++) {
int n = 0; int n = 0;
RVALUE *free = freelist;
RVALUE *final = final_list;
p = heaps[i]; pend = p + heaps_limits[i]; p = heaps[i]; pend = p + heaps_limits[i];
while (p < pend) { while (p < pend) {
@ -899,8 +901,19 @@ gc_sweep()
} }
p++; p++;
} }
if (n == heaps_limits[i] && freed + n > FREE_MIN) {
RVALUE *pp;
heaps_limits[i] = 0;
for (pp = final_list; pp != final; pp = pp->as.free.next) {
p->as.free.flags |= FL_SINGLETON; /* freeing page mark */
}
freelist = free; /* cancel this page from freelist */
}
else {
freed += n; freed += n;
} }
}
if (freed < FREE_MIN) { if (freed < FREE_MIN) {
add_heap(); add_heap();
} }
@ -918,11 +931,25 @@ gc_sweep()
for (p = final_list; p; p = tmp) { for (p = final_list; p; p = tmp) {
tmp = p->as.free.next; tmp = p->as.free.next;
run_final((VALUE)p); run_final((VALUE)p);
if (!FL_TEST(p, FL_SINGLETON)) { /* not freeing page */
p->as.free.flags = 0; p->as.free.flags = 0;
p->as.free.next = freelist; p->as.free.next = freelist;
freelist = p; freelist = p;
} }
} }
}
for (i = j = 0; j < heaps_used; i++) {
if (heaps_limits[i] == 0) {
free(heaps[i]);
heaps_used--;
}
else {
if (i != j) {
heaps[j] = heaps[i];
}
j++;
}
}
} }
void void

View file

@ -83,6 +83,14 @@ rb_class_real(cl)
return cl; return cl;
} }
VALUE
rb_obj_type(obj)
VALUE obj;
{
rb_warn("`type' is deprecated; use `class'");
return rb_class_real(CLASS_OF(obj));
}
VALUE VALUE
rb_obj_class(obj) rb_obj_class(obj)
VALUE obj; VALUE obj;
@ -1292,7 +1300,7 @@ Init_Object()
rb_define_method(rb_mKernel, "hash", rb_obj_id, 0); rb_define_method(rb_mKernel, "hash", rb_obj_id, 0);
rb_define_method(rb_mKernel, "id", rb_obj_id, 0); rb_define_method(rb_mKernel, "id", rb_obj_id, 0);
rb_define_method(rb_mKernel, "__id__", rb_obj_id, 0); rb_define_method(rb_mKernel, "__id__", rb_obj_id, 0);
rb_define_method(rb_mKernel, "type", rb_obj_class, 0); rb_define_method(rb_mKernel, "type", rb_obj_type, 0);
rb_define_method(rb_mKernel, "class", rb_obj_class, 0); rb_define_method(rb_mKernel, "class", rb_obj_class, 0);
rb_define_method(rb_mKernel, "clone", rb_obj_clone, 0); rb_define_method(rb_mKernel, "clone", rb_obj_clone, 0);