summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2013-02-11 17:34:56 +0100
committerBen Noordhuis <info@bnoordhuis.nl>2013-02-11 17:38:32 +0100
commited3d553d826963837dee5db9cf6cc88b2d5c62cc (patch)
tree623149511eeaddad2795a1cd4c1ab1273bb5de94 /src
parentaff8d9e716a1953ed1526b3f8ce8455850f780da (diff)
downloadnode-ed3d553d826963837dee5db9cf6cc88b2d5c62cc.tar.gz
typed arrays: make call-as-function work for ctors
Turn call-as-function calls into constructor calls. Makes the following snippet work: var buf = ArrayBuffer(32); // no 'new' but does the right thing
Diffstat (limited to 'src')
-rw-r--r--src/v8_typed_array.cc6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/v8_typed_array.cc b/src/v8_typed_array.cc
index 2fe019623..f44503edc 100644
--- a/src/v8_typed_array.cc
+++ b/src/v8_typed_array.cc
@@ -88,7 +88,7 @@ class ArrayBuffer {
static v8::Handle<v8::Value> V8New(const v8::Arguments& args) {
if (!args.IsConstructCall())
- return ThrowTypeError("Constructor cannot be called as a function.");
+ return node::FromConstructorTemplate(GetTemplate(), args);
// To match Chrome, we allow "new ArrayBuffer()".
// if (args.Length() != 1)
@@ -241,7 +241,7 @@ class TypedArray {
private:
static v8::Handle<v8::Value> V8New(const v8::Arguments& args) {
if (!args.IsConstructCall())
- return ThrowTypeError("Constructor cannot be called as a function.");
+ return node::FromConstructorTemplate(GetTemplate(), args);
// To match Chrome, we allow "new Float32Array()".
// if (args.Length() != 1)
@@ -613,7 +613,7 @@ class DataView {
private:
static v8::Handle<v8::Value> V8New(const v8::Arguments& args) {
if (!args.IsConstructCall())
- return ThrowTypeError("Constructor cannot be called as a function.");
+ return node::FromConstructorTemplate(GetTemplate(), args);
if (args.Length() < 1)
return ThrowError("Wrong number of arguments.");