On Dec 14, 11:31 am, Daniele Rizzo <[EMAIL PROTECTED]> wrote:
> How can i define an interface (idl) of function with optional arguments?

The long winded answer is that you don't. Just don't define the
arguments. JavaScript will see as many arguments as you pass (but
refuse to allow you to call an interface method with fewer than the
specified number of arguments).

C++ can talk to JavaScript and ask about these optional arguments. It's
painful and mean and should only be used if absolutely required for
compatibility with some bad existing Web API (of which there should be
none which aren't already handled).

However it's really the wrong approach.

If you need optional arguments, consider nsIArray, nsIPropertyBag (or a
similar), or for prototyping you can use a callback object (I tend to
favor using nsIObserver w/ nsISupportsPrimitives to make requests).

Normally you should be able to simply provide multiple distinctly named
methods which explain how they differ:

void printString(in AString string);
void printStringToStream(in AString string, in myIStream stream);

_______________________________________________
dev-tech-xpcom mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-xpcom

Reply via email to