static v8::Handle<v8::Value> getInt16Callback(const v8::Arguments& args) { INC_STATS("DOM.DataView.getInt16"); if (args.Length() < 1) 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))); if (args.Length() <= 1) { int result = imp->getInt16(byteOffset, ec); if (UNLIKELY(ec)) goto fail; return v8::Integer::New(result); } EXCEPTION_BLOCK(bool, littleEndian, MAYBE_MISSING_PARAMETER(args, 1, MissingIsUndefined)->BooleanValue()); int result = imp->getInt16(byteOffset, littleEndian, ec); if (UNLIKELY(ec)) goto fail; return v8::Integer::New(result); } fail: V8Proxy::setDOMException(ec); return v8::Handle<v8::Value>(); }
EncodedJSValue JSC_HOST_CALL jsDataViewPrototypeFunctionGetInt16(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() < 1) 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()); int argsCount = exec->argumentCount(); if (argsCount <= 1) { JSC::JSValue result = jsNumber(imp->getInt16(byteOffset, ec)); setDOMException(exec, ec); return JSValue::encode(result); } bool littleEndian(exec->argument(1).toBoolean(exec)); if (exec->hadException()) return JSValue::encode(jsUndefined()); JSC::JSValue result = jsNumber(imp->getInt16(byteOffset, littleEndian, ec)); setDOMException(exec, ec); return JSValue::encode(result); }