summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-12-03 09:30:33 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-12-03 09:30:33 +0000
commit379e85a5f5b243f307b97b76a762947ffbe6bc48 (patch)
treebfbe7e40f4e9e813d4cdce3a5776da1ec41a8080
parent744ec6294cbe29513af083bf1106b68247c72275 (diff)
* eval.c (proc_invoke): copy arguments to frame.argv.
[ruby-core:03861] * object.c (convert_type): use rb_respond_to() again. [ruby-dev:25021] * eval.c (rb_respond_to): funcall respond_to? if it's redefined. [ruby-dev:25021] * io.c (rb_file_initialize): [ruby-dev:25032] * lib/ostruct.rb (OpenStruct::Marshaler): OpenStruct can be marshaled again. [ruby-core:03862] * io.c (rb_io_ctl): [ruby-dev:25019] * io.c (io_fread): need not to null terminate. [ruby-dev:24998] * io.c (read_all): remove unnecessary rb_str_resize(). [ruby-dev:24996] * io.c (io_read): ditto. * io.c (rb_io_sysread): use temporary lock. [ruby-dev:24992] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog51
-rw-r--r--eval.c21
-rw-r--r--io.c14
-rw-r--r--lib/ostruct.rb29
-rw-r--r--object.c8
5 files changed, 107 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 0828352244..715e40b4d1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,20 @@
+Fri Dec 3 13:45:20 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (proc_invoke): copy arguments to frame.argv.
+ [ruby-core:03861]
+
Fri Dec 3 12:25:41 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* st.h: fix prototypes.
+Fri Dec 3 00:21:05 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * object.c (convert_type): use rb_respond_to() again.
+ [ruby-dev:25021]
+
+ * eval.c (rb_respond_to): funcall respond_to? if it's redefined.
+ [ruby-dev:25021]
+
Fri Dec 3 01:55:24 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk.rb: widget configuration by TkWindow#method_missing
@@ -20,6 +33,10 @@ Fri Dec 3 01:55:24 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/sample/demos-jp/widget: ditto.
+Fri Dec 3 00:11:48 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (rb_file_initialize): [ruby-dev:25032]
+
Thu Dec 2 16:41:03 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (rb_protect): prevent continuations created inside from being
@@ -28,12 +45,26 @@ Thu Dec 2 16:41:03 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (rb_callcc, rb_cont_call): prohibit calling from different
signal contexts. [ruby-dev:25022]
+Thu Dec 2 09:57:24 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * lib/ostruct.rb (OpenStruct::Marshaler): OpenStruct can be
+ marshaled again. [ruby-core:03862]
+
Thu Dec 2 09:30:06 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (thread_mark): mark thread group. [ruby-dev:25020]
* eval.c (thgroup_add): check whether the argument is really a Thread.
+Thu Dec 2 07:57:16 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (rb_io_ctl): [ruby-dev:25019]
+
+Wed Dec 1 02:21:02 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * signal.c (sighandler): call handler immediately only for default
+ handlers. [ruby-dev:25003]
+
Tue Nov 30 23:38:18 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* io.c (io_fread): need not to null terminate. [ruby-dev:24998]
@@ -45,11 +76,31 @@ Tue Nov 30 23:38:18 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* io.c (io_read): ditto.
+Tue Nov 30 16:18:50 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (io_fread): need not to null terminate. [ruby-dev:24998]
+
+ * io.c (read_all): remove unnecessary rb_str_resize().
+ [ruby-dev:24996]
+
+ * io.c (io_read): ditto.
+
+Tue Nov 30 00:49:08 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (rb_io_sysread): use temporary lock. [ruby-dev:24992]
+
Mon Nov 29 16:06:04 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/stringio/stringio.c (strio_write): insufficiently filled string
being extended when overwriting. [ruby-core:03836]
+Mon Nov 29 15:59:05 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * lib/ostruct.rb (OpenStruct::method_missing): check method
+ duplication for -d.
+
+ * lib/ostruct.rb (OpenStruct::initialize): ditto.
+
Mon Nov 29 15:22:28 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* test/io/nonblock/test_flush.rb: abandon tests when io/nonblock is
diff --git a/eval.c b/eval.c
index 7b75b84cc2..020ed33cd4 100644
--- a/eval.c
+++ b/eval.c
@@ -312,7 +312,7 @@ rb_clear_cache_by_class(klass)
static ID init, eqq, each, aref, aset, match, missing;
static ID added, singleton_added;
-static ID __id__, __send__;
+static ID __id__, __send__, respond_to;
void
rb_add_method(klass, mid, node, noex)
@@ -3943,17 +3943,25 @@ module_setup(module, n)
return result;
}
+static NODE *basic_respond_to = 0;
+
int
rb_respond_to(obj, id)
VALUE obj;
ID id;
{
- if (rb_method_boundp(CLASS_OF(obj), id, 0)) {
+ VALUE klass = CLASS_OF(obj);
+ if (rb_method_node(klass, respond_to) == basic_respond_to &&
+ rb_method_boundp(klass, id, 0)) {
return Qtrue;
}
+ else{
+ return rb_funcall(obj, respond_to, 1, ID2SYM(id));
+ }
return Qfalse;
}
+
/*
* call-seq:
* obj.respond_to?(symbol, include_private=false) => true or false
@@ -7581,7 +7589,10 @@ Init_eval()
rb_define_global_function("loop", rb_f_loop, 0);
rb_define_method(rb_mKernel, "respond_to?", rb_obj_respond_to, -1);
-
+ respond_to = rb_intern("respond_to?");
+ basic_respond_to = rb_method_node(rb_cObject, respond_to);
+ rb_global_variable((VALUE*)&basic_respond_to);
+
rb_define_global_function("raise", rb_f_raise, -1);
rb_define_global_function("fail", rb_f_raise, -1);
@@ -8152,6 +8163,10 @@ proc_invoke(proc, args, self, klass)
_block = *data;
if (self != Qundef) _block.frame.self = self;
if (klass) _block.frame.last_class = klass;
+ _block.frame.argc = RARRAY(args)->len;
+ _block.frame.argv = ALLOCA_N(VALUE, RARRAY(args)->len);
+ MEMCPY(_block.frame.argv, RARRAY(args)->ptr, VALUE, RARRAY(args)->len);
+ _block.frame.flags = FRAME_ALLOCA;
ruby_block = &_block;
PUSH_ITER(ITER_CUR);
diff --git a/io.c b/io.c
index 04e8d572bf..a3164363ec 100644
--- a/io.c
+++ b/io.c
@@ -2177,13 +2177,19 @@ rb_io_sysread(argc, argv, io)
if (READ_DATA_BUFFERED(fptr->f)) {
rb_raise(rb_eIOError, "sysread for buffered IO");
}
+ rb_str_locktmp(str);
+
n = fileno(fptr->f);
rb_thread_wait_fd(fileno(fptr->f));
rb_io_check_closed(fptr);
+ if (RSTRING(str)->len != ilen) {
+ rb_raise(rb_eRuntimeError, "buffer string modified");
+ }
TRAP_BEG;
- n = read(fileno(fptr->f), RSTRING(str)->ptr, RSTRING(str)->len);
+ n = read(fileno(fptr->f), RSTRING(str)->ptr, ilen);
TRAP_END;
+ rb_str_unlocktmp(str);
if (n == -1) {
rb_sys_fail(fptr->path);
}
@@ -3867,9 +3873,7 @@ rb_file_initialize(argc, argv, io)
VALUE io;
{
if (RFILE(io)->fptr) {
- rb_io_close_m(io);
- free(RFILE(io)->fptr);
- RFILE(io)->fptr = 0;
+ rb_raise(rb_eRuntimeError, "reinitializing File");
}
if (0 < argc && argc < 3) {
VALUE fd = rb_check_convert_type(argv[0], T_FIXNUM, "Fixnum", "to_int");
@@ -4477,7 +4481,6 @@ rb_io_ctl(io, req, arg, io_p)
int retval;
rb_secure(2);
- GetOpenFile(io, fptr);
if (NIL_P(arg) || arg == Qfalse) {
narg = 0;
@@ -4518,6 +4521,7 @@ rb_io_ctl(io, req, arg, io_p)
narg = (long)RSTRING(arg)->ptr;
}
}
+ GetOpenFile(io, fptr);
retval = io_cntl(fileno(fptr->f), cmd, narg, io_p);
if (retval < 0) rb_sys_fail(fptr->path);
if (TYPE(arg) == T_STRING && RSTRING(arg)->ptr[len] != 17) {
diff --git a/lib/ostruct.rb b/lib/ostruct.rb
index d92ee503ad..7f4668283b 100644
--- a/lib/ostruct.rb
+++ b/lib/ostruct.rb
@@ -48,15 +48,36 @@ class OpenStruct
if hash
for k,v in hash
@table[k.to_sym] = v
+ new_ostruct_member(k)
end
end
end
+ # Duplicate an OpenStruct object members.
+ def initialize_copy(orig)
+ super
+ @table = @table.dup
+ end
+
+ module Marshaler
+ def marshal_dump
+ table = @table
+ OpenStruct.new.instance_eval{@table=table; self}
+ end
+ def marshal_load(x)
+ @table = x.instance_variable_get("@table")
+ @table.each_key{|key| new_ostruct_member(key)}
+ end
+ end
+
def new_ostruct_member(name)
- self.instance_eval %{
- def #{name}; @table[:#{name}]; end
- def #{name}=(x); @table[:#{name}] = x; end
- }
+ unless self.respond_to?(name)
+ self.instance_eval %{
+ extend OpenStruct::Marshaler
+ def #{name}; @table[:#{name}]; end
+ def #{name}=(x); @table[:#{name}] = x; end
+ }
+ end
end
def method_missing(mid, *args) # :nodoc:
diff --git a/object.c b/object.c
index 1a54739d05..858ddf3f53 100644
--- a/object.c
+++ b/object.c
@@ -2036,9 +2036,10 @@ convert_type(val, tname, method, raise)
const char *tname, *method;
int raise;
{
- VALUE result = rb_funcall_rescue(val, rb_intern(method), 0);
+ ID m;
- if (result == Qundef) {
+ m = rb_intern(method);
+ if (!rb_respond_to(val, m)) {
if (raise) {
rb_raise(rb_eTypeError, "cannot convert %s into %s",
NIL_P(val) ? "nil" :
@@ -2048,11 +2049,10 @@ convert_type(val, tname, method, raise)
tname);
}
else {
- ruby_errinfo = Qnil;
return Qnil;
}
}
- return result;
+ return rb_funcall(val, m, 0);
}
VALUE