From: nobu.nokada@... Date: 2003-08-26T11:36:40+09:00 Subject: Re: 1.8.0 pb Hi, At Tue, 26 Aug 2003 04:45:25 +0900, thierry wilmot wrote: > in 1.6.8, all my structs/classes where wrapped this way: > > rb_define_method(rb_foo, "create", (RUBY_FUN_REF)foo_create, 0); > > static VALUE foo_create(VALUE self) > { > foo *ptr = new foo(self); > rb_iv_set(self, "ruby2cpp__", INT2FIX(ptr)); > VALUE obj = Data_Wrap_Struct(self, 0, cb_destroy_foo, ptr); > } I can't see the intention of the code. Is rb_foo a subclass of Class? Otherwise, you must not pass self to Data_Wrap_Struct(). > // add two methods > > rb_define_singleton_method(rb_foo, "new", (RUBY_FUN_REF)foo_new, 0); You should use rb_define_alloc_func() instead of overriding "new". static VALUE foo_allocate(VALUE self) { foo *ptr = new foo(self); VALUE obj = Data_Wrap_Struct(self, 0, cb_destroy_foo, ptr); rb_iv_set(obj, "ruby2cpp__", INT2FIX(ptr)); return obj; } -- Nobu Nakada