当前位置: 首页>>代码示例>>C++>>正文


C++ fb::JSAPIPtr类代码示例

本文整理汇总了C++中fb::JSAPIPtr的典型用法代码示例。如果您正苦于以下问题:C++ JSAPIPtr类的具体用法?C++ JSAPIPtr怎么用?C++ JSAPIPtr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了JSAPIPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getMemberCount

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;
}
开发者ID:scjohn,项目名称:FireBreath,代码行数:27,代码来源:IDispatchAPI.cpp

示例2: getMemberNames

void IDispatchAPI::getMemberNames(std::vector<std::string> &nameVector) const
{
    if (!host->isMainThread()) {
        typedef void (FB::JSAPI::*getMemberNamesType)(std::vector<std::string> *nameVector) const;
        host->CallOnMainThread(boost::bind((getMemberNamesType)&FB::JSAPI::getMemberNames, this, &nameVector));
        return;
    }
    if (is_JSAPI) {
        FB::JSAPIPtr tmp = inner.lock();
        if (tmp)
            tmp->getMemberNames(nameVector);
        return;
    }

    CComQIPtr<IDispatchEx> dispatchEx(m_obj);
    if (!dispatchEx) {
        throw FB::script_error("Cannot enumerate members; IDispatchEx not supported");
    }

	DISPID dispid = DISPID_STARTENUM;
	while (dispatchEx->GetNextDispID(fdexEnumAll, dispid, &dispid) != S_FALSE) {
		if (dispid < 0) {
			continue;
		}
		CComBSTR memberName;
		if (SUCCEEDED(dispatchEx->GetMemberName(dispid, &memberName))) {
			std::wstring name(memberName);
			nameVector.push_back(FB::wstring_to_utf8(name));
		}
	}
}
开发者ID:NoAntzWk,项目名称:FireBreath,代码行数:31,代码来源:IDispatchAPI.cpp

示例3: getMemberNames

void IDispatchAPI::getMemberNames(std::vector<std::string> &nameVector) const
{
    if (!host->isMainThread()) {
        typedef void (FB::JSAPI::*getMemberNamesType)(std::vector<std::string> *nameVector) const;
        host->CallOnMainThread(boost::bind((getMemberNamesType)&FB::JSAPI::getMemberNames, this, &nameVector));
        return;
    }
    if (is_JSAPI) {
        FB::JSAPIPtr tmp = inner.lock();
        if (tmp)
            tmp->getMemberNames(nameVector);
        return;
    }
    HRESULT hr;
    DISPID dispid;
    CComQIPtr<IDispatchEx> dispex(m_obj);
    if (!dispex) {
        throw FB::script_error("Cannot enumerate members; IDispatchEx not supported");
    }
    hr = dispex->GetNextDispID(fdexEnumAll, DISPID_STARTENUM, &dispid);
    while (SUCCEEDED(hr) && dispid > -1) {
        CComBSTR curName;
        hr = dispex->GetMemberName(dispid, &curName);
        std::wstring wStr(curName);
        nameVector.push_back(FB::wstring_to_utf8(wStr));
        hr = dispex->GetNextDispID(fdexEnumAll, dispid, &dispid);
    }
}
开发者ID:scjohn,项目名称:FireBreath,代码行数:28,代码来源:IDispatchAPI.cpp

示例4: GetProperty

// Methods to manage properties on the API
FB::variant NPObjectAPI::GetProperty(const std::string& propertyName)
{
    if (m_browser.expired())
        return FB::FBVoid();

    NpapiBrowserHostPtr browser(getHost());
    if (!browser->isMainThread()) {
        return browser->CallOnMainThread(boost::bind((FB::GetPropertyType)&JSAPI::GetProperty, this, propertyName));
    }
    if (is_JSAPI) {
        FB::JSAPIPtr tmp = inner.lock();
        if (tmp)
            return tmp->GetProperty(propertyName);
        else 
            return false;
    }
    NPVariant retVal;
    if (!browser->GetProperty(obj, browser->GetStringIdentifier(propertyName.c_str()), &retVal)) {
        browser->ReleaseVariantValue(&retVal);
        throw script_error(propertyName.c_str());
    } else {
        FB::variant ret = browser->getVariant(&retVal);
        browser->ReleaseVariantValue(&retVal);
        return ret;
    }
}
开发者ID:linkotec,项目名称:FireBreath,代码行数:27,代码来源:NPObjectAPI.cpp

示例5: getMemberCount

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;
}
开发者ID:NoAntzWk,项目名称:FireBreath,代码行数:30,代码来源:IDispatchAPI.cpp

示例6: GetProperty

