diff options
| author | Yukihiro Matsumoto <[email protected]> | 2012-05-10 23:11:20 +0900 |
|---|---|---|
| committer | Yukihiro Matsumoto <[email protected]> | 2012-05-10 23:11:20 +0900 |
| commit | 4e40121f71aaba2caa325ef30c163c2692b93aa6 (patch) | |
| tree | 4cc77c8e419fa12280c524c81be82b59ec73c5ec | |
| parent | 4d3ed8c4f92a53aca5cc11d343d6833b22204fc9 (diff) | |
| download | mruby-4e40121f71aaba2caa325ef30c163c2692b93aa6.tar.gz mruby-4e40121f71aaba2caa325ef30c163c2692b93aa6.zip | |
remove regex_class and match_class from mrb_state
| -rw-r--r-- | include/mruby.h | 4 | ||||
| -rw-r--r-- | src/re.c | 17 |
2 files changed, 8 insertions, 13 deletions
diff --git a/include/mruby.h b/include/mruby.h index e7cdeb8a5..7b15d5f9a 100644 --- a/include/mruby.h +++ b/include/mruby.h @@ -241,10 +241,6 @@ typedef struct mrb_state { struct RClass *string_class; struct RClass *array_class; struct RClass *hash_class; -#ifdef INCLUDE_REGEXP - struct RClass *regex_class; - struct RClass *match_class; -#endif #ifdef INCLUDE_ENCODING struct RClass *encode_class; struct RClass *converter_class; @@ -20,6 +20,9 @@ #include "error.h" #ifdef INCLUDE_REGEXP +#define REGEX_CLASS (mrb_class_obj_get(mrb, "Regexp")) +#define MATCH_CLASS (mrb_class_obj_get(mrb, "MatchData")) + //from opcode.h #define GETARG_A(i) ((((mrb_code)(i)) >> 24) & 0xff) #define GETARG_B(i) ((((mrb_code)(i)) >> 16) & 0xff) @@ -88,7 +91,7 @@ mrb_reg_s_new_instance(mrb_state *mrb, /*int argc, mrb_value *argv, */mrb_value struct RRegexp *re; mrb_get_args(mrb, "*", &argv, &argc); - re = mrb_obj_alloc(mrb, MRB_TT_REGEX, mrb->regex_class); + re = mrb_obj_alloc(mrb, MRB_TT_REGEX, REGEX_CLASS); re->ptr = 0; re->src = 0; re->usecnt = 0; @@ -1665,9 +1668,7 @@ match_alloc(mrb_state *mrb) { struct RMatch* m; - m = mrb_obj_alloc(mrb, MRB_TT_MATCH, mrb->match_class); - // NEWOBJ(match, struct RMatch); - // OBJSETUP(match, klass, T_MATCH); + m = mrb_obj_alloc(mrb, MRB_TT_MATCH, MATCH_CLASS); m->str = 0; m->rmatch = 0; @@ -2455,7 +2456,7 @@ mrb_reg_s_alloc(mrb_state *mrb, mrb_value dummy) //NEWOBJ(re, struct RRegexp); //OBJSETUP(re, klass, T_REGEXP); - re = mrb_obj_alloc(mrb, MRB_TT_REGEX, mrb->regex_class); + re = mrb_obj_alloc(mrb, MRB_TT_REGEX, REGEX_CLASS); re->ptr = 0; re->src = 0; @@ -2626,10 +2627,8 @@ void mrb_init_regexp(mrb_state *mrb) { struct RClass *s; - s = mrb->regex_class = mrb_define_class(mrb, "Regexp", mrb->object_class); + s = mrb_define_class(mrb, "Regexp", mrb->object_class); - //mrb->encode_class = mrb_define_class(mrb, "Encoding", mrb->object_class); - //mrb_define_alloc_func(mrb, s, mrb_reg_s_alloc); mrb_define_class_method(mrb, s, "compile", mrb_reg_s_new_instance, ARGS_ANY()); /* 15.2.15.6.1 */ mrb_define_class_method(mrb, s, "escape", mrb_reg_s_quote, ARGS_REQ(1)); /* 15.2.15.6.2 */ mrb_define_class_method(mrb, s, "last_match", mrb_reg_s_last_match, ARGS_ANY()); /* 15.2.15.6.3 */ @@ -2667,7 +2666,7 @@ mrb_init_regexp(mrb_state *mrb) //mrb_global_variable(®_cache); - s = mrb->match_class = mrb_define_class(mrb, "MatchData", mrb->object_class); + s = mrb_define_class(mrb, "MatchData", mrb->object_class); //mrb_undef_method(CLASS_OF(rb_cMatch), "new"); mrb_define_method(mrb, s, "[]", mrb_match_aref, ARGS_ANY()); /* 15.2.16.3.1 */ |
