[macruby-changes] [1996] MacRuby/branches/experimental/bridgesupport.cpp

source_changes at macosforge.org source_changes at macosforge.org
Mon Jul 6 01:04:46 PDT 2009


Revision: 1996
          http://trac.macosforge.org/projects/ruby/changeset/1996
Author:   lsansonetti at apple.com
Date:     2009-07-06 01:04:44 -0700 (Mon, 06 Jul 2009)
Log Message:
-----------
workaround missing 64-bit informal protocol annotations in BridgeSupport

Modified Paths:
--------------
    MacRuby/branches/experimental/bridgesupport.cpp

Modified: MacRuby/branches/experimental/bridgesupport.cpp
===================================================================
--- MacRuby/branches/experimental/bridgesupport.cpp	2009-07-05 23:27:19 UTC (rev 1995)
+++ MacRuby/branches/experimental/bridgesupport.cpp	2009-07-06 08:04:44 UTC (rev 1996)
@@ -23,6 +23,7 @@
 #include "vm.h"
 #include "compiler.h"
 #include "bridgesupport.h"
+#include "objc.h"
 
 #include <execinfo.h>
 #include <dlfcn.h>
@@ -986,8 +987,44 @@
 		? bs_informal_protocol_cmethods
 		: bs_informal_protocol_imethods;
 
-	    map[bs_inf_prot_method->name] =
-		new std::string(bs_inf_prot_method->type);
+	    char *type;
+#if __LP64__
+	    // XXX workaround a BridgeSupport bug: 64-bit annotations for
+	    // informal_protocol elements are missing!
+	    // Manually converting some 32-bit types to 64-bit...
+	    const size_t typelen = strlen(bs_inf_prot_method->type) + 1;
+	    type = (char *)alloca(typelen);
+	    *type = '\0';
+	    const char *p = bs_inf_prot_method->type;
+	    do {
+		const char *p2 = (char *)SkipFirstType(p);
+		const size_t len = p2 - p;
+		if (len == 1 && *p == _C_FLT) {
+		    // float -> double
+		    strlcat(type, "d", typelen);
+		}
+		else if (strncmp(p, "{_NSPoint=", 10) == 0) {
+		    strlcat(type, "{CGPoint=dd}", typelen);
+		}
+		else if (strncmp(p, "{_NSSize=", 9) == 0) {
+		    strlcat(type, "{CGSize=dd}", typelen);
+		}
+		else if (strncmp(p, "{_NSRect=", 9) == 0) {
+		    strlcat(type, "{CGRect={CGPoint=dd}{CGSize=dd}}", typelen);
+		}
+		else {
+		    char buf[100];
+		    strncpy(buf, p, len);
+		    buf[len] = '\0';
+		    strlcat(type, buf, typelen);
+		}
+		p = SkipStackSize(p2);
+	    }
+	    while (*p != '\0');
+#else
+	    type = bs_inf_prot_method->type;
+#endif
+	    map[bs_inf_prot_method->name] = new std::string(type);
 	    break;
 	}
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090706/501ad9bc/attachment.html>


More information about the macruby-changes mailing list