Pass value object attributes by reference (instead of pointer)
This underlines that no reference inside the setter is taken, and that these attributes are non-nullable. Also removes a couple of superfluous attribute macros.
This commit is contained in:
parent
5549ff78f0
commit
c9d5059238
29 changed files with 92 additions and 110 deletions
|
@ -166,7 +166,7 @@ defineClass(mrb_state *mrb, const char *name)
|
|||
PropKlass *prop; \
|
||||
mrb_get_args(mrb, "o", &propObj); \
|
||||
prop = getPrivateDataCheck<PropKlass>(mrb, propObj, PropKlass##Type); \
|
||||
GUARD_EXC( k->set##PropName(prop); ) \
|
||||
GUARD_EXC( k->set##PropName(*prop); ) \
|
||||
return propObj; \
|
||||
}
|
||||
|
||||
|
|
|
@ -57,10 +57,10 @@ MRB_METHOD(bitmapInitialize)
|
|||
|
||||
mrb_value fontProp = wrapProperty(mrb, self, font, CSfont, FontType);
|
||||
|
||||
wrapProperty(mrb, fontProp, font->getColor(), CScolor, ColorType);
|
||||
wrapProperty(mrb, fontProp, &font->getColor(), CScolor, ColorType);
|
||||
|
||||
if (rgssVer >= 3)
|
||||
wrapProperty(mrb, fontProp, font->getOutColor(), CSout_color, ColorType);
|
||||
wrapProperty(mrb, fontProp, &font->getOutColor(), CSout_color, ColorType);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@ -296,7 +296,7 @@ MRB_METHOD(bitmapSetFont)
|
|||
|
||||
font = getPrivateDataCheck<Font>(mrb, fontObj, FontType);
|
||||
|
||||
GUARD_EXC( b->setFont(font); )
|
||||
GUARD_EXC( b->setFont(*font); )
|
||||
|
||||
return mrb_nil_value();
|
||||
}
|
||||
|
|
|
@ -56,10 +56,10 @@ MRB_METHOD(fontInitialize)
|
|||
/* Wrap property objects */
|
||||
f->initDynAttribs();
|
||||
|
||||
wrapProperty(mrb, self, f->getColor(), CScolor, ColorType);
|
||||
wrapProperty(mrb, self, &f->getColor(), CScolor, ColorType);
|
||||
|
||||
if (rgssVer >= 3)
|
||||
wrapProperty(mrb, self, f->getOutColor(), CSout_color, ColorType);
|
||||
wrapProperty(mrb, self, &f->getOutColor(), CSout_color, ColorType);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@ -76,10 +76,10 @@ MRB_METHOD(fontInitializeCopy)
|
|||
/* Wrap property objects */
|
||||
f->initDynAttribs();
|
||||
|
||||
wrapProperty(mrb, self, f->getColor(), CScolor, ColorType);
|
||||
wrapProperty(mrb, self, &f->getColor(), CScolor, ColorType);
|
||||
|
||||
if (rgssVer >= 3)
|
||||
wrapProperty(mrb, self, f->getOutColor(), CSout_color, ColorType);
|
||||
wrapProperty(mrb, self, &f->getOutColor(), CSout_color, ColorType);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ MRB_METHOD(FontSetDefaultColor)
|
|||
|
||||
Color *c = getPrivateDataCheck<Color>(mrb, colorObj, ColorType);
|
||||
|
||||
Font::setDefaultColor(c);
|
||||
Font::setDefaultColor(*c);
|
||||
|
||||
return colorObj;
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ MRB_METHOD(FontSetDefaultOutColor)
|
|||
|
||||
Color *c = getPrivateDataCheck<Color>(mrb, colorObj, ColorType);
|
||||
|
||||
Font::setDefaultOutColor(c);
|
||||
Font::setDefaultOutColor(*c);
|
||||
|
||||
return colorObj;
|
||||
}
|
||||
|
@ -200,7 +200,7 @@ fontBindingInit(mrb_state *mrb)
|
|||
RClass *klass = defineClass(mrb, "Font");
|
||||
|
||||
Font::initDefaultDynAttribs();
|
||||
wrapProperty(mrb, mrb_obj_value(klass), Font::getDefaultColor(), CSdefault_color, ColorType);
|
||||
wrapProperty(mrb, mrb_obj_value(klass), &Font::getDefaultColor(), CSdefault_color, ColorType);
|
||||
|
||||
mrb_define_class_method(mrb, klass, "exist?", fontDoesExist, MRB_ARGS_REQ(1));
|
||||
|
||||
|
@ -219,7 +219,7 @@ fontBindingInit(mrb_state *mrb)
|
|||
{
|
||||
INIT_KLASS_PROP_BIND(Font, DefaultOutline, "default_outline");
|
||||
INIT_KLASS_PROP_BIND(Font, DefaultOutColor, "default_out_color");
|
||||
wrapProperty(mrb, mrb_obj_value(klass), Font::getDefaultOutColor(), CSdefault_out_color, ColorType);
|
||||
wrapProperty(mrb, mrb_obj_value(klass), &Font::getDefaultOutColor(), CSdefault_out_color, ColorType);
|
||||
}
|
||||
|
||||
mrb_define_method(mrb, klass, "initialize", fontInitialize, MRB_ARGS_OPT(2));
|
||||
|
|
|
@ -35,8 +35,8 @@ MRB_METHOD(planeInitialize)
|
|||
|
||||
p->initDynAttribs();
|
||||
|
||||
wrapProperty(mrb, self, p->getColor(), CScolor, ColorType);
|
||||
wrapProperty(mrb, self, p->getTone(), CStone, ToneType);
|
||||
wrapProperty(mrb, self, &p->getColor(), CScolor, ColorType);
|
||||
wrapProperty(mrb, self, &p->getTone(), CStone, ToneType);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -38,9 +38,9 @@ MRB_METHOD(spriteInitialize)
|
|||
/* Wrap property objects */
|
||||
s->initDynAttribs();
|
||||
|
||||
wrapProperty(mrb, self, s->getSrcRect(), CSsrc_rect, RectType);
|
||||
wrapProperty(mrb, self, s->getColor(), CScolor, ColorType);
|
||||
wrapProperty(mrb, self, s->getTone(), CStone, ToneType);
|
||||
wrapProperty(mrb, self, &s->getSrcRect(), CSsrc_rect, RectType);
|
||||
wrapProperty(mrb, self, &s->getColor(), CScolor, ColorType);
|
||||
wrapProperty(mrb, self, &s->getTone(), CStone, ToneType);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -59,9 +59,9 @@ MRB_METHOD(viewportInitialize)
|
|||
/* Wrap property objects */
|
||||
v->initDynAttribs();
|
||||
|
||||
wrapProperty(mrb, self, v->getRect(), CSrect, RectType);
|
||||
wrapProperty(mrb, self, v->getColor(), CScolor, ColorType);
|
||||
wrapProperty(mrb, self, v->getTone(), CStone, ToneType);
|
||||
wrapProperty(mrb, self, &v->getRect(), CSrect, RectType);
|
||||
wrapProperty(mrb, self, &v->getColor(), CScolor, ColorType);
|
||||
wrapProperty(mrb, self, &v->getTone(), CStone, ToneType);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ MRB_METHOD(windowInitialize)
|
|||
setPrivateData(self, w, WindowType);
|
||||
|
||||
w->initDynAttribs();
|
||||
wrapProperty(mrb, self, w->getCursorRect(), CScursor_rect, RectType);
|
||||
wrapProperty(mrb, self, &w->getCursorRect(), CScursor_rect, RectType);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue