Revision: 2908 http://trac.macosforge.org/projects/ruby/changeset/2908 Author: lsansonetti@apple.com Date: 2009-10-27 19:24:31 -0700 (Tue, 27 Oct 2009) Log Message: ----------- better MRI 1.9 C API compat Modified Paths: -------------- MacRuby/trunk/array.c MacRuby/trunk/dir.c MacRuby/trunk/error.c MacRuby/trunk/hash.c MacRuby/trunk/include/ruby/intern.h MacRuby/trunk/include/ruby/io.h MacRuby/trunk/include/ruby/ruby.h Modified: MacRuby/trunk/array.c =================================================================== --- MacRuby/trunk/array.c 2009-10-28 01:11:13 UTC (rev 2907) +++ MacRuby/trunk/array.c 2009-10-28 02:24:31 UTC (rev 2908) @@ -1495,8 +1495,8 @@ * a -- b -- c -- */ -VALUE -rb_ary_each(VALUE ary, SEL sel) +static VALUE +rb_ary_each_imp(VALUE ary, SEL sel) { long i; @@ -1508,6 +1508,12 @@ return ary; } +VALUE +rb_ary_each(VALUE ary) +{ + return rb_ary_each_imp(ary, 0); +} + /* * call-seq: * array.each_index {|index| block } -> array @@ -4285,7 +4291,7 @@ rb_objc_define_method(rb_cArray, "shift", rb_ary_shift_m, -1); rb_objc_define_method(rb_cArray, "unshift", rb_ary_unshift_m, -1); rb_objc_define_method(rb_cArray, "insert", rb_ary_insert_m, -1); - rb_objc_define_method(rb_cArray, "each", rb_ary_each, 0); + rb_objc_define_method(rb_cArray, "each", rb_ary_each_imp, 0); rb_objc_define_method(rb_cArray, "each_index", rb_ary_each_index, 0); rb_objc_define_method(rb_cArray, "reverse_each", rb_ary_reverse_each, 0); rb_objc_define_method(rb_cArray, "length", rb_ary_length, 0); Modified: MacRuby/trunk/dir.c =================================================================== --- MacRuby/trunk/dir.c 2009-10-28 01:11:13 UTC (rev 2907) +++ MacRuby/trunk/dir.c 2009-10-28 02:24:31 UTC (rev 2908) @@ -1642,8 +1642,6 @@ * Dir.glob(librbfiles) #=> ["lib/song.rb"] */ -VALUE rb_ary_each(VALUE recv, SEL sel); - static VALUE dir_s_glob(VALUE obj, SEL sel, int argc, VALUE *argv) { @@ -1671,7 +1669,7 @@ } if (rb_block_given_p()) { - rb_ary_each(ary, 0); + rb_ary_each(ary); return Qnil; } return ary; Modified: MacRuby/trunk/error.c =================================================================== --- MacRuby/trunk/error.c 2009-10-28 01:11:13 UTC (rev 2907) +++ MacRuby/trunk/error.c 2009-10-28 02:24:31 UTC (rev 2908) @@ -1140,6 +1140,15 @@ "TODO");//rb_id2name(rb_frame_this_func())); } +VALUE +rb_f_notimplement(VALUE rcv, SEL sel) +{ + rb_raise(rb_eNotImpError, + "%s() function is unimplemented on this machine", + sel_getName(sel)); + return Qnil; // never reached +} + void rb_fatal(const char *fmt, ...) { Modified: MacRuby/trunk/hash.c =================================================================== --- MacRuby/trunk/hash.c 2009-10-28 01:11:13 UTC (rev 2907) +++ MacRuby/trunk/hash.c 2009-10-28 02:24:31 UTC (rev 2908) @@ -620,6 +620,12 @@ return ifnone; } +VALUE +rb_hash_set_ifnone(VALUE hash, VALUE ifnone) +{ + return rb_hash_set_default(hash, 0, ifnone); +} + /* * call-seq: * hsh.default_proc -> anObject Modified: MacRuby/trunk/include/ruby/intern.h =================================================================== --- MacRuby/trunk/include/ruby/intern.h 2009-10-28 01:11:13 UTC (rev 2907) +++ MacRuby/trunk/include/ruby/intern.h 2009-10-28 02:24:31 UTC (rev 2908) @@ -58,6 +58,7 @@ VALUE rb_ary_pop(VALUE); VALUE rb_ary_shift(VALUE); VALUE rb_ary_unshift(VALUE, VALUE); +VALUE rb_ary_each(VALUE); VALUE rb_ary_entry(VALUE, long); VALUE rb_ary_join(VALUE, VALUE); VALUE rb_ary_print_on(VALUE, VALUE); @@ -197,6 +198,7 @@ return rb_enumeratorize(obj, sel, argc, argv); \ } while (0) /* error.c */ +VALUE rb_f_notimplement(VALUE rcv, SEL sel); VALUE rb_exc_new(VALUE, const char*, long); VALUE rb_exc_new2(VALUE, const char*); VALUE rb_exc_new3(VALUE, VALUE); @@ -371,6 +373,7 @@ VALUE rb_hash_delete_key(VALUE,VALUE); VALUE rb_hash_has_key(VALUE hash, VALUE key); VALUE rb_hash_keys(VALUE hash); +VALUE rb_hash_set_ifnone(VALUE hash, VALUE ifnone); struct st_table *rb_hash_tbl(VALUE); int rb_path_check(const char*); int rb_env_path_tainted(void); Modified: MacRuby/trunk/include/ruby/io.h =================================================================== --- MacRuby/trunk/include/ruby/io.h 2009-10-28 01:11:13 UTC (rev 2907) +++ MacRuby/trunk/include/ruby/io.h 2009-10-28 02:24:31 UTC (rev 2908) @@ -112,6 +112,12 @@ } } +// For MRI 1.9 compat. +#define HAVE_RB_IO_T 1 +#define rb_io_check_writable rb_io_assert_writable +#define rb_io_check_readable rb_io_assert_readable +#define GetOpenFile(obj,fp) (fp = ExtractIOStruct(obj)) + #if defined(__cplusplus) #if 0 { /* satisfy cc-mode */ Modified: MacRuby/trunk/include/ruby/ruby.h =================================================================== --- MacRuby/trunk/include/ruby/ruby.h 2009-10-28 01:11:13 UTC (rev 2907) +++ MacRuby/trunk/include/ruby/ruby.h 2009-10-28 02:24:31 UTC (rev 2908) @@ -194,6 +194,8 @@ #define ULONG2NUM(v) UINT2NUM(v) #define rb_uint_new(v) rb_uint2inum(v) +#define TIMET2NUM(t) LONG2NUM(t) + #ifdef HAVE_LONG_LONG VALUE rb_ll2inum(LONG_LONG); #define LL2NUM(v) rb_ll2inum(v)