Modified: MacRuby/trunk/hash.c (125 => 126)
--- 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 (125 => 126)
--- 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