[macruby-changes] [2976] MacRuby/trunk/vm.cpp

source_changes at macosforge.org source_changes at macosforge.org
Fri Nov 6 23:38:28 PST 2009


Revision: 2976
          http://trac.macosforge.org/projects/ruby/changeset/2976
Author:   lsansonetti at apple.com
Date:     2009-11-06 23:38:25 -0800 (Fri, 06 Nov 2009)
Log Message:
-----------
dispatch #method_added even during method registration, not compilation

Modified Paths:
--------------
    MacRuby/trunk/vm.cpp

Modified: MacRuby/trunk/vm.cpp
===================================================================
--- MacRuby/trunk/vm.cpp	2009-11-07 03:41:48 UTC (rev 2975)
+++ MacRuby/trunk/vm.cpp	2009-11-07 07:38:25 UTC (rev 2976)
@@ -767,6 +767,23 @@
     abort();
 }
 
+void
+RoxorCore::method_added(Class klass, SEL sel)
+{
+    if (get_running()) {
+	// Call method_added: or singleton_method_added:.
+	VALUE sym = ID2SYM(rb_intern(sel_getName(sel)));
+        if (RCLASS_SINGLETON(klass)) {
+	    VALUE sk = rb_iv_get((VALUE)klass, "__attached__");
+	    rb_vm_call(sk, selSingletonMethodAdded, 1, &sym, false);
+        }
+        else {
+	    rb_vm_call((VALUE)klass, selMethodAdded, 1, &sym, false);
+        }
+    }
+
+}
+
 rb_vm_method_node_t *
 RoxorCore::add_method(Class klass, SEL sel, IMP imp, IMP ruby_imp,
 	const rb_vm_arity_t &arity, int flags, const char *types)
@@ -857,18 +874,6 @@
 		    RCLASS_HAS_ROBJECT_ALLOC));
     }
 
-    if (get_running()) {
-	// Call method_added: or singleton_method_added:.
-	VALUE sym = ID2SYM(rb_intern(sel_getName(sel)));
-        if (RCLASS_SINGLETON(klass)) {
-	    VALUE sk = rb_iv_get((VALUE)klass, "__attached__");
-	    rb_vm_call(sk, selSingletonMethodAdded, 1, &sym, false);
-        }
-        else {
-	    rb_vm_call((VALUE)klass, selMethodAdded, 1, &sym, false);
-        }
-    }
-
     // Forward method definition to the included classes.
     if (RCLASS_VERSION(klass) & RCLASS_IS_INCLUDED) {
 	VALUE included_in_classes = rb_attr_get((VALUE)klass, 
@@ -1884,6 +1889,8 @@
 	}
     }
 
+    GET_CORE()->method_added(klass, sel);
+
     if (!added_modfunc && (v & RCLASS_SCOPE_MOD_FUNC)) {
 	added_modfunc = true;
 	redefined = false;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20091106/027e8ba9/attachment.html>


More information about the macruby-changes mailing list