MRI-Binding: Reduce number of object allocations

Previously, wrapped instances of mkxp core classes were
stored as RData ivars inside the actual object. This turned
out to be pointless as RData objects themselves are perfectly
valid objects that can carry ivars and have parent classes.
Therefore, the RData objects are now exposed directly to
the user scripts, effectively halving the amount of object
allocations.
This commit is contained in:
Jonas Kulla 2013-10-30 10:06:24 +01:00
parent 8dd6b63fc4
commit f067e0eff8
11 changed files with 37 additions and 25 deletions

View file

@ -45,7 +45,7 @@ RB_METHOD(fontInitialize)
Font *f = new Font(name, size);
setPrivateData(self, f, FontType);
setPrivateData(self, f);
/* Wrap property objects */
f->setColor(new Color(*f->getColor()));
@ -151,6 +151,7 @@ fontBindingInit()
INIT_TYPE(Font);
VALUE klass = rb_define_class("Font", rb_cObject);
rb_define_alloc_func(klass, classAllocate<&FontType>);
Font::setDefaultColor(new Color(*Font::getDefaultColor()));
wrapProperty(klass, Font::getDefaultColor(), "default_color", ColorType);