1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* eval.c (rb_mod_define_method): define_method should follow

default method visibility.

* eval.c (rb_attr): should warn if the default method visibility
  is "module_function" (can be error).

* eval.c (rb_mod_define_method): should define class/module method
  also if the visibility is "module_function".

* eval.c (rb_mod_define_method): should call hook method
  "method_added", and "singleton_method_added".

* ext/socket/socket.c (bsock_send): should raise EWOULDBLOCK
  exception.

* ext/socket/socket.c (s_recvfrom): ditto.

* ext/socket/socket.c (s_accept): ditto.

* ext/socket/socket.c (udp_send): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_6@1922 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2001-12-19 07:45:30 +00:00
parent 74097260ae
commit f55f4e1aeb
3 changed files with 68 additions and 41 deletions

View file

@ -1,3 +1,17 @@
Wed Dec 19 14:05:00 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (rb_mod_define_method): define_method should follow
default method visibility.
* eval.c (rb_attr): should warn if the default method visibility
is "module_function" (can be error).
* eval.c (rb_mod_define_method): should define class/module method
also if the visibility is "module_function".
* eval.c (rb_mod_define_method): should call hook method
"method_added", and "singleton_method_added".
Tue Dec 18 01:02:13 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (rb_thread_schedule): should not select a thread which is
@ -101,6 +115,17 @@ Wed Dec 5 23:36:56 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* regex.c (WC2MBC1ST): should not pass through > 0x80 number in UTF-8.
Wed Dec 5 20:05:18 2001 Florian Frank <flori@ping.de>
* ext/socket/socket.c (bsock_send): should raise EWOULDBLOCK
exception.
* ext/socket/socket.c (s_recvfrom): ditto.
* ext/socket/socket.c (s_accept): ditto.
* ext/socket/socket.c (udp_send): ditto.
Tue Dec 4 03:49:06 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* io.c (io_fread): EAGAIN/EWOULDBLOCK should not terminate and

59
eval.c
View file

@ -353,8 +353,8 @@ rb_disable_super(klass, name)
body->nd_noex |= NOEX_UNDEF;
}
else {
rb_add_method(klass, mid, 0, NOEX_UNDEF);
rb_clear_cache_by_id(mid);
rb_add_method(klass, mid, 0, NOEX_UNDEF);
}
}
@ -403,8 +403,8 @@ rb_export_method(klass, name, noex)
body->nd_noex = noex;
}
else {
rb_add_method(klass, name, NEW_ZSUPER(), noex);
rb_clear_cache_by_id(name);
rb_add_method(klass, name, NEW_ZSUPER(), noex);
}
}
}
@ -453,7 +453,9 @@ rb_attr(klass, id, read, write, ex)
else {
if (SCOPE_TEST(SCOPE_PRIVATE)) {
noex = NOEX_PRIVATE;
rb_warning("private attribute?");
rb_warning((scope_vmode == SCOPE_MODFUNC) ?
"attribute accessor as module_function" :
"private attribute?");
}
else if (SCOPE_TEST(SCOPE_PROTECTED)) {
noex = NOEX_PROTECTED;
@ -471,15 +473,15 @@ rb_attr(klass, id, read, write, ex)
sprintf(buf, "@%s", name);
attriv = rb_intern(buf);
if (read) {
rb_add_method(klass, id, NEW_IVAR(attriv), noex);
rb_clear_cache_by_id(id);
rb_add_method(klass, id, NEW_IVAR(attriv), noex);
rb_funcall(klass, added, 1, ID2SYM(id));
}
if (write) {
sprintf(buf, "%s=", name);
id = rb_intern(buf);
rb_add_method(klass, id, NEW_ATTRSET(attriv), noex);
rb_clear_cache_by_id(id);
rb_add_method(klass, id, NEW_ATTRSET(attriv), noex);
rb_funcall(klass, added, 1, ID2SYM(id));
}
}
@ -1547,8 +1549,8 @@ rb_undef(klass, id)
rb_raise(rb_eNameError, "undefined method `%s' for%s `%s'",
rb_id2name(id),s0,rb_class2name(c));
}
rb_add_method(klass, id, 0, NOEX_PUBLIC);
rb_clear_cache_by_id(id);
rb_add_method(klass, id, 0, NOEX_PUBLIC);
}
static VALUE
@ -1589,9 +1591,9 @@ rb_alias(klass, name, def)
body = body->nd_head;
}
rb_clear_cache_by_id(name);
st_insert(RCLASS(klass)->m_tbl, name,
NEW_METHOD(NEW_FBODY(body, def, origin), orig->nd_noex));
rb_clear_cache_by_id(name);
}
static VALUE
@ -2979,8 +2981,8 @@ rb_eval(self, n)
}
defn = copy_node_scope(node->nd_defn, ruby_cref);
rb_add_method(ruby_class, node->nd_mid, defn, noex);
rb_clear_cache_by_id(node->nd_mid);
rb_add_method(ruby_class, node->nd_mid, defn, noex);
if (scope_vmode == SCOPE_MODFUNC) {
rb_add_method(rb_singleton_class(ruby_class),
node->nd_mid, defn, NOEX_PUBLIC);
@ -3025,9 +3027,9 @@ rb_eval(self, n)
}
defn = copy_node_scope(node->nd_defn, ruby_cref);
defn->nd_rval = (VALUE)ruby_cref;
rb_clear_cache_by_id(node->nd_mid);
rb_add_method(klass, node->nd_mid, defn,
NOEX_PUBLIC|(body?body->nd_noex&NOEX_UNDEF:0));
rb_clear_cache_by_id(node->nd_mid);
rb_funcall(recv, singleton_added, 1, ID2SYM(node->nd_mid));
result = Qnil;
}
@ -5634,8 +5636,8 @@ rb_mod_modfunc(argc, argv, module)
if (body == 0 || body->nd_body == 0) {
rb_bug("undefined method `%s'; can't happen", rb_id2name(id));
}
rb_add_method(rb_singleton_class(module), id, body->nd_body, NOEX_PUBLIC);
rb_clear_cache_by_id(id);
rb_add_method(rb_singleton_class(module), id, body->nd_body, NOEX_PUBLIC);
rb_funcall(module, singleton_added, 1, ID2SYM(id));
}
return module;
@ -6862,6 +6864,8 @@ rb_mod_define_method(argc, argv, mod)
{
ID id;
VALUE body;
NODE *node;
int noex;
if (argc == 1) {
id = rb_to_id(argv[0]);
@ -6870,26 +6874,49 @@ rb_mod_define_method(argc, argv, mod)
else if (argc == 2) {
id = rb_to_id(argv[0]);
body = argv[1];
if (rb_obj_is_kind_of(body, rb_cMethod)) {
body = method_proc(body);
}
else if (!rb_obj_is_proc(body)) {
rb_raise(rb_eTypeError, "wrong argument type %s (expected Proc)",
rb_class2name(CLASS_OF(body)));
}
}
else {
rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)", argc);
}
if (TYPE(body) != T_DATA) {
/* type error */
rb_raise(rb_eTypeError, "wrong argument type (expected Proc)");
}
if (RDATA(body)->dmark == (RUBY_DATA_FUNC)bm_mark) {
rb_add_method(mod, id, NEW_DMETHOD(method_unbind(body)), NOEX_PUBLIC);
node = NEW_DMETHOD(method_unbind(body));
}
else if (RDATA(body)->dmark == (RUBY_DATA_FUNC)blk_mark) {
rb_add_method(mod, id, NEW_BMETHOD(body), NOEX_PUBLIC);
node = NEW_BMETHOD(body);
}
else {
/* type error */
rb_raise(rb_eTypeError, "wrong argument type (expected Proc)");
}
if (SCOPE_TEST(SCOPE_PRIVATE)) {
noex = NOEX_PRIVATE;
}
else if (SCOPE_TEST(SCOPE_PROTECTED)) {
noex = NOEX_PROTECTED;
}
else {
noex = NOEX_PUBLIC;
}
rb_clear_cache_by_id(id);
rb_add_method(mod, id, node, noex);
if (scope_vmode == SCOPE_MODFUNC) {
rb_add_method(rb_singleton_class(mod), id, node, NOEX_PUBLIC);
rb_funcall(mod, singleton_added, 1, ID2SYM(id));
}
if (FL_TEST(mod, FL_SINGLETON)) {
rb_funcall(rb_iv_get(mod, "__attached__"), singleton_added, 1, ID2SYM(id));
}
else {
rb_funcall(mod, added, 1, ID2SYM(id));
}
return body;
}

View file

@ -399,12 +399,6 @@ bsock_send(argc, argv, sock)
case EINTR:
rb_thread_schedule();
goto retry;
case EWOULDBLOCK:
#if EAGAIN != EWOULDBLOCK
case EAGAIN:
#endif
rb_thread_fd_writable(fd);
goto retry;
}
rb_sys_fail("send(2)");
}
@ -462,12 +456,6 @@ s_recvfrom(sock, argc, argv, from)
case EINTR:
rb_thread_schedule();
goto retry;
case EWOULDBLOCK:
#if EAGAIN != EWOULDBLOCK
case EAGAIN:
#endif
goto retry;
}
rb_sys_fail("recvfrom(2)");
}
@ -1089,12 +1077,6 @@ s_accept(class, fd, sockaddr, len)
case EINTR:
rb_thread_schedule();
goto retry;
case EWOULDBLOCK:
#if EAGAIN != EWOULDBLOCK
case EAGAIN:
#endif
goto retry;
}
rb_sys_fail(0);
}
@ -1317,13 +1299,6 @@ udp_send(argc, argv, sock)
case EINTR:
rb_thread_schedule();
goto retry;
case EWOULDBLOCK:
#if EAGAIN != EWOULDBLOCK
case EAGAIN:
#endif
rb_thread_fd_writable(fileno(f));
goto retry;
}
}
freeaddrinfo(res0);