summaryrefslogtreecommitdiffhomepage
path: root/src/class.c
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2020-08-19 10:38:30 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2020-10-12 16:21:50 +0900
commitcaee1f68a200d9df1831c4cf0e1954482c317474 (patch)
treee2417d71bdda57a90497bc3a25dd7dcfaeffc11f /src/class.c
parenta4302524d06c2b63617285286dcf41b5a45baf75 (diff)
downloadmruby-caee1f68a200d9df1831c4cf0e1954482c317474.tar.gz
mruby-caee1f68a200d9df1831c4cf0e1954482c317474.zip
Change the return type of `mrb_check_intern()` and friends.
They used to return `mrb_value` but now return `mrb_sym` for consistency with other `intern` functions. If symbols are not defined, `check` functions return `0`, instead of `nil` in the past. It causes API incompatibility but I believe few people use those functions out of the core, and those changes are very easy to handle, hopefully.
Diffstat (limited to 'src/class.c')
-rw-r--r--src/class.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/class.c b/src/class.c
index dd713ed7e..500e7f953 100644
--- a/src/class.c
+++ b/src/class.c
@@ -356,11 +356,9 @@ 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_value sym = mrb_check_intern_cstr(mrb, name);
- if (mrb_nil_p(sym)) {
- return FALSE;
- }
- return mrb_const_defined(mrb, mrb_obj_value(mrb->object_class), mrb_symbol(sym));
+ mrb_sym sym = mrb_check_intern_cstr(mrb, name);
+ if (!sym) return FALSE;
+ return mrb_const_defined(mrb, mrb_obj_value(mrb->object_class), sym);
}
MRB_API mrb_bool
@@ -372,11 +370,9 @@ 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_value sym = mrb_check_intern_cstr(mrb, name);
- if (mrb_nil_p(sym)) {
- return FALSE;
- }
- return mrb_const_defined_at(mrb, mrb_obj_value(outer), mrb_symbol(sym));
+ mrb_sym sym = mrb_check_intern_cstr(mrb, name);
+ if (!sym) return FALSE;
+ return mrb_const_defined_at(mrb, mrb_obj_value(outer), sym);
}
MRB_API mrb_bool