summaryrefslogtreecommitdiff
path: root/class.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-03-08 07:03:09 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-03-08 07:03:09 +0000
commitd497898c231f124ba187e2650be8af20b47b1a97 (patch)
treed7fbdd608eb0698296838406ea964328994e342c /class.c
parentd41f53d0b6ceaec8b9fffc9f79ee9335b2a25175 (diff)
* eval.c (cvar_cbase): utility function to find innermost non
singleton cbase. * eval.c (is_defined): adopt new cvar behavior. * eval.c (rb_eval): ditto. * eval.c (assign): ditto. * class.c (rb_mod_clone): should not call rb_obj_clone(), since Module does not provide "allocate". * class.c (rb_singleton_class): should crate new singleton class if obj is a class or module and attached object is different, which means metaclass of singleton class is sought. * time.c (time_s_alloc): now follows allocation framework. * eval.c (rb_eval): should initialize outer class variables from methods in singleton class definitions. * eval.c (assign): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2169 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'class.c')
-rw-r--r--class.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/class.c b/class.c
index 12d03f1..e0445cd 100644
--- a/class.c
+++ b/class.c
@@ -62,7 +62,8 @@ VALUE
rb_mod_clone(module)
VALUE module;
{
- VALUE clone = rb_obj_clone(module);
+ NEWOBJ(clone, struct RClass);
+ CLONESETUP(clone, module);
RCLASS(clone)->super = RCLASS(module)->super;
if (RCLASS(module)->iv_tbl) {
@@ -79,7 +80,7 @@ rb_mod_clone(module)
st_foreach(RCLASS(module)->m_tbl, clone_method, RCLASS(clone)->m_tbl);
}
- return clone;
+ return (VALUE)clone;
}
VALUE
@@ -652,6 +653,8 @@ rb_undef_method(klass, name)
rb_add_method(klass, rb_intern(name), 0, NOEX_UNDEF);
}
+#if 0
+
#define SPECIAL_SINGLETON(x,c) if (obj == (x)) {\
if (!FL_TEST(c, FL_SINGLETON)) {\
c = rb_singleton_class_new(c);\
@@ -660,6 +663,14 @@ rb_undef_method(klass, name)
return c;\
}
+#else
+
+#define SPECIAL_SINGLETON(x,c) if (obj == (x)) {\
+ return c;\
+}
+
+#endif
+
VALUE
rb_singleton_class(obj)
VALUE obj;
@@ -677,11 +688,14 @@ rb_singleton_class(obj)
}
DEFER_INTS;
- if (FL_TEST(RBASIC(obj)->klass, FL_SINGLETON)) {
+ if (FL_TEST(RBASIC(obj)->klass, FL_SINGLETON) &&
+ (BUILTIN_TYPE(obj) == T_CLASS || BUILTIN_TYPE(obj) == T_MODULE) &&
+ rb_iv_get(RBASIC(obj)->klass, "__attached__") == obj) {
klass = RBASIC(obj)->klass;
}
else {
klass = rb_make_metaclass(obj, RBASIC(obj)->klass);
+ RBASIC(klass)->klass = CLASS_OF(RCLASS(klass)->super);
}
if (OBJ_TAINTED(obj)) {
OBJ_TAINT(klass);