From: Ben Thomas Date: 2003-02-26T04:42:57+09:00 Subject: Re: General question about args (embedded code) Yukihiro Matsumoto wrote: > Hi, > > In message "Re: General question about args (embedded code)" > on 03/02/26, Ben Thomas writes: > > |When I debugged my example, the second argument is never passed to > |rb_const_get function. After I read the code of rb_protect, I though it > |was normal that this code doesn't work since rb_protect only pass 1 > |arguments to the function it's calling. But I'm not an expert in pure C, > |so I was thinking that maybe I'm missing something, that there was a way > |to pass many arguments without using helper functions... > > So you're expecting rb_const_get() to receive two arguments. Hmm, > rb_protect() calls its function argument with single argument, you > have to unpack by yourself, i.e. > > static VALUE > cget(VALUE *args) > { > return rb_const_get(args[0], (ID)args[1]); > } > > void > foo() > { > VALUE args[2]; > args[0] = rb_cObject; > args[1] = rb_intern("Foo"); > > rb_protect(cget, args, &result); > } > > Do you get it? > > matz. > > Yep, and it works just fine! Thankx for the answer! Ben.