Revision
127
Author
lsansonetti@apple.com
Date
2008-03-31 19:23:04 -0700 (Mon, 31 Mar 2008)

Log Message

fix rb_obj_freeze so that arrays and hashes can be frozen

Modified Paths

Diff

Modified: MacRuby/trunk/object.c (126 => 127)


--- MacRuby/trunk/object.c	2008-04-01 02:18:42 UTC (rev 126)
+++ MacRuby/trunk/object.c	2008-04-01 02:23:04 UTC (rev 127)
@@ -758,9 +758,16 @@
 rb_obj_freeze(VALUE obj)
 {
 #if WITH_OBJC
-    if (rb_objc_is_non_native(obj))
-	rb_raise(rb_eRuntimeError, "can't freeze pure objc object `%s'",
-	    RSTRING_PTR(rb_inspect(obj)));
+    if (rb_objc_is_non_native(obj)) {
+	int type = TYPE(obj);
+	if (type == T_ARRAY)
+	    rb_ary_freeze(obj);
+	else if (type == T_HASH)
+	    rb_hash_freeze(obj);
+	else
+	    rb_raise(rb_eRuntimeError, "can't freeze pure objc object `%s'",
+		    RSTRING_PTR(rb_inspect(obj)));
+    }
 #endif
     if (!OBJ_FROZEN(obj)) {
 	if (rb_safe_level() >= 4 && !OBJ_TAINTED(obj)) {