[macruby-changes] [589] MacRuby/branches/testing
source_changes at macosforge.org
source_changes at macosforge.org
Mon Sep 8 20:30:58 PDT 2008
Revision: 589
http://trac.macosforge.org/projects/ruby/changeset/589
Author: lsansonetti at apple.com
Date: 2008-09-08 20:30:58 -0700 (Mon, 08 Sep 2008)
Log Message:
-----------
backporting ri/rdoc fixes from trunk
Modified Paths:
--------------
MacRuby/branches/testing/Rakefile
MacRuby/branches/testing/array.c
MacRuby/branches/testing/ext/syck/rubyext.c
MacRuby/branches/testing/gc.c
MacRuby/branches/testing/hash.c
MacRuby/branches/testing/marshal.c
MacRuby/branches/testing/object.c
MacRuby/branches/testing/string.c
Modified: MacRuby/branches/testing/Rakefile
===================================================================
--- MacRuby/branches/testing/Rakefile 2008-09-09 03:26:36 UTC (rev 588)
+++ MacRuby/branches/testing/Rakefile 2008-09-09 03:30:58 UTC (rev 589)
@@ -181,7 +181,7 @@
txt = File.read(src)
txt.scan(/#include\s+\"([^"]+)\"/).flatten.each do |header|
p = header_path(header)
- if p
+ if p and !cont.include?(p)
cont << p
locate_headers(cont, p)
end
@@ -607,6 +607,15 @@
desc "Same as framework:install"
task :install => 'framework:install'
+desc "Generate and install RDoc/RI"
+task :install_doc => 'miniruby' do
+ doc_op = '.ext/rdoc'
+ unless File.exist?(doc_op)
+ sh "./miniruby -I./lib bin/rdoc --all --ri --op \"#{doc_op}\""
+ end
+ sh "./miniruby instruby.rb #{INSTRUBY_ARGS} --install=rdoc --rdoc-output=\"#{doc_op}\""
+end
+
desc "Same as macruby:build"
task :macruby => 'macruby:build'
Modified: MacRuby/branches/testing/array.c
===================================================================
--- MacRuby/branches/testing/array.c 2008-09-09 03:26:36 UTC (rev 588)
+++ MacRuby/branches/testing/array.c 2008-09-09 03:30:58 UTC (rev 589)
@@ -3409,6 +3409,7 @@
Init_Array(void)
{
rb_cCFArray = (VALUE)objc_getClass("NSCFArray");
+ rb_const_set(rb_cObject, rb_intern("NSCFArray"), rb_cCFArray);
rb_cArray = rb_cNSArray = (VALUE)objc_getClass("NSArray");
rb_cNSMutableArray = (VALUE)objc_getClass("NSMutableArray");
rb_set_class_path(rb_cNSMutableArray, rb_cObject, "NSMutableArray");
Modified: MacRuby/branches/testing/ext/syck/rubyext.c
===================================================================
--- MacRuby/branches/testing/ext/syck/rubyext.c 2008-09-09 03:26:36 UTC (rev 588)
+++ MacRuby/branches/testing/ext/syck/rubyext.c 2008-09-09 03:30:58 UTC (rev 589)
@@ -1115,6 +1115,18 @@
* scheme);
*/
+#if WITH_OBJC
+ if (subclass == rb_cCFString) {
+ subclass = rb_cNSMutableString;
+ }
+ else if (subclass == rb_cCFHash) {
+ subclass = rb_cNSMutableHash;
+ }
+ else if (subclass == rb_cCFArray) {
+ subclass = rb_cNSMutableArray;
+ }
+#endif
+
if ( rb_respond_to( target_class, s_call ) )
{
obj = rb_funcall( target_class, s_call, 2, type, val );
Modified: MacRuby/branches/testing/gc.c
===================================================================
--- MacRuby/branches/testing/gc.c 2008-09-09 03:26:36 UTC (rev 588)
+++ MacRuby/branches/testing/gc.c 2008-09-09 03:30:58 UTC (rev 589)
@@ -687,18 +687,21 @@
*
*/
-static bool
+bool
rb_objc_is_placeholder(void *obj)
{
+ static void *placeholder_str = NULL;
static void *placeholder_dict = NULL;
static void *placeholder_ary = NULL;
void *obj_klass;
+ if (placeholder_str == NULL)
+ placeholder_str = objc_getClass("NSPlaceholderMutableString");
if (placeholder_dict == NULL)
placeholder_dict = objc_getClass("__NSPlaceholderDictionary");
if (placeholder_ary == NULL)
placeholder_ary = objc_getClass("__NSPlaceholderArray");
obj_klass = *(void **)obj;
- return obj_klass == placeholder_dict || obj_klass == placeholder_ary;
+ return obj_klass == placeholder_str || obj_klass == placeholder_dict || obj_klass == placeholder_ary;
}
struct rb_objc_recorder_context {
Modified: MacRuby/branches/testing/hash.c
===================================================================
--- MacRuby/branches/testing/hash.c 2008-09-09 03:26:36 UTC (rev 588)
+++ MacRuby/branches/testing/hash.c 2008-09-09 03:30:58 UTC (rev 589)
@@ -2384,6 +2384,7 @@
id_default = rb_intern("default");
rb_cCFHash = (VALUE)objc_getClass("NSCFDictionary");
+ rb_const_set(rb_cObject, rb_intern("NSCFDictionary"), rb_cCFHash);
rb_cHash = rb_cNSHash = (VALUE)objc_getClass("NSDictionary");
rb_cNSMutableHash = (VALUE)objc_getClass("NSMutableDictionary");
rb_set_class_path(rb_cNSMutableHash, rb_cObject, "NSMutableDictionary");
Modified: MacRuby/branches/testing/marshal.c
===================================================================
--- MacRuby/branches/testing/marshal.c 2008-09-09 03:26:36 UTC (rev 588)
+++ MacRuby/branches/testing/marshal.c 2008-09-09 03:30:58 UTC (rev 589)
@@ -536,7 +536,18 @@
static void
w_objivar(VALUE obj, struct dump_call_arg *arg)
{
-#if !WITH_OBJC /* TODO */
+#if WITH_OBJC
+ VALUE ary = rb_obj_instance_variables(obj);
+ int i, len = RARRAY_LEN(ary);
+
+ w_encoding(obj, len, arg);
+
+ for (i = 0; i < len; i++) {
+ ID var_id = SYM2ID(RARRAY_AT(ary, i));
+ VALUE var_val = rb_ivar_get(obj, var_id);
+ w_obj_each(var_id, var_val, arg);
+ }
+#else
VALUE *ptr;
long i, len, num;
@@ -899,11 +910,13 @@
{
VALUE obj, port, a1, a2;
int limit = -1;
- struct dump_arg arg;
- struct dump_call_arg c_arg;
+ struct dump_arg *arg;
+ struct dump_call_arg *c_arg;
port = Qnil;
rb_scan_args(argc, argv, "12", &obj, &a1, &a2);
+ arg = (struct dump_arg *)xmalloc(sizeof(struct dump_arg));
+ c_arg = (struct dump_call_arg *)xmalloc(sizeof(struct dump_call_arg));
if (argc == 3) {
if (!NIL_P(a2)) limit = NUM2INT(a2);
if (NIL_P(a1)) goto type_error;
@@ -914,39 +927,39 @@
else if (NIL_P(a1)) goto type_error;
else port = a1;
}
- arg.dest = 0;
+ arg->dest = 0;
if (!NIL_P(port)) {
if (!rb_obj_respond_to(port, s_write, Qtrue)) {
type_error:
rb_raise(rb_eTypeError, "instance of IO needed");
}
- arg.str = rb_str_buf_new(0);
- arg.dest = port;
+ GC_WB(&arg->str, rb_str_buf_new(0));
+ GC_WB(&arg->dest, port);
if (rb_obj_respond_to(port, s_binmode, Qtrue)) {
rb_funcall2(port, s_binmode, 0, 0);
}
}
else {
port = rb_str_buf_new(0);
- arg.str = port;
+ GC_WB(&arg->str, port);
}
- RSTRING_BYTEPTR(arg.str); /* force bytestring creation */
+ RSTRING_BYTEPTR(arg->str); /* force bytestring creation */
- arg.symbols = st_init_numtable();
- arg.data = st_init_numtable();
- arg.taint = Qfalse;
- arg.compat_tbl = st_init_numtable();
- arg.wrapper = Data_Wrap_Struct(rb_cData, mark_dump_arg, 0, &arg);
- arg.encodings = 0;
- c_arg.obj = obj;
- c_arg.arg = &arg;
- c_arg.limit = limit;
+ GC_WB(&arg->symbols, st_init_numtable());
+ GC_WB(&arg->data, st_init_numtable());
+ arg->taint = Qfalse;
+ GC_WB(&arg->compat_tbl, st_init_numtable());
+ GC_WB(&arg->wrapper, Data_Wrap_Struct(rb_cData, mark_dump_arg, 0, arg));
+ arg->encodings = 0;
+ GC_WB(&c_arg->obj, obj);
+ GC_WB(&c_arg->arg, arg);
+ c_arg->limit = limit;
- w_byte(MARSHAL_MAJOR, &arg);
- w_byte(MARSHAL_MINOR, &arg);
+ w_byte(MARSHAL_MAJOR, arg);
+ w_byte(MARSHAL_MINOR, arg);
- rb_ensure(dump, (VALUE)&c_arg, dump_ensure, (VALUE)&arg);
+ rb_ensure(dump, (VALUE)c_arg, dump_ensure, (VALUE)arg);
return port;
}
@@ -1655,34 +1668,31 @@
VALUE port, proc;
int major, minor;
VALUE v;
- struct load_arg arg;
+ struct load_arg *arg;
+ arg = (struct load_arg *)xmalloc(sizeof(struct load_arg));
rb_scan_args(argc, argv, "11", &port, &proc);
v = rb_check_string_type(port);
if (!NIL_P(v)) {
- arg.taint = OBJ_TAINTED(port); /* original taintedness */
+ arg->taint = OBJ_TAINTED(port); /* original taintedness */
port = v;
}
else if (rb_obj_respond_to(port, s_getbyte, Qtrue) && rb_obj_respond_to(port, s_read, Qtrue)) {
if (rb_obj_respond_to(port, s_binmode, Qtrue)) {
rb_funcall2(port, s_binmode, 0, 0);
}
- arg.taint = Qtrue;
+ arg->taint = Qtrue;
}
else {
rb_raise(rb_eTypeError, "instance of IO needed");
}
- arg.src = port;
- arg.offset = 0;
- arg.compat_tbl = st_init_numtable();
-#if WITH_OBJC
- arg.compat_tbl_wrapper = Data_Wrap_Struct(rb_cData, NULL, 0, arg.compat_tbl);
-#else
- arg.compat_tbl_wrapper = Data_Wrap_Struct(rb_cData, rb_mark_tbl, 0, arg.compat_tbl);
-#endif
+ GC_WB(&arg->src, port);
+ arg->offset = 0;
+ GC_WB(&arg->compat_tbl, st_init_numtable());
+ GC_WB(&arg->compat_tbl_wrapper, Data_Wrap_Struct(rb_cData, NULL/*rb_mark_tbl*/, 0, arg->compat_tbl));
- major = r_byte(&arg);
- minor = r_byte(&arg);
+ major = r_byte(arg);
+ minor = r_byte(arg);
if (major != MARSHAL_MAJOR || minor > MARSHAL_MINOR) {
rb_raise(rb_eTypeError, "incompatible marshal file format (can't be read)\n\
\tformat version %d.%d required; %d.%d given",
@@ -1694,11 +1704,11 @@
MARSHAL_MAJOR, MARSHAL_MINOR, major, minor);
}
- arg.symbols = st_init_numtable();
- arg.data = rb_hash_new();
- if (NIL_P(proc)) arg.proc = 0;
- else arg.proc = proc;
- v = rb_ensure(load, (VALUE)&arg, load_ensure, (VALUE)&arg);
+ GC_WB(&arg->symbols, st_init_numtable());
+ GC_WB(&arg->data, rb_hash_new());
+ if (NIL_P(proc)) arg->proc = 0;
+ else arg->proc = proc;
+ v = rb_ensure(load, (VALUE)arg, load_ensure, (VALUE)arg);
return v;
}
@@ -1764,6 +1774,7 @@
rb_gc_register_address(&compat_allocator_tbl_wrapper);
compat_allocator_tbl_wrapper =
Data_Wrap_Struct(rb_cData, mark_marshal_compat_t, 0, compat_allocator_tbl);
+ rb_objc_retain((void *)compat_allocator_tbl_wrapper);
}
VALUE
Modified: MacRuby/branches/testing/object.c
===================================================================
--- MacRuby/branches/testing/object.c 2008-09-09 03:26:36 UTC (rev 588)
+++ MacRuby/branches/testing/object.c 2008-09-09 03:30:58 UTC (rev 589)
@@ -1499,6 +1499,12 @@
rb_raise(rb_eTypeError, "can't create instance of singleton class");
}
obj = rb_funcall(klass, ID_ALLOCATOR, 0, 0);
+
+ bool rb_objc_is_placeholder(void *obj);
+ if (rb_objc_is_placeholder((void *)obj)) {
+ obj = (VALUE)objc_msgSend((void *)obj, selInit);
+ }
+
return obj;
}
@@ -2532,6 +2538,8 @@
rb_define_global_function("String", rb_f_string, 1);
rb_define_global_function("Array", rb_f_array, 1);
+ rb_const_set(rb_cObject, rb_intern("NSNull"), (VALUE)objc_getClass("NSNull"));
+
rb_cNilClass = rb_define_class("NilClass", rb_cObject);
rb_define_method(rb_cNilClass, "to_i", nil_to_i, 0);
rb_define_method(rb_cNilClass, "to_f", nil_to_f, 0);
Modified: MacRuby/branches/testing/string.c
===================================================================
--- MacRuby/branches/testing/string.c 2008-09-09 03:26:36 UTC (rev 588)
+++ MacRuby/branches/testing/string.c 2008-09-09 03:30:58 UTC (rev 589)
@@ -413,6 +413,8 @@
CFMakeCollectable((CFTypeRef)dup);
+ rb_gc_malloc_increase(32 + (sizeof(UniChar) * RSTRING_LEN(dup)));
+
return dup;
}
@@ -822,6 +824,7 @@
data = (CFMutableDataRef)rb_str_cfdata2(str);
if (data != NULL) {
CFDataAppendBytes(data, (const UInt8 *)ptr, len);
+ rb_gc_malloc_increase(sizeof(UniChar) * len);
}
else {
long slen;
@@ -5243,7 +5246,7 @@
if (range.location + range.length > RSYMBOL(rcv)->len)
rb_bug("[Symbol getCharacters:range:] out of bounds");
- for (i = range.location; i < range.length; i++) {
+ for (i = range.location; i < range.location + range.length; i++) {
*buffer = RSYMBOL(rcv)->str[i];
buffer++;
}
@@ -5278,6 +5281,7 @@
Init_String(void)
{
rb_cCFString = (VALUE)objc_getClass("NSCFString");
+ rb_const_set(rb_cObject, rb_intern("NSCFString"), rb_cCFString);
rb_cString = rb_cNSString = (VALUE)objc_getClass("NSString");
rb_cNSMutableString = (VALUE)objc_getClass("NSMutableString");
rb_const_set(rb_cObject, rb_intern("String"), rb_cNSMutableString);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macruby-changes/attachments/20080908/5f7e3d7d/attachment-0001.html
More information about the macruby-changes
mailing list