[前][次][番号順一覧][スレッド一覧]

ruby-changes:14054

From: nobu <ko1@a...>
Date: Fri, 20 Nov 2009 04:49:58 +0900 (JST)
Subject: [ruby-changes:14054] Ruby:r25865 (mvm): * vm.c (rb_vm_send, rb_vm_recv): supported strings.

nobu	2009-11-20 04:39:53 +0900 (Fri, 20 Nov 2009)

  New Revision: 25865

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=25865

  Log:
    * vm.c (rb_vm_send, rb_vm_recv): supported strings.

  Modified files:
    branches/mvm/ChangeLog
    branches/mvm/string.c
    branches/mvm/vm.c

Index: mvm/ChangeLog
===================================================================
--- mvm/ChangeLog	(revision 25864)
+++ mvm/ChangeLog	(revision 25865)
@@ -1,3 +1,7 @@
+Fri Nov 20 04:39:40 2009  Nobuyoshi Nakada  <nobu@r...>
+
+	* vm.c (rb_vm_send, rb_vm_recv): supported strings.
+
 Fri Nov 20 04:38:44 2009  Nobuyoshi Nakada  <nobu@r...>
 
 	* thread.c (rb_queue_shift_wait): fixed the case of no-timeout.
Index: mvm/string.c
===================================================================
--- mvm/string.c	(revision 25864)
+++ mvm/string.c	(revision 25865)
@@ -7538,4 +7538,23 @@
     rb_define_method(rb_cSymbol, "swapcase", sym_swapcase, 0);
 
     rb_define_method(rb_cSymbol, "encoding", sym_encoding, 0);
+
+struct rb_objspace;
+VALUE rb_newobj_from_heap(struct rb_objspace*);
+void *rb_objspace_xmalloc(struct rb_objspace*, size_t);
+
+VALUE
+rb_str_copy_to_vm(VALUE str, struct rb_objspace *objspace)
+{
+    VALUE copy = rb_newobj_from_heap(objspace);
+    *RSTRING(copy) = *RSTRING(str);
+    if (!STR_EMBED_P(copy)) {
+	const long size = RSTRING(copy)->as.heap.len;
+	char *const ptr = rb_objspace_xmalloc(objspace, size);
+	RSTRING(copy)->as.heap.ptr = ptr;
+	memcpy(ptr, RSTRING(str)->as.heap.ptr, size);
+	ptr[size] = 0;
+    }
+    return copy;
 }
+}
Index: mvm/vm.c
===================================================================
--- mvm/vm.c	(revision 25864)
+++ mvm/vm.c	(revision 25865)
@@ -2079,11 +2079,13 @@
 VALUE
 rb_vm_send(VALUE self, VALUE val)
 {
+    VALUE rb_str_copy_to_vm(VALUE str, struct rb_objspace *objspace);
     rb_vm_t *vm;
 
     GetVMPtr(self, vm);
     if (!rb_special_const_p(val) && vm->objspace != GET_VM()->objspace) {
-	rb_raise(rb_eTypeError, "expected special constants");
+	StringValue(val);
+	val = rb_str_copy_to_vm(val, vm->objspace);
     }
     if (!vm->self) {
 	rb_raise(rb_eArgError, "terminated VM");
@@ -2103,7 +2105,8 @@
     if (!rb_queue_shift_wait(&vm->queue.message, &val, tv))
 	rb_sys_fail(0);
     if (!rb_special_const_p((VALUE)val)) {
-	rb_raise(rb_eTypeError, "expected special constants");
+	Check_Type((VALUE)val, T_STRING);
+	RBASIC(val)->klass = rb_cString;
     }
     return (VALUE)val;
 }

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]