diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2012-01-17 19:20:37 +0400 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2012-01-17 19:20:39 +0400 |
commit | 549443a7cc600e93cc1d1d1630108e7d0a035500 (patch) | |
tree | f8ac17f3108737c45ef6d7e5422c56c346386d48 /src | |
parent | 25410096b4c38eb9b17501ea06349872ab33e1ea (diff) |
typed arrays: set class name
Make obj.toString and Object.prototype.toString work correctly for typed arrays.
Diffstat (limited to 'src')
-rw-r--r-- | src/v8_typed_array.cc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/v8_typed_array.cc b/src/v8_typed_array.cc index 00eff8705db..4b80da0c871 100644 --- a/src/v8_typed_array.cc +++ b/src/v8_typed_array.cc @@ -140,6 +140,7 @@ class TypedArray { v8::HandleScope scope; ft_cache = v8::Persistent<v8::FunctionTemplate>::New( v8::FunctionTemplate::New(&TypedArray<TBytes, TEAType>::V8New)); + ft_cache->SetClassName(v8::String::New(TypeName())); v8::Local<v8::ObjectTemplate> instance = ft_cache->InstanceTemplate(); instance->SetInternalFieldCount(0); @@ -376,6 +377,20 @@ class TypedArray { return TypedArray<TBytes, TEAType>::GetTemplate()-> GetFunction()->NewInstance(3, argv); } + + static const char* TypeName() { + switch (TEAType) { + case v8::kExternalByteArray: return "Int8Array"; + case v8::kExternalUnsignedByteArray: return "Uint8Array"; + case v8::kExternalShortArray: return "Int16Array"; + case v8::kExternalUnsignedShortArray: return "Uint16Array"; + case v8::kExternalIntArray: return "Int32Array"; + case v8::kExternalUnsignedIntArray: return "Uint32Array"; + case v8::kExternalFloatArray: return "Float32Array"; + case v8::kExternalDoubleArray: return "Float64Array"; + } + abort(); + } }; class Int8Array : public TypedArray<1, v8::kExternalByteArray> { }; |