summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog2
-rw-r--r--eval.c22
-rw-r--r--ext/Setup1
-rw-r--r--ext/gtk/gtk.c22
-rw-r--r--ext/gtk/test5.rb7
-rw-r--r--ext/gtk/testd.rb96
-rw-r--r--lib/final.rb41
-rw-r--r--lib/finalize.rb121
-rw-r--r--lib/ftplib.rb6
-rw-r--r--lib/sync.rb8
-rw-r--r--lib/tempfile.rb14
-rw-r--r--ruby.h1
-rw-r--r--sample/ruby-mode.el2
-rw-r--r--variable.c133
14 files changed, 316 insertions, 160 deletions
diff --git a/ChangeLog b/ChangeLog
index c02d7e1534..029e20077c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,5 @@
Fri Jan 16 00:43:43 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
- * variable.c (rb_ivar_get): Files can have instance variables now.
-
* ruby.h (CLONESETUP): copies its singleton classes too.
* class.c (singleton_class_attached): saves binded object in the
diff --git a/eval.c b/eval.c
index c84031eac6..e4b5feb7f2 100644
--- a/eval.c
+++ b/eval.c
@@ -43,6 +43,7 @@ static VALUE f_binding _((VALUE));
static void f_END _((void));
#define SCOPE_PRIVATE FL_USER4
+#define SCOPE_MODFUNC FL_USER5
#define CACHE_SIZE 0x200
#define CACHE_MASK 0x1ff
@@ -717,6 +718,7 @@ ruby_init()
top_scope = the_scope;
/* default visibility is private at toplevel */
FL_SET(top_scope, SCOPE_PRIVATE);
+ FL_UNSET(top_scope, SCOPE_MODFUNC);
PUSH_TAG(PROT_NONE)
if ((state = EXEC_TAG()) == 0) {
@@ -2119,6 +2121,15 @@ rb_eval(self, node)
noex = NOEX_PUBLIC;
}
rb_add_method(the_class, node->nd_mid, node->nd_defn, noex);
+ if (FL_TEST(the_scope,SCOPE_MODFUNC)) {
+ rb_add_method(rb_singleton_class(the_class),
+ node->nd_mid, node->nd_defn, NOEX_PUBLIC);
+ }
+
+ if (FL_TEST(the_scope, SCOPE_MODFUNC)) {
+ rb_funcall(the_class, rb_intern("singleton_method_added"),
+ 1, INT2FIX(node->nd_mid));
+ }
if (FL_TEST(the_class, FL_SINGLETON)) {
VALUE recv = rb_iv_get(the_class, "__attached__");
rb_funcall(recv, rb_intern("singleton_method_added"),
@@ -3746,6 +3757,7 @@ f_load(obj, fname)
}
/* default visibility is private at loading toplevel */
FL_SET(the_scope, SCOPE_PRIVATE);
+ FL_UNSET(top_scope, SCOPE_MODFUNC);
state = EXEC_TAG();
last_func = the_frame->last_func;
@@ -3938,6 +3950,7 @@ mod_public(argc, argv, module)
{
if (argc == 0) {
FL_UNSET(the_scope, SCOPE_PRIVATE);
+ FL_UNSET(top_scope, SCOPE_MODFUNC);
}
else {
set_method_visibility(module, argc, argv, NOEX_PUBLIC);
@@ -3953,6 +3966,7 @@ mod_private(argc, argv, module)
{
if (argc == 0) {
FL_SET(the_scope, SCOPE_PRIVATE);
+ FL_UNSET(top_scope, SCOPE_MODFUNC);
}
else {
set_method_visibility(module, argc, argv, NOEX_PRIVATE);
@@ -4006,7 +4020,12 @@ mod_modfunc(argc, argv, module)
ID id;
NODE *body;
- rb_clear_cache();
+ if (argc == 0) {
+ FL_SET(the_scope, SCOPE_PRIVATE);
+ FL_SET(the_scope, SCOPE_MODFUNC);
+ return module;
+ }
+
set_method_visibility(module, argc, argv, NOEX_PRIVATE);
for (i=0; i<argc; i++) {
id = rb_to_id(argv[i]);
@@ -4015,6 +4034,7 @@ mod_modfunc(argc, argv, module)
NameError("undefined method `%s' for module `%s'",
rb_id2name(id), rb_class2name(module));
}
+ rb_clear_cache_by_id(id);
rb_add_method(rb_singleton_class(module), id, body->nd_body, NOEX_PUBLIC);
}
return module;
diff --git a/ext/Setup b/ext/Setup
index c92ac53e00..867d88cfda 100644
--- a/ext/Setup
+++ b/ext/Setup
@@ -10,3 +10,4 @@
#socket
#tkutil
#tcltklib
+gtk
diff --git a/ext/gtk/gtk.c b/ext/gtk/gtk.c
index 9114312195..ec4105acbb 100644
--- a/ext/gtk/gtk.c
+++ b/ext/gtk/gtk.c
@@ -196,19 +196,20 @@ static void
gobj_free(obj)
GtkObject *obj;
{
- VALUE self = get_value_from_gobject(obj);
-
- if (GTK_OBJECT_NEED_DESTROY(obj)) {
- gtk_object_destroy(obj);
- }
- rb_ivar_set(self, id_relatives, Qnil);
+ /* just a type mark */
}
static void
-delete_gobject(obj)
- GtkObject *obj;
+delete_gobject(gtkobj, obj)
+ GtkObject *gtkobj;
+ VALUE obj;
{
- ary_delete(gtk_object_list, get_value_from_gobject(obj));
+ struct RData *data;
+
+ data = RDATA(rb_ivar_get(obj, id_gtkdata));
+ data->dfree = 0;
+ data->data = 0;
+ ary_delete(gtk_object_list, obj);
}
static VALUE
@@ -223,7 +224,8 @@ make_gobject(klass, gtkobj)
gtk_object_set_user_data(gtkobj, (gpointer)obj);
rb_ivar_set(obj, id_gtkdata, data);
- gtk_signal_connect(gtkobj, "destroy", (GtkSignalFunc)delete_gobject, 0);
+ gtk_signal_connect(gtkobj, "destroy",
+ (GtkSignalFunc)delete_gobject, (gpointer)obj);
ary_push(gtk_object_list, obj);
return obj;
}
diff --git a/ext/gtk/test5.rb b/ext/gtk/test5.rb
index 714232079b..f1d5d734cf 100644
--- a/ext/gtk/test5.rb
+++ b/ext/gtk/test5.rb
@@ -21,10 +21,11 @@ button = []
end
0.upto(8) do |i|
button[i].signal_connect("clicked") do |w|
- if button[i+1].visible?
- button[i+1].hide
+ j = (i+1)%9
+ if button[j].visible?
+ button[j].hide
else
- button[i+1].show
+ button[j].show
end
end
button[i].show
diff --git a/ext/gtk/testd.rb b/ext/gtk/testd.rb
new file mode 100644
index 0000000000..52ce5db7e0
--- /dev/null
+++ b/ext/gtk/testd.rb
@@ -0,0 +1,96 @@
+require 'gtk'
+
+def create_menu(depth)
+ return nil if depth < 1
+
+ menu = Gtk::Menu::new()
+ group = nil
+ submenu = nil
+
+ for i in 0..4
+ buf = sprintf("item %2d - %d", depth, i+1)
+# menuitem = Gtk::MenuItem::new(buf)
+ menuitem = Gtk::RadioMenuItem.new(group, buf)
+ group = menuitem.group
+ if depth % 2
+ menuitem.set_show_toggle TRUE
+ end
+ menu.append menuitem
+ menuitem.show
+ if depth > 0
+ unless submenu
+ submenu = create_menu(depth - 1)
+ end
+ menuitem.set_submenu submenu
+ end
+ end
+ return menu
+end
+
+window = Gtk::Window::new(Gtk::WINDOW_TOPLEVEL)
+window.signal_connect("destroy") do
+ exit
+end
+window.signal_connect("delete_event") do
+ exit
+end
+window.set_title("menus")
+window.border_width(0)
+
+box1 = Gtk::VBox::new(FALSE, 0)
+window.add box1
+box1.show
+
+menubar = Gtk::MenuBar::new()
+box1.pack_start menubar, FALSE, TRUE, 0
+menubar.show
+
+menu = create_menu(2)
+menuitem = Gtk::MenuItem::new("test\nline2")
+menuitem.set_submenu menu
+menubar.append menuitem
+menuitem.show
+
+menuitem = Gtk::MenuItem::new("foo")
+menuitem.set_submenu menu
+menubar.append menuitem
+menuitem.show
+
+menuitem = Gtk::MenuItem::new("bar")
+menuitem.set_submenu menu
+menubar.append menuitem
+menuitem.show
+
+box2 = Gtk::VBox::new(FALSE, 10)
+box2.border_width 10
+box1.pack_start box2, TRUE, TRUE, 0
+box2.show
+
+optionmenu = Gtk::OptionMenu::new()
+optionmenu.set_menu create_menu(1)
+optionmenu.set_history 4
+box2.pack_start optionmenu, TRUE, TRUE, 0
+optionmenu.show
+
+separator = Gtk::HSeparator::new()
+box1.pack_start(separator, FALSE, TRUE, 0)
+separator.show
+
+box2 = Gtk::HBox::new(FALSE, 10)
+box2.border_width(10)
+box1.pack_start(box2, FALSE, TRUE, 0)
+box2.show
+
+button = Gtk::Button::new("close")
+button.signal_connect("clicked") do
+ window.destroy
+ exit
+end
+box2.pack_start(button, TRUE, TRUE, 0)
+button.set_flags(Gtk::CAN_DEFAULT);
+button.grab_default
+button.show
+
+window.show
+
+Gtk::main()
diff --git a/lib/final.rb b/lib/final.rb
new file mode 100644
index 0000000000..566d1aae42
--- /dev/null
+++ b/lib/final.rb
@@ -0,0 +1,41 @@
+#
+# $Id$
+# Copyright (C) 1998 Yukihiro Matsumoto. All rights reserved.
+
+# The ObjectSpace extention:
+#
+# ObjectSpace.define_finalizer(obj, proc=lambda())
+#
+# Defines the finalizer for the specified object.
+#
+# ObjectSpace.undefine_finalizer(obj)
+#
+# Removes the finalizers for the object. If multiple finalizers are
+# defined for the object, all finalizers will be removed.
+#
+
+module ObjectSpace
+ Finalizer = {}
+ def define_finalizer(obj, proc=lambda())
+ ObjectSpace.call_finalizer(obj)
+ if assoc = Finalizer[obj.id]
+ assoc.push(proc)
+ else
+ Finalizer[obj.id] = [proc]
+ end
+ end
+ def undefine_finalizer(obj)
+ Finalizer.delete(obj.id)
+ end
+ module_function :define_finalizer, :remove_finalizer
+
+ Generic_Finalizer = proc {|id|
+ if Finalizer.key? id
+ for proc in Finalizer[id]
+ proc.call(id)
+ end
+ Finalizer.delete(id)
+ end
+ }
+ add_finalizer Generic_Finalizer
+end
diff --git a/lib/finalize.rb b/lib/finalize.rb
index d91bb0d333..fcdb1dc448 100644
--- a/lib/finalize.rb
+++ b/lib/finalize.rb
@@ -1,8 +1,8 @@
#
# finalizer.rb -
# $Release Version: 0.2$
-# $Revision: 1.1.1.2 $
-# $Date: 1998/01/16 04:14:51 $
+# $Revision: 1.1.1.2.2.1 $
+# $Date: 1998/01/16 12:36:04 $
# by Keiju ISHITSUKA
#
# --
@@ -13,10 +13,10 @@
# add_dependency(obj, dependant, method = :finalize, *opt)
# 依存関係 R_method(obj, dependant) の追加
#
-# delete(obj_or_id, dependant, method = :finalize)
-# delete_dependency(obj_or_id, dependant, method = :finalize)
+# delete(obj, dependant, method = :finalize)
+# delete_dependency(obj, dependant, method = :finalize)
# 依存関係 R_method(obj, dependant) の削除
-# delete_all_dependency(obj_or_id, dependant)
+# delete_all_dependency(obj, dependant)
# 依存関係 R_*(obj, dependant) の削除
# delete_by_dependant(dependant, method = :finalize)
# 依存関係 R_method(*, dependant) の削除
@@ -25,11 +25,11 @@
# delete_all
# 全ての依存関係の削除.
#
-# finalize(obj_or_id, dependant, method = :finalize)
-# finalize_dependency(obj_or_id, dependant, method = :finalize)
+# finalize(obj, dependant, method = :finalize)
+# finalize_dependency(obj, dependant, method = :finalize)
# 依存関連 R_method(obj, dependtant) で結ばれるdependantを
# finalizeする.
-# finalize_all_dependency(obj_or_id, dependant)
+# finalize_all_dependency(obj, dependant)
# 依存関連 R_*(obj, dependtant) で結ばれるdependantをfinalizeする.
# finalize_by_dependant(dependant, method = :finalize)
# 依存関連 R_method(*, dependtant) で結ばれるdependantをfinalizeする.
@@ -44,50 +44,46 @@
#
module Finalizer
- RCS_ID='-$Header: /home/cvsroot/ruby/lib/finalize.rb,v 1.1.1.2 1998/01/16 04:14:51 matz Exp $-'
-
- # @dependency: {id => [[dependant, method, *opt], ...], ...}
+ RCS_ID='-$Header: /home/cvsroot/ruby/lib/finalize.rb,v 1.1.1.2.2.1 1998/01/16 12:36:04 matz Exp $-'
+
+ # Dependency: {id => [[dependant, method, opt], ...], ...}
+ Dependency = {}
# 依存関係 R_method(obj, dependant) の追加
def add_dependency(obj, dependant, method = :finalize, *opt)
ObjectSpace.call_finalizer(obj)
- method = method.intern unless method.kind_of?(Integer)
- assoc = [dependant, method].concat(opt)
- if dep = @dependency[obj.id]
+ assoc = [dependant, method, opt]
+ if dep = Dependency[obj.id]
dep.push assoc
else
- @dependency[obj.id] = [assoc]
+ Dependency[obj.id] = [assoc]
end
end
alias add add_dependency
# 依存関係 R_method(obj, dependant) の削除
- def delete_dependency(id, dependant, method = :finalize)
- id = id.id unless id.kind_of?(Integer)
- method = method.intern unless method.kind_of?(Integer)
- for assoc in @dependency[id]
- assoc.delete_if do
- |d, m, *o|
+ def delete_dependency(obj, dependant, method = :finalize)
+ id = obj.id
+ for assoc in Dependency[id]
+ assoc.delete_if do |d,m,*o|
d == dependant && m == method
end
- @dependency.delete(id) if assoc.empty?
+ Dependency.delete(id) if assoc.empty?
end
end
alias delete delete_dependency
# 依存関係 R_*(obj, dependant) の削除
- def delete_all_dependency(id, dependant)
- id = id.id unless id.kind_of?(Integer)
- method = method.intern unless method.kind_of?(Integer)
- for assoc in @dependency[id]
- assoc.delete_if do
- |d, m, *o|
+ def delete_all_dependency(obj, dependant)
+ id = obj.id
+ for assoc in Dependency[id]
+ assoc.delete_if do |d,m,*o|
d == dependant
end
- @dependency.delete(id) if assoc.empty?
+ Dependency.delete(id) if assoc.empty?
end
end
-
+
# 依存関係 R_method(*, dependant) の削除
def delete_by_dependant(dependant, method = :finalize)
method = method.intern unless method.kind_of?(Integer)
@@ -95,61 +91,63 @@ module Finalizer
delete(id, dependant, method)
end
end
-
+
# 依存関係 R_*(*, dependant) の削除
def delete_all_by_dependant(dependant)
- for id in @dependency.keys
+ for id in Dependency.keys
delete_all_dependency(id, dependant)
end
end
-
- # 依存関連 R_method(obj, dependtant) で結ばれるdependantをfinalizeす
+
+ # 依存関連 R_method(id, dependtant) で結ばれるdependantをfinalizeす
# る.
def finalize_dependency(id, dependant, method = :finalize)
- id = id.id unless id.kind_of?(Integer)
- method = method.intern unless method.kind_of?(Integer)
- for assocs in @dependency[id]
- assocs.delete_if do
- |d, m, *o|
- d.send(m, *o) if ret = d == dependant && m == method
- ret
+ for assocs in Dependency[id]
+ assocs.delete_if do |d, m, *o|
+ if d == dependant && m == method
+ d.send(m, *o)
+ true
+ else
+ false
+ end
end
- @dependency.delete(id) if assoc.empty?
+ Dependency.delete(id) if assoc.empty?
end
end
alias finalize finalize_dependency
- # 依存関連 R_*(obj, dependtant) で結ばれるdependantをfinalizeする.
+ # 依存関連 R_*(id, dependtant) で結ばれるdependantをfinalizeする.
def finalize_all_dependency(id, dependant)
- id = id.id unless id.kind_of?(Integer)
- method = method.intern unless method.kind_of?(Integer)
- for assoc in @dependency[id]
- assoc.delete_if do
- |d, m, *o|
- d.send(m, *o) if ret = d == dependant
+ for assoc in Dependency[id]
+ assoc.delete_if do |d, m, *o|
+ if d == dependant
+ d.send(m, *o)
+ true
+ else
+ false
+ end
end
- @dependency.delete(id) if assoc.empty?
+ Dependency.delete(id) if assoc.empty?
end
end
# 依存関連 R_method(*, dependtant) で結ばれるdependantをfinalizeする.
def finalize_by_dependant(dependant, method = :finalize)
- method = method.intern unless method.kind_of?(Integer)
- for id in @dependency.keys
+ for id in Dependency.keys
finalize(id, dependant, method)
end
end
# 依存関連 R_*(*, dependtant) で結ばれるdependantをfinalizeする.
def fainalize_all_by_dependant(dependant)
- for id in @dependency.keys
+ for id in Dependency.keys
finalize_all_dependency(id, dependant)
end
end
# Finalizerに登録されている全てのdependantをfinalizeする
def finalize_all
- for id, assocs in @dependency
+ for id, assocs in Dependency
for dependant, method, *opt in assocs
dependant.send(method, id, *opt)
end
@@ -159,26 +157,24 @@ module Finalizer
# finalize_* を安全に呼び出すためのイテレータ
def safe
- old_status = Thread.critical
- Thread.critical = TRUE
- ObjectSpace.remove_finalizer(@proc)
+ old_status, Thread.critical = Thread.critical, true
+ ObjectSpace.remove_finalizer(Proc)
yield
- ObjectSpace.add_finalizer(@proc)
+ ObjectSpace.add_finalizer(Proc)
Thread.critical = old_status
end
# ObjectSpace#add_finalizerへの登録関数
def final_of(id)
- if assocs = @dependency.delete(id)
+ if assocs = Dependency.delete(id)
for dependant, method, *opt in assocs
dependant.send(method, id, *opt)
end
end
end
- @dependency = Hash.new
- @proc = proc{|id| final_of(id)}
- ObjectSpace.add_finalizer(@proc)
+ Proc = proc{|id| final_of(id)}
+ ObjectSpace.add_finalizer(Proc)
module_function :add
module_function :add_dependency
@@ -202,4 +198,3 @@ module Finalizer
private_class_method :final_of
end
-
diff --git a/lib/ftplib.rb b/lib/ftplib.rb
index a03760daf8..5f949f7099 100644
--- a/lib/ftplib.rb
+++ b/lib/ftplib.rb
@@ -1,7 +1,7 @@
### ftplib.rb -*- Mode: ruby; tab-width: 8; -*-
-## $Revision: 1.1.1.1 $
-## $Date: 1998/01/16 04:05:49 $
+## $Revision: 1.1.1.1.4.1 $
+## $Date: 1998/01/16 12:36:05 $
## by maeda shugo <shugo@po.aianet.ne.jp>
### Code:
@@ -17,7 +17,7 @@ class FTPProtoError < FTPError; end
class FTP
- RCS_ID = '$Id: ftplib.rb,v 1.1.1.1 1998/01/16 04:05:49 matz Exp $'
+ RCS_ID = '$Id: ftplib.rb,v 1.1.1.1.4.1 1998/01/16 12:36:05 matz Exp $ '
FTP_PORT = 21
CRLF = "\r\n"
diff --git a/lib/sync.rb b/lib/sync.rb
index b5a3fc32b3..a804ade133 100644
--- a/lib/sync.rb
+++ b/lib/sync.rb
@@ -43,7 +43,7 @@ unless defined? Thread
fail "Thread not available for this ruby interpreter"
end
-require "finalize"
+require "final"
module Sync_m
RCS_ID='-$Header$-'
@@ -321,7 +321,11 @@ module Sync_m
def For_primitive_object.extend_object(obj)
super
obj.sync_extended
- Finalizer.add(obj, For_primitive_object, :sync_finalize)
+ # Changed to use `final.rb'.
+ # Finalizer.add(obj, For_primitive_object, :sync_finalize)
+ ObjectSpace.define_finalizer(obj) do |id|
+ For_primitive_object.sync_finalize(id)
+ end
end
def initialize
diff --git a/lib/tempfile.rb b/lib/tempfile.rb
index a6ffaa55fe..93869aebbc 100644
--- a/lib/tempfile.rb
+++ b/lib/tempfile.rb
@@ -6,11 +6,11 @@
# The class for temporary files.
# o creates a temporary file, which name is "basename.pid.n" with mode "w+".
# o Tempfile objects can be used like IO object.
-# o created temporary files are removed if it is closed or garbage collected,
-# or script termination.
+# o created temporary files are removed on closing or script termination.
# o file mode of the temporary files are 0600.
require 'delegate'
+require 'final'
class Tempfile < SimpleDelegater
Max_try = 10
@@ -45,8 +45,7 @@ class Tempfile < SimpleDelegater
File.unlink(@tmpdir + '/' + @tmpname + '.lock')
end
}
- ObjectSpace.call_finalizer(self)
- ObjectSpace.add_finalizer(@clean_files)
+ ObjectSpace.define_finalizer(self, @clean_files)
@tmpfile = open(@tmpname, 'w+')
super(@tmpfile)
@@ -57,8 +56,13 @@ class Tempfile < SimpleDelegater
end
end
+ def Tempfile.open(*args)
+ Tempfile.new(*args)
+ end
+
def close
- super
+ @tmpfile.close
@clean_files.call
+ ObjectSpace.undefine_finalizer(self)
end
end
diff --git a/ruby.h b/ruby.h
index 16153e09ca..0c1d01c702 100644
--- a/ruby.h
+++ b/ruby.h
@@ -227,7 +227,6 @@ struct RHash {
struct RFile {
struct RBasic basic;
- struct st_table *iv_tbl;
struct OpenFile *fptr;
};
diff --git a/sample/ruby-mode.el b/sample/ruby-mode.el
index 0f56477ea0..fb96b548f2 100644
--- a/sample/ruby-mode.el
+++ b/sample/ruby-mode.el
@@ -633,7 +633,7 @@ An end of a defun is found by moving forward from the beginning of one."
2 font-lock-type-face)
;; functions
'("^\\s *def[ \t]+.*$"
- 0 font-lock-function-name-face))
+ 0 font-lock-function-name-face t))
"*Additional expressions to highlight in ruby mode.")
(if (and (>= (string-to-int emacs-version) 20)
(not (featurep 'xemacs)))
diff --git a/variable.c b/variable.c
index afc4ea96b6..7511264330 100644
--- a/variable.c
+++ b/variable.c
@@ -97,14 +97,14 @@ fc_i(key, value, res)
}
static VALUE
-find_class_path(cls)
- VALUE cls;
+find_class_path(klass)
+ VALUE klass;
{
struct fc_result arg;
arg.name = 0;
arg.path = 0;
- arg.klass = cls;
+ arg.klass = klass;
arg.track = cObject;
arg.prev = 0;
if (RCLASS(cObject)->iv_tbl) {
@@ -114,30 +114,30 @@ find_class_path(cls)
st_foreach(class_tbl, fc_i, &arg);
}
if (arg.name) {
- rb_iv_set(cls, "__classpath__", arg.path);
+ rb_iv_set(klass, "__classpath__", arg.path);
return arg.path;
}
return Qnil;
}
static VALUE
-classname(cls)
- VALUE cls;
+classname(klass)
+ VALUE klass;
{
VALUE path;
- while (TYPE(cls) == T_ICLASS || FL_TEST(cls, FL_SINGLETON)) {
- cls = (VALUE)RCLASS(cls)->super;
+ while (TYPE(klass) == T_ICLASS || FL_TEST(klass, FL_SINGLETON)) {
+ klass = (VALUE)RCLASS(klass)->super;
}
- path = rb_iv_get(cls, "__classpath__");
+ path = rb_iv_get(klass, "__classpath__");
if (NIL_P(path)) {
- path = rb_iv_get(cls, "__classid__");
+ path = rb_iv_get(klass, "__classid__");
if (!NIL_P(path)) {
path = str_new2(rb_id2name(FIX2INT(path)));
}
}
if (NIL_P(path)) {
- path = find_class_path(cls);
+ path = find_class_path(klass);
if (NIL_P(path)) {
return 0;
}
@@ -158,25 +158,25 @@ mod_name(mod)
}
VALUE
-rb_class_path(cls)
- VALUE cls;
+rb_class_path(klass)
+ VALUE klass;
{
- VALUE path = classname(cls);
+ VALUE path = classname(klass);
if (path) return path;
else {
char buf[256];
char *s = "Class";
- if (TYPE(cls) == T_MODULE) s = "Module";
- sprintf(buf, "#<%s 0x%x>", s, cls);
+ if (TYPE(klass) == T_MODULE) s = "Module";
+ sprintf(buf, "#<%s 0x%x>", s, klass);
return str_new2(buf);
}
}
void
-rb_set_class_path(cls, under, name)
- VALUE cls, under;
+rb_set_class_path(klass, under, name)
+ VALUE klass, under;
char *name;
{
VALUE str;
@@ -189,7 +189,7 @@ rb_set_class_path(cls, under, name)
str_cat(str, "::", 2);
str_cat(str, name, strlen(name));
}
- rb_iv_set(cls, "__classpath__", str);
+ rb_iv_set(klass, "__classpath__", str);
}
VALUE
@@ -203,17 +203,17 @@ rb_path2class(path)
}
void
-rb_name_class(cls, id)
- VALUE cls;
+rb_name_class(klass, id)
+ VALUE klass;
ID id;
{
extern VALUE cString;
if (cString) {
- rb_iv_set(cls, "__classpath__", str_new2(rb_id2name(id)));
+ rb_iv_set(klass, "__classpath__", str_new2(rb_id2name(id)));
}
else {
- rb_iv_set(cls, "__classid__", INT2FIX(id));
+ rb_iv_set(klass, "__classid__", INT2FIX(id));
}
}
@@ -235,17 +235,17 @@ rb_autoload_id(id, filename)
}
void
-rb_autoload(cls, filename)
- char *cls, *filename;
+rb_autoload(klass, filename)
+ char *klass, *filename;
{
- rb_autoload_id(rb_intern(cls), filename);
+ rb_autoload_id(rb_intern(klass), filename);
}
VALUE
-f_autoload(obj, cls, file)
- VALUE obj, cls, file;
+f_autoload(obj, klass, file)
+ VALUE obj, klass, file;
{
- ID id = rb_to_id(cls);
+ ID id = rb_to_id(klass);
Check_Type(file, T_STRING);
rb_autoload_id(id, RSTRING(file)->ptr);
@@ -253,10 +253,10 @@ f_autoload(obj, cls, file)
}
char *
-rb_class2name(cls)
- VALUE cls;
+rb_class2name(klass)
+ VALUE klass;
{
- return RSTRING(rb_class_path(cls))->ptr;
+ return RSTRING(rb_class_path(klass))->ptr;
}
struct trace_var {
@@ -702,7 +702,6 @@ rb_ivar_get(obj, id)
case T_OBJECT:
case T_CLASS:
case T_MODULE:
- case T_FILE:
if (ROBJECT(obj)->iv_tbl && st_lookup(ROBJECT(obj)->iv_tbl, id, &val))
return val;
return Qnil;
@@ -729,7 +728,6 @@ rb_ivar_set(obj, id, val)
case T_OBJECT:
case T_CLASS:
case T_MODULE:
- case T_FILE:
if (!ROBJECT(obj)->iv_tbl) ROBJECT(obj)->iv_tbl = new_idhash();
st_insert(ROBJECT(obj)->iv_tbl, id, val);
break;
@@ -752,7 +750,6 @@ rb_ivar_defined(obj, id)
case T_OBJECT:
case T_CLASS:
case T_MODULE:
- case T_FILE:
if (ROBJECT(obj)->iv_tbl && st_lookup(ROBJECT(obj)->iv_tbl, id, 0))
return TRUE;
break;
@@ -782,7 +779,6 @@ obj_instance_variables(obj)
case T_OBJECT:
case T_CLASS:
case T_MODULE:
- case T_FILE:
if (ROBJECT(obj)->iv_tbl) {
st_foreach(ROBJECT(obj)->iv_tbl, ivar_i, hash);
}
@@ -808,7 +804,6 @@ obj_remove_instance_variable(obj, name)
case T_OBJECT:
case T_CLASS:
case T_MODULE:
- case T_FILE:
if (ROBJECT(obj)->iv_tbl) {
st_delete(ROBJECT(obj)->iv_tbl, &id, &val);
}
@@ -822,41 +817,41 @@ obj_remove_instance_variable(obj, name)
}
VALUE
-rb_const_get_at(cls, id)
- VALUE cls;
+rb_const_get_at(klass, id)
+ VALUE klass;
ID id;
{
VALUE value;
- if (RCLASS(cls)->iv_tbl && st_lookup(RCLASS(cls)->iv_tbl, id, &value)) {
+ if (RCLASS(klass)->iv_tbl && st_lookup(RCLASS(klass)->iv_tbl, id, &value)) {
return value;
}
- if (cls == cObject) {
- return rb_const_get(cls, id);
+ if (klass == cObject) {
+ return rb_const_get(klass, id);
}
NameError("Uninitialized constant %s::%s",
- RSTRING(rb_class_path(cls))->ptr,
+ RSTRING(rb_class_path(klass))->ptr,
rb_id2name(id));
/* not reached */
}
VALUE
-rb_const_get(cls, id)
- VALUE cls;
+rb_const_get(klass, id)
+ VALUE klass;
ID id;
{
VALUE value;
VALUE tmp;
- tmp = cls;
+ tmp = klass;
while (tmp) {
if (RCLASS(tmp)->iv_tbl && st_lookup(RCLASS(tmp)->iv_tbl,id,&value)) {
return value;
}
tmp = RCLASS(tmp)->super;
}
- if (BUILTIN_TYPE(cls) == T_MODULE) {
+ if (BUILTIN_TYPE(klass) == T_MODULE) {
return rb_const_get(cObject, id);
}
@@ -872,13 +867,13 @@ rb_const_get(cls, id)
module = str_new2(modname);
free(modname);
f_require(0, module);
- return rb_const_get(cls, id);
+ return rb_const_get(klass, id);
}
/* Uninitialized constant */
- if (cls && cls != cObject)
+ if (klass && klass != cObject)
NameError("Uninitialized constant %s::%s",
- RSTRING(rb_class_path(cls))->ptr,
+ RSTRING(rb_class_path(klass))->ptr,
rb_id2name(id));
else {
NameError("Uninitialized constant %s",rb_id2name(id));
@@ -952,15 +947,15 @@ mod_const_of(mod, ary)
}
int
-rb_const_defined_at(cls, id)
- VALUE cls;
+rb_const_defined_at(klass, id)
+ VALUE klass;
ID id;
{
- if (RCLASS(cls)->iv_tbl && st_lookup(RCLASS(cls)->iv_tbl, id, 0)) {
+ if (RCLASS(klass)->iv_tbl && st_lookup(RCLASS(klass)->iv_tbl, id, 0)) {
return TRUE;
}
- if (cls == cObject) {
- return rb_const_defined(cls, id);
+ if (klass == cObject) {
+ return rb_const_defined(klass, id);
}
return FALSE;
}
@@ -975,15 +970,15 @@ rb_autoload_defined(id)
}
int
-rb_const_defined(cls, id)
- VALUE cls;
+rb_const_defined(klass, id)
+ VALUE klass;
ID id;
{
- while (cls) {
- if (RCLASS(cls)->iv_tbl && st_lookup(RCLASS(cls)->iv_tbl, id, 0)) {
+ while (klass) {
+ if (RCLASS(klass)->iv_tbl && st_lookup(RCLASS(klass)->iv_tbl, id, 0)) {
return TRUE;
}
- cls = RCLASS(cls)->super;
+ klass = RCLASS(klass)->super;
}
if (st_lookup(class_tbl, id, 0))
return TRUE;
@@ -991,24 +986,24 @@ rb_const_defined(cls, id)
}
void
-rb_const_set(cls, id, val)
- VALUE cls;
+rb_const_set(klass, id, val)
+ VALUE klass;
ID id;
VALUE val;
{
- if (!RCLASS(cls)->iv_tbl) {
- RCLASS(cls)->iv_tbl = new_idhash();
+ if (!RCLASS(klass)->iv_tbl) {
+ RCLASS(klass)->iv_tbl = new_idhash();
}
- else if (st_lookup(RCLASS(cls)->iv_tbl, id, 0)) {
+ else if (st_lookup(RCLASS(klass)->iv_tbl, id, 0)) {
NameError("already initialized constant %s", rb_id2name(id));
}
- st_insert(RCLASS(cls)->iv_tbl, id, val);
+ st_insert(RCLASS(klass)->iv_tbl, id, val);
}
void
-rb_define_const(cls, name, val)
- VALUE cls;
+rb_define_const(klass, name, val)
+ VALUE klass;
char *name;
VALUE val;
{
@@ -1016,7 +1011,7 @@ rb_define_const(cls, name, val)
if (!rb_is_const_id(id)) {
NameError("wrong constant name %s", name);
}
- rb_const_set(cls, id, val);
+ rb_const_set(klass, id, val);
}
void