diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-09-08 09:52:26 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-09-08 09:52:26 +0000 |
commit | 5fbfc21b67f4bd68502e186024636f5bf4350f90 (patch) | |
tree | 3ff79b074c314852173be275c081b16483b1f3ac /object.c | |
parent | ea005c47faf3563b7fc9a3f92525a05e745df033 (diff) | |
download | ruby-5fbfc21b67f4bd68502e186024636f5bf4350f90.tar.gz |
internal.h: allocator function in rb_classext_t
* internal.h (struct rb_classext_struct): move allocator function into
rb_classext_t from ordinary method table. [ruby-dev:46121]
[Feature #6993]
* object.c (rb_obj_alloc): call allocator function directly.
* vm_method.c (rb_define_alloc_func, rb_undef_alloc_func)
(rb_get_alloc_func): use allocator function in rb_classext_t.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36925 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'object.c')
-rw-r--r-- | object.c | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -1655,6 +1655,7 @@ VALUE rb_obj_alloc(VALUE klass) { VALUE obj; + rb_alloc_func_t allocator; if (RCLASS_SUPER(klass) == 0 && klass != rb_cBasicObject) { rb_raise(rb_eTypeError, "can't instantiate uninitialized class"); @@ -1662,7 +1663,13 @@ rb_obj_alloc(VALUE klass) if (FL_TEST(klass, FL_SINGLETON)) { rb_raise(rb_eTypeError, "can't create instance of singleton class"); } - obj = rb_funcall(klass, ID_ALLOCATOR, 0, 0); + allocator = rb_get_alloc_func(klass); + if (!allocator) { + rb_raise(rb_eTypeError, "allocator undefined for %"PRIsVALUE, + klass); + } + + obj = (*allocator)(klass); if (rb_obj_class(obj) != rb_class_real(klass)) { rb_raise(rb_eTypeError, "wrong instance allocation"); } |