From c9d505923818eaede2d63827001900f314be608a Mon Sep 17 00:00:00 2001 From: Jonas Kulla Date: Sat, 25 Oct 2014 23:33:41 +0200 Subject: [PATCH] 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. --- binding-mri/binding-util.h | 2 +- binding-mri/font-binding.cpp | 16 ++++++++-------- binding-mri/plane-binding.cpp | 4 ++-- binding-mri/sprite-binding.cpp | 6 +++--- binding-mri/viewport-binding.cpp | 6 +++--- binding-mri/window-binding.cpp | 2 +- binding-mri/windowvx-binding.cpp | 4 ++-- binding-mruby/binding-util.h | 2 +- binding-mruby/bitmap-binding.cpp | 6 +++--- binding-mruby/font-binding.cpp | 16 ++++++++-------- binding-mruby/plane-binding.cpp | 4 ++-- binding-mruby/sprite-binding.cpp | 6 +++--- binding-mruby/viewport-binding.cpp | 6 +++--- binding-mruby/window-binding.cpp | 2 +- src/bitmap.cpp | 12 ++++++------ src/bitmap.h | 2 +- src/font.cpp | 29 +++++++++++++++-------------- src/font.h | 8 ++++---- src/plane.cpp | 6 +++--- src/plane.h | 4 ++-- src/sprite.cpp | 11 +++++------ src/sprite.h | 6 +++--- src/util.h | 16 ---------------- src/viewport.cpp | 6 +++--- src/viewport.h | 6 +++--- src/window.cpp | 3 +-- src/window.h | 2 +- src/windowvx.cpp | 5 ++--- src/windowvx.h | 4 ++-- 29 files changed, 92 insertions(+), 110 deletions(-) diff --git a/binding-mri/binding-util.h b/binding-mri/binding-util.h index d895f07..83589f7 100644 --- a/binding-mri/binding-util.h +++ b/binding-mri/binding-util.h @@ -340,7 +340,7 @@ rb_check_argc(int actual, int expected) VALUE propObj = *argv; \ PropKlass *prop; \ prop = getPrivateDataCheck(propObj, PropKlass##Type); \ - GUARD_EXC( k->set##PropName(prop); ) \ + GUARD_EXC( k->set##PropName(*prop); ) \ return propObj; \ } diff --git a/binding-mri/font-binding.cpp b/binding-mri/font-binding.cpp index 7574d45..ec6ae14 100644 --- a/binding-mri/font-binding.cpp +++ b/binding-mri/font-binding.cpp @@ -60,10 +60,10 @@ RB_METHOD(fontInitialize) /* Wrap property objects */ f->initDynAttribs(); - wrapProperty(self, f->getColor(), "color", ColorType); + wrapProperty(self, &f->getColor(), "color", ColorType); if (rgssVer >= 3) - wrapProperty(self, f->getOutColor(), "out_color", ColorType); + wrapProperty(self, &f->getOutColor(), "out_color", ColorType); if (NIL_P(name)) name = rb_iv_get(rb_obj_class(self), "default_name"); @@ -90,10 +90,10 @@ RB_METHOD(fontInitializeCopy) /* Wrap property objects */ f->initDynAttribs(); - wrapProperty(self, f->getColor(), "color", ColorType); + wrapProperty(self, &f->getColor(), "color", ColorType); if (rgssVer >= 3) - wrapProperty(self, f->getOutColor(), "out_color", ColorType); + wrapProperty(self, &f->getOutColor(), "out_color", ColorType); return self; } @@ -209,7 +209,7 @@ RB_METHOD(FontSetDefaultOutColor) Color *c = getPrivateDataCheck(colorObj, ColorType); - Font::setDefaultOutColor(c); + Font::setDefaultOutColor(*c); return colorObj; } @@ -248,7 +248,7 @@ RB_METHOD(FontSetDefaultColor) Color *c = getPrivateDataCheck(colorObj, ColorType); - Font::setDefaultColor(c); + Font::setDefaultColor(*c); return colorObj; } @@ -266,11 +266,11 @@ fontBindingInit() rb_define_alloc_func(klass, classAllocate<&FontType>); Font::initDefaultDynAttribs(); - wrapProperty(klass, Font::getDefaultColor(), "default_color", ColorType); + wrapProperty(klass, &Font::getDefaultColor(), "default_color", ColorType); rb_iv_set(klass, "default_name", rb_str_new_cstr(Font::getDefaultName())); if (rgssVer >= 3) - wrapProperty(klass, Font::getDefaultOutColor(), "default_out_color", ColorType); + wrapProperty(klass, &Font::getDefaultOutColor(), "default_out_color", ColorType); INIT_KLASS_PROP_BIND(Font, DefaultName, "default_name"); INIT_KLASS_PROP_BIND(Font, DefaultSize, "default_size"); diff --git a/binding-mri/plane-binding.cpp b/binding-mri/plane-binding.cpp index 0680263..626b7d7 100644 --- a/binding-mri/plane-binding.cpp +++ b/binding-mri/plane-binding.cpp @@ -35,8 +35,8 @@ RB_METHOD(planeInitialize) p->initDynAttribs(); - wrapProperty(self, p->getColor(), "color", ColorType); - wrapProperty(self, p->getTone(), "tone", ToneType); + wrapProperty(self, &p->getColor(), "color", ColorType); + wrapProperty(self, &p->getTone(), "tone", ToneType); return self; } diff --git a/binding-mri/sprite-binding.cpp b/binding-mri/sprite-binding.cpp index 0fa4b46..2404e4a 100644 --- a/binding-mri/sprite-binding.cpp +++ b/binding-mri/sprite-binding.cpp @@ -39,9 +39,9 @@ RB_METHOD(spriteInitialize) /* Wrap property objects */ s->initDynAttribs(); - wrapProperty(self, s->getSrcRect(), "src_rect", RectType); - wrapProperty(self, s->getColor(), "color", ColorType); - wrapProperty(self, s->getTone(), "tone", ToneType); + wrapProperty(self, &s->getSrcRect(), "src_rect", RectType); + wrapProperty(self, &s->getColor(), "color", ColorType); + wrapProperty(self, &s->getTone(), "tone", ToneType); return self; } diff --git a/binding-mri/viewport-binding.cpp b/binding-mri/viewport-binding.cpp index 566d66e..ca0e5da 100644 --- a/binding-mri/viewport-binding.cpp +++ b/binding-mri/viewport-binding.cpp @@ -64,9 +64,9 @@ RB_METHOD(viewportInitialize) /* Wrap property objects */ v->initDynAttribs(); - wrapProperty(self, v->getRect(), "rect", RectType); - wrapProperty(self, v->getColor(), "color", ColorType); - wrapProperty(self, v->getTone(), "tone", ToneType); + wrapProperty(self, &v->getRect(), "rect", RectType); + wrapProperty(self, &v->getColor(), "color", ColorType); + wrapProperty(self, &v->getTone(), "tone", ToneType); /* 'elements' holds all SceneElements that become children * of this viewport, so we can dispose them when the viewport diff --git a/binding-mri/window-binding.cpp b/binding-mri/window-binding.cpp index ed61b11..03b1e71 100644 --- a/binding-mri/window-binding.cpp +++ b/binding-mri/window-binding.cpp @@ -34,7 +34,7 @@ RB_METHOD(windowInitialize) w->initDynAttribs(); - wrapProperty(self, w->getCursorRect(), "cursor_rect", RectType); + wrapProperty(self, &w->getCursorRect(), "cursor_rect", RectType); return self; } diff --git a/binding-mri/windowvx-binding.cpp b/binding-mri/windowvx-binding.cpp index c9bcee3..0720775 100644 --- a/binding-mri/windowvx-binding.cpp +++ b/binding-mri/windowvx-binding.cpp @@ -53,10 +53,10 @@ RB_METHOD(windowVXInitialize) w->initDynAttribs(); - wrapProperty(self, w->getCursorRect(), "cursor_rect", RectType); + wrapProperty(self, &w->getCursorRect(), "cursor_rect", RectType); if (rgssVer >= 3) - wrapProperty(self, w->getTone(), "tone", ToneType); + wrapProperty(self, &w->getTone(), "tone", ToneType); Bitmap *contents = new Bitmap(1, 1); VALUE contentsObj = wrapObject(contents, BitmapType); diff --git a/binding-mruby/binding-util.h b/binding-mruby/binding-util.h index 142a386..b20427f 100644 --- a/binding-mruby/binding-util.h +++ b/binding-mruby/binding-util.h @@ -166,7 +166,7 @@ defineClass(mrb_state *mrb, const char *name) PropKlass *prop; \ mrb_get_args(mrb, "o", &propObj); \ prop = getPrivateDataCheck(mrb, propObj, PropKlass##Type); \ - GUARD_EXC( k->set##PropName(prop); ) \ + GUARD_EXC( k->set##PropName(*prop); ) \ return propObj; \ } diff --git a/binding-mruby/bitmap-binding.cpp b/binding-mruby/bitmap-binding.cpp index d200a83..74e7429 100644 --- a/binding-mruby/bitmap-binding.cpp +++ b/binding-mruby/bitmap-binding.cpp @@ -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(mrb, fontObj, FontType); - GUARD_EXC( b->setFont(font); ) + GUARD_EXC( b->setFont(*font); ) return mrb_nil_value(); } diff --git a/binding-mruby/font-binding.cpp b/binding-mruby/font-binding.cpp index 22e34cd..31cfd01 100644 --- a/binding-mruby/font-binding.cpp +++ b/binding-mruby/font-binding.cpp @@ -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(mrb, colorObj, ColorType); - Font::setDefaultColor(c); + Font::setDefaultColor(*c); return colorObj; } @@ -183,7 +183,7 @@ MRB_METHOD(FontSetDefaultOutColor) Color *c = getPrivateDataCheck(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)); diff --git a/binding-mruby/plane-binding.cpp b/binding-mruby/plane-binding.cpp index f61803d..ae1055d 100644 --- a/binding-mruby/plane-binding.cpp +++ b/binding-mruby/plane-binding.cpp @@ -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; } diff --git a/binding-mruby/sprite-binding.cpp b/binding-mruby/sprite-binding.cpp index 2575063..8ced0f7 100644 --- a/binding-mruby/sprite-binding.cpp +++ b/binding-mruby/sprite-binding.cpp @@ -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; } diff --git a/binding-mruby/viewport-binding.cpp b/binding-mruby/viewport-binding.cpp index 0061a2d..67f2244 100644 --- a/binding-mruby/viewport-binding.cpp +++ b/binding-mruby/viewport-binding.cpp @@ -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; } diff --git a/binding-mruby/window-binding.cpp b/binding-mruby/window-binding.cpp index 1f31b77..efa4da0 100644 --- a/binding-mruby/window-binding.cpp +++ b/binding-mruby/window-binding.cpp @@ -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; } diff --git a/src/bitmap.cpp b/src/bitmap.cpp index 242c12b..43e8301 100644 --- a/src/bitmap.cpp +++ b/src/bitmap.cpp @@ -941,12 +941,12 @@ void Bitmap::drawText(const IntRect &rect, const char *str, int align) return; TTF_Font *font = p->font->getSdlFont(); - Color *fontColor = p->font->getColor(); + const Color &fontColor = p->font->getColor(); SDL_Color c; - fontColor->toSDLColor(c); + fontColor.toSDLColor(c); - float txtAlpha = fontColor->norm.w; + float txtAlpha = fontColor.norm.w; SDL_Surface *txtSurf; @@ -1186,11 +1186,11 @@ IntRect Bitmap::textSize(const char *str) return IntRect(0, 0, w, h); } -DEF_ATTR_RD_SIMPLE(Bitmap, Font, Font*, p->font) +DEF_ATTR_RD_SIMPLE(Bitmap, Font, Font&, *p->font) -void Bitmap::setFont(Font *value) +void Bitmap::setFont(Font &value) { - *p->font = *value; + *p->font = value; } void Bitmap::setInitFont(Font *value) diff --git a/src/bitmap.h b/src/bitmap.h index 6217da1..732e9c6 100644 --- a/src/bitmap.h +++ b/src/bitmap.h @@ -99,7 +99,7 @@ public: IntRect textSize(const char *str); - DECL_ATTR(Font, Font*) + DECL_ATTR(Font, Font&) /* Sets initial reference without copying by value, * use at construction */ diff --git a/src/font.cpp b/src/font.cpp index ea8c736..058dd21 100644 --- a/src/font.cpp +++ b/src/font.cpp @@ -350,21 +350,22 @@ void Font::setSize(int value) static void guardDisposed() {} -DEF_ATTR_RD_SIMPLE(Font, Size, int, p->size) -DEF_ATTR_SIMPLE (Font, Bold, bool, p->bold) -DEF_ATTR_SIMPLE (Font, Italic, bool, p->italic) -DEF_ATTR_SIMPLE (Font, Shadow, bool, p->shadow) -DEF_ATTR_SIMPLE (Font, Outline, bool, p->outline) -DEF_ATTR_OBJ_VALUE(Font, Color, Color*, p->color) -DEF_ATTR_OBJ_VALUE(Font, OutColor, Color*, p->outColor) +DEF_ATTR_RD_SIMPLE(Font, Size, int, p->size) -DEF_ATTR_SIMPLE_STATIC (Font, DefaultSize, int, FontPrivate::defaultSize) -DEF_ATTR_SIMPLE_STATIC (Font, DefaultBold, bool, FontPrivate::defaultBold) -DEF_ATTR_SIMPLE_STATIC (Font, DefaultItalic, bool, FontPrivate::defaultItalic) -DEF_ATTR_SIMPLE_STATIC (Font, DefaultShadow, bool, FontPrivate::defaultShadow) -DEF_ATTR_SIMPLE_STATIC (Font, DefaultOutline, bool, FontPrivate::defaultOutline) -DEF_ATTR_OBJ_VALUE_STATIC(Font, DefaultColor, Color*, FontPrivate::defaultColor) -DEF_ATTR_OBJ_VALUE_STATIC(Font, DefaultOutColor, Color*, FontPrivate::defaultOutColor) +DEF_ATTR_SIMPLE(Font, Bold, bool, p->bold) +DEF_ATTR_SIMPLE(Font, Italic, bool, p->italic) +DEF_ATTR_SIMPLE(Font, Shadow, bool, p->shadow) +DEF_ATTR_SIMPLE(Font, Outline, bool, p->outline) +DEF_ATTR_SIMPLE(Font, Color, Color&, *p->color) +DEF_ATTR_SIMPLE(Font, OutColor, Color&, *p->outColor) + +DEF_ATTR_SIMPLE_STATIC(Font, DefaultSize, int, FontPrivate::defaultSize) +DEF_ATTR_SIMPLE_STATIC(Font, DefaultBold, bool, FontPrivate::defaultBold) +DEF_ATTR_SIMPLE_STATIC(Font, DefaultItalic, bool, FontPrivate::defaultItalic) +DEF_ATTR_SIMPLE_STATIC(Font, DefaultShadow, bool, FontPrivate::defaultShadow) +DEF_ATTR_SIMPLE_STATIC(Font, DefaultOutline, bool, FontPrivate::defaultOutline) +DEF_ATTR_SIMPLE_STATIC(Font, DefaultColor, Color&, *FontPrivate::defaultColor) +DEF_ATTR_SIMPLE_STATIC(Font, DefaultOutColor, Color&, *FontPrivate::defaultOutColor) const char *Font::getDefaultName() { diff --git a/src/font.h b/src/font.h index a37c935..3586a94 100644 --- a/src/font.h +++ b/src/font.h @@ -92,19 +92,19 @@ public: DECL_ATTR( Size, int ) DECL_ATTR( Bold, bool ) DECL_ATTR( Italic, bool ) - DECL_ATTR( Color, Color* ) + DECL_ATTR( Color, Color& ) DECL_ATTR( Shadow, bool ) DECL_ATTR( Outline, bool ) - DECL_ATTR( OutColor, Color* ) + DECL_ATTR( OutColor, Color& ) DECL_ATTR_STATIC( DefaultName, const char* ) DECL_ATTR_STATIC( DefaultSize, int ) DECL_ATTR_STATIC( DefaultBold, bool ) DECL_ATTR_STATIC( DefaultItalic, bool ) - DECL_ATTR_STATIC( DefaultColor, Color* ) + DECL_ATTR_STATIC( DefaultColor, Color& ) DECL_ATTR_STATIC( DefaultShadow, bool ) DECL_ATTR_STATIC( DefaultOutline, bool ) - DECL_ATTR_STATIC( DefaultOutColor, Color* ) + DECL_ATTR_STATIC( DefaultOutColor, Color& ) /* Assigns heap allocated objects to object properties; * using this in pure C++ will cause memory leaks diff --git a/src/plane.cpp b/src/plane.cpp index f050489..3df691e 100644 --- a/src/plane.cpp +++ b/src/plane.cpp @@ -161,9 +161,9 @@ DEF_ATTR_RD_SIMPLE(Plane, ZoomX, float, p->zoomX) DEF_ATTR_RD_SIMPLE(Plane, ZoomY, float, p->zoomY) DEF_ATTR_RD_SIMPLE(Plane, BlendType, int, p->blendType) -DEF_ATTR_SIMPLE (Plane, Opacity, int, p->opacity) -DEF_ATTR_OBJ_VALUE(Plane, Color, Color*, p->color) -DEF_ATTR_OBJ_VALUE(Plane, Tone, Tone*, p->tone) +DEF_ATTR_SIMPLE(Plane, Opacity, int, p->opacity) +DEF_ATTR_SIMPLE(Plane, Color, Color&, *p->color) +DEF_ATTR_SIMPLE(Plane, Tone, Tone&, *p->tone) Plane::~Plane() { diff --git a/src/plane.h b/src/plane.h index 91a9e03..c6b2d6a 100644 --- a/src/plane.h +++ b/src/plane.h @@ -44,8 +44,8 @@ public: DECL_ATTR( ZoomY, float ) DECL_ATTR( Opacity, int ) DECL_ATTR( BlendType, int ) - DECL_ATTR( Color, Color* ) - DECL_ATTR( Tone, Tone* ) + DECL_ATTR( Color, Color& ) + DECL_ATTR( Tone, Tone& ) void initDynAttribs(); diff --git a/src/sprite.cpp b/src/sprite.cpp index 681e219..49d9f29 100644 --- a/src/sprite.cpp +++ b/src/sprite.cpp @@ -317,12 +317,11 @@ DEF_ATTR_RD_SIMPLE(Sprite, WaveLength, int, p->wave.length) DEF_ATTR_RD_SIMPLE(Sprite, WaveSpeed, int, p->wave.speed) DEF_ATTR_RD_SIMPLE(Sprite, WavePhase, float, p->wave.phase) -DEF_ATTR_SIMPLE (Sprite, BushOpacity, int, p->bushOpacity) -DEF_ATTR_SIMPLE (Sprite, Opacity, int, p->opacity) - -DEF_ATTR_OBJ_VALUE(Sprite, SrcRect, Rect*, p->srcRect) -DEF_ATTR_OBJ_VALUE(Sprite, Color, Color*, p->color) -DEF_ATTR_OBJ_VALUE(Sprite, Tone, Tone*, p->tone) +DEF_ATTR_SIMPLE(Sprite, BushOpacity, int, p->bushOpacity) +DEF_ATTR_SIMPLE(Sprite, Opacity, int, p->opacity) +DEF_ATTR_SIMPLE(Sprite, SrcRect, Rect&, *p->srcRect) +DEF_ATTR_SIMPLE(Sprite, Color, Color&, *p->color) +DEF_ATTR_SIMPLE(Sprite, Tone, Tone&, *p->tone) void Sprite::setBitmap(Bitmap *bitmap) { diff --git a/src/sprite.h b/src/sprite.h index 8a9ba09..3b82f04 100644 --- a/src/sprite.h +++ b/src/sprite.h @@ -47,7 +47,7 @@ public: void update(); DECL_ATTR( Bitmap, Bitmap* ) - DECL_ATTR( SrcRect, Rect* ) + DECL_ATTR( SrcRect, Rect& ) DECL_ATTR( X, int ) DECL_ATTR( Y, int ) DECL_ATTR( OX, int ) @@ -60,8 +60,8 @@ public: DECL_ATTR( BushOpacity, int ) DECL_ATTR( Opacity, int ) DECL_ATTR( BlendType, int ) - DECL_ATTR( Color, Color* ) - DECL_ATTR( Tone, Tone* ) + DECL_ATTR( Color, Color& ) + DECL_ATTR( Tone, Tone& ) DECL_ATTR( WaveAmp, int ) DECL_ATTR( WaveLength, int ) DECL_ATTR( WaveSpeed, int ) diff --git a/src/util.h b/src/util.h index 2a48ef4..ffad798 100644 --- a/src/util.h +++ b/src/util.h @@ -152,20 +152,4 @@ inline C *dataPtr(std::vector &v) #define DEF_ATTR_SIMPLE_STATIC(klass, name, type, location) \ DEF_ATTR_SIMPLE_DETAILED(klass, name, type, location, ) -#define DEF_ATTR_OBJ_VALUE(klass, name, type, location) \ - DEF_ATTR_RD_SIMPLE_DETAILED(klass, name, type, location, const) \ - void klass :: set##name(type value) \ - { \ - guardDisposed(); \ - *location = *value; \ - } - -#define DEF_ATTR_OBJ_VALUE_STATIC(klass, name, type, location) \ - DEF_ATTR_RD_SIMPLE_DETAILED(klass, name, type, location, ) \ - void klass :: set##name(type value) \ - { \ - guardDisposed(); \ - *location = *value; \ - } - #endif // UTIL_H diff --git a/src/viewport.cpp b/src/viewport.cpp index fed9f18..eba2ccc 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -147,9 +147,9 @@ void Viewport::update() DEF_ATTR_RD_SIMPLE(Viewport, OX, int, geometry.xOrigin) DEF_ATTR_RD_SIMPLE(Viewport, OY, int, geometry.yOrigin) -DEF_ATTR_OBJ_VALUE(Viewport, Rect, Rect*, p->rect) -DEF_ATTR_OBJ_VALUE(Viewport, Color, Color*, p->color) -DEF_ATTR_OBJ_VALUE(Viewport, Tone, Tone*, p->tone) +DEF_ATTR_SIMPLE(Viewport, Rect, Rect&, *p->rect) +DEF_ATTR_SIMPLE(Viewport, Color, Color&, *p->color) +DEF_ATTR_SIMPLE(Viewport, Tone, Tone&, *p->tone) void Viewport::setOX(int value) { diff --git a/src/viewport.h b/src/viewport.h index 416d4da..fe3eb4d 100644 --- a/src/viewport.h +++ b/src/viewport.h @@ -39,11 +39,11 @@ public: void update(); - DECL_ATTR( Rect, Rect* ) + DECL_ATTR( Rect, Rect& ) DECL_ATTR( OX, int ) DECL_ATTR( OY, int ) - DECL_ATTR( Color, Color* ) - DECL_ATTR( Tone, Tone* ) + DECL_ATTR( Color, Color& ) + DECL_ATTR( Tone, Tone& ) void initDynAttribs(); diff --git a/src/window.cpp b/src/window.cpp index a5f5fad..6b94586 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -706,6 +706,7 @@ void Window::update() DEF_ATTR_SIMPLE(Window, X, int, p->position.x) DEF_ATTR_SIMPLE(Window, Y, int, p->position.y) +DEF_ATTR_SIMPLE(Window, CursorRect, Rect&, *p->cursorRect) DEF_ATTR_RD_SIMPLE(Window, Windowskin, Bitmap*, p->windowskin) DEF_ATTR_RD_SIMPLE(Window, Contents, Bitmap*, p->contents) @@ -720,8 +721,6 @@ DEF_ATTR_RD_SIMPLE(Window, Opacity, int, p->opacity) DEF_ATTR_RD_SIMPLE(Window, BackOpacity, int, p->backOpacity) DEF_ATTR_RD_SIMPLE(Window, ContentsOpacity, int, p->contentsOpacity) -DEF_ATTR_OBJ_VALUE(Window, CursorRect, Rect*, p->cursorRect) - void Window::setWindowskin(Bitmap *value) { guardDisposed(); diff --git a/src/window.h b/src/window.h index f7cfc04..98184d1 100644 --- a/src/window.h +++ b/src/window.h @@ -43,7 +43,7 @@ public: DECL_ATTR( Windowskin, Bitmap* ) DECL_ATTR( Contents, Bitmap* ) DECL_ATTR( Stretch, bool ) - DECL_ATTR( CursorRect, Rect* ) + DECL_ATTR( CursorRect, Rect& ) DECL_ATTR( Active, bool ) DECL_ATTR( Pause, bool ) DECL_ATTR( X, int ) diff --git a/src/windowvx.cpp b/src/windowvx.cpp index 0b01a6e..84f5ab8 100644 --- a/src/windowvx.cpp +++ b/src/windowvx.cpp @@ -882,6 +882,8 @@ bool WindowVX::isClosed() const DEF_ATTR_SIMPLE(WindowVX, X, int, p->geo.x) DEF_ATTR_SIMPLE(WindowVX, Y, int, p->geo.y) +DEF_ATTR_SIMPLE(WindowVX, CursorRect, Rect&, *p->cursorRect) +DEF_ATTR_SIMPLE(WindowVX, Tone, Tone&, *p->tone) DEF_ATTR_RD_SIMPLE(WindowVX, Windowskin, Bitmap*, p->windowskin) DEF_ATTR_RD_SIMPLE(WindowVX, Contents, Bitmap*, p->contents) @@ -899,9 +901,6 @@ DEF_ATTR_RD_SIMPLE(WindowVX, BackOpacity, int, p->backOpacity) DEF_ATTR_RD_SIMPLE(WindowVX, ContentsOpacity, int, p->contentsOpacity) DEF_ATTR_RD_SIMPLE(WindowVX, Openness, int, p->openness) -DEF_ATTR_OBJ_VALUE(WindowVX, CursorRect, Rect*, p->cursorRect) -DEF_ATTR_OBJ_VALUE(WindowVX, Tone, Tone*, p->tone) - void WindowVX::setWindowskin(Bitmap *value) { guardDisposed(); diff --git a/src/windowvx.h b/src/windowvx.h index d0e1eca..63f8d04 100644 --- a/src/windowvx.h +++ b/src/windowvx.h @@ -48,7 +48,7 @@ public: DECL_ATTR( Windowskin, Bitmap* ) DECL_ATTR( Contents, Bitmap* ) - DECL_ATTR( CursorRect, Rect* ) + DECL_ATTR( CursorRect, Rect& ) DECL_ATTR( Active, bool ) DECL_ATTR( ArrowsVisible, bool ) DECL_ATTR( Pause, bool ) @@ -64,7 +64,7 @@ public: DECL_ATTR( BackOpacity, int ) DECL_ATTR( ContentsOpacity, int ) DECL_ATTR( Openness, int ) - DECL_ATTR( Tone, Tone* ) + DECL_ATTR( Tone, Tone& ) void initDynAttribs();