[macruby-changes] [434] MacRuby/branches/lrz_unstable
source_changes at macosforge.org
source_changes at macosforge.org
Wed Aug 13 15:31:55 PDT 2008
Revision: 434
http://trac.macosforge.org/projects/ruby/changeset/434
Author: lsansonetti at apple.com
Date: 2008-08-13 15:31:54 -0700 (Wed, 13 Aug 2008)
Log Message:
-----------
wip
Modified Paths:
--------------
MacRuby/branches/lrz_unstable/array.c
MacRuby/branches/lrz_unstable/hash.c
MacRuby/branches/lrz_unstable/io.c
MacRuby/branches/lrz_unstable/string.c
MacRuby/branches/lrz_unstable/vm_insnhelper.c
Modified: MacRuby/branches/lrz_unstable/array.c
===================================================================
--- MacRuby/branches/lrz_unstable/array.c 2008-08-13 22:31:28 UTC (rev 433)
+++ MacRuby/branches/lrz_unstable/array.c 2008-08-13 22:31:54 UTC (rev 434)
@@ -1538,34 +1538,35 @@
return Qfalse;
}
-#if WITH_OBJC
-static inline VALUE
-rb_ary_dup2(VALUE ary)
-{
- CFMutableArrayRef dup;
-
- dup = CFArrayCreateMutableCopy(NULL, 0, (CFArrayRef)ary);
- CFMakeCollectable(dup);
-
- return (VALUE)dup;
-}
-#endif
-
VALUE
rb_ary_dup(VALUE ary)
{
#if WITH_OBJC
- VALUE dup = rb_ary_dup2(ary);
+ VALUE dup;
+
+ dup = (VALUE)CFArrayCreateMutableCopy(NULL, 0, (CFArrayRef)ary);
+ if (OBJ_TAINTED(ary))
+ OBJ_TAINT(dup);
+
+ CFMakeCollectable((CFTypeRef)dup);
#else
VALUE dup = rb_ary_new2(RARRAY_LEN(ary));
MEMCPY(RARRAY_PTR(dup), RARRAY_PTR(ary), VALUE, RARRAY_LEN(ary));
RARRAY(dup)->len = RARRAY_LEN(ary);
-
#endif
return dup;
}
+static VALUE
+rb_ary_clone(VALUE ary)
+{
+ VALUE clone = rb_ary_dup(ary);
+ if (OBJ_FROZEN(ary))
+ OBJ_FREEZE(clone);
+ return clone;
+}
+
extern VALUE rb_output_fs;
static VALUE
@@ -4244,8 +4245,9 @@
rb_define_method(rb_cArray, "drop_while", rb_ary_drop_while, 0);
#if WITH_OBJC
- /* to return a mutable copy */
+ /* to return mutable copies */
rb_define_method(rb_cArray, "dup", rb_ary_dup, 0);
+ rb_define_method(rb_cArray, "clone", rb_ary_clone, 0);
#endif
id_cmp = rb_intern("<=>");
Modified: MacRuby/branches/lrz_unstable/hash.c
===================================================================
--- MacRuby/branches/lrz_unstable/hash.c 2008-08-13 22:31:28 UTC (rev 433)
+++ MacRuby/branches/lrz_unstable/hash.c 2008-08-13 22:31:54 UTC (rev 434)
@@ -314,10 +314,21 @@
rb_hash_dup(VALUE rcv)
{
VALUE dup = (VALUE)CFDictionaryCreateMutableCopy(NULL, 0, (CFDictionaryRef)rcv);
+ if (OBJ_TAINTED(rcv))
+ OBJ_TAINT(dup);
CFMakeCollectable((CFTypeRef)dup);
return dup;
}
+static VALUE
+rb_hash_clone(VALUE rcv)
+{
+ VALUE clone = rb_hash_dup(rcv);
+ if (OBJ_FROZEN(rcv))
+ OBJ_FREEZE(clone);
+ return clone;
+}
+
VALUE
rb_hash_new(void)
{
@@ -3041,8 +3052,9 @@
rb_include_module(rb_cHash, rb_mEnumerable);
#if WITH_OBJC
- /* to return a mutable copy */
+ /* to return mutable copies */
rb_define_method(rb_cHash, "dup", rb_hash_dup, 0);
+ rb_define_method(rb_cHash, "clone", rb_hash_clone, 0);
#else
rb_define_alloc_func(rb_cHash, hash_alloc);
#endif
Modified: MacRuby/branches/lrz_unstable/io.c
===================================================================
--- MacRuby/branches/lrz_unstable/io.c 2008-08-13 22:31:28 UTC (rev 433)
+++ MacRuby/branches/lrz_unstable/io.c 2008-08-13 22:31:54 UTC (rev 434)
@@ -3972,7 +3972,7 @@
write_fptr->fd = write_fd;
write_fptr->mode = (modef & ~FMODE_READABLE)| FMODE_SYNC|FMODE_DUPLEX;
fptr->mode &= ~FMODE_WRITABLE;
- fptr->tied_io_for_writing = write_port;
+ GC_WB(&fptr->tied_io_for_writing, write_port);
rb_ivar_set(port, rb_intern("@tied_io_for_writing"), write_port);
}
@@ -4589,7 +4589,7 @@
write_io = GetWriteIO(io);
if (io != write_io) {
write_io = rb_obj_dup(write_io);
- fptr->tied_io_for_writing = write_io;
+ GC_WB(&fptr->tied_io_for_writing, write_io);
rb_ivar_set(dest, rb_intern("@tied_io_for_writing"), write_io);
}
Modified: MacRuby/branches/lrz_unstable/string.c
===================================================================
--- MacRuby/branches/lrz_unstable/string.c 2008-08-13 22:31:28 UTC (rev 433)
+++ MacRuby/branches/lrz_unstable/string.c 2008-08-13 22:31:54 UTC (rev 434)
@@ -901,6 +901,9 @@
if (data != NULL)
rb_str_cfdata_set(dup, data);
+ if (OBJ_TAINTED(str))
+ OBJ_TAINT(dup);
+
CFMakeCollectable((CFTypeRef)dup);
#else
VALUE dup = str_alloc(rb_obj_class(str));
@@ -910,6 +913,14 @@
return dup;
}
+static VALUE
+rb_str_clone(VALUE str)
+{
+ VALUE clone = rb_str_dup(str);
+ if (OBJ_FROZEN(str))
+ OBJ_FREEZE(clone);
+ return clone;
+}
/*
* call-seq:
@@ -8723,8 +8734,9 @@
rb_define_method(rb_cString, "transform", rb_str_transform, 1);
rb_define_method(rb_cString, "transform!", rb_str_transform_bang, 1);
- /* to return a mutable copy */
+ /* to return mutable copies */
rb_define_method(rb_cString, "dup", rb_str_dup, 0);
+ rb_define_method(rb_cString, "clone", rb_str_clone, 0);
#endif
id_to_s = rb_intern("to_s");
Modified: MacRuby/branches/lrz_unstable/vm_insnhelper.c
===================================================================
--- MacRuby/branches/lrz_unstable/vm_insnhelper.c 2008-08-13 22:31:28 UTC (rev 433)
+++ MacRuby/branches/lrz_unstable/vm_insnhelper.c 2008-08-13 22:31:54 UTC (rev 434)
@@ -791,6 +791,24 @@
}
}
else {
+#if WITH_OBJC
+ if (flag & VM_CALL_SUPER_BIT) {
+ VALUE k;
+ for (k = CLASS_OF(recv); k != 0; k = RCLASS_SUPER(k)) {
+ VALUE ary = rb_ivar_get(k, idIncludedModules);
+ if (ary != Qnil) {
+ int i, count = RARRAY_LEN(ary);
+ for (i = 0; i < count; i++) {
+ VALUE imod = RARRAY_AT(ary, i);
+ mn = rb_objc_method_node(imod, id, NULL, NULL);
+ if (mn != NULL) {
+ goto start_method_dispatch;
+ }
+ }
+ }
+ }
+ }
+#endif
/* method missing */
if (id == idMethodMissing) {
rb_bug("method missing");
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macruby-changes/attachments/20080813/b3908451/attachment-0001.html
More information about the macruby-changes
mailing list