summaryrefslogtreecommitdiff
path: root/class.c
diff options
context:
space:
mode:
authorYukihiro Matsumoto <matz@ruby-lang.org>1995-02-21 18:56:56 +0900
committerTakashi Kokubun <takashikkbn@gmail.com>2019-08-17 22:09:31 +0900
commit2f106ab85c4f4e171374aee261f5a12bdd923c41 (patch)
tree6810f0a05ad8df30a269eb522eea5f77186b90c6 /class.c
parentc080fb6d10bbcb697b6ba16e640de8db3f1973d0 (diff)
version 0.67v0_67
https://cache.ruby-lang.org/pub/ruby/1.0/ruby-0.66-0.67.diff.gz Tue Feb 21 18:56:56 1995 Yukihiro Matsumoto (matz@ix-02) * io.c(STDIN, STDOUT, STDERR): 定数として定義.今までの$stdinなど は将来なくなるかも知れない. * io.c(select): bug fix. * version 0.67 Mon Feb 20 16:10:14 1995 Yukihiro Matsumoto (matz@ix-02) * parse.y(yylex): 定数を`%識別子'から,第1文字が大文字の識別子に変 更.それにともないクラスは定数となった. * eval.c: クラス定義内のselfがクラス定義外部のthe_classだった. * variable.c(rb_name_class): クラス名をインスタンス変数に格納する. Thu Feb 16 15:36:17 1995 Yukihiro Matsumoto (matz@ix-02) * parse.y: BLOCKをbraceで表現する文法に変更したものを作ってみる. MLに提示してみるが反応がない. * object.c(do,forever): なくした. Wed Feb 15 13:20:49 1995 Yukihiro Matsumoto (matz@ix-02) * re.c(new): 第2引数が与えられて,かつnilでないときだけ設定するよ うに(以前はnilの時にも設定を行なっていた). * parse.y(parse_regexp): 正規表現リテラルで大文字小文字を無視する かどうか指定できるように. Tue Feb 14 00:55:33 1995 Yukihiro Matsumoto (matz@dyna) * parse.y: (compexpr) -> (expr). Fri Feb 10 16:30:00 1995 Yukihiro Matsumoto (matz@ix-02) * ruby.c(load_file): scriptを読み込む時だけ"#!"の解析を行うように. * ruby.c(readin): ファイル読み込み時に先頭に"#!"があり,rubyに引数 が与えられていれば,その引数も有効になる. * parse.y(yylex): コメント行の終りが`\'であった時,次の行に継続し ているとみなすようにした.
Diffstat (limited to 'class.c')
-rw-r--r--class.c55
1 files changed, 49 insertions, 6 deletions
diff --git a/class.c b/class.c
index 6c790b79ee..2d051832c8 100644
--- a/class.c
+++ b/class.c
@@ -16,6 +16,7 @@
#include "st.h"
struct st_table *new_idhash();
+extern st_table *rb_class_tbl;
extern VALUE C_Class;
extern VALUE C_Module;
@@ -81,7 +82,6 @@ rb_define_class_id(id, super)
struct RClass *cls = (struct RClass*)class_new(super);
rb_name_class(cls, id);
-
/* make metaclass */
RBASIC(cls)->class = single_class_new(super?super->class:C_Class);
@@ -93,7 +93,29 @@ rb_define_class(name, super)
char *name;
VALUE super;
{
- return rb_define_class_id(rb_intern(name), super);
+ VALUE class;
+ ID id;
+
+ id = rb_intern(name);
+ class = rb_define_class_id(id, super);
+ st_add_direct(rb_class_tbl, id, class);
+
+ return class;
+}
+
+rb_define_class_under(under, name, super)
+ VALUE under;
+ char *name;
+ VALUE super;
+{
+ VALUE class;
+ ID id;
+
+ id = rb_intern(name);
+ class = rb_define_class_id(id, super);
+ rb_const_set(under, id, class);
+
+ return class;
}
VALUE
@@ -112,9 +134,11 @@ VALUE
rb_define_module_id(id)
ID id;
{
+ extern st_table *rb_class_tbl;
struct RClass *mdl = (struct RClass*)module_new();
rb_name_class(mdl, id);
+
return (VALUE)mdl;
}
@@ -122,7 +146,28 @@ VALUE
rb_define_module(name)
char *name;
{
- return rb_define_module_id(rb_intern(name));
+ VALUE module;
+ ID id;
+
+ id = rb_intern(name);
+ module = rb_define_module_id(id);
+ st_add_direct(rb_class_tbl, id, module);
+
+ return module;
+}
+
+rb_define_module_under(under, name)
+ VALUE under;
+ char *name;
+{
+ VALUE module;
+ ID id;
+
+ id = rb_intern(name);
+ module = rb_define_module_id(id);
+ rb_const_set(under, id, module);
+
+ return module;
}
static struct RClass *
@@ -189,9 +234,7 @@ rb_add_method(class, mid, node, noex)
if (class == Qnil) class = (struct RClass*)C_Object;
if (st_lookup(class->m_tbl, mid, &body)) {
- if (verbose) {
- Warning("redefine %s", rb_id2name(mid));
- }
+ Warning("redefine %s", rb_id2name(mid));
rb_clear_cache(body);
}
body = NEW_METHOD(node, noex);