[macruby-changes] [3943] MacRuby/trunk/objc.m

source_changes at macosforge.org source_changes at macosforge.org
Tue Apr 20 13:24:51 PDT 2010


Revision: 3943
          http://trac.macosforge.org/projects/ruby/changeset/3943
Author:   lsansonetti at apple.com
Date:     2010-04-20 13:24:50 -0700 (Tue, 20 Apr 2010)
Log Message:
-----------
do not auto-initialize classes that are not NSObject-based

Modified Paths:
--------------
    MacRuby/trunk/objc.m

Modified: MacRuby/trunk/objc.m
===================================================================
--- MacRuby/trunk/objc.m	2010-04-20 05:12:16 UTC (rev 3942)
+++ MacRuby/trunk/objc.m	2010-04-20 20:24:50 UTC (rev 3943)
@@ -650,6 +650,19 @@
 void
 rb_objc_force_class_initialize(Class klass)
 {
+    // Do not do anything in case the class is not NSObject-based
+    // (likely Proxy).
+    bool ok = false;
+    for (Class k = klass; k != NULL; k = class_getSuperclass(k)) {
+	if (k == (Class)rb_cNSObject) {
+	    ok = true;
+	    break;
+	}
+    }
+    if (!ok) {
+	return;
+    }
+
     // This forces +initialize to be called.
     class_getMethodImplementation(klass, @selector(initialize));
 }
@@ -678,7 +691,9 @@
     rb_objc_define_method(rb_mKernel, "load_bridge_support_file",
 	    rb_objc_load_bs, 1);
 
-    Method m = class_getInstanceMethod(objc_getClass("NSKeyValueUnnestedProperty"), sel_registerName("isaForAutonotifying"));
+    Class k = objc_getClass("NSKeyValueUnnestedProperty");
+    assert(k != NULL);
+    Method m = class_getInstanceMethod(k, @selector(isaForAutonotifying));
     assert(m != NULL);
     old_imp_isaForAutonotifying = method_getImplementation(m);
     method_setImplementation(m, (IMP)rb_obj_imp_isaForAutonotifying);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100420/d0c12da5/attachment.html>


More information about the macruby-changes mailing list