Hello,

	I'm thinking about "class_added" callback as symmectic function
	for "method_added".

	Can be used like:
irb(main):001:0> module AAA
irb(main):002:1> def AAA.class_added(klass)
irb(main):003:2> puts "Class #{klass} added..."
irb(main):004:2> end
irb(main):005:1> end
nil
irb(main):006:0> module AAA
irb(main):007:1> class BBB
irb(main):008:2> end
irb(main):009:1> end
Class AAA::BBB added...
nil
rb(main):010:0>

	Implementation follows:

Index: class.c
===================================================================
RCS file: /src/ruby/class.c,v
retrieving revision 1.38
diff -u -r1.38 class.c
--- class.c	2002/04/10 08:45:22	1.38
+++ class.c	2002/04/11 10:33:20
@@ -176,6 +176,14 @@
 }
 
 VALUE
+rb_class_added(outer, klass)
+    VALUE outer, klass;
+{
+    if (!outer) outer = rb_cObject;
+    return rb_funcall(outer, rb_intern("class_added"), 1, klass);
+}
+
+VALUE
 rb_define_class(name, super)
     const char *name;
     VALUE super;
@@ -202,6 +210,7 @@
     }
     klass = rb_define_class_id(id, super);
     rb_class_inherited(super, klass);
+    rb_class_added(rb_cObject, klass);
     st_add_direct(rb_class_tbl, id, klass);
 
     return klass;
@@ -234,6 +243,7 @@
     klass = rb_define_class_id(id, super);
     rb_set_class_path(klass, outer, name);
     rb_class_inherited(super, klass);
+    rb_class_added(outer, klass);
     rb_const_set(outer, id, klass);
 
     return klass;
Index: eval.c
===================================================================
RCS file: /src/ruby/eval.c,v
retrieving revision 1.280
diff -u -r1.280 eval.c
--- eval.c	2002/04/11 10:02:59	1.280
+++ eval.c	2002/04/11 10:33:25
@@ -3254,6 +3254,7 @@
 		klass = rb_define_class_id(node->nd_cname, super);
 		rb_set_class_path(klass,ruby_class,rb_id2name(node->nd_cname));
 		rb_class_inherited(super, klass);
+		rb_class_added(ruby_class, klass);
 		rb_const_set(ruby_class, node->nd_cname, klass);
 	    }
 	    if (ruby_wrapper) {
Index: intern.h
===================================================================
RCS file: /src/ruby/intern.h,v
retrieving revision 1.84
diff -u -r1.84 intern.h
--- intern.h	2002/03/15 08:51:31	1.84
+++ intern.h	2002/04/11 10:33:26
@@ -100,6 +100,7 @@
 void rb_singleton_class_attached _((VALUE,VALUE));
 VALUE rb_make_metaclass _((VALUE, VALUE));
 VALUE rb_class_inherited _((VALUE, VALUE));
+VALUE rb_class_added _((VALUE, VALUE));
 VALUE rb_define_class_id _((ID, VALUE));
 VALUE rb_module_new _((void));
 VALUE rb_define_module_id _((ID));
Index: object.c
===================================================================
RCS file: /src/ruby/object.c,v
retrieving revision 1.76
diff -u -r1.76 object.c
--- object.c	2002/04/11 10:02:59	1.76
+++ object.c	2002/04/11 10:33:26
@@ -650,6 +650,7 @@
     rb_make_metaclass(klass, RBASIC(super)->klass);
     rb_obj_call_init(klass, argc, argv);
     rb_class_inherited(super, klass);
+    rb_class_added(rb_cObject, klass);
 
     return klass;
 }
@@ -1202,7 +1203,8 @@
     rb_define_private_method(rb_cModule, "method_added", rb_obj_dummy, 1);
     rb_define_private_method(rb_cModule, "method_removed", rb_obj_dummy, 1);
     rb_define_private_method(rb_cModule, "method_undefined", rb_obj_dummy, 1);
-
+    rb_define_private_method(rb_cModule, "class_added", rb_obj_dummy, 1);
+    
     /*
      * Ruby's Class Hierarchy Chart
      *

-- 
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Michal Rokos                         Czech Technical University, Prague
E-mail:m.rokos / sh.cvut.cz  ICQ:36118339  Jabber:majkl / jabber.sh.cvut.cz
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-