[macruby-changes] [4892] MacRuby/trunk/bridgesupport.cpp

source_changes at macosforge.org source_changes at macosforge.org
Fri Nov 5 19:04:16 PDT 2010


Revision: 4892
          http://trac.macosforge.org/projects/ruby/changeset/4892
Author:   lsansonetti at apple.com
Date:     2010-11-05 19:04:14 -0700 (Fri, 05 Nov 2010)
Log Message:
-----------
when doing sanity pointer type check, ignore '=' characters in type signatures

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

Modified: MacRuby/trunk/bridgesupport.cpp
===================================================================
--- MacRuby/trunk/bridgesupport.cpp	2010-11-06 01:44:41 UTC (rev 4891)
+++ MacRuby/trunk/bridgesupport.cpp	2010-11-06 02:04:14 UTC (rev 4892)
@@ -1524,6 +1524,31 @@
 #endif
 }
 
+// Comparing types by making sure '=' characters are ignored, since these
+// may be sometimes present, sometimes not present in signatures returned by
+// the runtime or BridgeSupport files.
+static bool
+compare_types(const char *t1, const char *t2)
+{
+    while (true) {
+	if (*t1 == '=') {
+	    t1++;
+	}
+	if (*t2 == '=') {
+	    t2++;
+	}
+	if (*t1 != *t2) {
+	    return false;
+	}
+	if (*t1 == '\0') {
+	    break;
+	}
+	t1++;
+	t2++;
+    }
+    return true;
+}
+
 // Called by the kernel:
 
 extern "C"
@@ -1546,7 +1571,7 @@
     // is 'C' (which means converted from void*) or the target argument pointer
     // type is void*.
     if (type[1] != _C_VOID && ptr_type[0] != _C_UCHR
-	    && strcmp(ptr_type, &type[1]) != 0) {
+	    && !compare_types(ptr_type, &type[1])) {
 	rb_raise(rb_eTypeError,
 		"expected instance of Pointer of type `%s', got `%s'",
 		type + 1,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101105/36c6decc/attachment-0001.html>


More information about the macruby-changes mailing list