MRI-Binding: Properly init Bitmap in Graphics#snap_to_bitmap

This commit is contained in:
Jonas Kulla 2014-07-16 05:27:16 +02:00
parent b8d861b4cd
commit b878149f5c
2 changed files with 20 additions and 11 deletions

View File

@ -30,6 +30,19 @@
DEF_TYPE(Bitmap); 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) RB_METHOD(bitmapInitialize)
{ {
Bitmap *b = 0; Bitmap *b = 0;
@ -50,16 +63,7 @@ RB_METHOD(bitmapInitialize)
} }
setPrivateData(self, b); setPrivateData(self, b);
bitmapInitProps(b, 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);
return self; return self;
} }

View File

@ -152,6 +152,8 @@ RB_METHOD(graphicsFadein)
return Qnil; return Qnil;
} }
void bitmapInitProps(Bitmap *b, VALUE self);
RB_METHOD(graphicsSnapToBitmap) RB_METHOD(graphicsSnapToBitmap)
{ {
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
@ -159,7 +161,10 @@ RB_METHOD(graphicsSnapToBitmap)
Bitmap *result = 0; Bitmap *result = 0;
GUARD_EXC( result = shState->graphics().snapToBitmap(); ); GUARD_EXC( result = shState->graphics().snapToBitmap(); );
return wrapObject(result, BitmapType); VALUE obj = wrapObject(result, BitmapType);
bitmapInitProps(result, obj);
return obj;
} }
#endif #endif