* include/ruby/ruby.h (OBJ_WRITE): cast to (VALUE *) for second

parameter `slot'. You don't need to write a cast (VALUE *) any more.
* class.c, compile.c, hash.c, iseq.c, proc.c, re.c, variable.c,
  vm.c, vm_method.c: remove cast expressions for OBJ_WRITE().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41548 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2013-06-21 19:52:40 +00:00
Родитель 671c196384
Коммит 4223f00713
11 изменённых файлов: 51 добавлений и 43 удалений

Просмотреть файл

@ -1,3 +1,11 @@
Sat Jun 22 04:48:53 2013 Koichi Sasada <ko1@atdot.net>
* include/ruby/ruby.h (OBJ_WRITE): cast to (VALUE *) for second
parameter `slot'. You don't need to write a cast (VALUE *) any more.
* class.c, compile.c, hash.c, iseq.c, proc.c, re.c, variable.c,
vm.c, vm_method.c: remove cast expressions for OBJ_WRITE().
Sat Jun 22 04:37:08 2013 Koichi Sasada <ko1@atdot.net>
* gc.c (slot_sweep_body): rename to slot_sweep().

Просмотреть файл

@ -146,7 +146,7 @@ clone_method(VALUE klass, ID mid, const rb_method_entry_t *me)
rb_iseq_t *iseq;
newiseqval = rb_iseq_clone(me->def->body.iseq->self, klass);
GetISeqPtr(newiseqval, iseq);
OBJ_WRITE(iseq->self, (VALUE *)&iseq->cref_stack, rewrite_cref_stack(me->def->body.iseq->cref_stack, me->klass, klass));
OBJ_WRITE(iseq->self, &iseq->cref_stack, rewrite_cref_stack(me->def->body.iseq->cref_stack, me->klass, klass));
rb_add_method(klass, mid, VM_METHOD_TYPE_ISEQ, iseq, me->flag);
RB_GC_GUARD(newiseqval);
}

Просмотреть файл

@ -278,7 +278,7 @@ r_value(VALUE value)
if (compile_debug) rb_compile_bug strs; \
GET_THREAD()->errinfo = iseq->compile_data->err_info; \
rb_compile_error strs; \
OBJ_WRITE(iseq->self, (VALUE *)&iseq->compile_data->err_info, GET_THREAD()->errinfo); \
OBJ_WRITE(iseq->self, &iseq->compile_data->err_info, GET_THREAD()->errinfo); \
GET_THREAD()->errinfo = tmp; \
ret = 0; \
break; \
@ -1706,7 +1706,7 @@ iseq_set_exception_table(rb_iseq_t *iseq)
}
}
OBJ_WRITE(iseq->self, (VALUE *)&iseq->compile_data->catch_table_ary, 0); /* free */
OBJ_WRITE(iseq->self, &iseq->compile_data->catch_table_ary, 0); /* free */
return COMPILE_OK;
}

2
hash.c
Просмотреть файл

@ -56,7 +56,7 @@ static ID id_hash, id_yield, id_default;
VALUE
rb_hash_set_ifnone(VALUE hash, VALUE ifnone)
{
OBJ_WRITE(hash, (VALUE *)(&RHASH(hash)->ifnone), ifnone);
OBJ_WRITE(hash, (&RHASH(hash)->ifnone), ifnone);
return hash;
}

Просмотреть файл

