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


C++ setDOMException函数代码示例

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


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

示例1: setDOMException

void V8SVGLength::convertToSpecifiedUnitsMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    SVGPropertyTearOff<SVGLength>* wrapper = V8SVGLength::toNative(info.Holder());
    if (wrapper->isReadOnly()) {
        setDOMException(NoModificationAllowedError, info.GetIsolate());
        return;
    }

    if (info.Length() < 1) {
        throwTypeError(ExceptionMessages::failedToExecute("convertToSpecifiedUnits", "SVGLength", ExceptionMessages::notEnoughArguments(1, info.Length())), info.GetIsolate());
        return;
    }

    SVGLength& imp = wrapper->propertyReference();
    ExceptionState exceptionState(info.Holder(), info.GetIsolate());
    V8TRYCATCH_VOID(int, unitType, toUInt32(info[0]));
    SVGLengthContext lengthContext(wrapper->contextElement());
    imp.convertToSpecifiedUnits(unitType, lengthContext, exceptionState);
    if (exceptionState.throwIfNeeded())
        return;
    wrapper->commitChange();
}
开发者ID:Igalia,项目名称:blink,代码行数:22,代码来源:V8SVGLengthCustom.cpp

示例2: throwVMError

EncodedJSValue JSC_HOST_CALL JSWebSocketConstructor::constructJSWebSocket(ExecState* exec)
{
    JSWebSocketConstructor* jsConstructor = static_cast<JSWebSocketConstructor*>(exec->callee());
    ScriptExecutionContext* context = jsConstructor->scriptExecutionContext();
    if (!context)
        return throwVMError(exec, createReferenceError(exec, "WebSocket constructor associated document is unavailable"));

    if (!exec->argumentCount())
        return throwVMError(exec, createSyntaxError(exec, "Not enough arguments"));

    String urlString = ustringToString(exec->argument(0).toString(exec));
    if (exec->hadException())
        return throwVMError(exec, createSyntaxError(exec, "wrong URL"));
    RefPtr<WebSocket> webSocket = WebSocket::create(context);
    ExceptionCode ec = 0;
    if (exec->argumentCount() < 2)
        webSocket->connect(urlString, ec);
    else {
        JSValue protocolsValue = exec->argument(1);
        if (isJSArray(&exec->globalData(), protocolsValue)) {
            Vector<String> protocols;
            JSArray* protocolsArray = asArray(protocolsValue);
            for (unsigned i = 0; i < protocolsArray->length(); ++i) {
                String protocol = ustringToString(protocolsArray->getIndex(i).toString(exec));
                if (exec->hadException())
                    return JSValue::encode(JSValue());
                protocols.append(protocol);
            }
            webSocket->connect(urlString, protocols, ec);
        } else {
            String protocol = ustringToString(protocolsValue.toString(exec));
            if (exec->hadException())
                return JSValue::encode(JSValue());
            webSocket->connect(urlString, protocol, ec);
        }
    }
    setDOMException(exec, ec);
    return JSValue::encode(CREATE_DOM_WRAPPER(exec, jsConstructor->globalObject(), WebSocket, webSocket.get()));
}
开发者ID:1833183060,项目名称:wke,代码行数:39,代码来源:JSWebSocketCustom.cpp

示例3: getObjectParameter

static JSValue getObjectParameter(JSWebGLRenderingContextBase* obj, ExecState* exec, ObjectType objectType)
{
    if (exec->argumentCount() != 2)
        return exec->vm().throwException(exec, createNotEnoughArgumentsError(exec));
    
    ExceptionCode ec = 0;
    WebGLRenderingContextBase& context = obj->impl();
    unsigned target = exec->uncheckedArgument(0).toInt32(exec);
    if (exec->hadException())
        return jsUndefined();
    unsigned pname = exec->uncheckedArgument(1).toInt32(exec);
    if (exec->hadException())
        return jsUndefined();
    WebGLGetInfo info;
    switch (objectType) {
    case kBuffer:
        info = context.getBufferParameter(target, pname, ec);
        break;
    case kRenderbuffer:
        info = context.getRenderbufferParameter(target, pname, ec);
        break;
    case kTexture:
        info = context.getTexParameter(target, pname, ec);
        break;
    case kVertexAttrib:
        // target => index
        info = context.getVertexAttrib(target, pname, ec);
        break;
    default:
        notImplemented();
        break;
    }
    if (ec) {
        setDOMException(exec, ec);
        return jsUndefined();
    }
    return toJS(exec, obj->globalObject(), info);
}
开发者ID:houzhenggang,项目名称:webkit,代码行数:38,代码来源:JSWebGLRenderingContextBaseCustom.cpp

示例4: createReferenceError

