MRI-Binding: Properly init Bitmap in Graphics#snap_to_bitmap
This commit is contained in:
		
							parent
							
								
									b8d861b4cd
								
							
						
					
					
						commit
						b878149f5c
					
				
					 2 changed files with 20 additions and 11 deletions
				
			
		| 
						 | 
				
			
			@ -30,6 +30,19 @@
 | 
			
		|||
 | 
			
		||||
DEF_TYPE(Bitmap);
 | 
			
		||||
 | 
			
		||||
void bitmapInitProps(Bitmap *b, VALUE self)
 | 
			
		||||
{
 | 
			
		||||
	/* Wrap properties */
 | 
			
		||||
	VALUE fontKlass = rb_const_get(rb_cObject, rb_intern("Font"));
 | 
			
		||||
	VALUE fontObj = rb_obj_alloc(fontKlass);
 | 
			
		||||
	rb_obj_call_init(fontObj, 0, 0);
 | 
			
		||||
 | 
			
		||||
	Font *font = getPrivateData<Font>(fontObj);
 | 
			
		||||
	b->setFont(font);
 | 
			
		||||
 | 
			
		||||
	rb_iv_set(self, "font", fontObj);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
RB_METHOD(bitmapInitialize)
 | 
			
		||||
{
 | 
			
		||||
	Bitmap *b = 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -50,16 +63,7 @@ RB_METHOD(bitmapInitialize)
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	setPrivateData(self, b);
 | 
			
		||||
 | 
			
		||||
	/* Wrap properties */
 | 
			
		||||
	VALUE fontKlass = rb_const_get(rb_cObject, rb_intern("Font"));
 | 
			
		||||
	VALUE fontObj = rb_obj_alloc(fontKlass);
 | 
			
		||||
	rb_obj_call_init(fontObj, 0, 0);
 | 
			
		||||
 | 
			
		||||
	Font *font = getPrivateData<Font>(fontObj);
 | 
			
		||||
	b->setFont(font);
 | 
			
		||||
 | 
			
		||||
	rb_iv_set(self, "font", fontObj);
 | 
			
		||||
	bitmapInitProps(b, self);
 | 
			
		||||
 | 
			
		||||
	return self;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -152,6 +152,8 @@ RB_METHOD(graphicsFadein)
 | 
			
		|||
	return Qnil;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void bitmapInitProps(Bitmap *b, VALUE self);
 | 
			
		||||
 | 
			
		||||
RB_METHOD(graphicsSnapToBitmap)
 | 
			
		||||
{
 | 
			
		||||
	RB_UNUSED_PARAM;
 | 
			
		||||
| 
						 | 
				
			
			@ -159,7 +161,10 @@ RB_METHOD(graphicsSnapToBitmap)
 | 
			
		|||
	Bitmap *result = 0;
 | 
			
		||||
	GUARD_EXC( result = shState->graphics().snapToBitmap(); );
 | 
			
		||||
 | 
			
		||||
	return wrapObject(result, BitmapType);
 | 
			
		||||
	VALUE obj = wrapObject(result, BitmapType);
 | 
			
		||||
	bitmapInitProps(result, obj);
 | 
			
		||||
 | 
			
		||||
	return obj;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue