Exemplo n.º 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);
}
Exemplo n.º 2
0
JSValue jsInt32ArrayLength(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSInt32Array* castedThis = static_cast<JSInt32Array*>(asObject(slotBase));
    UNUSED_PARAM(exec);
    Int32Array* imp = static_cast<Int32Array*>(castedThis->impl());
    JSValue result = jsNumber(imp->length());
    return result;
}
Exemplo n.º 3
0
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));
}
Exemplo n.º 4
0
            static v8::Handle<v8::Value> New (const v8::Arguments& args){

        if (args.Length() == 1 && args[0]->IsUint32()) {
                
//        std::cout<<"New  "<<args[0]->ToUint32()->IntegerValue()<<std::endl;
                Int32Array* array = new Int32Array(args[0]->ToUint32()->IntegerValue());
                array->Wrap(args.This());
        }
        else if(args.Length() == 1 && args[0]->IsObject())
        {
         // unwrap array buffer object
        ArrayBuffer* buf = ObjectWrap::Unwrap<ArrayBuffer>(args[0]->ToObject());
               Int32Array* array = new Int32Array(buf->length/4);
                array->Wrap(args.This());
            
        }
//    std::cout<<"old Int32Array New "<<std::endl;
                return args.This();
            }
Exemplo n.º 5
0
static v8::Handle<v8::Value> lengthAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
    INC_STATS("DOM.Int32Array.length._get");
    Int32Array* imp = V8Int32Array::toNative(info.Holder());
    return v8::Integer::NewFromUnsigned(imp->length());
}