Restore old function names for compatibility; ref
`mrb_check_intern()` to return `mrb_value`
`mrb_intern_check()` to return `mrb_sym` [NEW]
Other new functions:
`mrb_intern_check_cstr()`
`mrb_intern_check_str()`
MODIFY
include/mruby.h
include/mruby.h
@@ -1097,10 +1097,15 @@ MRB_API mrb_sym mrb_intern(mrb_state*,const char*,size_t);
MRB_API mrb_sym mrb_intern_static(mrb_state*,const char*,size_t);
#define mrb_intern_lit(mrb, lit) mrb_intern_static(mrb, (lit ""), mrb_strlen_lit(lit))
MRB_API mrb_sym mrb_intern_str(mrb_state*,mrb_value);
-/* mrb_check_intern series functions returns 0 if the symbol is not defined */
-MRB_API mrb_sym mrb_check_intern_cstr(mrb_state*,const char*);
-MRB_API mrb_sym mrb_check_intern(mrb_state*,const char*,size_t);
-MRB_API mrb_sym mrb_check_intern_str(mrb_state*,mrb_value);
+/* mrb_intern_check series functions returns 0 if the symbol is not defined */
+MRB_API mrb_sym mrb_intern_check_cstr(mrb_state*,const char*);
+MRB_API mrb_sym mrb_intern_check(mrb_state*,const char*,size_t);
+MRB_API mrb_sym mrb_intern_check_str(mrb_state*,mrb_value);
+/* mrb_check_intern series functions returns nil if the symbol is not defined */
+/* otherwise returns mrb_value */
+MRB_API mrb_value mrb_check_intern_cstr(mrb_state*,const char*);
+MRB_API mrb_value mrb_check_intern(mrb_state*,const char*,size_t);
+MRB_API mrb_value mrb_check_intern_str(mrb_state*,mrb_value);
MRB_API const char *mrb_sym_name(mrb_state*,mrb_sym);
MRB_API const char *mrb_sym_name_len(mrb_state*,mrb_sym,mrb_int*);
MRB_API const char *mrb_sym_dump(mrb_state*,mrb_sym);

MODIFY
mrbgems/mruby-bin-debugger/tools/mrdb/apibreak.c
mrbgems/mruby-bin-debugger/tools/mrdb/apibreak.c
@@ -151,7 +151,7 @@ compare_break_method(mrb_state *mrb, mrb_debug_breakpoint *bp, struct RClass *cl
}
sc = mrb_class_get(mrb, method_p->class_name);
- ssym = mrb_check_intern_cstr(mrb, method_p->method_name);
+ ssym = mrb_intern_check_cstr(mrb, method_p->method_name);
m = mrb_method_search_vm(mrb, &sc, ssym);
if (MRB_METHOD_UNDEF_P(m)) {
return MRB_DEBUG_OK;

MODIFY
mrbgems/mruby-sprintf/src/sprintf.c
mrbgems/mruby-sprintf/src/sprintf.c
@@ -699,7 +699,7 @@ retry:
}
CHECKNAMEARG(start, p - start + 1);
get_hash(mrb, &hash, argc, argv);
- id = mrb_check_intern(mrb, start + 1, p - start - 1);
+ id = mrb_intern_check(mrb, start + 1, p - start - 1);
if (id) {
nextvalue = mrb_hash_fetch(mrb, hash, mrb_symbol_value(id), mrb_undef_value());
}

MODIFY
src/class.c
src/class.c
@@ -575,7 +575,7 @@ mrb_vm_define_class(mrb_state *mrb, mrb_value outer, mrb_value super, mrb_sym id
MRB_API mrb_bool
mrb_class_defined(mrb_state *mrb, const char *name)
{
- mrb_sym sym = mrb_check_intern_cstr(mrb, name);
+ mrb_sym sym = mrb_intern_check_cstr(mrb, name);
if (!sym) return FALSE;
return mrb_const_defined(mrb, mrb_obj_value(mrb->object_class), sym);
}
@@ -589,7 +589,7 @@ mrb_class_defined_id(mrb_state *mrb, mrb_sym name)
MRB_API mrb_bool
mrb_class_defined_under(mrb_state *mrb, struct RClass *outer, const char *name)
{
- mrb_sym sym = mrb_check_intern_cstr(mrb, name);
+ mrb_sym sym = mrb_intern_check_cstr(mrb, name);
if (!sym) return FALSE;
return mrb_const_defined_at(mrb, mrb_obj_value(outer), sym);
}

MODIFY
src/symbol.c
src/symbol.c
@@ -268,7 +268,7 @@ mrb_intern_str(mrb_state *mrb, mrb_value str)
}
MRB_API mrb_sym
-mrb_check_intern(mrb_state *mrb, const char *name, size_t len)
+mrb_intern_check(mrb_state *mrb, const char *name, size_t len)
{
mrb_sym sym;
@@ -278,16 +278,40 @@ mrb_check_intern(mrb_state *mrb, const char *name, size_t len)
return 0;
}
+MRB_API mrb_value
+mrb_check_intern(mrb_state *mrb, const char *name, size_t len)
+{
+ mrb_sym sym = mrb_intern_check(mrb, name, len);
+ if (sym == 0) return mrb_nil_value();
+ return mrb_symbol_value(sym);
+}
+
MRB_API mrb_sym
+mrb_intern_check_cstr(mrb_state *mrb, const char *name)
+{
+ return mrb_intern_check(mrb, name, strlen(name));
+}
+
+MRB_API mrb_value
mrb_check_intern_cstr(mrb_state *mrb, const char *name)
{
- return mrb_check_intern(mrb, name, strlen(name));
+ mrb_sym sym = mrb_intern_check_cstr(mrb, name);
+ if (sym == 0) return mrb_nil_value();
+ return mrb_symbol_value(sym);
}
MRB_API mrb_sym
+mrb_intern_check_str(mrb_state *mrb, mrb_value str)
+{
+ return mrb_intern_check(mrb, RSTRING_PTR(str), RSTRING_LEN(str));
+}
+
+MRB_API mrb_value
mrb_check_intern_str(mrb_state *mrb, mrb_value str)
{
- return mrb_check_intern(mrb, RSTRING_PTR(str), RSTRING_LEN(str));
+ mrb_sym sym = mrb_intern_check_str(mrb, str);
+ if (sym == 0) return mrb_nil_value();
+ return mrb_symbol_value(sym);
}
static const char*

Restore old function names for compatibility; ref #5070

- `mrb_check_intern()` to return `mrb_value`
- `mrb_intern_check()` to return `mrb_sym` [NEW]

Other new functions:

- `mrb_intern_check_cstr()`
- `mrb_intern_check_str()`