Mark,
Yes this is legal, but you've misused it. You can't decalre the
second param as type nsISupports. It should be of type nsQIResult
- or some '[ptr] native' type that you make up (see the
nsQIResult declaration in nsrootidl.idl). The issue is that by
declaring it nsISupports you are saying that it has a specific
type - nsISupports - yet you also declare that its type will be
told at runtime by using iid_is. This confuses the system. We
should add an error rule to the xpidl compiler to detect this. I
know mccabe added a check that the iid_is refers to is an iid,
but an additional check is needed. I filed:
http://bugzilla.mozilla.org/show_bug.cgi?id=68178
FWIW, The docs were not written by the person who implemented
this stuff and they do have errors. They talk about normal usage.
But what you are trying to do is perfectly reasonable. And I'm
pretty sure it will work if you fix the declaration type. If not
then let me know and I will fix it. There is an example in
xpctest.idl that uses 'inout' (but not 'in'). Also, the code you
sited is in the module I call xpti not xptcall :)
John.
Mark Hammond wrote:
>
> Hi all,
> I stumbled across the following method definition in an IDL:
>
> void doSomething(in nsIIDRef iid,[iid_is(iid)] in nsISupports s);
>
> Note that the last param specified iid_is, but is "in".
>
> I understand that it doesn't make a real lot of sense, but my question
> simply is "is it legal"?
>
> Searching around the docs, I find
> http://www.mozilla.org/scriptable/xpidl/notes/keywords.txt, which states:
>
> """
> iid_is // used to say that some other param indicates at runtime
> // the interfcace type for this out param (in [])
> """
>
> I also found
> http://www.mozilla.org/scriptable/xpidl/idl-authors-guide/keywords.html,
> which says:
>
> """
> Used to declare that some other param indicates (at runtime) the
> interface type for this out param. You almost certainly won't need to
> use this.
> """
>
> So the docs seem to imply it is _not_ legal. However, xpidl lets it
> pass without warning.
>
> The bigger problem is when Python (and possibly js - haven't tried yet)
> attempts to call nsIInterfaceInfo::GetIIDForParam() - xptcall asserts in
> this block:
>
> if(XPT_TDP_TAG(td->prefix) != TD_INTERFACE_TYPE) {
> NS_ASSERTION(0, "not an interface");
> return NS_ERROR_INVALID_ARG;
> }
>
> So - it seems we have a bug _somewhere_. My question is where :-)
> Should this be considered a bug in xpidl for allowing that construct, or
> in xptcall for failing to get the IID?
>
> Thanks,
>
> Mark.