diff options
| author | Mitchell Blank Jr <[email protected]> | 2012-05-20 09:43:14 -0700 |
|---|---|---|
| committer | Mitchell Blank Jr <[email protected]> | 2012-05-20 09:43:14 -0700 |
| commit | 9e336b00e5934dbe583edfd1db6370fa4e78745d (patch) | |
| tree | 08448056bc440124baab552e716c383f5e3f5ef7 /src/re.c | |
| parent | ec8f97d2a6facab56ff78cc62ebf1928d06bed4a (diff) | |
| download | mruby-9e336b00e5934dbe583edfd1db6370fa4e78745d.tar.gz mruby-9e336b00e5934dbe583edfd1db6370fa4e78745d.zip | |
More C++ compilability work: mrb_obj_alloc void* conversions
One of the biggest set of changes needed to make C++ compile, is that you
can't autoconvert "void*" to a different pointer type without a cast (you
can of course, convert pointers *to* "void*"!)
For the first part, convert the users of "mrb_obj_alloc". Since it has
to return something, make it RBasic* (that's what mrb_obj_alloc() is
operating on anyway). This way, even in C you'll get a warning if you
don't cast it.
For places where there are a lot of similar calls to mrb_obj_alloc(),
this can be easily hidden through a macro. I did this in string.c:
#define mrb_obj_alloc_string(mrb) ((struct RString *) mrb_obj_alloc((mrb), MRB_TT_STRING, (mrb)->string_class))
I also updated the mrb_object() macro to also return a RBasic* -- my
previous commit changed that from "void*" -> "RObject*", but I figure
it should be consistent with mrb_obj_alloc()
Diffstat (limited to 'src/re.c')
| -rw-r--r-- | src/re.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -88,7 +88,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, REGEX_CLASS); + re = (struct RRegexp *) mrb_obj_alloc(mrb, MRB_TT_REGEX, REGEX_CLASS); re->ptr = 0; re->src = 0; re->usecnt = 0; @@ -1665,7 +1665,7 @@ match_alloc(mrb_state *mrb) { struct RMatch* m; - m = mrb_obj_alloc(mrb, MRB_TT_MATCH, MATCH_CLASS); + m = (struct RMatch *) mrb_obj_alloc(mrb, MRB_TT_MATCH, MATCH_CLASS); m->str = 0; m->rmatch = 0; @@ -2453,7 +2453,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, REGEX_CLASS); + re = (struct RRegexp *) mrb_obj_alloc(mrb, MRB_TT_REGEX, REGEX_CLASS); re->ptr = 0; re->src = 0; |