JSValue JSIDBObjectStore::createIndex(ExecState* exec)
{
    ScriptExecutionContext* context = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext();
    if (!context)
        return exec->vm().throwException(exec, createReferenceError(exec, "IDBObjectStore script execution context is unavailable"));

    if (exec->argumentCount() < 2)
        return exec->vm().throwException(exec, createNotEnoughArgumentsError(exec));

    String name = exec->argument(0).toString(exec)->value(exec);
    if (exec->hadException())
        return jsUndefined();

    IDBKeyPath keyPath = idbKeyPathFromValue(exec, exec->argument(1));
    if (exec->hadException())
        return jsUndefined();

    JSValue optionsValue = exec->argument(2);
    if (!optionsValue.isUndefinedOrNull() && !optionsValue.isObject())
        return throwTypeError(exec, "Not an object.");

    bool unique = false;
    bool multiEntry = false;
    if (!optionsValue.isUndefinedOrNull()) {
        unique = optionsValue.get(exec, Identifier(exec, "unique")).toBoolean(exec);
        if (exec->hadException())
            return jsUndefined();

        multiEntry = optionsValue.get(exec, Identifier(exec, "multiEntry")).toBoolean(exec);
        if (exec->hadException())
            return jsUndefined();
    }

    ExceptionCode ec = 0;
    JSValue result = toJS(exec, globalObject(), impl().createIndex(context, name, keyPath, unique, multiEntry, ec).get());
    setDOMException(exec, ec);
    return result;
}
开发者ID:CannedFish,项目名称:webkitgtk,代码行数:38,代码来源:JSIDBObjectStoreCustom.cpp

示例5: switch

std::unique_ptr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForImportKey(ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSValue value)
{
    switch (algorithm) {
    case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
        return std::make_unique<CryptoAlgorithmParameters>();
    case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
        return createRsaKeyParamsWithHash(exec, value);
    case CryptoAlgorithmIdentifier::RSA_PSS:
        return std::make_unique<CryptoAlgorithmParameters>();
    case CryptoAlgorithmIdentifier::RSA_OAEP:
        return createRsaKeyParamsWithHash(exec, value);
    case CryptoAlgorithmIdentifier::ECDSA:
    case CryptoAlgorithmIdentifier::ECDH:
    case CryptoAlgorithmIdentifier::AES_CTR:
    case CryptoAlgorithmIdentifier::AES_CBC:
    case CryptoAlgorithmIdentifier::AES_CMAC:
    case CryptoAlgorithmIdentifier::AES_GCM:
    case CryptoAlgorithmIdentifier::AES_CFB:
    case CryptoAlgorithmIdentifier::AES_KW:
        return std::make_unique<CryptoAlgorithmParameters>();
    case CryptoAlgorithmIdentifier::HMAC:
        return createHmacParams(exec, value);
    case CryptoAlgorithmIdentifier::DH:
        return std::make_unique<CryptoAlgorithmParameters>();
    case CryptoAlgorithmIdentifier::SHA_1:
    case CryptoAlgorithmIdentifier::SHA_224:
    case CryptoAlgorithmIdentifier::SHA_256:
    case CryptoAlgorithmIdentifier::SHA_384:
    case CryptoAlgorithmIdentifier::SHA_512:
    case CryptoAlgorithmIdentifier::CONCAT:
    case CryptoAlgorithmIdentifier::HKDF_CTR:
    case CryptoAlgorithmIdentifier::PBKDF2:
        setDOMException(exec, NOT_SUPPORTED_ERR);
        return nullptr;
    }
    RELEASE_ASSERT_NOT_REACHED();
    return nullptr;
}
开发者ID:cheekiatng,项目名称:webkit,代码行数:38,代码来源:JSCryptoAlgorithmDictionary.cpp

示例6: jsIDBCursorPrototypeFunctionUpdate

EncodedJSValue JSC_HOST_CALL jsIDBCursorPrototypeFunctionUpdate(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    if (!thisValue.inherits(&JSIDBCursor::s_info))
        return throwVMTypeError(exec);
    JSIDBCursor* castedThis = static_cast<JSIDBCursor*>(asObject(thisValue));
    ASSERT_GC_OBJECT_INHERITS(castedThis, &JSIDBCursor::s_info);
    IDBCursor* imp = static_cast<IDBCursor*>(castedThis->impl());
    if (exec->argumentCount() < 1)
        return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
    ExceptionCode ec = 0;
    ScriptExecutionContext* scriptContext = static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext();
    if (!scriptContext)
        return JSValue::encode(jsUndefined());
    RefPtr<SerializedScriptValue> value(SerializedScriptValue::create(exec, exec->argument(0)));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());


    JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->update(scriptContext, value, ec)));
    setDOMException(exec, ec);
    return JSValue::encode(result);
}
开发者ID:Xertz,项目名称:EAWebKit,代码行数:23,代码来源:JSIDBCursor.cpp

