aboutsummaryrefslogtreecommitdiffstats
path: root/ext/zlib
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/zlib
parentaacd7710462142df7397618ffff4279e495f10f9 (diff)
downloadruby-83aba0486298d61b39f3ed3492042690a889807f.tar.gz
* 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/zlib')
-rw-r--r--ext/zlib/zlib.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c
index 64a3e697c6..db153e3694 100644
--- a/ext/zlib/zlib.c
+++ b/ext/zlib/zlib.c
@@ -633,7 +633,7 @@ zstream_expand_buffer(struct zstream *z)
VALUE self = (VALUE)z->stream.opaque;
rb_str_resize(z->buf, z->buf_filled);
- RBASIC(z->buf)->klass = rb_cString;
+ rb_obj_reveal(z->buf, rb_cString);
OBJ_INFECT(z->buf, self);
rb_protect(rb_yield, z->buf, &state);
@@ -678,7 +678,7 @@ zstream_expand_buffer_into(struct zstream *z, unsigned long size)
z->buf_filled = 0;
z->stream.next_out = (Bytef*)RSTRING_PTR(z->buf);
z->stream.avail_out = MAX_UINT(size);
- RBASIC(z->buf)->klass = 0;
+ rb_obj_hide(z->buf);
}
else if (z->stream.avail_out != size) {
rb_str_resize(z->buf, z->buf_filled + size);
@@ -740,7 +740,7 @@ zstream_append_buffer(struct zstream *z, const Bytef *src, long len)
z->buf_filled = len;
z->stream.next_out = (Bytef*)RSTRING_PTR(z->buf);
z->stream.avail_out = 0;
- RBASIC(z->buf)->klass = 0;
+ rb_obj_hide(z->buf);
return;
}
@@ -782,7 +782,7 @@ zstream_detach_buffer(struct zstream *z)
else {
dst = z->buf;
rb_str_resize(dst, z->buf_filled);
- RBASIC(dst)->klass = rb_cString;
+ rb_obj_reveal(dst, rb_cString);
}
OBJ_INFECT(dst, self);
@@ -811,7 +811,7 @@ zstream_shift_buffer(struct zstream *z, long len)
}
dst = rb_str_subseq(z->buf, 0, len);
- RBASIC(dst)->klass = rb_cString;
+ rb_obj_reveal(dst, rb_cString);
z->buf_filled -= len;
memmove(RSTRING_PTR(z->buf), RSTRING_PTR(z->buf) + len,
z->buf_filled);
@@ -866,7 +866,7 @@ zstream_append_input(struct zstream *z, const Bytef *src, long len)
if (NIL_P(z->input)) {
z->input = rb_str_buf_new(len);
rb_str_buf_cat(z->input, (const char*)src, len);
- RBASIC(z->input)->klass = 0;
+ rb_obj_hide(z->input);
}
else {
rb_str_buf_cat(z->input, (const char*)src, len);
@@ -915,10 +915,10 @@ zstream_detach_input(struct zstream *z)
}
else {
dst = z->input;
- RBASIC(dst)->klass = rb_cString;
+ rb_obj_reveal(dst, rb_cString);
}
z->input = Qnil;
- RBASIC(dst)->klass = rb_cString;
+ rb_obj_reveal(dst, rb_cString);
return dst;
}