@ -969,7 +969,7 @@ struct RArray {
#define RARRAY_AREF(a, i) (RARRAY_RAWPTR(a)[i])
#define RARRAY_ASET(a, i, v) do { \
const VALUE _ary_ = (a); \
OBJ_WRITE(_ary_, (VALUE *)&RARRAY_RAWPTR(_ary_)[i], (v)); \
OBJ_WRITE(_ary_, &RARRAY_RAWPTR(_ary_)[i], (v)); \
} while (0)
#define RARRAY_PTR(a) ((VALUE *)RARRAY_RAWPTR(RGENGC_WB_PROTECTED_ARRAY ? OBJ_WB_GIVEUP((VALUE)a) : ((VALUE)a)))
@ -1010,8 +1010,8 @@ struct RRational {
const VALUE den;
};
#define RRATIONAL_SET_NUM(rat, n) OBJ_WRITE((rat), ((VALUE *)(&((struct RRational *)(rat))->num)),(n))
#define RRATIONAL_SET_DEN(rat, d) OBJ_WRITE((rat), ((VALUE *)(&((struct RRational *)(rat))->den)),(d))
#define RRATIONAL_SET_NUM(rat, n) OBJ_WRITE((rat), &((struct RRational *)(rat))->num,(n))
#define RRATIONAL_SET_DEN(rat, d) OBJ_WRITE((rat), &((struct RRational *)(rat))->den,(d))
struct RComplex {
struct RBasic basic;
@ -1019,8 +1019,8 @@ struct RComplex {
const VALUE imag;
};
#define RCOMPLEX_SET_REAL(cmp, r) OBJ_WRITE((cmp), ((VALUE *)(&((struct RComplex *)(cmp))->real)),(r))
#define RCOMPLEX_SET_IMAG(cmp, i) OBJ_WRITE((cmp), ((VALUE *)(&((struct RComplex *)(cmp))->imag)),(i))
#define RCOMPLEX_SET_REAL(cmp, r) OBJ_WRITE((cmp), &((struct RComplex *)(cmp))->real,(r))
#define RCOMPLEX_SET_IMAG(cmp, i) OBJ_WRITE((cmp), &((struct RComplex *)(cmp))->imag,(i))
struct RData {
struct RBasic basic;
@ -1131,7 +1131,7 @@ struct RStruct {
RSTRUCT(st)->as.heap.ptr)
#define RSTRUCT_PTR(st) ((VALUE *)RSTRUCT_RAWPTR(RGENGC_WB_PROTECTED_STRUCT ? OBJ_WB_GIVEUP((VALUE)st) : (VALUE)st))
#define RSTRUCT_SET(st, idx, v) OBJ_WRITE(st, (VALUE *)&RSTRUCT_RAWPTR(st)[idx], v)
#define RSTRUCT_SET(st, idx, v) OBJ_WRITE(st, &RSTRUCT_RAWPTR(st)[idx], (v))
#define RSTRUCT_GET(st, idx) (RSTRUCT_RAWPTR(st)[idx])
#define RBIGNUM_EMBED_LEN_MAX ((int)((sizeof(VALUE)*3)/sizeof(BDIGIT)))
@ -1258,7 +1258,7 @@ void rb_gc_giveup_promoted_writebarrier(VALUE obj);
#define OBJ_SHADE(x) OBJ_WB_GIVEUP(x) /* RGENGC terminology */
#endif
#define OBJ_WRITE(a, slot, b) rb_obj_write((VALUE)(a), (slot), (VALUE)(b), __FILE__, __LINE__)
#define OBJ_WRITE(a, slot, b) rb_obj_write((VALUE)(a), (VALUE *)(slot), (VALUE)(b), __FILE__, __LINE__)
#define OBJ_WRITTEN(a, oldv, b) rb_obj_written((VALUE)(a), (VALUE)(oldv), (VALUE)(b), __FILE__, __LINE__)
static inline VALUE

44
iseq.c
Просмотреть файл

@ -184,20 +184,20 @@ static rb_iseq_location_t *
iseq_location_setup(rb_iseq_t *iseq, VALUE path, VALUE absolute_path, VALUE name, size_t first_lineno)
{
rb_iseq_location_t *loc = &iseq->location;
OBJ_WRITE(iseq->self, (VALUE *)&loc->path, path);
OBJ_WRITE(iseq->self, &loc->path, path);
if (RTEST(absolute_path) && rb_str_cmp(path, absolute_path) == 0) {
OBJ_WRITE(iseq->self, (VALUE *)&loc->absolute_path, path);
OBJ_WRITE(iseq->self, &loc->absolute_path, path);
}
else {
OBJ_WRITE(iseq->self, (VALUE *)&loc->absolute_path, absolute_path);
OBJ_WRITE(iseq->self, &loc->absolute_path, absolute_path);
}
OBJ_WRITE(iseq->self, (VALUE *)&loc->label, name);
OBJ_WRITE(iseq->self, (VALUE *)&loc->base_label, name);
OBJ_WRITE(iseq->self, &loc->label, name);
OBJ_WRITE(iseq->self, &loc->base_label, name);
loc->first_lineno = first_lineno;
return loc;
}
#define ISEQ_SET_CREF(iseq, cref) OBJ_WRITE((iseq)->self, (VALUE *)&(iseq)->cref_stack, (cref))
#define ISEQ_SET_CREF(iseq, cref) OBJ_WRITE((iseq)->self, &(iseq)->cref_stack, (cref))
static void
set_relation(rb_iseq_t *iseq, const VALUE parent)
@ -209,7 +209,7 @@ set_relation(rb_iseq_t *iseq, const VALUE parent)
/* set class nest stack */
if (type == ISEQ_TYPE_TOP) {
/* toplevel is private */
OBJ_WRITE(iseq->self, (VALUE *)&iseq->cref_stack, NEW_CREF(rb_cObject));
OBJ_WRITE(iseq->self, &iseq->cref_stack, NEW_CREF(rb_cObject));
iseq->cref_stack->nd_refinements = Qnil;
iseq->cref_stack->nd_visi = NOEX_PRIVATE;
if (th->top_wrapper) {
@ -246,7 +246,7 @@ void
rb_iseq_add_mark_object(rb_iseq_t *iseq, VALUE obj)
{
if (!RTEST(iseq->mark_ary)) {
OBJ_WRITE(iseq->self, (VALUE *)&iseq->mark_ary, rb_ary_tmp_new(3));
OBJ_WRITE(iseq->self, &iseq->mark_ary, rb_ary_tmp_new(3));
RBASIC_CLEAR_CLASS(iseq->mark_ary);
}
rb_ary_push(iseq->mark_ary, obj);
@ -262,7 +262,7 @@ prepare_iseq_build(rb_iseq_t *iseq,
iseq->arg_rest = -1;
iseq->arg_block = -1;
iseq->arg_keyword = -1;
OBJ_WRITE(iseq->self, (VALUE *)&iseq->klass, 0);
OBJ_WRITE(iseq->self, &iseq->klass, 0);
set_relation(iseq, parent);
OBJ_FREEZE(name);
@ -270,11 +270,11 @@ prepare_iseq_build(rb_iseq_t *iseq,
iseq_location_setup(iseq, path, absolute_path, name, first_lineno);
if (iseq != iseq->local_iseq) {
OBJ_WRITE(iseq->self, (VALUE *)&iseq->location.base_label, iseq->local_iseq->location.label);
OBJ_WRITE(iseq->self, &iseq->location.base_label, iseq->local_iseq->location.label);
}
iseq->defined_method_id = 0;
OBJ_WRITE(iseq->self, (VALUE *)&iseq->mark_ary, 0);
OBJ_WRITE(iseq->self, &iseq->mark_ary, 0);
/*
* iseq->special_block_builder = GC_GUARDED_PTR_REF(block_opt);
@ -284,15 +284,15 @@ prepare_iseq_build(rb_iseq_t *iseq,
iseq->compile_data = ALLOC(struct iseq_compile_data);
MEMZERO(iseq->compile_data, struct iseq_compile_data, 1);
OBJ_WRITE(iseq->self, (VALUE *)&iseq->compile_data->err_info, Qnil);
OBJ_WRITE(iseq->self, (VALUE *)&iseq->compile_data->mark_ary, rb_ary_tmp_new(3));
OBJ_WRITE(iseq->self, &iseq->compile_data->err_info, Qnil);
OBJ_WRITE(iseq->self, &iseq->compile_data->mark_ary, rb_ary_tmp_new(3));
iseq->compile_data->storage_head = iseq->compile_data->storage_current =
(struct iseq_compile_data_storage *)
ALLOC_N(char, INITIAL_ISEQ_COMPILE_DATA_STORAGE_BUFF_SIZE +
sizeof(struct iseq_compile_data_storage));
OBJ_WRITE(iseq->self, (VALUE *)&iseq->compile_data->catch_table_ary, rb_ary_new());
OBJ_WRITE(iseq->self, &iseq->compile_data->catch_table_ary, rb_ary_new());
iseq->compile_data->storage_head->pos = 0;
iseq->compile_data->storage_head->next = 0;
iseq->compile_data->storage_head->size =
@ -302,12 +302,12 @@ prepare_iseq_build(rb_iseq_t *iseq,
iseq->compile_data->option = option;
iseq->compile_data->last_coverable_line = -1;
OBJ_WRITE(iseq->self, (VALUE *)&iseq->coverage, Qfalse);
OBJ_WRITE(iseq->self, &iseq->coverage, Qfalse);
if (!GET_THREAD()->parse_in_eval) {
VALUE coverages = rb_get_coverages();
if (RTEST(coverages)) {
OBJ_WRITE(iseq->self, (VALUE *)&iseq->coverage, rb_hash_lookup(coverages, path));
if (NIL_P(iseq->coverage)) OBJ_WRITE(iseq->self, (VALUE *)&iseq->coverage, Qfalse);
OBJ_WRITE(iseq->self, &iseq->coverage, rb_hash_lookup(coverages, path));
if (NIL_P(iseq->coverage)) OBJ_WRITE(iseq->self, &iseq->coverage, Qfalse);
}
}
@ -1907,7 +1907,7 @@ rb_iseq_clone(VALUE iseqval, VALUE newcbase)
iseq1->self = newiseq;
if (!iseq1->orig) {
OBJ_WRITE(iseq1->self, (VALUE *)&iseq1->orig, iseqval);
OBJ_WRITE(iseq1->self, &iseq1->orig, iseqval);
}
if (iseq0->local_iseq == iseq0) {
iseq1->local_iseq = iseq1;
@ -1919,7 +1919,7 @@ rb_iseq_clone(VALUE iseqval, VALUE newcbase)
if (iseq0->cref_stack->nd_next) {
iseq1->cref_stack->nd_next = iseq0->cref_stack->nd_next;
}
OBJ_WRITE(iseq1, (VALUE *)&iseq1->klass, newcbase);
OBJ_WRITE(iseq1, &iseq1->klass, newcbase);
}
return newiseq;
@ -2071,10 +2071,10 @@ rb_iseq_build_for_ruby2cext(
/* copy iseq */
MEMCPY(iseq, iseq_template, rb_iseq_t, 1); /* TODO: write barrier, *iseq = *iseq_template; */
OBJ_WRITE(iseq->self, (VALUE *)&iseq->location.label, rb_str_new2(name));
OBJ_WRITE(iseq->self, (VALUE *)&iseq->location.path, rb_str_new2(path));
OBJ_WRITE(iseq->self, &iseq->location.label, rb_str_new2(name));
OBJ_WRITE(iseq->self, &iseq->location.path, rb_str_new2(path));
iseq->location.first_lineno = first_lineno;
OBJ_WRITE(iseq->self, (VALUE *)&iseq->mark_ary, 0);
OBJ_WRITE(iseq->self, &iseq->mark_ary, 0);
iseq->self = iseqval;
iseq->iseq = ALLOC_N(VALUE, iseq->iseq_size);

2
proc.c
Просмотреть файл

@ -1467,7 +1467,7 @@ rb_mod_define_method(int argc, VALUE *argv, VALUE mod)
GetProcPtr(body, proc);
if (BUILTIN_TYPE(proc->block.iseq) != T_NODE) {
proc->block.iseq->defined_method_id = id;
OBJ_WRITE(proc->block.iseq->self, (VALUE *)&proc->block.iseq->klass, mod);
OBJ_WRITE(proc->block.iseq->self, &proc->block.iseq->klass, mod);
proc->is_lambda = TRUE;
proc->is_from_method = TRUE;
proc->block.klass = mod;

4
re.c
Просмотреть файл

@ -2438,7 +2438,7 @@ rb_reg_initialize(VALUE obj, const char *s, long len, rb_encoding *enc,
options & ARG_REG_OPTION_MASK, err,
sourcefile, sourceline);
if (!re->ptr) return -1;
OBJ_WRITE(obj, (VALUE *)&re->src, rb_enc_str_new(s, len, enc));
OBJ_WRITE(obj, &re->src, rb_enc_str_new(s, len, enc));
OBJ_FREEZE(re->src);
RB_GC_GUARD(unescaped);
return 0;
@ -2473,7 +2473,7 @@ rb_reg_s_alloc(VALUE klass)
NEWOBJ_OF(re, struct RRegexp, klass, T_REGEXP | (RGENGC_WB_PROTECTED_REGEXP ? FL_WB_PROTECTED : 0));
re->ptr = 0;
OBJ_WRITE(re, (VALUE *)&re->src, 0);
OBJ_WRITE(re, &re->src, 0);
re->usecnt = 0;
return (VALUE)re;

Просмотреть файл

@ -2184,8 +2184,8 @@ rb_const_set(VALUE klass, ID id, VALUE val)
ce->flag = visibility;
ce->line = rb_sourceline();
st_insert(RCLASS_CONST_TBL(klass), (st_data_t)id, (st_data_t)ce);
OBJ_WRITE(klass, (VALUE *)&ce->value, val);
OBJ_WRITE(klass, (VALUE *)&ce->file, rb_sourcefilename());
OBJ_WRITE(klass, &ce->value, val);
OBJ_WRITE(klass, &ce->file, rb_sourcefilename());
}
void

4
vm.c
Просмотреть файл

@ -2031,7 +2031,7 @@ vm_define_method(rb_thread_t *th, VALUE obj, ID id, VALUE iseqval,
/* dup */
COPY_CREF(miseq->cref_stack, cref);
miseq->cref_stack->nd_visi = NOEX_PUBLIC;
OBJ_WRITE(miseq->self, (VALUE *)&miseq->klass, klass);
OBJ_WRITE(miseq->self, &miseq->klass, klass);
miseq->defined_method_id = id;
rb_add_method(klass, id, VM_METHOD_TYPE_ISEQ, miseq, noex);
@ -2532,7 +2532,7 @@ rb_vm_set_progname(VALUE filename)
rb_thread_t *th = GET_VM()->main_thread;
rb_control_frame_t *cfp = (void *)(th->stack + th->stack_size);
--cfp;
OBJ_WRITE(cfp->iseq->self, (VALUE *)&cfp->iseq->location.path, filename);
OBJ_WRITE(cfp->iseq->self, &cfp->iseq->location.path, filename);
}
#if defined(ENABLE_VM_OBJSPACE) && ENABLE_VM_OBJSPACE

Просмотреть файл

@ -426,16 +426,16 @@ rb_add_method(VALUE klass, ID mid, rb_method_type_t type, void *opts, rb_method_
case VM_METHOD_TYPE_ATTRSET:
case VM_METHOD_TYPE_IVAR:
def->body.attr.id = (ID)opts;
OBJ_WRITE(klass, (VALUE *)&def->body.attr.location, Qfalse);
OBJ_WRITE(klass, &def->body.attr.location, Qfalse);
th = GET_THREAD();
cfp = rb_vm_get_ruby_level_next_cfp(th, th->cfp);
if (cfp && (line = rb_vm_get_sourceline(cfp))) {
VALUE location = rb_ary_new3(2, cfp->iseq->location.path, INT2FIX(line));
OBJ_WRITE(klass, (VALUE *)&def->body.attr.location, rb_ary_freeze(location));
OBJ_WRITE(klass, &def->body.attr.location, rb_ary_freeze(location));
}
break;
case VM_METHOD_TYPE_BMETHOD:
OBJ_WRITE(klass, (VALUE *)&def->body.proc, (VALUE)opts);
OBJ_WRITE(klass, &def->body.proc, (VALUE)opts);
break;
case VM_METHOD_TYPE_NOTIMPLEMENTED:
setup_method_cfunc_struct(&def->body.cfunc, rb_f_notimplement, -1);