示例7: jsUndefined

JSValue JSHistory::replaceState(ExecState* exec)
{
    RefPtr<SerializedScriptValue> historyState = SerializedScriptValue::create(exec, exec->argument(0), 0);
    if (exec->hadException())
        return jsUndefined();

    String title = valueToStringWithUndefinedOrNullCheck(exec, exec->argument(1));
    if (exec->hadException())
        return jsUndefined();
        
    String url;
    if (exec->argumentCount() > 2) {
        url = valueToStringWithUndefinedOrNullCheck(exec, exec->argument(2));
        if (exec->hadException())
            return jsUndefined();
    }

    ExceptionCode ec = 0;
    impl()->stateObjectAdded(historyState.release(), title, url, History::StateObjectReplace, ec);
    setDOMException(exec, ec);

    return jsUndefined();
}
开发者ID:paul99,项目名称:third_party,代码行数:23,代码来源:JSHistoryCustom.cpp

示例8: constructSharedWorker

static JSObject* constructSharedWorker(ExecState* exec, JSObject* constructor, const ArgList& args)
{
    JSSharedWorkerConstructor* jsConstructor = static_cast<JSSharedWorkerConstructor*>(constructor);

    if (args.size() < 1)
        return throwError(exec, SyntaxError, "Not enough arguments");

    UString scriptURL = args.at(0).toString(exec);
    UString name;
    if (args.size() > 1)
        name = args.at(1).toString(exec);

    if (exec->hadException())
        return 0;

    // FIXME: We need to use both the dynamic scope and the lexical scope (dynamic scope for resolving the worker URL)
    DOMWindow* window = asJSDOMWindow(exec->lexicalGlobalObject())->impl();
    ExceptionCode ec = 0;
    RefPtr<SharedWorker> worker = SharedWorker::create(scriptURL, name, window->document(), ec);
    setDOMException(exec, ec);

    return asObject(toJS(exec, jsConstructor->globalObject(), worker.release()));
}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:23,代码来源:JSSharedWorkerConstructor.cpp

示例9: constructEventSource

static JSObject* constructEventSource(ExecState* exec, JSObject* constructor, const ArgList& args)
{
    if (args.size() < 1)
        return throwError(exec, SyntaxError, "Not enough arguments");

    UString url = args.at(0).toString(exec);
    if (exec->hadException())
        return 0;

    JSEventSourceConstructor* jsConstructor =  static_cast<JSEventSourceConstructor*>(constructor);
    ScriptExecutionContext* context = jsConstructor->scriptExecutionContext();
    if (!context)
        return throwError(exec, ReferenceError, "EventSource constructor associated document is unavailable");

    ExceptionCode ec = 0;
    RefPtr<EventSource> eventSource = EventSource::create(url, context, ec);
    if (ec) {
        setDOMException(exec, ec);
        return 0;
    }

    return asObject(toJS(exec, jsConstructor->globalObject(), eventSource.release()));
}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:23,代码来源:JSEventSourceConstructor.cpp

示例10: createNotEnoughArgumentsError

JSValue JSWebGLRenderingContextBase::getFramebufferAttachmentParameter(ExecState& state)
{
    if (state.argumentCount() != 3)
        return state.vm().throwException(&state, createNotEnoughArgumentsError(&state));
    
    ExceptionCode ec = 0;
    WebGLRenderingContextBase& context = wrapped();
    unsigned target = state.uncheckedArgument(0).toInt32(&state);
    if (state.hadException())
        return jsUndefined();
    unsigned attachment = state.uncheckedArgument(1).toInt32(&state);
    if (state.hadException())
        return jsUndefined();
    unsigned pname = state.uncheckedArgument(2).toInt32(&state);
    if (state.hadException())
        return jsUndefined();
    WebGLGetInfo info = context.getFramebufferAttachmentParameter(target, attachment, pname, ec);
    if (ec) {
        setDOMException(&state, ec);
        return jsUndefined();
    }
    return toJS(&state, globalObject(), info);
}
开发者ID:Comcast,项目名称:WebKitForWayland,代码行数:23,代码来源:JSWebGLRenderingContextBaseCustom.cpp

示例11: throwVMError

EncodedJSValue JSC_HOST_CALL JSWorkerConstructor::constructJSWorker(ExecState* exec)
{
    JSWorkerConstructor* jsConstructor = static_cast<JSWorkerConstructor*>(exec->callee());

    if (!exec->argumentCount())
        return throwVMError(exec, createTypeError(exec, "Not enough arguments"));

    UString scriptURL = exec->argument(0).toString(exec);
    if (exec->hadException())
        return JSValue::encode(JSValue());

    // See section 4.8.2 step 14 of WebWorkers for why this is the lexicalGlobalObject. 
    DOMWindow* window = asJSDOMWindow(exec->lexicalGlobalObject())->impl();

    ExceptionCode ec = 0;
    RefPtr<Worker> worker = Worker::create(ustringToString(scriptURL), window->document(), ec);
    if (ec) {
        setDOMException(exec, ec);
        return JSValue::encode(JSValue());
    }

    return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), worker.release())));
}
开发者ID:Xertz,项目名称:EAWebKit,代码行数:23,代码来源:JSWorkerCustom.cpp

示例12: createNotEnoughArgumentsError

JSValue JSWebGLRenderingContextBase::getFramebufferAttachmentParameter(ExecState* exec)
{
    if (exec->argumentCount() != 3)
        return exec->vm().throwException(exec, createNotEnoughArgumentsError(exec));
    
    ExceptionCode ec = 0;
    WebGLRenderingContextBase& context = impl();
    unsigned target = exec->uncheckedArgument(0).toInt32(exec);
    if (exec->hadException())
        return jsUndefined();
    unsigned attachment = exec->uncheckedArgument(1).toInt32(exec);
    if (exec->hadException())
        return jsUndefined();
    unsigned pname = exec->uncheckedArgument(2).toInt32(exec);
    if (exec->hadException())
        return jsUndefined();
    WebGLGetInfo info = context.getFramebufferAttachmentParameter(target, attachment, pname, ec);
    if (ec) {
        setDOMException(exec, ec);
        return jsUndefined();
    }
    return toJS(exec, globalObject(), info);
}
开发者ID:houzhenggang,项目名称:webkit,代码行数:23,代码来源:JSWebGLRenderingContextBaseCustom.cpp

示例13: el

JSObject* JSHTMLOptionElementConstructor::construct(ExecState* exec, const List& args)
{
    int exception = 0;
    RefPtr<Element> el(m_doc->createElement("option", exception));
    HTMLOptionElement* opt = 0;
    if (el) {
        opt = static_cast<HTMLOptionElement*>(el.get());
        int sz = args.size();
        RefPtr<Text> text = m_doc->createTextNode("");
        opt->appendChild(text, exception);
        if (exception == 0 && sz > 0)
            text->setData(args[0]->toString(exec), exception);
        if (exception == 0 && sz > 1)
            opt->setValue(args[1]->toString(exec));
        if (exception == 0 && sz > 2)
            opt->setDefaultSelected(args[2]->toBoolean(exec));
        if (exception == 0 && sz > 3)
            opt->setSelected(args[3]->toBoolean(exec));
    }

    setDOMException(exec, exception);
    return static_cast<JSObject*>(toJS(exec, opt));
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:23,代码来源:JSHTMLOptionElementConstructor.cpp

示例14: ustringToString

bool JSStorage::putDelegate(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot&)
{
    // Only perform the custom put if the object doesn't have a native property by this name.
    // Since hasProperty() would end up calling canGetItemsForName() and be fooled, we need to check
    // the native property slots manually.
    PropertySlot slot;
    if (getStaticValueSlot<JSStorage, Base>(exec, s_info.propHashTable(exec), this, propertyName, slot))
        return false;
        
    JSValue prototype = this->prototype();
    if (prototype.isObject() && asObject(prototype)->hasProperty(exec, propertyName))
        return false;
    
    String stringValue = ustringToString(value.toString(exec)->value(exec));
    if (exec->hadException())
        return true;
    
    ExceptionCode ec = 0;
    impl()->setItem(identifierToString(propertyName), stringValue, ec);
    setDOMException(exec, ec);

    return true;
}
开发者ID:CannedFish,项目名称:deepin-webkit,代码行数:23,代码来源:JSStorageCustom.cpp

示例15: throwSyntaxError

JSValue JSWebGLRenderingContext::getFramebufferAttachmentParameter(ExecState* exec)
{
    if (exec->argumentCount() != 3)
        return throwSyntaxError(exec);

    ExceptionCode ec = 0;
    WebGLRenderingContext* context = static_cast<WebGLRenderingContext*>(impl());
    unsigned target = exec->argument(0).toInt32(exec);
    if (exec->hadException())
        return jsUndefined();
    unsigned attachment = exec->argument(1).toInt32(exec);
    if (exec->hadException())
        return jsUndefined();
    unsigned pname = exec->argument(2).toInt32(exec);
    if (exec->hadException())
        return jsUndefined();
    WebGLGetInfo info = context->getFramebufferAttachmentParameter(target, attachment, pname, ec);
    if (ec) {
        setDOMException(exec, ec);
        return jsUndefined();
    }
    return toJS(exec, globalObject(), info);
}
开发者ID:Treeeater,项目名称:Chromium_on_windows,代码行数:23,代码来源:JSWebGLRenderingContextCustom.cpp


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