From: ts Date: 2001-09-04T14:29:13+09:00 Subject: [ruby-talk:20839] Re: Calling member methods from C++ >>>>> "B" == =?ISO-8859-1?Q?Bernhard Gl=FCck?= writes: B> If i Make OnFire a class method everything works as expected.. However B> I need to call instance methods.... If you look at your first message [ruby-talk:20588] "Calling class member functions from C++", you'll find static VALUE cname##New( VALUE self ) \ { \ ObjectPtr * inst = new ObjectPtr(); \ *inst = Factory()->CreateObject(#cname); \ VALUE t = Data_Wrap_Struct(self,0,SE_DELETE(cname##Delete),inst); \ rb_obj_call_init(t, 0, NULL); \ Object * obj = inst->Get(); \ obj->LinkScriptClass( self ); \ return t; \ } \ `self' is the class, `t' is the instance You are storing the *class* when you write obj->LinkScriptClass( self ); I suspect, but not really sure that in these lines String callString = "On"; callString += m_msg; // Generated for the method ID callId = rb_intern( callString ); // Now create the parameter array for the call... Array args; // And make the script call rb_funcall2_protect( val,callId,args.Size(),args.Begin() ); that `val' is the value that you have stored in cname##New, this mean that `val' is the *class* and not the instance. When you call rb_funcall2(val, ...); you are calling a class method, because `val' is the *class* In cname##New just store the instance rather than the class. p.s.: I don't know your source but probably you don't need to store the instance. Guy Decoux