Commit fc891067 authored by skandhas's avatar skandhas

add function:check_const_name

parent 97545127
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "mruby.h" #include "mruby.h"
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <ctype.h>
#include "mruby/class.h" #include "mruby/class.h"
#include "mruby/proc.h" #include "mruby/proc.h"
#include "mruby/string.h" #include "mruby/string.h"
...@@ -1442,6 +1443,18 @@ mrb_sym_value(mrb_state *mrb, mrb_value val) ...@@ -1442,6 +1443,18 @@ mrb_sym_value(mrb_state *mrb, mrb_value val)
return mrb_symbol(val); return mrb_symbol(val);
} }
static void
check_const_name(mrb_state *mrb, mrb_sym id)
{
const char *s;
int len;
s = mrb_sym2name_len(mrb, id, &len);
if (len < 1 || !ISUPPER(*s)) {
mrb_name_error(mrb, id, "wrong constant name %s", s);
}
}
mrb_value mrb_value
mrb_mod_const_defined(mrb_state *mrb, mrb_value mod) mrb_mod_const_defined(mrb_state *mrb, mrb_value mod)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment