[macruby-changes] [4935] MacRuby/trunk/object.c

source_changes at macosforge.org source_changes at macosforge.org
Mon Nov 22 18:20:37 PST 2010


Revision: 4935
          http://trac.macosforge.org/projects/ruby/changeset/4935
Author:   lsansonetti at apple.com
Date:     2010-11-22 18:20:35 -0800 (Mon, 22 Nov 2010)
Log Message:
-----------
improve RubyObject's -conformsToProtocol: by calling the super imp first and registering the given protocol in the class if the magic works

Modified Paths:
--------------
    MacRuby/trunk/object.c

Modified: MacRuby/trunk/object.c
===================================================================
--- MacRuby/trunk/object.c	2010-11-23 02:19:33 UTC (rev 4934)
+++ MacRuby/trunk/object.c	2010-11-23 02:20:35 UTC (rev 4935)
@@ -2908,15 +2908,18 @@
 conformsToProtocolAndAncestors(void *self, SEL sel, Class klass,
 	void *protocol, IMP super)
 {
+    if (super != NULL) {
+	if (((bool(*)(void *, SEL, Protocol *))super)(self, sel, protocol)) {
+	    return true;
+	}
+    }
     if (protocol != NULL) {
 	Protocol *p = (Protocol *)protocol;
 	if (conformsToProtocol(klass, p)) {
+	    class_addProtocol(klass, p);
 	    return true;
 	}
     }
-    if (super != NULL) {
-	return ((bool(*)(void *, SEL, Protocol *))super)(self, sel, protocol);
-    }
     return false;
 }
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101122/f64aa2cd/attachment-0001.html>


More information about the macruby-changes mailing list