In C++, it not a problem. Neither is it in Java where using the #pragma 
directive in IDL you can get the generated Java file to be placed in a 
package. However, in javascript in seems that there is a problem.

In the scripting interface for our product we have the following sort of 
structure:

interface IBrowser
{
   INode getNode();
}

interface INode
{
   function1();
}

interface IImage : INode
{
   function2();
}

Now if the IBrowser interface returns an INode which actually is on an 
object that supports the IImage interface, then the only way to call 
function2() is by using QI to get the IImage interface.

It's bad enough that we have to call QI  (which we don't have to do 
under IE or NS4.x) but if we also have to use IID's in javascript (can 
you do this?) then I think we're going to have a tough job getting our 
content guys to write any content that works on NS6.

Is there any other way of doing this? One thing I looked at was using 
nsIXPCScriptable, am I right in thinking that this can be used to 
dynamically query an interface for the methods that it supports? This 
looked quite scary to use though!

Dave

Pierre Phaneuf wrote:

> David Brittain wrote:
> 
>> var interface = plugin.QueryInterface(Components.interfaces.IPlugin);
>> 
>> In this case how does javascript know which IPlugin to use, given that
>> there may be a number of interfaces called IPlugin. As I understand it
>> the namespace feature in XPCOM is not implemented, therefore is there
>> not a problem with multiple vendors providing components which have the
>> same interface names. Is there any way to get around this?
> 
> 
> In C++, the parameter to QueryInterface is a UUID (universally unique
> ID), and thus does not need a namespace.
> 
> For JavaScript, this might be a bit "looser"...
> 



Reply via email to