diff --git a/src/v8_typed_array.cc b/src/v8_typed_array.cc index 4a76f97059..d8a8c28b8f 100644 --- a/src/v8_typed_array.cc +++ b/src/v8_typed_array.cc @@ -305,27 +305,9 @@ class TypedArray { if (args.Length() < 1) return ThrowError("Wrong number of arguments."); - if (args[0]->IsNumber()) { - unsigned int index = args[0]->Uint32Value(); - void* ptr = args.This()->GetIndexedPropertiesExternalArrayData(); - - if (TEAType == v8::kExternalByteArray) - return v8::Integer::New(reinterpret_cast(ptr)[index]); - else if (TEAType == v8::kExternalUnsignedByteArray) - return v8::Integer::New(reinterpret_cast(ptr)[index]); - else if (TEAType == v8::kExternalShortArray) - return v8::Integer::New(reinterpret_cast(ptr)[index]); - else if (TEAType == v8::kExternalUnsignedShortArray) - return v8::Integer::New(reinterpret_cast(ptr)[index]); - else if (TEAType == v8::kExternalIntArray) - return v8::Integer::New(reinterpret_cast(ptr)[index]); - else if (TEAType == v8::kExternalUnsignedIntArray) - return v8::Integer::New(reinterpret_cast(ptr)[index]); - else if (TEAType == v8::kExternalFloatArray) - return v8::Number::New(reinterpret_cast(ptr)[index]); - else if (TEAType == v8::kExternalDoubleArray) - return v8::Number::New(reinterpret_cast(ptr)[index]); - } + if (args[0]->IsNumber()) + return args.This()->Get(args[0]->Uint32Value()); + return v8::Undefined(); } @@ -336,38 +318,8 @@ class TypedArray { //if (!args[0]->IsObject()) // return ThrowTypeError("Type error."); - if (args[0]->IsNumber()) { - // index, value - unsigned int index = args[0]->Uint32Value(); - void* ptr = args.This()->GetIndexedPropertiesExternalArrayData(); - if (TEAType == v8::kExternalByteArray) - reinterpret_cast(ptr)[index] = (char) args[1]->Int32Value(); - else if (TEAType == v8::kExternalUnsignedByteArray) - reinterpret_cast(ptr)[index] = - (unsigned char) args[1]->Int32Value(); - else if (TEAType == v8::kExternalShortArray) - reinterpret_cast(ptr)[index] = (short) args[1]->Int32Value(); - else if (TEAType == v8::kExternalUnsignedShortArray) - reinterpret_cast(ptr)[index] = - (unsigned short) args[1]->Int32Value(); - else if (TEAType == v8::kExternalIntArray) - reinterpret_cast(ptr)[index] = (int) args[1]->Int32Value(); - else if (TEAType == v8::kExternalUnsignedIntArray) - reinterpret_cast(ptr)[index] = - (unsigned int) args[1]->Int32Value(); - else if (TEAType == v8::kExternalFloatArray) - reinterpret_cast(ptr)[index] = (float) args[1]->NumberValue(); - else if (TEAType == v8::kExternalDoubleArray) - reinterpret_cast(ptr)[index] = (double) args[1]->NumberValue(); - else if (TEAType == v8::kExternalPixelArray) { - int value = args[1]->Int32Value(); - if (value < 0) - value = 0; - else if (value > 255) - value = 255; - reinterpret_cast(ptr)[index] = - (unsigned char) value; - } + if (args[0]->IsNumber()) { // index, value + args.This()->Set(args[0]->Uint32Value(), args[1]); } else if (args[0]->IsObject()) { v8::Handle obj = v8::Handle::Cast(args[0]);