[macruby-changes] [1731] MacRuby/branches/experimental/compiler.cpp

source_changes at macosforge.org source_changes at macosforge.org
Thu Jun 4 17:02:15 PDT 2009


Revision: 1731
          http://trac.macosforge.org/projects/ruby/changeset/1731
Author:   lsansonetti at apple.com
Date:     2009-06-04 17:02:14 -0700 (Thu, 04 Jun 2009)
Log Message:
-----------
fixed Ruby -> _C_CHARPTR/_C_SEL convertors

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

Modified: MacRuby/branches/experimental/compiler.cpp
===================================================================
--- MacRuby/branches/experimental/compiler.cpp	2009-06-05 00:01:32 UTC (rev 1730)
+++ MacRuby/branches/experimental/compiler.cpp	2009-06-05 00:02:14 UTC (rev 1731)
@@ -4241,37 +4241,34 @@
     }
 }
 
-extern "C"
-void
-rb_vm_rval_to_ocsel(VALUE rval, SEL *ocval)
+static inline const char *
+rval_to_c_str(VALUE rval)
 {
     if (NIL_P(rval)) {
-	*ocval = NULL;
+	return NULL;
     }
     else {
-	const char *cstr;
-
 	switch (TYPE(rval)) {
-	    case T_STRING:
-		cstr = StringValuePtr(rval);
-		break;
-
 	    case T_SYMBOL:
-		cstr = rb_sym2name(rval);
-		break;
-
-	    default:
-		convert_error(_C_SEL, rval);
+		return rb_sym2name(rval);
 	}
-	*ocval = sel_registerName(cstr);
+	return StringValueCStr(rval);
     }
 }
 
 extern "C"
 void
+rb_vm_rval_to_ocsel(VALUE rval, SEL *ocval)
+{
+    const char *cstr = rval_to_c_str(rval);
+    *ocval = cstr == NULL ? NULL : sel_registerName(cstr);
+}
+
+extern "C"
+void
 rb_vm_rval_to_charptr(VALUE rval, const char **ocval)
 {
-    *ocval = NIL_P(rval) ? NULL : StringValueCStr(rval);
+    *ocval = rval_to_c_str(rval);
 }
 
 static inline long
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090604/9bea72f7/attachment-0001.html>


More information about the macruby-changes mailing list