mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
cast MRB_ENV_STACK_LEN to (mrb_int); ref #2600
This commit is contained in:
@@ -20,7 +20,8 @@ struct REnv {
|
||||
ptrdiff_t cioff;
|
||||
};
|
||||
|
||||
#define MRB_ENV_STACK_LEN(e) ((e)->flags)
|
||||
#define MRB_SET_ENV_STACK_LEN(e,len) (e)->flags = (unsigned int)(len)
|
||||
#define MRB_ENV_STACK_LEN(e) ((mrb_int)(e)->flags)
|
||||
#define MRB_ENV_UNSHARE_STACK(e) ((e)->cioff = -1)
|
||||
#define MRB_ENV_STACK_SHARED_P(e) ((e)->cioff >= 0)
|
||||
|
||||
|
||||
@@ -70,4 +70,7 @@ MRuby::GemBox.new do |conf|
|
||||
|
||||
# Use extensional Kernel module
|
||||
conf.gem :core => "mruby-kernel-ext"
|
||||
|
||||
# Use extensional Kernel module
|
||||
conf.gem :github => "matz/mruby-thread"
|
||||
end
|
||||
|
||||
@@ -532,9 +532,9 @@ gc_mark_children(mrb_state *mrb, struct RBasic *obj)
|
||||
struct REnv *e = (struct REnv*)obj;
|
||||
|
||||
if (!MRB_ENV_STACK_SHARED_P(e)) {
|
||||
int i, len;
|
||||
mrb_int i, len;
|
||||
|
||||
len = (int)MRB_ENV_STACK_LEN(e);
|
||||
len = MRB_ENV_STACK_LEN(e);
|
||||
for (i=0; i<len; i++) {
|
||||
mrb_gc_mark_value(mrb, e->stack[i]);
|
||||
}
|
||||
|
||||
+2
-2
@@ -40,7 +40,7 @@ env_new(mrb_state *mrb, int nlocals)
|
||||
struct REnv *e;
|
||||
|
||||
e = (struct REnv*)mrb_obj_alloc(mrb, MRB_TT_ENV, (struct RClass*)mrb->c->ci->proc->env);
|
||||
MRB_ENV_STACK_LEN(e) = (unsigned int)nlocals;
|
||||
MRB_SET_ENV_STACK_LEN(e, nlocals);
|
||||
e->mid = mrb->c->ci->mid;
|
||||
e->cioff = mrb->c->ci - mrb->c->cibase;
|
||||
e->stack = mrb->c->stack;
|
||||
@@ -126,7 +126,7 @@ mrb_proc_cfunc_env_get(mrb_state *mrb, mrb_int idx)
|
||||
if (!e) {
|
||||
mrb_raise(mrb, E_TYPE_ERROR, "Can't get cfunc env from cfunc Proc without REnv.");
|
||||
}
|
||||
if (idx < 0 || (mrb_int)MRB_ENV_STACK_LEN(e) <= idx) {
|
||||
if (idx < 0 || MRB_ENV_STACK_LEN(e) <= idx) {
|
||||
mrb_raisef(mrb, E_INDEX_ERROR, "Env index out of range: %S (expected: 0 <= index < %S)",
|
||||
mrb_fixnum_value(idx), mrb_fixnum_value(MRB_ENV_STACK_LEN(e)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user