diff options
author | Dean McNamee <dean@gmail.com> | 2012-12-07 21:59:48 +0100 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2012-12-17 17:37:51 +0100 |
commit | ba00fb01996f275412713fe78f4bb43239bcf714 (patch) | |
tree | fcbacf88c3dc59a4dcefbf745d1d8c23eed366f7 | |
parent | a3877ab53e7559e5055be9c8033e588a1db8b6aa (diff) | |
download | node-ba00fb01996f275412713fe78f4bb43239bcf714.tar.gz |
typed arrays: re-export SizeOfArrayElementForType()
Although it is not used externally by node, it is needed by upstream and Plask.
This effectively reverts:
commit 1444801374bafb9a467a7ddeb214a9f92b311b80
Author: Aaron Jacobs <jacobsa@google.com>
Date: Thu Mar 15 13:26:35 2012 +1100
typed arrays: unexport SizeOfArrayElementForType()
It isn't used anywhere else, so made it an implementation detail in
v8_typed_array.cc.
-rw-r--r-- | src/v8_typed_array.cc | 44 | ||||
-rw-r--r-- | src/v8_typed_array.h | 2 |
2 files changed, 24 insertions, 22 deletions
diff --git a/src/v8_typed_array.cc b/src/v8_typed_array.cc index 6c2303221..41211c901 100644 --- a/src/v8_typed_array.cc +++ b/src/v8_typed_array.cc @@ -33,25 +33,6 @@ using node::ThrowRangeError; using node::ThrowTypeError; 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 { const char* name; v8::Handle<v8::Value> (*func)(const v8::Arguments& args); @@ -90,7 +71,7 @@ class ArrayBuffer { v8::Object* obj = v8::Object::Cast(*value); void* ptr = obj->GetIndexedPropertiesExternalArrayData(); - int element_size = SizeOfArrayElementForType( + int element_size = v8_typed_array::SizeOfArrayElementForType( obj->GetIndexedPropertiesExternalArrayDataType()); int size = obj->GetIndexedPropertiesExternalArrayDataLength() * element_size; @@ -714,7 +695,7 @@ class DataView { unsigned int index = args[0]->Uint32Value(); bool little_endian = args[1]->BooleanValue(); // TODO(deanm): All of these things should be cacheable. - int element_size = SizeOfArrayElementForType( + int element_size = v8_typed_array::SizeOfArrayElementForType( args.This()->GetIndexedPropertiesExternalArrayDataType()); int size = args.This()->GetIndexedPropertiesExternalArrayDataLength() * element_size; @@ -734,7 +715,7 @@ class DataView { unsigned int index = args[0]->Int32Value(); bool little_endian = args[2]->BooleanValue(); // TODO(deanm): All of these things should be cacheable. - int element_size = SizeOfArrayElementForType( + int element_size = v8_typed_array::SizeOfArrayElementForType( args.This()->GetIndexedPropertiesExternalArrayDataType()); int size = args.This()->GetIndexedPropertiesExternalArrayDataLength() * element_size; @@ -844,6 +825,25 @@ void AttachBindings(v8::Handle<v8::Object> obj) { 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 NODE_MODULE(node_typed_array, v8_typed_array::AttachBindings) diff --git a/src/v8_typed_array.h b/src/v8_typed_array.h index 47b66945c..dc518ccdd 100644 --- a/src/v8_typed_array.h +++ b/src/v8_typed_array.h @@ -28,6 +28,8 @@ namespace v8_typed_array { void AttachBindings(v8::Handle<v8::Object> obj); +int SizeOfArrayElementForType(v8::ExternalArrayType type); + } // namespace v8_typed_array #endif // V8_TYPED_ARRAY_H_ |