modules/mruby/src/class.c in webruby-0.1.1 vs modules/mruby/src/class.c in webruby-0.1.2
- old
+ new
@@ -309,11 +309,10 @@
{
struct RProc *p;
int ai = mrb_gc_arena_save(mrb);
p = mrb_proc_new_cfunc(mrb, func);
- p->target_class = c;
mrb_define_method_raw(mrb, c, mid, p);
mrb_gc_arena_restore(mrb, ai);
}
void
@@ -493,11 +492,11 @@
ps = va_arg(ap, char**);
if (i < argc) {
ss = to_str(mrb, *sp++);
s = mrb_str_ptr(ss);
- if (strlen(s->ptr) < s->len) {
+ if ((mrb_int)strlen(s->ptr) < s->len) {
mrb_raise(mrb, E_ARGUMENT_ERROR, "String contains NUL");
}
*ps = s->ptr;
i++;
}
@@ -1435,11 +1434,12 @@
{
mrb_value m;
if (!mrb_obj_respond_to(c, a)) {
mrb_name_error(mrb, a, "undefined method '%S' for class '%S'", mrb_sym2str(mrb, a), mrb_obj_value(c));
- } else {
+ }
+ else {
MRB_SET_VALUE(m, MRB_TT_PROC, value.p, 0);
mrb_define_method_vm(mrb, c, a, m);
}
}
@@ -1482,12 +1482,13 @@
if (mrb_nil_p(blk)) {
mrb_raise(mrb, E_ARGUMENT_ERROR, "no block given");
}
p = (struct RProc*)mrb_obj_alloc(mrb, MRB_TT_PROC, mrb->proc_class);
mrb_proc_copy(p, mrb_proc_ptr(blk));
+ p->flags |= MRB_PROC_STRICT;
mrb_define_method_raw(mrb, c, mid, p);
- return blk;
+ return mrb_symbol_value(mid);
}
static void
check_cv_name_sym(mrb_state *mrb, mrb_sym id)
{
@@ -1517,11 +1518,12 @@
mrb_get_args(mrb, "o", &sym_or_str);
if (mrb_symbol_p(sym_or_str) || mrb_string_p(sym_or_str)) {
return sym_or_str;
- } else {
+ }
+ else {
mrb_value obj = mrb_funcall(mrb, sym_or_str, "inspect", 0);
mrb_raisef(mrb, E_TYPE_ERROR, "%S is not a symbol", obj);
return mrb_nil_value();
}
}
@@ -1549,11 +1551,12 @@
id = get_sym_or_str_arg(mrb);
if (mrb_symbol_p(id)) {
check_cv_name_sym(mrb, mrb_symbol(id));
defined_p = mrb_cv_defined(mrb, mod, mrb_symbol(id));
- } else {
+ }
+ else {
mrb_value sym;
check_cv_name_str(mrb, id);
sym = mrb_check_intern_str(mrb, id);
if (mrb_nil_p(sym)) {
defined_p = FALSE;
@@ -1701,11 +1704,12 @@
mrb_bool method_defined_p;
id = get_sym_or_str_arg(mrb);
if (mrb_symbol_p(id)) {
method_defined_p = mrb_obj_respond_to(mrb_class_ptr(mod), mrb_symbol(id));
- } else {
+ }
+ else {
mrb_value sym = mrb_check_intern_str(mrb, id);
if (mrb_nil_p(sym)) {
method_defined_p = FALSE;
}
else {
@@ -1785,10 +1789,11 @@
id = get_sym_or_str_arg(mrb);
if (mrb_type(id) == MRB_TT_SYMBOL) {
check_const_name_sym(mrb, mrb_symbol(id));
const_defined_p = mrb_const_defined(mrb, mod, mrb_symbol(id));
- } else {
+ }
+ else {
mrb_value sym;
check_const_name_str(mrb, id);
sym = mrb_check_intern_str(mrb, id);
if (mrb_nil_p(sym)) {
const_defined_p = FALSE;