const char* fmt = (i == 0) ? "(%s" : (i == count-1) ? ", %s)" : ", %s"; name = JS_sprintf_append(name, fmt, array[i]->GetNameString());
*_retval = str; return NS_OK;
XPCWrappedNative::ToString(XPCCallContext& ccx,                           XPCWrappedNativeTearOff* to /* = nsnull */ ) const{#ifdef DEBUG#  define FMT_ADDR " @ 0x%p"#  define PARAM_ADDR(w) , w#else#  define FMT_ADDR ""#  define PARAM_ADDR(w)#endif    char* sz = nsnull;    char* name = nsnull;    XPCNativeScriptableInfo* si = GetScriptableInfo();    if(si)        name = JS_smprintf("%s", si->GetJSClass()->name);    if(to)    {        const char* fmt = name ? " (%s)" : "%s";        name = JS_sprintf_append(name, fmt,                                 to->GetInterface()->GetNameString());    }    else if(!name)    {        XPCNativeSet* set = GetSet();        XPCNativeInterface** array = set->GetInterfaceArray();        PRUint16 count = set->GetInterfaceCount();        if(count == 1)            name = JS_sprintf_append(name, "%s", array[0]->GetNameString());        else if(count == 2 &&                array[0] == XPCNativeInterface::GetISupports(ccx))        {            name = JS_sprintf_append(name, "%s", array[1]->GetNameString());        }        else        {            for(PRUint16 i = 0; i < count; i++)            {                const char* fmt = (i == 0) ?                                    "(%s" : (i == count-1) ?                                        ", %s)" : ", %s";                name = JS_sprintf_append(name, fmt,                                         array[i]->GetNameString());            }        }    }    if(!name)    {        return nsnull;    }    const char* fmt = "[xpconnect wrapped %s" FMT_ADDR "]";    if(si)    {        fmt = "[object %s" FMT_ADDR "]";    }    sz = JS_smprintf(fmt, name PARAM_ADDR(this));    JS_smprintf_free(name);    return sz;#undef FMT_ADDR#undef PARAM_ADDR}