Exemplo n.º 1
0
static v8::Handle<v8::Value> setFloat64Callback(const v8::Arguments& args)
{
    INC_STATS("DOM.DataView.setFloat64");
    if (args.Length() < 2)
        return throwError("Not enough arguments", V8Proxy::TypeError);
    DataView* imp = V8DataView::toNative(args.Holder());
    ExceptionCode ec = 0;
    {
    EXCEPTION_BLOCK(unsigned, byteOffset, toUInt32(MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined)));
    EXCEPTION_BLOCK(double, value, static_cast<double>(MAYBE_MISSING_PARAMETER(args, 1, MissingIsUndefined)->NumberValue()));
    if (args.Length() <= 2) {
        imp->setFloat64(byteOffset, value, ec);
        if (UNLIKELY(ec))
            goto fail;
        return v8::Handle<v8::Value>();
    }
    EXCEPTION_BLOCK(bool, littleEndian, MAYBE_MISSING_PARAMETER(args, 2, MissingIsUndefined)->BooleanValue());
    imp->setFloat64(byteOffset, value, littleEndian, ec);
    if (UNLIKELY(ec))
        goto fail;
    return v8::Handle<v8::Value>();
    }
    fail:
    V8Proxy::setDOMException(ec);
    return v8::Handle<v8::Value>();
}
Exemplo n.º 2
0
EncodedJSValue JSC_HOST_CALL jsDataViewPrototypeFunctionSetFloat64(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    if (!thisValue.inherits(&JSDataView::s_info))
        return throwVMTypeError(exec);
    JSDataView* castedThis = static_cast<JSDataView*>(asObject(thisValue));
    ASSERT_GC_OBJECT_INHERITS(castedThis, &JSDataView::s_info);
    DataView* imp = static_cast<DataView*>(castedThis->impl());
    if (exec->argumentCount() < 2)
        return throwVMError(exec, createSyntaxError(exec, "Not enough arguments"));
    ExceptionCode ec = 0;
    unsigned byteOffset(exec->argument(0).toUInt32(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    double value(exec->argument(1).toNumber(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());

    int argsCount = exec->argumentCount();
    if (argsCount <= 2) {
        imp->setFloat64(byteOffset, value, ec);
        setDOMException(exec, ec);
        return JSValue::encode(jsUndefined());
    }

    bool littleEndian(exec->argument(2).toBoolean(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());

    imp->setFloat64(byteOffset, value, littleEndian, ec);
    setDOMException(exec, ec);
    return JSValue::encode(jsUndefined());
}