[macruby-changes] [122] MacRuby/trunk

source_changes at macosforge.org source_changes at macosforge.org
Fri Mar 28 22:20:07 PDT 2008


Revision: 122
          http://trac.macosforge.org/projects/ruby/changeset/122
Author:   lsansonetti at apple.com
Date:     2008-03-28 22:20:07 -0700 (Fri, 28 Mar 2008)

Log Message:
-----------
fixing more regressions, fixing named args -> fixing build and install

Modified Paths:
--------------
    MacRuby/trunk/array.c
    MacRuby/trunk/class.c
    MacRuby/trunk/compile.c
    MacRuby/trunk/dir.c
    MacRuby/trunk/hash.c
    MacRuby/trunk/include/ruby/intern.h
    MacRuby/trunk/include/ruby/ruby.h
    MacRuby/trunk/insns.def
    MacRuby/trunk/io.c
    MacRuby/trunk/string.c
    MacRuby/trunk/vm_insnhelper.c

Modified: MacRuby/trunk/array.c
===================================================================
--- MacRuby/trunk/array.c	2008-03-28 22:38:12 UTC (rev 121)
+++ MacRuby/trunk/array.c	2008-03-29 05:20:07 UTC (rev 122)
@@ -48,12 +48,12 @@
 };
 
 /* This variable will always stay NULL, we only use its address. */
-static void *rb_objc_assoc_key = NULL;
+static void *rb_objc_ary_assoc_key = NULL;
 
 static struct rb_objc_ary_struct *
 rb_objc_ary_get_struct(VALUE ary)
 {
-    return rb_objc_get_associative_ref((void *)ary, &rb_objc_assoc_key);
+    return rb_objc_get_associative_ref((void *)ary, &rb_objc_ary_assoc_key);
 }
 
 static struct rb_objc_ary_struct *
@@ -64,7 +64,7 @@
     s = rb_objc_ary_get_struct(ary);
     if (s == NULL) {
         s = xmalloc(sizeof(struct rb_objc_ary_struct));
-        rb_objc_set_associative_ref((void *)ary, &rb_objc_assoc_key, s);
+        rb_objc_set_associative_ref((void *)ary, &rb_objc_ary_assoc_key, s);
         s->frozen = false;
         s->named_args = false;
     }
@@ -1533,6 +1533,8 @@
     if (n > 0)
 	CFArrayAppendArray((CFMutableArrayRef)dup, (CFArrayRef)ary,
 		CFRangeMake(0, n));
+    if (rb_ary_is_named_args(ary))
+	rb_ary_set_named_args(dup, true);
 #else
     VALUE dup = rb_ary_new2(RARRAY_LEN(ary));
 
@@ -3860,6 +3862,19 @@
 
 #undef INSTALL_METHOD
 }
