}
+inline size_t InternalExternalArraySize(enum ExternalArrayType type) {
+ switch (type) {
+ case v8::kExternalUint8Array:
+ return sizeof(uint8_t);
+ case v8::kExternalInt8Array:
+ return sizeof(int8_t);
+ case v8::kExternalInt16Array:
+ return sizeof(int16_t);
+ case v8::kExternalUint16Array:
+ return sizeof(uint16_t);
+ case v8::kExternalInt32Array:
+ return sizeof(int32_t);
+ case v8::kExternalUint32Array:
+ return sizeof(uint32_t);
+ case v8::kExternalFloat32Array:
+ return sizeof(float); // NOLINT(runtime/sizeof)
+ case v8::kExternalFloat64Array:
+ return sizeof(double); // NOLINT(runtime/sizeof)
+ case v8::kExternalUint8ClampedArray:
+ return sizeof(uint8_t);
+ }
+ return 0;
+}
+
+
void CallbackInfo::WeakCallback(Isolate* isolate, Local<Object> object) {
void* array_data = object->GetIndexedPropertiesExternalArrayData();
size_t array_length = object->GetIndexedPropertiesExternalArrayDataLength();
enum ExternalArrayType array_type =
object->GetIndexedPropertiesExternalArrayDataType();
- size_t array_size = ExternalArraySize(array_type);
+ size_t array_size = InternalExternalArraySize(array_type);
CHECK_GT(array_size, 0);
if (array_size > 1 && array_data != NULL) {
CHECK_GT(array_length * array_size, array_length); // Overflow check.
// return size of external array type, or 0 if unrecognized
size_t ExternalArraySize(enum ExternalArrayType type) {
- switch (type) {
- case v8::kExternalUint8Array:
- return sizeof(uint8_t);
- case v8::kExternalInt8Array:
- return sizeof(int8_t);
- case v8::kExternalInt16Array:
- return sizeof(int16_t);
- case v8::kExternalUint16Array:
- return sizeof(uint16_t);
- case v8::kExternalInt32Array:
- return sizeof(int32_t);
- case v8::kExternalUint32Array:
- return sizeof(uint32_t);
- case v8::kExternalFloat32Array:
- return sizeof(float); // NOLINT(runtime/sizeof)
- case v8::kExternalFloat64Array:
- return sizeof(double); // NOLINT(runtime/sizeof)
- case v8::kExternalUint8ClampedArray:
- return sizeof(uint8_t);
- }
- return 0;
+ return InternalExternalArraySize(type);
}
size_t source_length = source->GetIndexedPropertiesExternalArrayDataLength();
enum ExternalArrayType source_type =
source->GetIndexedPropertiesExternalArrayDataType();
- size_t source_size = ExternalArraySize(source_type);
+ size_t source_size = InternalExternalArraySize(source_type);
size_t dest_length = dest->GetIndexedPropertiesExternalArrayDataLength();
enum ExternalArrayType dest_type =
dest->GetIndexedPropertiesExternalArrayDataType();
- size_t dest_size = ExternalArraySize(dest_type);
+ size_t dest_size = InternalExternalArraySize(dest_type);
// optimization for Uint8 arrays (i.e. Buffers)
if (source_size != 1 || dest_size != 1) {
size_t source_len = source->GetIndexedPropertiesExternalArrayDataLength();
enum ExternalArrayType source_type =
source->GetIndexedPropertiesExternalArrayDataType();
- size_t source_size = ExternalArraySize(source_type);
+ size_t source_size = InternalExternalArraySize(source_type);
CHECK_NE(source_size, 0);
array_type = kExternalUint8Array;
} else {
array_type = static_cast<ExternalArrayType>(args[2]->Uint32Value());
- size_t type_length = ExternalArraySize(array_type);
+ size_t type_length = InternalExternalArraySize(array_type);
CHECK_GE(type_length * length, length);
length *= type_length;
}
Handle<Object> obj,
size_t length,
enum ExternalArrayType type) {
- size_t type_size = ExternalArraySize(type);
+ size_t type_size = InternalExternalArraySize(type);
CHECK_LE(length, kMaxLength);
CHECK_GT(type_size, 0);
enum ExternalArrayType type) {
CHECK_EQ(false, obj->HasIndexedPropertiesInExternalArrayData());
env->isolate()->AdjustAmountOfExternalAllocatedMemory(length);
- size_t size = length / ExternalArraySize(type);
+ size_t size = length / InternalExternalArraySize(type);
obj->SetIndexedPropertiesToExternalArrayData(data, type, size);
CallbackInfo::New(env->isolate(),
CallbackInfo::kInternal,
size_t length = obj->GetIndexedPropertiesExternalArrayDataLength();
enum ExternalArrayType array_type =
obj->GetIndexedPropertiesExternalArrayDataType();
- size_t array_size = ExternalArraySize(array_type);
+ size_t array_size = InternalExternalArraySize(array_type);
CHECK_GT(array_size, 0);
CHECK_GE(length * array_size, length);
env->set_using_smalloc_alloc_cb(true);
CallbackInfo* info = CallbackInfo::New(isolate, ownership, obj, fn, hint);
obj->SetHiddenValue(env->smalloc_p_string(), External::New(isolate, info));
- size_t size = length / ExternalArraySize(type);
+ size_t size = length / InternalExternalArraySize(type);
obj->SetIndexedPropertiesToExternalArrayData(data, type, size);
}
enum ExternalArrayType type) {
CHECK_LE(length, kMaxLength);
- size_t type_size = ExternalArraySize(type);
+ size_t type_size = InternalExternalArraySize(type);
CHECK_GT(type_size, 0);
CHECK_GE(length * type_size, length);
/**
* Return byte size of external array type.
*/
-NODE_EXTERN size_t ExternalArraySize(enum v8::ExternalArrayType type);
+NODE_DEPRECATED(
+ "Use typed arrays",
+ NODE_EXTERN size_t ExternalArraySize(enum v8::ExternalArrayType type));
/**
* Allocate external array data onto obj.
* v8::Integer::NewFromUnsigned(array_length));
* \code
*/
-NODE_EXTERN void Alloc(v8::Isolate* isolate,
- v8::Handle<v8::Object> obj,
- size_t length,
- enum v8::ExternalArrayType type =
- v8::kExternalUnsignedByteArray);
-NODE_EXTERN void Alloc(v8::Isolate* isolate,
- v8::Handle<v8::Object> obj,
- char* data,
- size_t length,
- enum v8::ExternalArrayType type =
- v8::kExternalUnsignedByteArray);
-NODE_EXTERN void Alloc(v8::Isolate* isolate,
- v8::Handle<v8::Object> obj,
- size_t length,
- FreeCallback fn,
- void* hint,
- enum v8::ExternalArrayType type =
- v8::kExternalUnsignedByteArray);
-NODE_EXTERN void Alloc(v8::Isolate* isolate,
- v8::Handle<v8::Object> obj,
- char* data,
- size_t length,
- FreeCallback fn,
- void* hint,
- enum v8::ExternalArrayType type =
- v8::kExternalUnsignedByteArray);
+NODE_DEPRECATED(
+ "Use typed arrays",
+ NODE_EXTERN void Alloc(v8::Isolate* isolate,
+ v8::Handle<v8::Object> obj,
+ size_t length,
+ enum v8::ExternalArrayType type =
+ v8::kExternalUnsignedByteArray));
+NODE_DEPRECATED(
+ "Use typed arrays",
+ NODE_EXTERN void Alloc(v8::Isolate* isolate,
+ v8::Handle<v8::Object> obj,
+ char* data,
+ size_t length,
+ enum v8::ExternalArrayType type =
+ v8::kExternalUnsignedByteArray));
+NODE_DEPRECATED(
+ "Use typed arrays",
+ NODE_EXTERN void Alloc(v8::Isolate* isolate,
+ v8::Handle<v8::Object> obj,
+ size_t length,
+ FreeCallback fn,
+ void* hint,
+ enum v8::ExternalArrayType type =
+ v8::kExternalUnsignedByteArray));
+NODE_DEPRECATED(
+ "Use typed arrays",
+ NODE_EXTERN void Alloc(v8::Isolate* isolate,
+ v8::Handle<v8::Object> obj,
+ char* data,
+ size_t length,
+ FreeCallback fn,
+ void* hint,
+ enum v8::ExternalArrayType type =
+ v8::kExternalUnsignedByteArray));
/**
* Free memory associated with an externally allocated object. If no external
* memory is allocated to the object then nothing will happen.
*/
-NODE_EXTERN void AllocDispose(v8::Isolate* isolate, v8::Handle<v8::Object> obj);
+NODE_DEPRECATED(
+ "Use typed arrays",
+ NODE_EXTERN void AllocDispose(v8::Isolate* isolate,
+ v8::Handle<v8::Object> obj));
/**
* Check if the Object has externally allocated memory.
*/
-NODE_EXTERN bool HasExternalData(v8::Isolate* isolate,
- v8::Local<v8::Object> obj);
+NODE_DEPRECATED(
+ "Use typed arrays",
+ NODE_EXTERN bool HasExternalData(v8::Isolate* isolate,
+ v8::Local<v8::Object> obj));
// Internal use