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
				
			
		| 
						 | 
				
			
			@ -340,7 +340,7 @@ rb_check_argc(int actual, int expected)
 | 
			
		|||
		VALUE propObj = *argv; \
 | 
			
		||||
		PropKlass *prop; \
 | 
			
		||||
		prop = getPrivateDataCheck<PropKlass>(propObj, PropKlass##Type); \
 | 
			
		||||
		GUARD_EXC( k->set##PropName(prop); ) \
 | 
			
		||||
		GUARD_EXC( k->set##PropName(*prop); ) \
 | 
			
		||||
		return propObj; \
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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<Color>(colorObj, ColorType);
 | 
			
		||||
 | 
			
		||||
	Font::setDefaultOutColor(c);
 | 
			
		||||
	Font::setDefaultOutColor(*c);
 | 
			
		||||
 | 
			
		||||
	return colorObj;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -248,7 +248,7 @@ RB_METHOD(FontSetDefaultColor)
 | 
			
		|||
 | 
			
		||||
	Color *c = getPrivateDataCheck<Color>(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");
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue