summaryrefslogtreecommitdiff
path: root/ext/socket
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-13 10:49:11 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-13 10:49:11 +0000
commit83aba0486298d61b39f3ed3492042690a889807f (patch)
tree42d060575f0931f834aa85d2493d3c9693b18a4e /ext/socket
parentaacd7710462142df7397618ffff4279e495f10f9 (diff)
* include/ruby/ruby.h: constify RBasic::klass and add
RBASIC_CLASS(obj) macro which returns a class of `obj'. This change is a part of RGENGC branch [ruby-trunk - Feature #8339]. * object.c: add new function rb_obj_reveal(). This function reveal interal (hidden) object by rb_obj_hide(). Note that do not change class before and after hiding. Only permitted example is: klass = RBASIC_CLASS(obj); rb_obj_hide(obj); .... rb_obj_reveal(obj, klass); TODO: API design. rb_obj_reveal() should be replaced with others. TODO: modify constified variables using cast may be harmful for compiler's analysis and optimizaton. Any idea to prohibt inserting RBasic::klass directly? If rename RBasic::klass and force to use RBASIC_CLASS(obj), then all codes such as `RBASIC(obj)->klass' will be compilation error. Is it acceptable? (We have similar experience at Ruby 1.9, for example "RARRAY(ary)->ptr" to "RARRAY_PTR(ary)". * internal.h: add some macros. * RBASIC_CLEAR_CLASS(obj) clear RBasic::klass to make it internal object. * RBASIC_SET_CLASS(obj, cls) set RBasic::klass. * RBASIC_SET_CLASS_RAW(obj, cls) same as RBASIC_SET_CLASS without write barrier (planned). * RCLASS_SET_SUPER(a, b) set super class of a. * array.c, class.c, compile.c, encoding.c, enum.c, error.c, eval.c, file.c, gc.c, hash.c, io.c, iseq.c, marshal.c, object.c, parse.y, proc.c, process.c, random.c, ruby.c, sprintf.c, string.c, thread.c, transcode.c, vm.c, vm_eval.c, win32/file.c: Use above macros and functions to access RBasic::klass. * ext/coverage/coverage.c, ext/readline/readline.c, ext/socket/ancdata.c, ext/socket/init.c, * ext/zlib/zlib.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/socket')
-rw-r--r--ext/socket/ancdata.c2
-rw-r--r--ext/socket/init.c4
2 files changed, 3 insertions, 3 deletions
diff --git a/ext/socket/ancdata.c b/ext/socket/ancdata.c
index 3e6431e..7fe9659 100644
--- a/ext/socket/ancdata.c
+++ b/ext/socket/ancdata.c
@@ -1677,7 +1677,7 @@ bsock_recvmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
else {
rb_str_resize(dat_str, ss);
OBJ_TAINT(dat_str);
- RBASIC(dat_str)->klass = rb_cString;
+ rb_obj_reveal(dat_str, rb_cString);
}
ret = rb_ary_new3(3, dat_str,
diff --git a/ext/socket/init.c b/ext/socket/init.c
index a5ffe7b..6d98a66 100644
--- a/ext/socket/init.c
+++ b/ext/socket/init.c
@@ -132,7 +132,7 @@ rsock_s_recvfrom(VALUE sock, int argc, VALUE *argv, enum sock_recv_type from)
arg.str = str = rb_tainted_str_new(0, buflen);
klass = RBASIC(str)->klass;
- RBASIC(str)->klass = 0;
+ rb_obj_hide(str);
while (rb_io_check_closed(fptr),
rb_thread_wait_fd(arg.fd),
@@ -145,7 +145,7 @@ rsock_s_recvfrom(VALUE sock, int argc, VALUE *argv, enum sock_recv_type from)
}
}
- RBASIC(str)->klass = klass;
+ rb_obj_reveal(str, klass);
if (slen < RSTRING_LEN(str)) {
rb_str_set_len(str, slen);
}