From: ts Date: 2001-09-25T14:15:45+09:00 Subject: [ruby-talk:21658] Re: C++ / Ruby questions again >>>>> "B" == =?ISO-8859-1?Q?Bernhard Gl=FCck?= writes: B> Hm that's a nice thing for ruby. but unfortunatly it does not help B> me... I need to call a ruby instance method from C++ ... so i need to B> know in C++ how many parameters the ruby instance method i want to B> call takes.... B> So the ruby method for doing this does not help me.. B> Is there a way of doing the same using the C API ? Well, when you call : rb_funcall(obj, rb_intern("tt"), 1, INT2FIX(12)); this is like if you have made the method call (in ruby) obj.tt(12) If I've understood actually you use rb_respond_to(), this mean that you write something like this if (rb_respond_to(obj, rb_intern("tt"))) { VALUE res = rb_funcall2(obj, rb_intern("tt"), 0, 0); } else { /* send an error message */ } You can replace it with something like this if (rb_respond_to(obj, rb_intern("tt"))) { VALUE method, arity; method = rb_funcall(obj, rb_intern("method"), 1, rb_str_new2("tt")); arity = rb_funcall2(method, rb_intern("arity"), 0, 0); rb_warn("tt take %d args", NUM2INT(arity)); } else { /* send an error message */ } Guy Decoux