[macruby-changes] [4151] MacRuby/trunk

source_changes at macosforge.org source_changes at macosforge.org
Tue May 25 15:07:02 PDT 2010


Revision: 4151
          http://trac.macosforge.org/projects/ruby/changeset/4151
Author:   lsansonetti at apple.com
Date:     2010-05-25 15:07:00 -0700 (Tue, 25 May 2010)
Log Message:
-----------
don't recognize ^v as a CF type + misc cleaning

Modified Paths:
--------------
    MacRuby/trunk/bridgesupport.cpp
    MacRuby/trunk/bs.c
    MacRuby/trunk/bs.h
    MacRuby/trunk/compiler.cpp
    MacRuby/trunk/objc.h

Modified: MacRuby/trunk/bridgesupport.cpp
===================================================================
--- MacRuby/trunk/bridgesupport.cpp	2010-05-25 20:48:34 UTC (rev 4150)
+++ MacRuby/trunk/bridgesupport.cpp	2010-05-25 22:07:00 UTC (rev 4151)
@@ -1252,6 +1252,11 @@
 	case BS_ELEMENT_CFTYPE:
 	{
 	    bs_element_cftype_t *bs_cftype = (bs_element_cftype_t *)value;
+	    assert(bs_cftype->type[0] == _C_PTR);
+	    if (bs_cftype->type[1] == _C_VOID) {
+		// Do not register ^v as a valid CFType.
+		break;
+	    }
 	    std::map<std::string, bs_element_cftype_t *>::iterator
 		iter = bs_cftypes.find(bs_cftype->type);
 	    if (iter == bs_cftypes.end()) {

Modified: MacRuby/trunk/bs.c
===================================================================
--- MacRuby/trunk/bs.c	2010-05-25 20:48:34 UTC (rev 4150)
+++ MacRuby/trunk/bs.c	2010-05-25 22:07:00 UTC (rev 4151)
@@ -1075,7 +1075,7 @@
 		  free(fptr_args[i].type);
 	      }
 	      snprintf(new_type, sizeof(new_type),
-		       "%c%s%c", _C_FPTR_B, tmp_type, _C_FPTR_E);
+		       "%c%s%c", _MR_C_FPTR_B, tmp_type, _MR_C_FPTR_E);
 
 	      if (atom->val == BS_XML_RETVAL) {
 		  bs_element_retval_t *retval =

Modified: MacRuby/trunk/bs.h
===================================================================
--- MacRuby/trunk/bs.h	2010-05-25 20:48:34 UTC (rev 4150)
+++ MacRuby/trunk/bs.h	2010-05-25 22:07:00 UTC (rev 4151)
@@ -37,8 +37,8 @@
 #include <objc/runtime.h>
 
 /* Extend objc/runtime.h and add function pointers tokens */
-#define _C_FPTR_B '<'
-#define _C_FPTR_E '>'
+#define _MR_C_FPTR_B '<'
+#define _MR_C_FPTR_E '>'
 
 /* Attribute and element representations.
  * See BridgeSupport(5) for more information.

Modified: MacRuby/trunk/compiler.cpp
===================================================================
--- MacRuby/trunk/compiler.cpp	2010-05-25 20:48:34 UTC (rev 4150)
+++ MacRuby/trunk/compiler.cpp	2010-05-25 22:07:00 UTC (rev 4151)
@@ -5248,7 +5248,8 @@
 {
     type = SkipTypeModifiers(type);
 
-    if (*type == _C_PTR && GET_CORE()->find_bs_cftype(type) != NULL) {
+    if (type[0] == _C_PTR && type[1] != _C_VOID
+	    && GET_CORE()->find_bs_cftype(type) != NULL) {
 	type = "@";
     }
 
@@ -5377,7 +5378,7 @@
 	    }
 	    break;
 
-        case _C_FPTR_B:
+        case _MR_C_FPTR_B:
 	    {
 		GlobalVariable *proc_gvar =
 		    new GlobalVariable(*RoxorCompiler::module,
@@ -5395,7 +5396,7 @@
 
 		std::vector<std::string> arg_ctypes;
 		std::vector<const Type *> arg_types;
-		while (*p != _C_FPTR_E) {
+		while (*p != _MR_C_FPTR_E) {
 		    p = GetFirstType(p, buf, buf_len);
 		    arg_ctypes.push_back(std::string(buf));
 		    arg_types.push_back(convert_type(buf));
@@ -5606,7 +5607,8 @@
 {
     type = SkipTypeModifiers(type);
 
-    if (*type == _C_PTR && GET_CORE()->find_bs_cftype(type) != NULL) {
+    if (type[0] == _C_PTR && type[1] != _C_VOID
+	    && GET_CORE()->find_bs_cftype(type) != NULL) {
 	type = "@";
     }
 
@@ -5826,7 +5828,7 @@
 	    }
 	    break;
 
-	case _C_FPTR_B:
+	case _MR_C_FPTR_B:
 	    return PtrTy;
 
 	case _C_STRUCT_B:
@@ -6256,6 +6258,9 @@
 	arg_types.push_back(buf);
     }
 
+    free(buf);
+    buf = NULL;
+
     // Create the function.
     FunctionType *ft = FunctionType::get(f_ret_type, f_types, false);
     Function *f = cast<Function>(module->getOrInsertFunction("", ft));
@@ -6316,9 +6321,10 @@
     }
 
     // Call the Ruby implementation.
-    Value *ret_val = compile_protected_call(imp, params);
+    Instruction *ruby_call_insn = compile_protected_call(imp, params);
 
     // Convert the return value into Objective-C type (if any).
+    Value *ret_val = ruby_call_insn;
     if (f_ret_type != VoidTy) {
 	ret_val = compile_conversion_to_c(ret_type.c_str(), ret_val,
 		new AllocaInst(f_ret_type, "", bb));
@@ -6353,7 +6359,11 @@
     rescue_invoke_bb = old_rescue_invoke_bb;
 #endif
 
-    free(buf);
+    // Now that the function is finished, we can inline the Ruby method.
+    if (CallInst::classof(ruby_call_insn)) {
+	CallInst *insn = cast<CallInst>(ruby_call_insn);
+	InlineFunction(insn);
+    }
 
     return f;
 }

Modified: MacRuby/trunk/objc.h
===================================================================
--- MacRuby/trunk/objc.h	2010-05-25 20:48:34 UTC (rev 4150)
+++ MacRuby/trunk/objc.h	2010-05-25 22:07:00 UTC (rev 4151)
@@ -118,30 +118,30 @@
 {
     while (1) {
         switch (*type++) {
+	    case _C_CONST:
+	    case _C_PTR:
             case 'O':   /* bycopy */
             case 'n':   /* in */
             case 'o':   /* out */
             case 'N':   /* inout */
-            case 'r':   /* const */
             case 'V':   /* oneway */
-            case '^':   /* pointers */
                 break;
 
                 /* arrays */
-            case '[':
-                return type + SubtypeUntil (type, ']') + 1;
+            case _C_ARY_B:
+                return type + SubtypeUntil (type, _C_ARY_E) + 1;
 
                 /* structures */
-            case '{':
-                return type + SubtypeUntil (type, '}') + 1;
+            case _C_STRUCT_B:
+                return type + SubtypeUntil (type, _C_STRUCT_E) + 1;
 
                 /* unions */
-            case '(':
-                return type + SubtypeUntil (type, ')') + 1;
+            case _C_UNION_B:
+                return type + SubtypeUntil (type, _C_UNION_E) + 1;
 
                 /* Function pointers */
-            case '<':
-                return type + SubtypeUntil (type, '>') + 1;
+            case _MR_C_FPTR_B:
+                return type + SubtypeUntil (type, _MR_C_FPTR_E) + 1;
 
                 /* basic types */
             default:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100525/5952576f/attachment.html>


More information about the macruby-changes mailing list