[macruby-changes] [900] MacRuby/branches/experimental

source_changes at macosforge.org source_changes at macosforge.org
Thu Mar 12 20:23:14 PDT 2009


Revision: 900
          http://trac.macosforge.org/projects/ruby/changeset/900
Author:   lsansonetti at apple.com
Date:     2009-03-12 20:23:13 -0700 (Thu, 12 Mar 2009)
Log Message:
-----------
fixed IO regressions + other bugs

Modified Paths:
--------------
    MacRuby/branches/experimental/Rakefile
    MacRuby/branches/experimental/class.c
    MacRuby/branches/experimental/encoding.c
    MacRuby/branches/experimental/file.c
    MacRuby/branches/experimental/include/ruby/io.h
    MacRuby/branches/experimental/include/ruby/ruby.h
    MacRuby/branches/experimental/inits.c
    MacRuby/branches/experimental/io.c
    MacRuby/branches/experimental/process.c
    MacRuby/branches/experimental/roxor.cpp
    MacRuby/branches/experimental/ruby.c
    MacRuby/branches/experimental/string.c
    MacRuby/branches/experimental/variable.c

Modified: MacRuby/branches/experimental/Rakefile
===================================================================
--- MacRuby/branches/experimental/Rakefile	2009-03-13 02:37:24 UTC (rev 899)
+++ MacRuby/branches/experimental/Rakefile	2009-03-13 03:23:13 UTC (rev 900)
@@ -92,10 +92,10 @@
 LDFLAGS << " -lpthread -ldl -lxml2 -lobjc -lffi -lauto -framework Foundation"
 DLDFLAGS = "-dynamiclib -undefined suppress -flat_namespace -install_name #{INSTALL_NAME} -current_version #{MACRUBY_VERSION} -compatibility_version #{MACRUBY_VERSION}"
 
-# removed: marshal, file, process
+# removed: marshal
 OBJS = %w{ 
   array bignum class compar complex enum enumerator error eval file load proc 
-  gc hash inits io math numeric object pack parse prec  
+  gc hash inits io math numeric object pack parse prec dir process
   random range rational re regcomp regenc regerror regexec regparse regsyntax
   ruby set signal sprintf st string struct time transcode util variable version
   thread id objc bs encoding main dln dmyext enc/ascii 

Modified: MacRuby/branches/experimental/class.c
===================================================================
--- MacRuby/branches/experimental/class.c	2009-03-13 02:37:24 UTC (rev 899)
+++ MacRuby/branches/experimental/class.c	2009-03-13 03:23:13 UTC (rev 900)
@@ -112,8 +112,9 @@
     rb_objc_define_method(klass, "initialize_copy", rb_obj_init_copy, 1);
 
     static SEL sel_isEqual = 0;
-    if (sel_isEqual == 0)
+    if (sel_isEqual == 0) {
 	sel_isEqual = sel_registerName("isEqual:");
+    }
     class_addMethod((Class)klass, sel_isEqual, (IMP)rb_obj_imp_isEqual, "c@:@");
 
     class_addMethod((Class)klass, selInit, (IMP)rb_obj_imp_init, "@@:");

Modified: MacRuby/branches/experimental/encoding.c
===================================================================
--- MacRuby/branches/experimental/encoding.c	2009-03-13 02:37:24 UTC (rev 899)
+++ MacRuby/branches/experimental/encoding.c	2009-03-13 03:23:13 UTC (rev 900)
@@ -33,7 +33,7 @@
 {
     const CFStringEncoding *e;
 
-    __encodings = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
+    __encodings = CFDictionaryCreateMutable(NULL, 0, NULL, &kCFTypeDictionaryValueCallBacks);
     
     /* XXX CFStringGetListOfAvailableEncodings() is a costly call and should
      * be called on demand and not by default when the interpreter starts.

Modified: MacRuby/branches/experimental/file.c
===================================================================
--- MacRuby/branches/experimental/file.c	2009-03-13 02:37:24 UTC (rev 899)
+++ MacRuby/branches/experimental/file.c	2009-03-13 03:23:13 UTC (rev 900)
@@ -11,14 +11,6 @@
 
 **********************************************************************/
 
-#ifdef _WIN32
-#include "missing/file.h"
-#endif
-#ifdef __CYGWIN__
-#include <windows.h>
-#include <sys/cygwin.h>
-#endif
-
 #include "ruby/ruby.h"
 #include "ruby/io.h"
 #include "ruby/signal.h"

Modified: MacRuby/branches/experimental/include/ruby/io.h
===================================================================
--- MacRuby/branches/experimental/include/ruby/io.h	2009-03-13 02:37:24 UTC (rev 899)
+++ MacRuby/branches/experimental/include/ruby/io.h	2009-03-13 03:23:13 UTC (rev 900)
@@ -29,38 +29,9 @@
     CFStringRef path;
     pid_t pid;
     int lineno;
+    int fd;
 } rb_io_t;
 
-
-#define CreateIOStruct(obj, fp) do {\
-    if (RFILE(obj)->fptr) {\
-	rb_io_close(obj);\
-	free(RFILE(obj)->fptr);\
-	RFILE(obj)->fptr = 0;\
-    }\
-    fp = 0;\
-    fp = RFILE(obj)->fptr = ALLOC(rb_io_t);\
-    fp->fd = -1;\
-    fp->stdio_file = NULL;\
-    fp->mode = 0;\
-    fp->pid = 0;\
-    fp->lineno = 0;\
-    fp->path = NULL;\
-    fp->finalize = 0;\
-    fp->refcnt = 1;\
-    fp->wbuf = NULL;\
-    fp->wbuf_off = 0;\
-    fp->wbuf_len = 0;\
-    fp->wbuf_capa = 0;\
-    fp->rbuf = NULL;\
-    fp->rbuf_off = 0;\
-    fp->rbuf_len = 0;\
-    fp->rbuf_capa = 0;\
-    fp->tied_io_for_writing = 0;\
-    fp->enc = 0;\
-    fp->enc2 = 0;\
-} while (0)
-
 #define HAVE_RB_IO_T 1
 
 #define FMODE_READABLE  1

