From: ts Date: 2003-03-30T02:35:09+09:00 Subject: Re: C-API: Setting a Ruby-Object in a wrapped C struct >>>>> "L" == Lenny writes: L> Now i don't know how to write a corresponding "bar=()" function. Can anybody L> give me a hint? iv_set_var() seems to be unnecessary inefficient. static VALUE setBar(VALUE self, VALUE obj) { foo *p; Data_Get_Struct(self, foo, p); p->bar = obj; return obj; } /* ... */ rb_define_method(Foo, "bar", getBar, 0); rb_define_method(Foo, "bar=", setBar, 1); p.s. : don't forget to have a mark function for your struct and mark p->bar Guy Decoux