mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Add more const qualifier for RProc
This commit is contained in:
+4
-4
@@ -22,7 +22,7 @@
|
||||
#define METHOD_MID(m) MT_KEY_SYM((m).flags)
|
||||
|
||||
union mt_ptr {
|
||||
struct RProc *proc;
|
||||
const struct RProc *proc;
|
||||
mrb_func_t func;
|
||||
};
|
||||
|
||||
@@ -285,7 +285,7 @@ mrb_gc_mark_mt(mrb_state *mrb, struct RClass *c)
|
||||
union mt_ptr *vals = t->ptr;
|
||||
for (int i=0; i<t->alloc; i++) {
|
||||
if (MT_KEY_P(keys[i]) && (keys[i] & MT_FUNC) == 0) { /* Proc pointer */
|
||||
struct RProc *p = vals[i].proc;
|
||||
const struct RProc *p = vals[i].proc;
|
||||
mrb_gc_mark(mrb, (struct RBasic*)p);
|
||||
}
|
||||
}
|
||||
@@ -755,7 +755,7 @@ mrb_define_method_raw(mrb_state *mrb, struct RClass *c, mrb_sym mid, mrb_method_
|
||||
}
|
||||
if (!h) h = c->mt = mt_new(mrb);
|
||||
if (MRB_METHOD_PROC_P(m)) {
|
||||
struct RProc *p = MRB_METHOD_PROC(m);
|
||||
struct RProc *p = (struct RProc*)MRB_METHOD_PROC(m);
|
||||
|
||||
ptr.proc = p;
|
||||
if (p) {
|
||||
@@ -2217,7 +2217,7 @@ mrb_alias_method(mrb_state *mrb, struct RClass *c, mrb_sym a, mrb_sym b)
|
||||
mrb_method_t m = mrb_method_search(mrb, c, b);
|
||||
|
||||
if (!MRB_METHOD_CFUNC_P(m)) {
|
||||
struct RProc *p = MRB_METHOD_PROC(m);
|
||||
const struct RProc *p = MRB_METHOD_PROC(m);
|
||||
if (!MRB_PROC_CFUNC_P(p) && !MRB_PROC_ALIAS_P(p)) {
|
||||
struct RProc *pnew = MRB_OBJ_ALLOC(mrb, MRB_TT_PROC, mrb->proc_class);
|
||||
|
||||
|
||||
+6
-6
@@ -199,7 +199,7 @@ mrb_proc_cfunc_env_get(mrb_state *mrb, mrb_int idx)
|
||||
}
|
||||
|
||||
mrb_value
|
||||
mrb_proc_get_self(mrb_state *mrb, struct RProc *p, struct RClass **target_class_p)
|
||||
mrb_proc_get_self(mrb_state *mrb, const struct RProc *p, struct RClass **target_class_p)
|
||||
{
|
||||
if (MRB_PROC_CFUNC_P(p)) {
|
||||
*target_class_p = mrb->object_class;
|
||||
@@ -222,7 +222,7 @@ mrb_proc_get_self(mrb_state *mrb, struct RProc *p, struct RClass **target_class_
|
||||
}
|
||||
|
||||
void
|
||||
mrb_proc_copy(mrb_state *mrb, struct RProc *a, struct RProc *b)
|
||||
mrb_proc_copy(mrb_state *mrb, struct RProc *a, const struct RProc *b)
|
||||
{
|
||||
if (a->body.irep) {
|
||||
/* already initialized proc */
|
||||
@@ -288,8 +288,8 @@ mrb_proc_eql(mrb_state *mrb, mrb_value self, mrb_value other)
|
||||
if (mrb_type(self) != MRB_TT_PROC) return FALSE;
|
||||
if (mrb_type(other) != MRB_TT_PROC) return FALSE;
|
||||
|
||||
struct RProc *p1 = mrb_proc_ptr(self);
|
||||
struct RProc *p2 = mrb_proc_ptr(other);
|
||||
const struct RProc *p1 = mrb_proc_ptr(self);
|
||||
const struct RProc *p2 = mrb_proc_ptr(other);
|
||||
if (MRB_PROC_CFUNC_P(p1)) {
|
||||
if (!MRB_PROC_CFUNC_P(p1)) return FALSE;
|
||||
if (p1->body.func != p2->body.func) return FALSE;
|
||||
@@ -308,7 +308,7 @@ proc_eql(mrb_state *mrb, mrb_value self)
|
||||
static mrb_value
|
||||
proc_hash(mrb_state *mrb, mrb_value self)
|
||||
{
|
||||
struct RProc *p = mrb_proc_ptr(self);
|
||||
const struct RProc *p = mrb_proc_ptr(self);
|
||||
return mrb_int_value(mrb, (mrb_int)(((intptr_t)p->body.irep)^MRB_TT_PROC));
|
||||
}
|
||||
|
||||
@@ -325,7 +325,7 @@ static mrb_value
|
||||
proc_lambda(mrb_state *mrb, mrb_value self)
|
||||
{
|
||||
mrb_value blk;
|
||||
struct RProc *p;
|
||||
const struct RProc *p;
|
||||
|
||||
mrb_get_args(mrb, "&", &blk);
|
||||
if (mrb_nil_p(blk)) {
|
||||
|
||||
@@ -810,7 +810,7 @@ exec_irep(mrb_state *mrb, mrb_value self, const struct RProc *p)
|
||||
}
|
||||
|
||||
mrb_value
|
||||
mrb_exec_irep(mrb_state *mrb, mrb_value self, struct RProc *p)
|
||||
mrb_exec_irep(mrb_state *mrb, mrb_value self, const struct RProc *p)
|
||||
{
|
||||
mrb_callinfo *ci = mrb->c->ci;
|
||||
if (ci->cci == CINFO_NONE) {
|
||||
@@ -968,7 +968,7 @@ eval_under(mrb_state *mrb, mrb_value self, mrb_value blk, struct RClass *c)
|
||||
return mrb_yield_with_class(mrb, blk, 1, &self, self, c);
|
||||
}
|
||||
ci->u.target_class = c;
|
||||
struct RProc *p = mrb_proc_ptr(blk);
|
||||
const struct RProc *p = mrb_proc_ptr(blk);
|
||||
/* just in case irep is NULL; #6065 */
|
||||
if (p->body.irep == NULL) return mrb_nil_value();
|
||||
CI_PROC_SET(ci, p);
|
||||
@@ -1053,7 +1053,7 @@ mrb_yield_with_class(mrb_state *mrb, mrb_value b, mrb_int argc, const mrb_value
|
||||
|
||||
mrb_callinfo *ci = mrb->c->ci;
|
||||
mrb_int n = mrb_ci_nregs(ci);
|
||||
struct RProc *p = mrb_proc_ptr(b);
|
||||
const struct RProc *p = mrb_proc_ptr(b);
|
||||
mrb_sym mid;
|
||||
|
||||
if (MRB_PROC_ENV_P(p)) {
|
||||
@@ -1087,7 +1087,7 @@ mrb_yield_with_class(mrb_state *mrb, mrb_value b, mrb_int argc, const mrb_value
|
||||
MRB_API mrb_value
|
||||
mrb_yield_argv(mrb_state *mrb, mrb_value b, mrb_int argc, const mrb_value *argv)
|
||||
{
|
||||
struct RProc *p = mrb_proc_ptr(b);
|
||||
const struct RProc *p = mrb_proc_ptr(b);
|
||||
struct RClass *tc;
|
||||
mrb_value self = mrb_proc_get_self(mrb, p, &tc);
|
||||
|
||||
@@ -1097,7 +1097,7 @@ mrb_yield_argv(mrb_state *mrb, mrb_value b, mrb_int argc, const mrb_value *argv)
|
||||
MRB_API mrb_value
|
||||
mrb_yield(mrb_state *mrb, mrb_value b, mrb_value arg)
|
||||
{
|
||||
struct RProc *p = mrb_proc_ptr(b);
|
||||
const struct RProc *p = mrb_proc_ptr(b);
|
||||
struct RClass *tc;
|
||||
mrb_value self = mrb_proc_get_self(mrb, p, &tc);
|
||||
|
||||
@@ -1109,7 +1109,7 @@ mrb_yield_cont(mrb_state *mrb, mrb_value b, mrb_value self, mrb_int argc, const
|
||||
{
|
||||
check_block(mrb, b);
|
||||
|
||||
struct RProc *p = mrb_proc_ptr(b);
|
||||
const struct RProc *p = mrb_proc_ptr(b);
|
||||
mrb_callinfo *ci = mrb->c->ci;
|
||||
|
||||
stack_extend_adjust(mrb, 4, &argv);
|
||||
@@ -2951,7 +2951,7 @@ RETRY_TRY_BLOCK:
|
||||
|
||||
CASE(OP_DEF, BB) {
|
||||
struct RClass *target = mrb_class_ptr(regs[a]);
|
||||
struct RProc *p = mrb_proc_ptr(regs[a+1]);
|
||||
const struct RProc *p = mrb_proc_ptr(regs[a+1]);
|
||||
mrb_method_t m;
|
||||
mrb_sym mid = irep->syms[b];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user