Beispiel #1
0
size_t IDispatchAPI::getMemberCount() const
{
    if (!host->isMainThread()) {
        return host->CallOnMainThread(boost::bind(&IDispatchAPI::getMemberCount, this));
    }

    if (is_JSAPI) {
        FB::JSAPIPtr tmp = inner.lock();
		if (!tmp) {
			// TODO: check if this should be -1
			return 0;
		}
		return tmp->getMemberCount();
    }

    CComQIPtr<IDispatchEx> dispatchEx(m_obj);
    if (!dispatchEx) {
        return -1;
    }

    size_t count = 0;
    DISPID dispid = DISPID_STARTENUM;    
    while (dispatchEx->GetNextDispID(fdexEnumAll, dispid, &dispid) != S_FALSE) {
        if (dispid >= 0) {
			++count;
		}
    }

    return count;
}
Beispiel #2
0
size_t IDispatchAPI::getMemberCount() const
{
    if (!host->isMainThread()) {
        return host->CallOnMainThread(boost::bind(&IDispatchAPI::getMemberCount, this));
    }
    if (is_JSAPI) {
        FB::JSAPIPtr tmp = inner.lock();
        if (tmp)
            return tmp->getMemberCount();
        else 
            return 0;
    }
    HRESULT hr;
    DISPID dispid;
    size_t count(0);

    CComQIPtr<IDispatchEx> dispex(m_obj);
    if (!dispex) {
        return -1;
    }
    hr = dispex->GetNextDispID(fdexEnumAll, DISPID_STARTENUM, &dispid);
    while (SUCCEEDED(hr)) {
        count++;
        hr = dispex->GetNextDispID(fdexEnumAll, dispid, &dispid);
    }
    return count;
}
Beispiel #3
0
size_t NPObjectAPI::getMemberCount() const
{
    if (m_browser.expired())
        return 0;

    NpapiBrowserHostPtr browser(getHost());
    if (!browser->isMainThread()) {
        return browser->CallOnMainThread(boost::bind(&NPObjectAPI::getMemberCount, this));
    }
    if (is_JSAPI) {
        FB::JSAPIPtr tmp = inner.lock();
        if (tmp)
            return tmp->getMemberCount();
        else 
            return 0;
    }
    NPIdentifier *idArray(NULL);
    uint32_t count;
    browser->Enumerate(obj, &idArray, &count);
    browser->MemFree(idArray);
    return (size_t)count;
}
Beispiel #4
0
size_t IDispatchAPI::getMemberCount() const
{
    if (m_browser.expired() || m_obj.expired())
        return 0;

    ActiveXBrowserHostPtr browser(getHost());
    if (!browser->isMainThread()) {
        return browser->CallOnMainThread(boost::bind(&IDispatchAPI::getMemberCount, this));
    }

    if (is_JSAPI) {
        FB::JSAPIPtr tmp = inner.lock();
        if (!tmp) {
            // TODO: check if this should be -1
            return 0;
        }
        return tmp->getMemberCount();
    }

    size_t count = 0;
    try {
        CComQIPtr<IDispatchEx> dispatchEx(getIDispatch());
        if (!dispatchEx) {
            return -1;
        }

        DISPID dispid = DISPID_STARTENUM;    
        while (dispatchEx->GetNextDispID(fdexEnumAll, dispid, &dispid) != S_FALSE) {
            if (dispid >= 0) {
                ++count;
            }
        }
    } catch (...) {}

    return count;
}