// Methods to manage properties on the API
FB::variant IDispatchAPI::GetProperty(const std::string& propertyName)
{
    if (!host->isMainThread()) {
        return host->CallOnMainThread(boost::bind((FB::GetPropertyType)&IDispatchAPI::GetProperty, this, propertyName));
    }
    if (is_JSAPI) {
        FB::JSAPIPtr tmp = inner.lock();
        if (tmp)
            return tmp->GetProperty(propertyName);
        else 
            return false;
    }

    DISPPARAMS params;
    params.cArgs = 0;
    params.cNamedArgs = 0;

    VARIANT res;
    EXCEPINFO eInfo;

    HRESULT hr = E_NOTIMPL;
    CComQIPtr<IDispatchEx> dispex(m_obj);
    if (dispex) {
        hr = dispex->InvokeEx(getIDForName(FB::utf8_to_wstring(propertyName)), LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET, &params,
            &res, &eInfo, NULL);
    } else {
        hr = m_obj->Invoke(getIDForName(FB::utf8_to_wstring(propertyName)), IID_NULL, LOCALE_USER_DEFAULT,
            DISPATCH_PROPERTYGET, &params, &res, NULL, NULL);
    }
    if (SUCCEEDED(hr)) {
        return m_browser->getVariant(&res);
    } else {
        throw FB::script_error("Could not get property");
    }
}
开发者ID:scjohn,项目名称:FireBreath,代码行数:36,代码来源:IDispatchAPI.cpp

示例7: getMemberNames

void NPObjectAPI::getMemberNames(std::vector<std::string> &nameVector) const
{
    if (m_browser.expired())
        return;

    NpapiBrowserHostPtr browser(getHost());
    if (!browser->isMainThread()) {
        typedef void (FB::JSAPI::*getMemberNamesType)(std::vector<std::string> *nameVector) const;
        browser->CallOnMainThread(boost::bind((getMemberNamesType)&FB::JSAPI::getMemberNames, this, &nameVector));
        return;
    }
    if (is_JSAPI) {
        FB::JSAPIPtr tmp = inner.lock();
        if (tmp)
            tmp->getMemberNames(nameVector);
        return;
    }
    NPIdentifier *idArray(NULL);
    uint32_t count;

    browser->Enumerate(obj, &idArray, &count);
    for (uint32_t i = 0; i < count; i++) {
        nameVector.push_back(browser->StringFromIdentifier(idArray[i]));
    }
    browser->MemFree(idArray);
}
开发者ID:linkotec,项目名称:FireBreath,代码行数:26,代码来源:NPObjectAPI.cpp

示例8: script_error

FB::variant FB::JSFunction::exec( const std::vector<variant>& args )
{
    FB::JSAPIPtr api = m_apiWeak.lock();
    if (!api)
        throw new FB::script_error("Invalid JSAPI object");
    // Force calls to use the zone this function was created with
    FB::scoped_zonelock _l(api, getZone());
    return api->Invoke(m_methodName, args);
}
开发者ID:leeight,项目名称:FireBreath,代码行数:9,代码来源:JSFunction.cpp

示例9: SetProperty

void IDispatchAPI::SetProperty(const std::string& propertyName, const FB::variant& value)
{
    if (m_browser.expired() || m_obj.expired())
        return;

    ActiveXBrowserHostPtr browser(getHost());
    if (!browser->isMainThread()) {
        browser->CallOnMainThread(boost::bind((FB::SetPropertyType)&IDispatchAPI::SetProperty, this, propertyName, value));
        return;
    }

    if (is_JSAPI) {
        FB::JSAPIPtr tmp = inner.lock();
        if (tmp)
            tmp->SetProperty(propertyName, value);
        return;
    }

    DISPID dispId = getIDForName(FB::utf8_to_wstring(propertyName));
    if (dispId == DISPID_UNKNOWN) {
        throw FB::script_error("Could not set property");
    }

    CComVariant arg[1];
    VARIANTARG rawArg[1];
    DISPID namedArg[1];
    DISPPARAMS params;
    params.cArgs = 1;
    params.cNamedArgs = 1;
    params.rgdispidNamedArgs = namedArg;
    params.rgvarg = rawArg;

    browser->getComVariant(&arg[0], value);
    rawArg[0] = arg[0];
    namedArg[0] = DISPID_PROPERTYPUT;

    HRESULT hr;
    CComVariant result;
    CComExcepInfo exceptionInfo;
    CComQIPtr<IDispatchEx> dispatchEx(getIDispatch());
    if (dispatchEx) {
        hr = dispatchEx->InvokeEx(dispId, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPUTREF, &params,
            &result, &exceptionInfo, NULL);
        if (hr == DISP_E_MEMBERNOTFOUND) {
            hr = dispatchEx->InvokeEx(dispId, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPUT, &params,
                NULL, &exceptionInfo, NULL);
        }
    } else {
        hr = getIDispatch()->Invoke(dispId, IID_NULL, LOCALE_USER_DEFAULT,
            DISPATCH_PROPERTYPUT, &params, &result, &exceptionInfo, NULL);
    }

    if (FAILED(hr)) {
        throw FB::script_error("Could not set property");
    }
}
开发者ID:1833183060,项目名称:FireBreath,代码行数:56,代码来源:IDispatchAPI.cpp

示例10: AddTrack

void RemoteMediaStream::AddTrack(FB::JSAPIPtr pTrack)
{
    if("video" == pTrack->GetProperty("kind").convert_cast<std::string>())
    {
        m_videoTracks.push_back(FB::variant(pTrack));
    }
    else if("audio" == pTrack->GetProperty("kind").convert_cast<std::string>())
    {
        m_audioTracks.push_back(FB::variant(pTrack));
    }
}
开发者ID:bobwolff68,项目名称:gocastmain,代码行数:11,代码来源:GCPMediaStream.cpp

示例11: GetProperty

// Methods to manage properties on the API
FB::variant IDispatchAPI::GetProperty(const std::string& propertyName)
{
    if (m_browser.expired() || m_obj.expired())
        return FB::FBVoid();

    ActiveXBrowserHostPtr browser(getHost());
    if (!browser->isMainThread()) {
        return browser->CallOnMainThread(boost::bind((FB::GetPropertyType)&IDispatchAPI::GetProperty, this, propertyName));
    }
    
    if (is_JSAPI) {
        FB::JSAPIPtr tmp = inner.lock();
        if (!tmp) {
            return false;
        }
        return tmp->GetProperty(propertyName);
    }

    DISPID dispId = getIDForName(FB::utf8_to_wstring(propertyName));
    if (dispId == DISPID_UNKNOWN && propertyName != "toString") {
        throw FB::script_error("Could not get property");
    }

    // TODO: how can toString == DISPID_UNKNOWN work?

    DISPPARAMS params;
    params.cArgs = 0;
    params.cNamedArgs = 0;

    HRESULT hr;
    CComVariant result;
    CComExcepInfo exceptionInfo;
    try {
        CComQIPtr<IDispatchEx> dispatchEx(getIDispatch());
        if (dispatchEx) {
            hr = dispatchEx->InvokeEx(dispId, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET, &params,
                &result, &exceptionInfo, NULL);
        } else {
            hr = getIDispatch()->Invoke(dispId, IID_NULL, LOCALE_USER_DEFAULT,
                DISPATCH_PROPERTYGET, &params, &result, &exceptionInfo, NULL);
        }

        if (FAILED(hr)) {
            throw FB::script_error("Could not get property");
        }

        return browser->getVariant(&result);
    } catch (...) {
        throw FB::script_error("Could not get property");
    }
}
开发者ID:1833183060,项目名称:FireBreath,代码行数:52,代码来源:IDispatchAPI.cpp

示例12: RemoveProperty

void NPObjectAPI::RemoveProperty(int idx)
{
    if (m_browser.expired())
        return;

    NpapiBrowserHostPtr browser(getHost());
    std::string strIdx(boost::lexical_cast<std::string>(idx));
    if (is_JSAPI) {
        FB::JSAPIPtr tmp = inner.lock();
        if (tmp)
            return tmp->RemoveProperty(idx);
    }
    return RemoveProperty(strIdx);
}
开发者ID:linkotec,项目名称:FireBreath,代码行数:14,代码来源:NPObjectAPI.cpp

示例13: HasProperty

bool NPObjectAPI::HasProperty(int idx) const
{
    if (m_browser.expired())
        return false;

    NpapiBrowserHostPtr browser(getHost());
    if (is_JSAPI) {
        FB::JSAPIPtr tmp = inner.lock();
        if (tmp)
            return tmp->HasProperty(idx);
        else 
            return false;
    }
    return browser->HasProperty(obj, browser->GetIntIdentifier(idx));
}
开发者ID:linkotec,项目名称:FireBreath,代码行数:15,代码来源:NPObjectAPI.cpp

示例14: ptr

boost::shared_ptr<FB::JSAPISecureProxy> FB::JSAPISecureProxy::create( const FB::SecurityZone zone, const FB::JSAPIPtr &inner )
{
    boost::shared_ptr<FB::JSAPISecureProxy> ptr(new FB::JSAPISecureProxy(zone, inner));
    inner->registerProxy(ptr);
    // This is necessary because you can't use shared_from_this in the constructor
    return ptr;
}
开发者ID:epitech-labfree,项目名称:FireBreath,代码行数:7,代码来源:JSAPISecureProxy.cpp

示例15: set_source

void GCPAPI::set_source(const FB::JSAPIPtr& stream)
{
    m_srcStream = stream;
    if(NULL != stream.get())
    {
        std::string msg = m_htmlId.convert_cast<std::string>();
        msg += ": Setting video track renderer...";
        FBLOG_INFO_CUSTOM("GCAPAPI::set_source", msg);

        if("localPlayer" == m_htmlId.convert_cast<std::string>())
        {            
			if(NULL != getPlugin()->Renderer())
			{
                getPlugin()->Renderer()->SetPreviewMode(true);
				(GoCast::RtcCenter::Instance())->SetLocalVideoTrackRenderer(getPlugin()->Renderer());
			}
        }
        else
        {
            if(NULL != getPlugin()->Renderer())
            {
                (GoCast::RtcCenter::Instance())->SetRemoteVideoTrackRenderer(m_htmlId.convert_cast<std::string>(),
                                                                             getPlugin()->Renderer());                
            }
		}
    }
}
开发者ID:Bayerner,项目名称:webrtc_plugin,代码行数:27,代码来源:GCPAPI.cpp


注:本文中的fb::JSAPIPtr类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。