示例#1
0
static v8::Handle<v8::Value> setFloat32Callback(const v8::Arguments& args)
{
    INC_STATS("DOM.DataView.setFloat32");
    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(float, value, static_cast<float>(MAYBE_MISSING_PARAMETER(args, 1, MissingIsUndefined)->NumberValue()));
    if (args.Length() <= 2) {
        imp->setFloat32(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->setFloat32(byteOffset, value, littleEndian, ec);
    if (UNLIKELY(ec))
        goto fail;
    return v8::Handle<v8::Value>();
    }
    fail:
    V8Proxy::setDOMException(ec);
    return v8::Handle<v8::Value>();
}
示例#2
0
EncodedJSValue JSC_HOST_CALL jsDataViewPrototypeFunctionSetFloat32(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());
    float value(exec->argument(1).toFloat(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());

    int argsCount = exec->argumentCount();
    if (argsCount <= 2) {
        imp->setFloat32(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->setFloat32(byteOffset, value, littleEndian, ec);
    setDOMException(exec, ec);
    return JSValue::encode(jsUndefined());
}