From: Lyle Johnson Date: 2005-02-10T00:29:47+09:00 Subject: Re: A couple of Ruby API questions On Thu, 10 Feb 2005 00:00:33 +0900, Jon McClintock wrote: > It's not quite that easy. Ruby lets you define a method that takes a > variable number of arguments, but then how do you actually pass them to > a varargs function? ... > > Unless you build some ungodly switch statement on the number of > arguments. Surely I'm not the first person to run into this? You're not the first person to run into this, but most people punt on trying to find some general purpose solution to the problem (which seems to be what you're asking for) and instead look for a way to wrap the *specific* varargs function that makes sense for the targeted scripting language. There's a pretty good discussion of this issue in the SWIG documentation, here: http://www.swig.org/Doc1.3/Varargs.html It includes some strategies (including the use of libffi) for dealing with these kinds of functions. Hope this helps, Lyle