[macruby-changes] [126] MacRuby/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Mon Mar 31 19:18:43 PDT 2008
Revision: 126
http://trac.macosforge.org/projects/ruby/changeset/126
Author: lsansonetti at apple.com
Date: 2008-03-31 19:18:42 -0700 (Mon, 31 Mar 2008)
Log Message:
-----------
fixing Hash#{clone,dup}
Modified Paths:
--------------
MacRuby/trunk/hash.c
MacRuby/trunk/object.c
Modified: MacRuby/trunk/hash.c
===================================================================
--- MacRuby/trunk/hash.c 2008-04-01 00:29:16 UTC (rev 125)
+++ MacRuby/trunk/hash.c 2008-04-01 02:18:42 UTC (rev 126)
@@ -347,17 +347,18 @@
s->has_proc_default = has_proc_default;
}
-VALUE
-rb_hash_clone(VALUE hash)
+static void
+rb_objc_ary_copy_struct(VALUE old, VALUE new)
{
-#if 0 // TODO
- VALUE klass, dup;
- long n;
+ struct rb_objc_hash_struct *s;
- klass = rb_obj_class(ary);
- dup = hash_alloc(klass);
-#endif
- return Qnil;
+ s = rb_objc_hash_get_struct(old);
+ if (s != NULL) {
+ struct rb_objc_hash_struct *n;
+
+ n = rb_objc_hash_get_struct2(new);
+ memcpy(n, s, sizeof(struct rb_objc_hash_struct));
+ }
}
#endif
@@ -405,6 +406,23 @@
#endif
}
+#if WITH_OBJC
+static VALUE rb_hash_replace(VALUE, VALUE);
+
+VALUE
+rb_hash_clone(VALUE hash)
+{
+ VALUE klass, dup;
+ long n;
+
+ klass = rb_obj_class(hash);
+ dup = hash_alloc(klass);
+ rb_hash_replace(dup, hash);
+ rb_objc_ary_copy_struct(hash, dup);
+ return dup;
+}
+#endif
+
static void
rb_hash_modify_check(VALUE hash)
{
Modified: MacRuby/trunk/object.c
===================================================================
--- MacRuby/trunk/object.c 2008-04-01 00:29:16 UTC (rev 125)
+++ MacRuby/trunk/object.c 2008-04-01 02:18:42 UTC (rev 126)
@@ -160,10 +160,14 @@
#if WITH_OBJC
if (rb_objc_is_non_native(obj)) {
int type = TYPE(obj);
- if (type == T_ARRAY)
- if (rb_ary_tainted(obj)) rb_ary_taint(dest);
- else if (type == T_HASH)
- if (rb_hash_tainted(obj)) rb_hash_taint(dest);
+ if (type == T_ARRAY) {
+ if (rb_ary_tainted(obj))
+ rb_ary_taint(dest);
+ }
+ else if (type == T_HASH) {
+ if (rb_hash_tainted(obj))
+ rb_hash_taint(dest);
+ }
goto call_init_copy;
}
#endif
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macruby-changes/attachments/20080331/8e50e48f/attachment.html
More information about the macruby-changes
mailing list