@ -33,25 +33,6 @@ using node::ThrowRangeError;
using node : : ThrowTypeError ;
using node : : ThrowTypeError ;
using node : : ThrowError ;
using node : : ThrowError ;
int SizeOfArrayElementForType ( v8 : : ExternalArrayType type ) {
switch ( type ) {
case v8 : : kExternalByteArray :
case v8 : : kExternalUnsignedByteArray :
return 1 ;
case v8 : : kExternalShortArray :
case v8 : : kExternalUnsignedShortArray :
return 2 ;
case v8 : : kExternalIntArray :
case v8 : : kExternalUnsignedIntArray :
case v8 : : kExternalFloatArray :
return 4 ;
case v8 : : kExternalDoubleArray :
return 8 ;
default :
return 0 ;
}
}
struct BatchedMethods {
struct BatchedMethods {
const char * name ;
const char * name ;
v8 : : Handle < v8 : : Value > ( * func ) ( const v8 : : Arguments & args ) ;
v8 : : Handle < v8 : : Value > ( * func ) ( const v8 : : Arguments & args ) ;
@ -90,7 +71,7 @@ class ArrayBuffer {
v8 : : Object * obj = v8 : : Object : : Cast ( * value ) ;
v8 : : Object * obj = v8 : : Object : : Cast ( * value ) ;
void * ptr = obj - > GetIndexedPropertiesExternalArrayData ( ) ;
void * ptr = obj - > GetIndexedPropertiesExternalArrayData ( ) ;
int element_size = SizeOfArrayElementForType (
int element_size = v8_typed_array : : SizeOfArrayElementForType (
obj - > GetIndexedPropertiesExternalArrayDataType ( ) ) ;
obj - > GetIndexedPropertiesExternalArrayDataType ( ) ) ;
int size =
int size =
obj - > GetIndexedPropertiesExternalArrayDataLength ( ) * element_size ;
obj - > GetIndexedPropertiesExternalArrayDataLength ( ) * element_size ;
@ -714,7 +695,7 @@ class DataView {
unsigned int index = args [ 0 ] - > Uint32Value ( ) ;
unsigned int index = args [ 0 ] - > Uint32Value ( ) ;
bool little_endian = args [ 1 ] - > BooleanValue ( ) ;
bool little_endian = args [ 1 ] - > BooleanValue ( ) ;
// TODO(deanm): All of these things should be cacheable.
// TODO(deanm): All of these things should be cacheable.
int element_size = SizeOfArrayElementForType (
int element_size = v8_typed_array : : SizeOfArrayElementForType (
args . This ( ) - > GetIndexedPropertiesExternalArrayDataType ( ) ) ;
args . This ( ) - > GetIndexedPropertiesExternalArrayDataType ( ) ) ;
int size = args . This ( ) - > GetIndexedPropertiesExternalArrayDataLength ( ) *
int size = args . This ( ) - > GetIndexedPropertiesExternalArrayDataLength ( ) *
element_size ;
element_size ;
@ -734,7 +715,7 @@ class DataView {
unsigned int index = args [ 0 ] - > Int32Value ( ) ;
unsigned int index = args [ 0 ] - > Int32Value ( ) ;
bool little_endian = args [ 2 ] - > BooleanValue ( ) ;
bool little_endian = args [ 2 ] - > BooleanValue ( ) ;
// TODO(deanm): All of these things should be cacheable.
// TODO(deanm): All of these things should be cacheable.
int element_size = SizeOfArrayElementForType (
int element_size = v8_typed_array : : SizeOfArrayElementForType (
args . This ( ) - > GetIndexedPropertiesExternalArrayDataType ( ) ) ;
args . This ( ) - > GetIndexedPropertiesExternalArrayDataType ( ) ) ;
int size = args . This ( ) - > GetIndexedPropertiesExternalArrayDataLength ( ) *
int size = args . This ( ) - > GetIndexedPropertiesExternalArrayDataLength ( ) *
element_size ;
element_size ;
@ -844,6 +825,25 @@ void AttachBindings(v8::Handle<v8::Object> obj) {
DataView : : GetTemplate ( ) - > GetFunction ( ) ) ;
DataView : : GetTemplate ( ) - > GetFunction ( ) ) ;
}
}
int SizeOfArrayElementForType ( v8 : : ExternalArrayType type ) {
switch ( type ) {
case v8 : : kExternalByteArray :
case v8 : : kExternalUnsignedByteArray :
return 1 ;
case v8 : : kExternalShortArray :
case v8 : : kExternalUnsignedShortArray :
return 2 ;
case v8 : : kExternalIntArray :
case v8 : : kExternalUnsignedIntArray :
case v8 : : kExternalFloatArray :
return 4 ;
case v8 : : kExternalDoubleArray :
return 8 ;
default :
return 0 ;
}
}
} // namespace v8_typed_array
} // namespace v8_typed_array
NODE_MODULE ( node_typed_array , v8_typed_array : : AttachBindings )
NODE_MODULE ( node_typed_array , v8_typed_array : : AttachBindings )