[macruby-changes] [697] MacRuby/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Sat Nov 1 22:12:37 PDT 2008
Revision: 697
http://trac.macosforge.org/projects/ruby/changeset/697
Author: lsansonetti at apple.com
Date: 2008-11-01 22:12:37 -0700 (Sat, 01 Nov 2008)
Log Message:
-----------
better implementation for -[Symbol isEqual:]
Modified Paths:
--------------
MacRuby/trunk/objc.h
MacRuby/trunk/string.c
Modified: MacRuby/trunk/objc.h
===================================================================
--- MacRuby/trunk/objc.h 2008-11-02 04:40:33 UTC (rev 696)
+++ MacRuby/trunk/objc.h 2008-11-02 05:12:37 UTC (rev 697)
@@ -41,4 +41,16 @@
rb_objc_install_method(klass, sel_registerName(selname), imp);
}
+static inline bool
+rb_objc_is_kind_of(id object, Class klass)
+{
+ Class cls;
+ for (cls = *(Class *)object; cls != NULL; cls = class_getSuperclass(cls)) {
+ if (cls == klass) {
+ return true;
+ }
+ }
+ return false;
+}
+
#endif /* __OBJC_H_ */
Modified: MacRuby/trunk/string.c
===================================================================
--- MacRuby/trunk/string.c 2008-11-02 04:40:33 UTC (rev 696)
+++ MacRuby/trunk/string.c 2008-11-02 05:12:37 UTC (rev 697)
@@ -5242,7 +5242,13 @@
static bool
imp_rb_symbol_isEqual(void *rcv, SEL sel, void *other)
{
- return rcv == other;
+ if (other == NULL)
+ return false;
+ if (rcv == other)
+ return true;
+ if (!rb_objc_is_kind_of(other, (Class)rb_cNSString))
+ return false;
+ return CFStringCompare((CFStringRef)rcv, (CFStringRef)other, 0) == 0;
}
static void
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20081101/c76c8d1f/attachment.html>
More information about the macruby-changes
mailing list