diff --git a/binding-mri/bitmap-binding.cpp b/binding-mri/bitmap-binding.cpp index ad06d6f..b37182f 100644 --- a/binding-mri/bitmap-binding.cpp +++ b/binding-mri/bitmap-binding.cpp @@ -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(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(fontObj); - b->setFont(font); - - rb_iv_set(self, "font", fontObj); + bitmapInitProps(b, self); return self; } diff --git a/binding-mri/graphics-binding.cpp b/binding-mri/graphics-binding.cpp index 43b18e1..afd41b2 100644 --- a/binding-mri/graphics-binding.cpp +++ b/binding-mri/graphics-binding.cpp @@ -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