+
+void
+rb_ary_set_named_args(VALUE ary, bool flag)
+{
+    rb_objc_ary_get_struct2(ary)->named_args = flag;
+}
+
+bool
+rb_ary_is_named_args(VALUE ary)
+{
+    struct rb_objc_ary_struct *s = rb_objc_ary_get_struct(ary);
+    return s != NULL && s->named_args;
+}
 #endif
 
 /* Arrays are ordered, integer-indexed collections of any object. 

Modified: MacRuby/trunk/class.c
===================================================================
--- MacRuby/trunk/class.c	2008-03-28 22:38:12 UTC (rev 121)
+++ MacRuby/trunk/class.c	2008-03-29 05:20:07 UTC (rev 122)
@@ -1088,19 +1088,8 @@
 	if (class_isMetaClass(ocklass))
 	    return klass;
 
-	if (!FL_TEST(klass, FL_SINGLETON)) {
+	if (!FL_TEST(klass, FL_SINGLETON))
 	    klass = rb_make_metaclass(obj, klass);
-#if 0
-	    Class newocklass;
-
-	    newocklass = objc_allocateClassPair(ocklass, "MetaClassFoo", 0);
-	    assert(newocklass != NULL);
-	    objc_registerClassPair(newocklass);
-	    rb_objc_install_array_primitives(newocklass);
-	    *(Class *)obj = newocklass;
-	    klass = rb_objc_import_class(newocklass);
-#endif
-	}
 	return klass;
     }
 #endif

Modified: MacRuby/trunk/compile.c
===================================================================
--- MacRuby/trunk/compile.c	2008-03-28 22:38:12 UTC (rev 121)
+++ MacRuby/trunk/compile.c	2008-03-29 05:20:07 UTC (rev 122)
@@ -1989,7 +1989,7 @@
 	    iseq_add_mark_object_compile_time(iseq, ary);
 #if WITH_OBJC
 	    if (node_root->flags & NODE_ARRAY_NAMED_ARGS)
-		FL_SET(ary, RARRAY_NAMED_ARGS);
+		rb_ary_set_named_args(ary, true);
 #endif
 	    ADD_INSN1(ret, nd_line(node_root), duparray, ary);
 	}

Modified: MacRuby/trunk/dir.c
===================================================================
--- MacRuby/trunk/dir.c	2008-03-28 22:38:12 UTC (rev 121)
+++ MacRuby/trunk/dir.c	2008-03-29 05:20:07 UTC (rev 122)
@@ -789,6 +789,7 @@
 	char *cwd = my_getcwd();
 
 	args.old_path = rb_tainted_str_new2(cwd); xfree(cwd);
+	rb_objc_retain(args.old_path);
 	args.new_path = path;
 	args.done = Qfalse;
 	return rb_ensure(chdir_yield, (VALUE)&args, chdir_restore, (VALUE)&args);

Modified: MacRuby/trunk/hash.c
===================================================================
--- MacRuby/trunk/hash.c	2008-03-28 22:38:12 UTC (rev 121)
+++ MacRuby/trunk/hash.c	2008-03-29 05:20:07 UTC (rev 122)
@@ -267,12 +267,12 @@
 };
 
 /* This variable will always stay NULL, we only use its address. */
-static void *rb_objc_assoc_key = NULL;
+static void *rb_objc_hash_assoc_key = NULL;
 
 static struct rb_objc_hash_struct *
 rb_objc_hash_get_struct(VALUE hash)
 {
-    return rb_objc_get_associative_ref((void *)hash, &rb_objc_assoc_key);
+    return rb_objc_get_associative_ref((void *)hash, &rb_objc_hash_assoc_key);
 }
 
 static struct rb_objc_hash_struct *
@@ -283,7 +283,7 @@
     s = rb_objc_hash_get_struct(hash);
     if (s == NULL) {
 	s = xmalloc(sizeof(struct rb_objc_hash_struct));
-	rb_objc_set_associative_ref((void *)hash, &rb_objc_assoc_key, s);
+	rb_objc_set_associative_ref((void *)hash, &rb_objc_hash_assoc_key, s);
 	s->ifnone = Qnil;
 	s->has_proc_default = false;
 	s->frozen = false;

Modified: MacRuby/trunk/include/ruby/intern.h
===================================================================
--- MacRuby/trunk/include/ruby/intern.h	2008-03-28 22:38:12 UTC (rev 121)
+++ MacRuby/trunk/include/ruby/intern.h	2008-03-29 05:20:07 UTC (rev 122)
@@ -79,6 +79,8 @@
 VALUE rb_get_values_at(VALUE, long, int, VALUE*, VALUE(*)(VALUE,long));
 #if WITH_OBJC
 VALUE rb_ary_elt(VALUE, long);
+void rb_ary_set_named_args(VALUE, bool);
+bool rb_ary_is_named_args(VALUE);
 #endif
 /* bignum.c */
 VALUE rb_big_clone(VALUE);

Modified: MacRuby/trunk/include/ruby/ruby.h
===================================================================
--- MacRuby/trunk/include/ruby/ruby.h	2008-03-28 22:38:12 UTC (rev 121)
+++ MacRuby/trunk/include/ruby/ruby.h	2008-03-29 05:20:07 UTC (rev 122)
@@ -535,9 +535,6 @@
 # define RARRAY_PTR(a) (rb_ary_ptr(a)) 
 # define RARRAY_AT(a,i) (rb_ary_elt(a, i))
 #endif
-#if WITH_OBJC
-# define RARRAY_NAMED_ARGS FL_USER1
-#endif
 
 struct RRegexp {
     struct RBasic basic;
@@ -728,7 +725,7 @@
 #define ALLOCA_N(type,n) (type*)alloca(sizeof(type)*(n))
 
 #define MEMZERO(p,type,n) memset((p), 0, sizeof(type)*(n))
-#if WITH_OBJC
+#if 0//WITH_OBJC
 void *rb_gc_memmove(void *, const void *, size_t); 
 # define MEMCPY(p1,p2,type,n) rb_gc_memmove((p1), (p2), sizeof(type)*(n))
 # define MEMMOVE(p1,p2,type,n) rb_gc_memmove((p1), (p2), sizeof(type)*(n))

Modified: MacRuby/trunk/insns.def
===================================================================
--- MacRuby/trunk/insns.def	2008-03-28 22:38:12 UTC (rev 121)
+++ MacRuby/trunk/insns.def	2008-03-29 05:20:07 UTC (rev 122)
@@ -439,7 +439,7 @@
 (VALUE val) // inc += 1 - num;
 {
     val = rb_ary_new4((long)num, STACK_ADDR_FROM_TOP(num));
-    FL_SET(val, RARRAY_NAMED_ARGS);
+    rb_ary_set_named_args(val, true);
     POPN(num);
 }
 
@@ -464,7 +464,7 @@
 (VALUE val)
 {
     val = rb_ary_dup(ary);
-    FL_SET(val, RARRAY_NAMED_ARGS);
+    rb_ary_set_named_args(val, true);
 }
 
 /**

Modified: MacRuby/trunk/io.c
===================================================================
--- MacRuby/trunk/io.c	2008-03-28 22:38:12 UTC (rev 121)
+++ MacRuby/trunk/io.c	2008-03-29 05:20:07 UTC (rev 122)
@@ -323,7 +323,7 @@
 	    fptr->rbuf_capa = len;
 	else
 	    fptr->rbuf_capa = 8192;
-        fptr->rbuf = ALLOC_N(char, fptr->rbuf_capa);
+        GC_WB(&fptr->rbuf, ALLOC_N(char, fptr->rbuf_capa));
     }
     if (fptr->rbuf_capa < len + fptr->rbuf_len) {
 	rb_raise(rb_eIOError, "ungetc failed");
@@ -695,7 +695,7 @@
         fptr->wbuf_off = 0;
         fptr->wbuf_len = 0;
         fptr->wbuf_capa = 8192;
-        fptr->wbuf = ALLOC_N(char, fptr->wbuf_capa);
+        GC_WB(&fptr->wbuf, ALLOC_N(char, fptr->wbuf_capa));
     }
     if ((fptr->mode & (FMODE_SYNC|FMODE_TTY)) ||
         (fptr->wbuf && fptr->wbuf_capa <= fptr->wbuf_len + len)) {
@@ -1012,7 +1012,7 @@
         fptr->rbuf_off = 0;
         fptr->rbuf_len = 0;
         fptr->rbuf_capa = 8192;
-        fptr->rbuf = ALLOC_N(char, fptr->rbuf_capa);
+        GC_WB(&fptr->rbuf, ALLOC_N(char, fptr->rbuf_capa));
     }
     if (fptr->rbuf_len == 0) {
       retry:
@@ -3430,7 +3430,7 @@
     struct pipe_list *list;
 
     list = ALLOC(struct pipe_list);
-    GC_GB(&list->fptr, fptr);
+    list->fptr = fptr;
     list->next = pipe_list;
     pipe_list = list;
 }

Modified: MacRuby/trunk/string.c
===================================================================
--- MacRuby/trunk/string.c	2008-03-28 22:38:12 UTC (rev 121)
+++ MacRuby/trunk/string.c	2008-03-29 05:20:07 UTC (rev 122)
@@ -359,7 +359,7 @@
     str = str_alloc(klass);
     if (len > RSTRING_EMBED_LEN_MAX) {
 	RSTRING(str)->as.heap.aux.capa = len;
-	RSTRING(str)->as.heap.ptr = ALLOC_N(char,len+1);
+	GC_WB(&RSTRING(str)->as.heap.ptr, ALLOC_N(char,len+1));
 	STR_SET_NOEMBED(str);
     }
     if (ptr) {
@@ -549,7 +549,7 @@
     }
     FL_SET(str, STR_NOEMBED);
     RSTRING(str)->as.heap.aux.capa = capa;
-    RSTRING(str)->as.heap.ptr = ALLOC_N(char, capa+1);
+    GC_WB(&RSTRING(str)->as.heap.ptr, ALLOC_N(char, capa+1));
     RSTRING(str)->as.heap.ptr[0] = '\0';
 
     return str;
@@ -982,7 +982,7 @@
     }
     STR_SET_NOEMBED(str);
     ptr[len] = 0;
-    RSTRING(str)->as.heap.ptr = ptr;
+    GC_WB(&RSTRING(str)->as.heap.ptr, ptr);
     RSTRING(str)->as.heap.len = len;
     RSTRING(str)->as.heap.aux.capa = len;
     STR_UNSET_NOCAPA(str);
@@ -4325,7 +4325,7 @@
 	    t += tlen;
 	}
 	*t = '\0';
-	RSTRING(str)->as.heap.ptr = buf;
+	GC_WB(&RSTRING(str)->as.heap.ptr, buf);
 	RSTRING(str)->as.heap.len = t - buf;
 	STR_SET_NOEMBED(str);
 	RSTRING(str)->as.heap.aux.capa = max;
@@ -4389,7 +4389,7 @@
 	    xfree(RSTRING(str)->as.heap.ptr);
 	}
 	*t = '\0';
-	RSTRING(str)->as.heap.ptr = buf;
+	GC_WB(&RSTRING(str)->as.heap.ptr, buf);
 	RSTRING(str)->as.heap.len = t - buf;
 	STR_SET_NOEMBED(str);
 	RSTRING(str)->as.heap.aux.capa = max;

Modified: MacRuby/trunk/vm_insnhelper.c
===================================================================
--- MacRuby/trunk/vm_insnhelper.c	2008-03-28 22:38:12 UTC (rev 121)
+++ MacRuby/trunk/vm_insnhelper.c	2008-03-29 05:20:07 UTC (rev 122)
@@ -1120,13 +1120,10 @@
     NODE *mn;
     char buf[128];
 
-    if (0) {
-#if 0 /* FIXME */
-	/* *pmn == NULL 
+    if (/* *pmn == NULL 
 	&&*/ *pnum == 2 
 	&& TYPE(argv[1]) == T_ARRAY 
-	&& FL_TEST(argv[1], RARRAY_NAMED_ARGS)) {
-#endif
+	&& rb_ary_is_named_args(argv[1])) {
 
 	unsigned i, count;
 
@@ -1146,12 +1143,9 @@
 	    strncat(buf, ":", sizeof buf);
 	}
 
-//printf("buf is %s\n", buf);
-
 	id = rb_intern(buf);
 	if ((mn = rb_method_node(CLASS_OF(recv), id)) != NULL 
 	    || (mn = rb_objc_define_objc_mid_closure(recv, id, NULL)) != NULL) {
-#if 1
 	    unsigned j, newnum = 1 + (count / 2);
 	    void **new_argv = alloca(sizeof(void *) * newnum);
 	    new_argv[0] = (void *)argv[0];
@@ -1162,7 +1156,6 @@
 	    cfp->bp -= newnum - *pnum;
 
 	    memcpy(argv, new_argv, sizeof(void *) * newnum);
-#endif
 	    *pmn = mn;
 	    *pid = id;
 	    *pnum = newnum;

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macruby-changes/attachments/20080328/a597e02f/attachment-0001.html


More information about the macruby-changes mailing list