nsCOMPtr<nsIInterfaceInfoManager> iim = getter_AddRefs(XPTI_GetInterfaceInfoManager()); NS_ASSERTION(iim, "could not get interface info manager");
nsCOMPtr<nsIInterfaceInfoManager> iim(do_GetService(NS_INTERFACEINFOMANAGER_SERVICE_CONTRACTID, &rv)); NS_ENSURE_SUCCESS(rv, rv);
  static nsresult GetInterfaceName(nsIInterfaceInfo* aIInfo,                                   PRUint16 aMethodIndex,                                   const nsXPTParamInfo* aParamInfo,                                   char** aResult)  {    static const char isupp_str[] = "nsISupports";    nsIID* iid;    nsresult rv = aIInfo->GetIIDForParam(aMethodIndex, aParamInfo, &iid);    if (NS_FAILED(rv)) {      // GetIIDForParam will sometimes fail to find an interface, particularly      // if that interface is not defined in an IDL file.  In those cases, just      // return |nsISupports|.      //      // For example, the |onStreamComplete| method for the interface      // |nsIUnicharStreamLoaderObserver| takes a param of      // |nsIUnicharInputStream|, which is defined in a simple header file, not      // an IDL file.      *aResult = (char*) nsMemory::Clone(isupp_str, sizeof(isupp_str));      rv = (*aResult == nsnull) ? NS_ERROR_OUT_OF_MEMORY : NS_OK;    } else {      // In Javaconnect, we handle weak references internally; no need for the      // |nsIWeakReference| interface.  So just return |nsISupports|.      if (iid->Equals(NS_GET_IID(nsIWeakReference))) {        *aResult = (char*) nsMemory::Clone(isupp_str, sizeof(isupp_str));        rv = (*aResult == nsnull) ? NS_ERROR_OUT_OF_MEMORY : NS_OK;      } else {        // Some methods take parameters of non-scriptable interfaces.  But we        // only output scriptable interfaces.  So if one of the param types is        // a non-scriptable interface, output |nsISupports| instead of the        // interface name.        nsCOMPtr<nsIInterfaceInfo> info;        nsCOMPtr<nsIInterfaceInfoManager> iim =          getter_AddRefs(XPTI_GetInterfaceInfoManager());        NS_ASSERTION(iim, "could not get interface info manager");        rv = iim->GetInfoForIID(iid, getter_AddRefs(info));        NS_ENSURE_SUCCESS(rv, rv);        PRBool scriptable;        if (NS_SUCCEEDED(rv)) {          info->IsScriptable(&scriptable);        }        if (NS_FAILED(rv) || !scriptable) {          *aResult = (char*) nsMemory::Clone(isupp_str, sizeof(isupp_str));          rv = (*aResult == nsnull) ? NS_ERROR_OUT_OF_MEMORY : NS_OK;        } else {          // If is scriptable, get name for given IID          rv = iim->GetNameForIID(iid, aResult);        }      }      nsMemory::Free(iid);    }    return rv;  }