Modified: MacRuby/branches/experimental/include/ruby/ruby.h
===================================================================
--- MacRuby/branches/experimental/include/ruby/ruby.h	2009-03-13 02:37:24 UTC (rev 899)
+++ MacRuby/branches/experimental/include/ruby/ruby.h	2009-03-13 03:23:13 UTC (rev 900)
@@ -671,7 +671,8 @@
     void *data;
 };
 
-#define ExtractIOStruct(obj) RFILE(rb_io_taint_check(obj))->fptr
+#define ExtractIOStruct(obj) RFILE(obj)->fptr
+//#define ExtractIOStruct(obj) RFILE(rb_io_taint_check(obj))->fptr
 
 #define DATA_PTR(dta) (RDATA(dta)->data)
 

Modified: MacRuby/branches/experimental/inits.c
===================================================================
--- MacRuby/branches/experimental/inits.c	2009-03-13 02:37:24 UTC (rev 899)
+++ MacRuby/branches/experimental/inits.c	2009-03-13 03:23:13 UTC (rev 900)
@@ -17,7 +17,7 @@
 void Init_Comparable(void);
 void Init_Complex(void);
 void Init_transcode(void);
-//void Init_Dir(void);
+void Init_Dir(void);
 void Init_Enumerable(void);
 void Init_Enumerator(void);
 void Init_Exception(void);
@@ -37,7 +37,7 @@
 void Init_Precision(void);
 void Init_sym(void);
 void Init_id(void);
-//void Init_process(void);
+void Init_process(void);
 void Init_Random(void);
 void Init_Range(void);
 void Init_Rational(void);
@@ -82,14 +82,14 @@
     Init_Regexp();
     Init_pack();
     Init_transcode();
-    // Init_marshal();
+    //Init_marshal();
     Init_Range();
     Init_IO();
-    // Init_Dir();
+    Init_Dir();
     Init_Time();
     Init_Random();
     Init_signal();
-//    Init_process();
+    Init_process();
     Init_load();
     Init_Proc();
     Init_Binding();

Modified: MacRuby/branches/experimental/io.c
===================================================================
--- MacRuby/branches/experimental/io.c	2009-03-13 02:37:24 UTC (rev 899)
+++ MacRuby/branches/experimental/io.c	2009-03-13 03:23:13 UTC (rev 900)
@@ -90,7 +90,6 @@
         UPDATE_MAXFD((filedes)[1]); \
     } while (0)
 
-
 #define argf_of(obj) (*(struct argf *)DATA_PTR(obj))
 #define ARGF argf_of(argf)
 
@@ -112,61 +111,79 @@
 VALUE
 rb_io_taint_check(VALUE io)
 {
-    if (!OBJ_TAINTED(io) && rb_safe_level() >= 4)
+    if (!OBJ_TAINTED(io) && rb_safe_level() >= 4) {
 	rb_raise(rb_eSecurityError, "Insecure: operation on untainted IO");
+    }
     rb_check_frozen(io);
     return io;
 }
 
