summaryrefslogtreecommitdiff
path: root/class.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-12-14 06:50:43 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-12-14 06:50:43 +0000
commit9d228b13deccfdf23f44e2c465f723a2a7b3bcbd (patch)
tree9a4d769804c389b6b03bbfdf65e8e0a03288c8e8 /class.c
parentc18d3740a925e8752c3b93acea6087fb0e03be53 (diff)
19991214
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@587 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'class.c')
-rw-r--r--class.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/class.c b/class.c
index 6ffd328..4698947 100644
--- a/class.c
+++ b/class.c
@@ -130,7 +130,7 @@ rb_define_class_under(outer, name, super)
id = rb_intern(name);
klass = rb_define_class_id(id, super);
- rb_shvar_set(outer, id, klass);
+ rb_const_set(outer, id, klass);
rb_set_class_path(klass, outer, name);
return klass;
@@ -186,7 +186,7 @@ rb_define_module_under(outer, name)
id = rb_intern(name);
module = rb_define_module_id(id);
- rb_shvar_set(outer, id, module);
+ rb_const_set(outer, id, module);
rb_set_class_path(module, outer, name);
return module;
@@ -368,7 +368,7 @@ method_list(mod, option, func)
VALUE klass;
VALUE *p, *q, *pend;
- if (!FL_TEST(mod, FL_TAINT) && rb_safe_level() >= 4)
+ if (!OBJ_TAINTED(mod) && rb_safe_level() >= 4)
rb_raise(rb_eSecurityError, "Insecure: can't get metainfo");
ary = rb_ary_new();
for (klass = mod; klass; klass = RCLASS(klass)->super) {
@@ -431,7 +431,7 @@ rb_obj_singleton_methods(obj)
VALUE klass;
VALUE *p, *q, *pend;
- if (rb_safe_level() >= 4 && !FL_TEST(obj, FL_TAINT))
+ if (rb_safe_level() >= 4 && !OBJ_TAINTED(obj))
rb_raise(rb_eSecurityError, "Insecure: can't get metainfo");
ary = rb_ary_new();
klass = CLASS_OF(obj);
@@ -510,15 +510,26 @@ VALUE
rb_singleton_class(obj)
VALUE obj;
{
+ VALUE klass;
if (rb_special_const_p(obj)) {
rb_raise(rb_eTypeError, "can't define singleton");
}
if (FL_TEST(RBASIC(obj)->klass, FL_SINGLETON)) {
- return RBASIC(obj)->klass;
+ klass = RBASIC(obj)->klass;
+ }
+ else {
+ klass = rb_singleton_class_new(RBASIC(obj)->klass);
+ RBASIC(obj)->klass = klass;
+ rb_singleton_class_attached(klass, obj);
+ }
+ if (OBJ_TAINTED(obj)) {
+ OBJ_TAINT(klass);
}
- RBASIC(obj)->klass = rb_singleton_class_new(RBASIC(obj)->klass);
- rb_singleton_class_attached(RBASIC(obj)->klass, obj);
- return RBASIC(obj)->klass;
+ else {
+ FL_UNSET(klass, FL_TAINT);
+ }
+
+ return klass;
}
void