Class Info doesn't seem to be working for me...  I'd like some help.

I'm writing a C++ class, called "Object", which implements two
interfaces, iObject and iQueryResult, in addition to nsIClassInfo and
nsISupports.  (Yes, I know that those are somewhat lousy names).

My IDL files contain:

  [scriptable, uuid(78de02d5-e650-4343-a263-0e4a6d6d47ae)]
  interface iQueryResult : nsISupports
  {
        const unsigned short    QR_IOBJECT                      = 0;
        const unsigned short    QR_IFIELD                       = 1;
        const unsigned short    QR_QUERYRESULTSET       = 2;

        readonly attribute unsigned short queryResultType;
  };

  [scriptable, uuid(8d2b6b37-997e-49b7-9f3d-c68923057c4a)]
  interface iObject: iQueryResult
  {
    ...
  }


My Object.h contains:

  class Object : public iObject
  {
    ...
        NS_DECL_ISUPPORTS
        NS_DECL_IOBJECT
        NS_DECL_IQUERYRESULT
    ...
  }

My Object.cpp contains

  NS_IMPL_ISUPPORTS2_CI(Object, iObject, iQueryResult)

My XPCOMModules.cpp contains

  NS_GENERIC_FACTORY_CONSTRUCTOR(Object)
  NS_DECL_CLASSINFO(Object)

  static nsModuleComponentInfo components[] =
  {
   {
      "Object Class",
      OBJECT_CID,
      OBJECT_CONTRACT_ID,
      ObjectConstructor,
      nsnull,
      nsnull,
      nsnull,
      NS_CI_INTERFACE_GETTER_NAME(Object),
      nsnull,
      &NS_CLASSINFO_NAME(Object)
   },
   ...
  }
  NS_IMPL_NSGETMODULE(myModule, components)

My xulunit test case is:
  function test_iObject_classinfo {
    ...
    alert(object);
    var info =
object.QueryInterface(Components.interfaces.nsIClassInfo);
    ...
  }

The alert says object is an [xpconnect wrapped iObject @ .... ] which
is what I expect.
However, the test crashes on the next line with an NS_NOINTERFACE
error.

It appears that Javascript does not believe that the object supports
nsIClassInfo.  According to the docs I found online at
http://www.mozilla.org/projects/xpcom/nsIClassInfo.html this should be
enough to get classinfo stuff working.  The code at
http://lxr.mozilla.org/mozilla1.8.0/source/xpcom/sample/nsSampleModule.cpp
looks similar with nothing obviously out of place.

Clearly, I'm missing something.  Can anyone help me out?

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

Reply via email to