From: nobu.nokada@... Date: 2002-01-08T05:35:04+09:00 Subject: Re: addign class attr reader in C extension At Tue, 8 Jan 2002 03:18:43 +0900, ts wrote: > P> str = rb_str_new2("plugin2 test string"); > P> rb_iv_set(self, "@str", str); > P> rb_define_attr(str, "str", 1, 1); // <-- > > rb_define_attr(CLASS_OF(self), "str", Qtrue, Qtrue); It's equivalent to: class Plugin2 def initialize @str = "plugin2 test string" class << self attr_accessor :str end end end I guess it's better like this: > void Init_plg2() { > cPlugin2 = rb_define_class("Plugin2", rb_cObject); > rb_define_method(cPlugin2, "initialize", plg2_init, 0); rb_define_attr(cPlugin2, "str", Qtrue, Qtrue); > } -- Nobu Nakada