コード例 #1
0
EncodedJSValue JSC_HOST_CALL jsInt32ArrayPrototypeFunctionSubarray(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    if (!thisValue.inherits(&JSInt32Array::s_info))
        return throwVMTypeError(exec);
    JSInt32Array* castedThis = static_cast<JSInt32Array*>(asObject(thisValue));
    ASSERT_GC_OBJECT_INHERITS(castedThis, &JSInt32Array::s_info);
    Int32Array* imp = static_cast<Int32Array*>(castedThis->impl());
    int start(exec->argument(0).toInt32(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());

    int argsCount = exec->argumentCount();
    if (argsCount <= 1) {

        JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->subarray(start)));
        return JSValue::encode(result);
    }

    int end(exec->argument(1).toInt32(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());


    JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->subarray(start, end)));
    return JSValue::encode(result);
}
コード例 #2
0
ファイル: V8Int32Array.cpp プロジェクト: sinoory/webv8
static v8::Handle<v8::Value> subarrayCallback(const v8::Arguments& args)
{
    INC_STATS("DOM.Int32Array.subarray");
    Int32Array* imp = V8Int32Array::toNative(args.Holder());
    EXCEPTION_BLOCK(int, start, toInt32(args[0]));
    if (args.Length() <= 1) {
        return toV8(imp->subarray(start));
    }
    EXCEPTION_BLOCK(int, end, toInt32(args[1]));
    return toV8(imp->subarray(start, end));
}