-void
+static void
 rb_io_check_initialized(rb_io_t *fptr)
 {
-    if (!fptr) {
-	    rb_raise(rb_eIOError, "uninitialized stream");
+    if (fptr == NULL) {
+	rb_raise(rb_eIOError, "uninitialized stream");
     }
 }
 
-void rb_io_assert_writable(rb_io_t *io_struct) {
+static void 
+rb_io_assert_writable(rb_io_t *io_struct)
+{
     rb_io_check_initialized(io_struct);
-    if(CFWriteStreamGetStatus(io_struct->writeStream) != kCFStreamStatusOpen) {
+    if (io_struct->writeStream == NULL
+	|| CFWriteStreamGetStatus(io_struct->writeStream) != kCFStreamStatusOpen) {
         rb_raise(rb_eIOError, "unable to read stream");
     }
 }
 
-void rb_io_assert_readable(rb_io_t *io_struct) {
+static void
+rb_io_assert_readable(rb_io_t *io_struct)
+{
     rb_io_check_initialized(io_struct);
-    if(CFReadStreamGetStatus(io_struct->readStream) != kCFStreamStatusOpen) {
+    if (io_struct->readStream == NULL
+	|| CFReadStreamGetStatus(io_struct->readStream) != kCFStreamStatusOpen) {
         rb_raise(rb_eIOError, "unable to read stream");
     }
 }
 
-bool rb_io_is_open(rb_io_t *io_struct) {
-    return ((CFReadStreamGetStatus(io_struct->readStream) == kCFStreamStatusOpen) &&
-            (CFWriteStreamGetStatus(io_struct->writeStream) == kCFStreamStatusOpen));
-}
-
-FILE* rb_io_get_write_stream_file_struct(rb_io_t *io_struct)
+static bool
+rb_io_is_open(rb_io_t *io_struct) 
 {
-    return (FILE*)CFWriteStreamCopyProperty(io_struct->writeStream, 
-        kCFStreamPropertySocketNativeHandle);
+    return (io_struct->readStream == NULL
+	    || CFReadStreamGetStatus(io_struct->readStream) == kCFStreamStatusOpen)
+	&& (io_struct->writeStream == NULL
+	    || CFWriteStreamGetStatus(io_struct->writeStream) == kCFStreamStatusOpen);
 }
 
-
-FILE* rb_io_get_read_stream_file_struct(rb_io_t *io_struct)
+#if 0
+// These methods are not used yet.
+static int
+rb_io_get_fd_from_data(CFDataRef data)
 {
-    return (FILE*)CFReadStreamCopyProperty(io_struct->readStream, 
-        kCFStreamPropertySocketNativeHandle);
+    assert(data != NULL);
+    int fd;
+    assert(CFDataGetLength(data) == sizeof(fd));
+    CFDataGetBytes(data, CFRangeMake(0, sizeof(fd)), (UInt8 *)&fd);
+    CFRelease(data);
+    return fd;
 }
 
-int rb_io_get_write_stream_fd(rb_io_t *io_struct)
+static int
+rb_io_get_read_stream_fd(rb_io_t *io_struct)
 {
-    return fileno(rb_io_get_write_stream_file_struct(io_struct));
+    CFDataRef data = CFReadStreamCopyProperty(io_struct->readStream, 
+	    kCFStreamPropertySocketNativeHandle);
+    return rb_io_get_fd_from_data(data);
 }
 
-int rb_io_get_read_stream_fd(rb_io_t *io_struct)
+static int
+rb_io_get_write_stream_fd(rb_io_t *io_struct)
 {
-    return fileno(rb_io_get_read_stream_file_struct(io_struct));
+    CFDataRef data = CFWriteStreamCopyProperty(io_struct->writeStream, 
+	    kCFStreamPropertySocketNativeHandle);
+    return rb_io_get_fd_from_data(data);
 }
+#endif
 
 #define FMODE_PREP (1<<16)
 #define IS_PREP_STDIO(f) ((f)->mode & FMODE_PREP)
@@ -236,24 +253,57 @@
     struct RFile *io = ALLOC(struct RFile);
     OBJSETUP(io, klass, T_FILE);
     GC_WB(&io->fptr, ALLOC(rb_io_t));
-    MEMZERO(io->fptr, rb_io_t, 1);
     return (VALUE)io;
 }
 
 static VALUE
 prep_io(int fd, int mode, VALUE klass, const char *path)
 {
+    // TODO honor mode
+
     VALUE io = io_alloc(rb_cIO, 0);
-    CFReadStreamRef r;
-    CFWriteStreamRef w;
-    CFStreamCreatePairWithSocket(NULL, fd, &r, &w);
-    CFReadStreamOpen(r);
-    CFWriteStreamOpen(w);
+
+    CFReadStreamRef r = NULL;
+    CFWriteStreamRef w = NULL;
+    
+    if (path != NULL) {
+	CFURLRef url = CFURLCreateFromFileSystemRepresentation(NULL,
+		(const UInt8 *)path, strlen(path), false);
+	assert(url != NULL);
+	if (mode & FMODE_READABLE) {
+	    r = CFReadStreamCreateWithFile(NULL, url);
+	    assert(r != NULL);
+	}
+	if (mode & FMODE_WRITABLE) {
+	    w = CFWriteStreamCreateWithFile(NULL, url);
+	    assert(w != NULL);
+	}
+	CFRelease(url);	
+    }
+    else {
+	// TODO
+	//CFStreamCreatePairWithSocket(NULL, fd, &r, &w);
+	abort();
+    }
+
+    assert(r != NULL || w != NULL);
+
+    if (r != NULL && !CFReadStreamOpen(r)) {
+	rb_raise(rb_eRuntimeError, "cannot open read stream");
+    }
+    if (w != NULL && !CFWriteStreamOpen(w)) {
+	rb_raise(rb_eRuntimeError, "cannot open write stream");
+    }
+
     GC_WB(&RFILE(io)->fptr->readStream, r);
     GC_WB(&RFILE(io)->fptr->writeStream, w);
-    CFMakeCollectable(r);
-    CFMakeCollectable(w);
+    
+    //CFMakeCollectable(r);
+    //CFMakeCollectable(w);
+    
+    RFILE(io)->fptr->fd = fd;
     rb_objc_keep_for_exit_finalize((VALUE)io);
+
     return io;
 }
 
@@ -294,15 +344,32 @@
     
     io_struct = ExtractIOStruct(io);
     rb_io_assert_writable(io_struct);
+
     // TODO: Account for the port not being IO, use funcall to call .write()
     // instead.
+
     to_write = rb_obj_as_string(to_write);
-    buffer = (UInt8*)rb_str_byteptr(to_write);
-    length = (CFIndex)rb_str_bytelen(to_write);
-    
-    if(length == 0) {
+
+    if (CLASS_OF(to_write) == rb_cByteString) {
+	CFMutableDataRef data = rb_bytestring_wrapped_data(to_write);
+	buffer = CFDataGetMutableBytePtr(data);
+	length = CFDataGetLength(data);
+    }
+    else {
+	buffer = (UInt8 *)CFStringGetCStringPtr((CFStringRef)to_write, kCFStringEncodingUTF8);
+	if (buffer != NULL) {
+	    length = CFStringGetLength((CFStringRef)to_write);
+	}
+	else {
+	    buffer = (UInt8 *)rb_str_byteptr(to_write);
+	    length = (CFIndex)rb_str_bytelen(to_write);
+	}
+    }
+
+    if (length == 0) {
         return INT2FIX(0);
     }
+
     return LONG2FIX(CFWriteStreamWrite(io_struct->writeStream, buffer, length));
 }
 
@@ -583,7 +650,7 @@
 rb_io_fileno(VALUE io, SEL sel)
 {
     rb_io_t *io_struct = ExtractIOStruct(io);
-    return INT2FIX(rb_io_get_read_stream_fd(io_struct));
+    return INT2FIX(io_struct->fd);
 }
 
 
@@ -1977,11 +2044,11 @@
  *     f = File.new("newfile", File::CREAT|File::TRUNC|File::RDWR, 0644)
  */
 
-// static VALUE
-// rb_file_initialize(VALUE io, SEL sel, int argc, VALUE *argv)
-// {
-// rb_notimplement();
-// }
+static VALUE
+rb_file_initialize(VALUE io, SEL sel, int argc, VALUE *argv)
+{
+    rb_notimplement();
+}
 
 /*
  *  call-seq:
@@ -2076,17 +2143,19 @@
 // rb_notimplement();
 // }
 
+#if 0
 static VALUE
 argf_lineno_getter(ID id, VALUE *var)
 {
-rb_notimplement();
+    rb_notimplement();
 }
 
 static void
 argf_lineno_setter(VALUE val, ID id, VALUE *var)
 {
-rb_notimplement();
+    rb_notimplement();
 }
+#endif
 
 /*
  *  call-seq:
@@ -2649,16 +2718,18 @@
 rb_notimplement();
 }
 
+#if 0
 static VALUE
 argf_filename_getter(ID id, VALUE *var)
 {
-rb_notimplement();
+    rb_notimplement();
 }
+#endif
 
 static VALUE
 argf_file(VALUE argf, SEL sel)
 {
-rb_notimplement();
+    rb_notimplement();
 }
 
 static VALUE
@@ -2697,23 +2768,27 @@
 rb_notimplement();
 }
 
+#if 0
 static VALUE
 opt_i_get(ID id, VALUE *var)
 {
-rb_notimplement();
+    rb_notimplement();
 }
+#endif
 
 static VALUE
 argf_inplace_mode_set(VALUE argf, VALUE val)
 {
-rb_notimplement();
+    rb_notimplement();
 }
 
+#if 0
 static void
 opt_i_set(VALUE val, ID id, VALUE *var)
 {
-rb_notimplement();
+    rb_notimplement();
 }
+#endif
 
 const char *
 ruby_get_inplace_mode(void)
@@ -2733,16 +2808,19 @@
 rb_notimplement();
 }
 
+#if 0
 static VALUE
 argf_argv_getter(ID id, VALUE *var)
 {
-rb_notimplement();
+    rb_notimplement();
 }
+#endif
 
 VALUE
 rb_get_argv(void)
 {
-rb_notimplement();
+    // TODO
+    return Qnil;
 }
 
 /*
@@ -2825,13 +2903,18 @@
 void
 rb_write_error2(const char *mesg, long len)
 {
-    rb_notimplement();
+    if (rb_stderr == orig_stderr || RFILE(orig_stderr)->fptr->fd < 0) {
+	fwrite(mesg, sizeof(char), len, stderr);
+    }
+    else {
+	rb_io_write(rb_stderr, 0, rb_str_new(mesg, len));
+    }
 }
 
 void
 rb_write_error(const char *mesg)
 {
-    rb_notimplement();
+    rb_write_error2(mesg, strlen(mesg));
 }
 
 static void
@@ -2996,26 +3079,23 @@
     rb_objc_define_method(rb_cIO, "internal_encoding", rb_io_internal_encoding, 0);
     rb_objc_define_method(rb_cIO, "set_encoding", rb_io_set_encoding, -1);
 
-
     // TODO: Replace these with their real equivalents - they're nil now.
-    rb_stdin = prep_stdio(stdin, FMODE_READABLE, rb_cIO, "<STDIN>");
+    rb_stdin = prep_stdio(stdin, FMODE_READABLE, rb_cIO, "/dev/stdin");
     rb_define_variable("$stdin", &rb_stdin);
     rb_define_global_const("STDIN", rb_stdin);
     
-    rb_stdout = prep_stdio(stdout, FMODE_WRITABLE, rb_cIO, "<STDOUT>");
+    rb_stdout = prep_stdio(stdout, FMODE_WRITABLE, rb_cIO, "/dev/stdout");
     rb_define_hooked_variable("$stdout", &rb_stdout, 0, stdout_setter);
     rb_define_hooked_variable("$>", &rb_stdout, 0, stdout_setter);
     rb_define_global_const("STDOUT", rb_stdout);
     
-    rb_stderr = prep_stdio(stderr, FMODE_WRITABLE|FMODE_SYNC, rb_cIO, "<STDERR>");
+    rb_stderr = prep_stdio(stderr, FMODE_WRITABLE|FMODE_SYNC, rb_cIO, "/dev/stderr");
     rb_define_hooked_variable("$stderr", &rb_stderr, 0, stdout_setter);
     rb_define_global_const("STDERR", rb_stderr);
-    
-
+ 
     orig_stdout = rb_stdout;
     rb_deferr = orig_stderr = rb_stderr;
 
-
     rb_cARGF = rb_class_new(rb_cObject);
     rb_set_class_path(rb_cARGF, rb_cObject, "ARGF.class");
     rb_objc_define_method(*(VALUE *)rb_cARGF, "alloc", argf_alloc, 0);
@@ -3076,6 +3156,7 @@
 
     argf = Qnil;
 
+#if 0 // TODO
     rb_define_readonly_variable("$<", &argf);
     rb_define_global_const("ARGF", argf);
 
@@ -3085,34 +3166,35 @@
 
     rb_define_hooked_variable("$-i", &argf, opt_i_get, opt_i_set);
     rb_define_hooked_variable("$*", &argf, argf_argv_getter, 0);
-    
-    //Init_File();
+#endif
 
-    //rb_objc_define_method(rb_cFile, "initialize",  rb_file_initialize, -1);
-// 
-//     rb_file_const("RDONLY", INT2FIX(O_RDONLY));
-//     rb_file_const("WRONLY", INT2FIX(O_WRONLY));
-//     rb_file_const("RDWR", INT2FIX(O_RDWR));
-//     rb_file_const("APPEND", INT2FIX(O_APPEND));
-//     rb_file_const("CREAT", INT2FIX(O_CREAT));
-//     rb_file_const("EXCL", INT2FIX(O_EXCL));
-// #if defined(O_NDELAY) || defined(O_NONBLOCK)
-// #   ifdef O_NONBLOCK
-//     rb_file_const("NONBLOCK", INT2FIX(O_NONBLOCK));
-// #   else
-//     rb_file_const("NONBLOCK", INT2FIX(O_NDELAY));
-// #   endif
-// #endif
-//     rb_file_const("TRUNC", INT2FIX(O_TRUNC));
-// #ifdef O_NOCTTY
-//     rb_file_const("NOCTTY", INT2FIX(O_NOCTTY));
-// #endif
-// #ifdef O_BINARY
-//     rb_file_const("BINARY", INT2FIX(O_BINARY));
-// #else
-//     rb_file_const("BINARY", INT2FIX(0));
-// #endif
-// #ifdef O_SYNC
-//     rb_file_const("SYNC", INT2FIX(O_SYNC));
-// #endif
+    Init_File();
+
+    rb_objc_define_method(rb_cFile, "initialize",  rb_file_initialize, -1);
+
+    rb_file_const("RDONLY", INT2FIX(O_RDONLY));
+    rb_file_const("WRONLY", INT2FIX(O_WRONLY));
+    rb_file_const("RDWR", INT2FIX(O_RDWR));
+    rb_file_const("APPEND", INT2FIX(O_APPEND));
+    rb_file_const("CREAT", INT2FIX(O_CREAT));
+    rb_file_const("EXCL", INT2FIX(O_EXCL));
+#if defined(O_NDELAY) || defined(O_NONBLOCK)
+# ifdef O_NONBLOCK
+    rb_file_const("NONBLOCK", INT2FIX(O_NONBLOCK));
+# else
+    rb_file_const("NONBLOCK", INT2FIX(O_NDELAY));
+# endif
+#endif
+    rb_file_const("TRUNC", INT2FIX(O_TRUNC));
+#ifdef O_NOCTTY
+    rb_file_const("NOCTTY", INT2FIX(O_NOCTTY));
+#endif
+#ifdef O_BINARY
+    rb_file_const("BINARY", INT2FIX(O_BINARY));
+#else
+    rb_file_const("BINARY", INT2FIX(0));
+#endif
+#ifdef O_SYNC
+    rb_file_const("SYNC", INT2FIX(O_SYNC));
+#endif
 }

Modified: MacRuby/branches/experimental/process.c
===================================================================
--- MacRuby/branches/experimental/process.c	2009-03-13 02:37:24 UTC (rev 899)
+++ MacRuby/branches/experimental/process.c	2009-03-13 03:23:13 UTC (rev 900)
@@ -1261,6 +1261,7 @@
 static VALUE
 check_exec_redirect_fd(VALUE v)
 {
+#if 0 // TODO
     VALUE tmp;
     int fd;
     if (FIXNUM_P(v)) {
@@ -1280,6 +1281,8 @@
         rb_raise(rb_eArgError, "negative file descriptor");
     }
     return INT2FIX(fd);
+#endif
+    abort();
 }
 
 static void
@@ -1319,7 +1322,7 @@
         if (NIL_P(flags))
             flags = INT2NUM(O_RDONLY);
         else if (TYPE(flags) == T_STRING)
-            flags = INT2NUM(rb_io_mode_modenum(StringValueCStr(flags)));
+            flags = INT2FIX(0);//TODO INT2NUM(rb_io_mode_modenum(StringValueCStr(flags)));
         else
             flags = rb_to_int(flags);
         perm = rb_ary_entry(val, 2);
@@ -2159,7 +2162,7 @@
 #ifdef HAVE_FORK
     obj = rb_ary_entry(options, EXEC_OPTION_CLOSE_OTHERS);
     if (obj != Qfalse) {
-        rb_close_before_exec(3, FIX2LONG(obj), e->redirect_fds);
+        // TODO rb_close_before_exec(3, FIX2LONG(obj), e->redirect_fds);
     }
 #endif
 
@@ -2212,6 +2215,7 @@
 #if SIZEOF_INT == SIZEOF_LONG
 #define proc_syswait (VALUE (*)(VALUE))rb_syswait
 #else
+#if 0 // not used
 static VALUE
 proc_syswait(VALUE pid)
 {
@@ -2220,7 +2224,9 @@
 }
 #endif
 #endif
+#endif
 
+#if 0 // not used
 static int
 move_fds_to_avoid_crash(int *fdp, int n, VALUE fds)
 {
@@ -2242,7 +2248,9 @@
     }
     return 0;
 }
+#endif
 
+#if 0 // not used
 static int
 pipe_nocrash(int filedes[2], VALUE fds)
 {
@@ -2261,6 +2269,7 @@
     }
     return ret;
 }
+#endif
 
 /*
  * Forks child process, and returns the process ID in the parent
@@ -2288,6 +2297,7 @@
 rb_pid_t
 rb_fork(int *status, int (*chfunc)(void*), void *charg, VALUE fds)
 {
+#if 0 // TODO
     rb_pid_t pid;
     int err, state = 0;
 #ifdef FD_CLOEXEC
@@ -2378,6 +2388,8 @@
     }
 #endif
     return pid;
+#endif
+    abort();
 }
 #endif
 

Modified: MacRuby/branches/experimental/roxor.cpp
===================================================================
--- MacRuby/branches/experimental/roxor.cpp	2009-03-13 02:37:24 UTC (rev 899)
+++ MacRuby/branches/experimental/roxor.cpp	2009-03-13 03:23:13 UTC (rev 900)
@@ -1671,20 +1671,27 @@
     if (type == NODE_SCOPE) {
 	NODE *n = node->nd_args;
 	int arity = 0;
-	bool default_args = false;
+	bool opt_or_splat = false;
 	if (n != NULL) {
 	    arity = n->nd_frml;
 	    NODE *n_opt = n->nd_opt;
 	    if (n_opt != NULL) {
 		NODE *ni = n_opt;
-		default_args = true;
+		opt_or_splat = true;
 		while (ni != NULL) {
 		    arity++;
 		    ni = ni->nd_next;
 		}
 	    }
+#if 0
+	    NODE *n_aux = n->nd_next;
+	    if (n_aux != NULL) {
+		opt_or_splat = true;
+		arity++;
+	    }
+#endif
 	}
-	return default_args && negative_arity ? -arity : arity;
+	return opt_or_splat && negative_arity ? -arity : arity;
     }
 
     if (type == NODE_FBODY) {

Modified: MacRuby/branches/experimental/ruby.c
===================================================================
--- MacRuby/branches/experimental/ruby.c	2009-03-13 02:37:24 UTC (rev 899)
+++ MacRuby/branches/experimental/ruby.c	2009-03-13 03:23:13 UTC (rev 900)
@@ -629,22 +629,6 @@
     rb_warn("don't know how to dump `%.*s', (insns)", len, str);
 }
 
-void
-rb_exit(int status)
-{
-#if 0 // XXX should we call pthread_exit()
-    if (GET_THREAD()->tag) {
-	VALUE args[2];
-
-	args[0] = INT2NUM(status);
-	args[1] = rb_str_new2("exit");
-	rb_exc_raise(rb_class_new_instance(2, args, rb_eSystemExit));
-    }
-#endif
-    ruby_finalize();
-    exit(status);
-}
-
 static int
 proc_options(int argc, char **argv, struct cmdline_options *opt)
 {
@@ -1130,7 +1114,7 @@
 #endif
     GC_WB(&opt->script_name, rb_str_new4(rb_progname));
     opt->script = RSTRING_PTR(opt->script_name);
-    //ruby_set_argv(argc, argv);
+    ruby_set_argv(argc, argv);
     process_sflag(opt);
 
     ruby_init_loadpath();
@@ -1599,8 +1583,8 @@
     rb_define_hooked_variable("$PROGRAM_NAME", &rb_progname, 0, set_arg0);
     GC_ROOT(&rb_progname);
 
-    //rb_define_global_const("ARGV", rb_argv);
-    //rb_global_variable(&rb_argv0);
+    rb_define_global_const("ARGV", rb_argv);
+    rb_global_variable(&rb_argv0);
 
 #ifdef MSDOS
     /*
@@ -1615,6 +1599,7 @@
 void
 ruby_set_argv(int argc, char **argv)
 {
+#if 0 // TODO
     int i;
     VALUE av = rb_argv;
 
@@ -1631,6 +1616,7 @@
 	OBJ_FREEZE(arg);
 	rb_ary_push(av, arg);
     }
+#endif
 }
 
 static VALUE

Modified: MacRuby/branches/experimental/string.c
===================================================================
--- MacRuby/branches/experimental/string.c	2009-03-13 02:37:24 UTC (rev 899)
+++ MacRuby/branches/experimental/string.c	2009-03-13 03:23:13 UTC (rev 900)
@@ -5644,7 +5644,8 @@
     rb_objc_define_method(rb_cSymbol, "intern", sym_to_sym, 0);
     rb_objc_define_method(rb_cSymbol, "to_sym", sym_to_sym, 0);
     
-        
+    install_symbol_primitives();
+
     rb_cByteString = (VALUE)objc_allocateClassPair((Class)objc_getClass("NSMutableString"), "ByteString", 0);
     class_addIvar((Class)rb_cByteString, "wrappedData", sizeof(id), 0, "@");
     rb_objc_install_method2((Class)rb_cByteString, "length", (IMP)imp_rb_bytestring_length);
@@ -5654,8 +5655,5 @@
     rb_objc_define_method(rb_cByteString, "initialize", rb_bytestring_initialize, -1);
     rb_objc_define_method(*(VALUE *)rb_cByteString, "alloc", rb_bytestring_alloc, 0);
 
-    
     wrappedDataOffset = ivar_getOffset(class_getInstanceVariable((Class)rb_cByteString, "wrappedData"));
-
-    install_symbol_primitives();
 }

Modified: MacRuby/branches/experimental/variable.c
===================================================================
--- MacRuby/branches/experimental/variable.c	2009-03-13 02:37:24 UTC (rev 899)
+++ MacRuby/branches/experimental/variable.c	2009-03-13 03:23:13 UTC (rev 900)
@@ -858,7 +858,8 @@
 	    rb_error_frozen("object");
     }
     if (generic_iv_dict == NULL) {
-	generic_iv_dict = CFDictionaryCreateMutable(kCFAllocatorMalloc, 0, NULL, &rb_cfdictionary_value_cb);
+	generic_iv_dict = CFDictionaryCreateMutable(NULL, 0, NULL, &rb_cfdictionary_value_cb);
+	rb_objc_retain(generic_iv_dict);
 	obj_dict = NULL;
     }
     else {
@@ -866,7 +867,7 @@
 	    (CFDictionaryRef)generic_iv_dict, (const void *)obj);
     }
     if (obj_dict == NULL) {
-	obj_dict = CFDictionaryCreateMutable(kCFAllocatorMalloc, 0, NULL, &rb_cfdictionary_value_cb);
+	obj_dict = CFDictionaryCreateMutable(NULL, 0, NULL, &rb_cfdictionary_value_cb);
 	CFDictionarySetValue(generic_iv_dict, (const void *)obj, 
 	    (const void *)obj_dict);
 	CFMakeCollectable(obj_dict);
@@ -939,7 +940,7 @@
 	&& clone_dict != NULL)
 	CFDictionaryRemoveValue(generic_iv_dict, (const void *)clone);
 
-    clone_dict = CFDictionaryCreateMutableCopy(kCFAllocatorMalloc, 0, obj_dict);
+    clone_dict = CFDictionaryCreateMutableCopy(NULL, 0, obj_dict);
     CFDictionarySetValue(generic_iv_dict, (const void *)clone, 
 	(const void *)clone_dict);
     CFMakeCollectable(clone_dict);
@@ -982,7 +983,8 @@
     }
     else {
 	if (generic_iv_dict == NULL) {
-	    generic_iv_dict = CFDictionaryCreateMutable(kCFAllocatorMalloc, 0, NULL, &rb_cfdictionary_value_cb);
+	    generic_iv_dict = CFDictionaryCreateMutable(NULL, 0, NULL, &rb_cfdictionary_value_cb);
+	    rb_objc_retain(generic_iv_dict);
 	}
 	CFDictionarySetValue(generic_iv_dict, (const void *)mod, (const void *)dict);
     }
@@ -995,7 +997,7 @@
 
     dict = rb_class_ivar_dict(mod);
     if (dict == NULL) {
-	dict = CFDictionaryCreateMutable(kCFAllocatorMalloc, 0, NULL, &rb_cfdictionary_value_cb);
+	dict = CFDictionaryCreateMutable(NULL, 0, NULL, &rb_cfdictionary_value_cb);
 	rb_class_ivar_set_dict(mod, dict);
 	CFMakeCollectable(dict);
     }
@@ -1092,7 +1094,7 @@
 		    if (ROBJECT(obj)->tbl == NULL) {
 			CFMutableDictionaryRef tbl;
 
-			tbl = CFDictionaryCreateMutable(kCFAllocatorMalloc, 0, NULL, 
+			tbl = CFDictionaryCreateMutable(NULL, 0, NULL, 
 				&rb_cfdictionary_value_cb);
 
 			GC_WB(&ROBJECT(obj)->tbl, tbl);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090312/7c92876c/attachment-0001.html>


More information about the macruby-changes mailing list