mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
mrb_load_xxx to return undef + mrb_undef_p
This commit is contained in:
+1
-1
@@ -81,7 +81,7 @@ typedef struct mrb_value {
|
||||
#define mrb_symbol(o) (o).value.sym
|
||||
#define mrb_object(o) ((struct RBasic *) (o).value.p)
|
||||
#define FIXNUM_P(o) ((o).tt == MRB_TT_FIXNUM)
|
||||
#define UNDEF_P(o) ((o).tt == MRB_TT_UNDEF)
|
||||
#define mrb_undef_p(o) ((o).tt == MRB_TT_UNDEF)
|
||||
|
||||
#include "mruby/object.h"
|
||||
|
||||
|
||||
+1
-1
@@ -1038,7 +1038,7 @@ mrb_obj_remove_instance_variable(mrb_state *mrb, mrb_value self)
|
||||
|
||||
mrb_get_args(mrb, "n", &sym);
|
||||
val = mrb_iv_remove(mrb, self, sym);
|
||||
if (UNDEF_P(val)) {
|
||||
if (mrb_undef_p(val)) {
|
||||
mrb_name_error(mrb, sym, "instance variable %s not defined", mrb_sym2name(mrb, sym));
|
||||
}
|
||||
return val;
|
||||
|
||||
+3
-3
@@ -4874,7 +4874,7 @@ load_exec(mrb_state *mrb, parser_state *p, mrbc_context *c)
|
||||
|
||||
if (!p) {
|
||||
mrb_parser_free(p);
|
||||
return mrb_nil_value();
|
||||
return mrb_undef_value();
|
||||
}
|
||||
if (p->capture_errors && (!p->tree || p->nerr)) {
|
||||
char buf[256];
|
||||
@@ -4883,13 +4883,13 @@ load_exec(mrb_state *mrb, parser_state *p, mrbc_context *c)
|
||||
p->error_buffer[0].lineno, p->error_buffer[0].message);
|
||||
mrb->exc = (struct RObject*)mrb_object(mrb_exc_new(mrb, E_SYNTAX_ERROR, buf, n));
|
||||
mrb_parser_free(p);
|
||||
return mrb_nil_value();
|
||||
return mrb_undef_value();
|
||||
}
|
||||
n = mrb_generate_code(mrb, p->tree);
|
||||
mrb_parser_free(p);
|
||||
if (n < 0) {
|
||||
mrb->exc = (struct RObject*)mrb_object(mrb_exc_new(mrb, E_SCRIPT_ERROR, "codegen error", 13));
|
||||
return mrb_nil_value();
|
||||
return mrb_undef_value();
|
||||
}
|
||||
if (c) {
|
||||
if (c->dump_result) codedump_all(mrb, n);
|
||||
|
||||
+4
-4
@@ -145,7 +145,7 @@ mrb_fix2binstr(mrb_state *mrb, mrb_value x, int base)
|
||||
blen += (l);\
|
||||
} while (0)
|
||||
|
||||
#define GETARG() (!UNDEF_P(nextvalue) ? nextvalue : \
|
||||
#define GETARG() (!mrb_undef_p(nextvalue) ? nextvalue : \
|
||||
posarg == -1 ? \
|
||||
(mrb_raise(mrb, E_ARGUMENT_ERROR, "unnumbered(%d) mixed with numbered", nextarg), mrb_undef_value()) : \
|
||||
posarg == -2 ? \
|
||||
@@ -201,7 +201,7 @@ get_hash(mrb_state *mrb, mrb_value *hash, int argc, const mrb_value *argv)
|
||||
{
|
||||
mrb_value tmp;
|
||||
|
||||
if (!UNDEF_P(*hash)) return *hash;
|
||||
if (!mrb_undef_p(*hash)) return *hash;
|
||||
if (argc != 2) {
|
||||
mrb_raise(mrb, E_ARGUMENT_ERROR, "one hash required");
|
||||
}
|
||||
@@ -586,7 +586,7 @@ retry:
|
||||
n = 0;
|
||||
GETNUM(n, width);
|
||||
if (*p == '$') {
|
||||
if (!UNDEF_P(nextvalue)) {
|
||||
if (!mrb_undef_p(nextvalue)) {
|
||||
mrb_raise(mrb, E_ARGUMENT_ERROR, "value given twice - %d$", n);
|
||||
}
|
||||
nextvalue = GETPOSARG(n);
|
||||
@@ -614,7 +614,7 @@ retry:
|
||||
symname = mrb_str_new(mrb, start + 1, p - start - 1);
|
||||
id = mrb_intern_str(mrb, symname);
|
||||
nextvalue = GETNAMEARG(mrb_symbol_value(id), start, (int)(p - start + 1));
|
||||
if (UNDEF_P(nextvalue)) {
|
||||
if (mrb_undef_p(nextvalue)) {
|
||||
mrb_raise(mrb, E_KEY_ERROR, "key%.*s not found", (int)(p - start + 1), start);
|
||||
}
|
||||
if (term == '}') goto format_s;
|
||||
|
||||
+1
-1
@@ -179,7 +179,7 @@ main(int argc, char **argv)
|
||||
c->dump_result = 1;
|
||||
c->no_exec = 1;
|
||||
result = mrb_load_file_cxt(mrb, args.rfp, c);
|
||||
if (mrb_nil_p(result)) {
|
||||
if (mrb_undef_p(result)) {
|
||||
cleanup(&args);
|
||||
mrb_close(mrb);
|
||||
return -1;
|
||||
|
||||
Reference in New Issue
Block a user