summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/runtime/JSArrayBufferConstructor.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2016-05-24 08:28:08 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2016-05-24 08:28:08 +0000
commita4e969f4965059196ca948db781e52f7cfebf19e (patch)
tree6ca352808c8fdc52006a0f33f6ae3c593b23867d /Source/JavaScriptCore/runtime/JSArrayBufferConstructor.cpp
parent41386e9cb918eed93b3f13648cbef387e371e451 (diff)
downloadWebKitGtk-tarball-a4e969f4965059196ca948db781e52f7cfebf19e.tar.gz
webkitgtk-2.12.3webkitgtk-2.12.3
Diffstat (limited to 'Source/JavaScriptCore/runtime/JSArrayBufferConstructor.cpp')
-rw-r--r--Source/JavaScriptCore/runtime/JSArrayBufferConstructor.cpp33
1 files changed, 20 insertions, 13 deletions
diff --git a/Source/JavaScriptCore/runtime/JSArrayBufferConstructor.cpp b/Source/JavaScriptCore/runtime/JSArrayBufferConstructor.cpp
index ca7e030e8..03f077784 100644
--- a/Source/JavaScriptCore/runtime/JSArrayBufferConstructor.cpp
+++ b/Source/JavaScriptCore/runtime/JSArrayBufferConstructor.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2013, 2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -28,17 +28,18 @@
#include "Error.h"
#include "ExceptionHelpers.h"
+#include "GetterSetter.h"
#include "JSArrayBuffer.h"
#include "JSArrayBufferPrototype.h"
#include "JSGlobalObject.h"
-#include "Operations.h"
+#include "JSCInlines.h"
namespace JSC {
static EncodedJSValue JSC_HOST_CALL arrayBufferFuncIsView(ExecState*);
const ClassInfo JSArrayBufferConstructor::s_info = {
- "Function", &Base::s_info, 0, 0,
+ "Function", &Base::s_info, 0,
CREATE_METHOD_TABLE(JSArrayBufferConstructor)
};
@@ -47,22 +48,23 @@ JSArrayBufferConstructor::JSArrayBufferConstructor(VM& vm, Structure* structure)
{
}
-void JSArrayBufferConstructor::finishCreation(VM& vm, JSArrayBufferPrototype* prototype)
+void JSArrayBufferConstructor::finishCreation(VM& vm, JSArrayBufferPrototype* prototype, GetterSetter* speciesSymbol)
{
- Base::finishCreation(vm, "ArrayBuffer");
+ Base::finishCreation(vm, ASCIILiteral("ArrayBuffer"));
putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, DontEnum | DontDelete | ReadOnly);
putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), DontEnum | DontDelete | ReadOnly);
+ putDirectNonIndexAccessor(vm, vm.propertyNames->speciesSymbol, speciesSymbol, Accessor | ReadOnly | DontEnum);
JSGlobalObject* globalObject = this->globalObject();
- JSC_NATIVE_FUNCTION(vm.propertyNames->isView, arrayBufferFuncIsView, DontEnum, 1);
+ JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->isView, arrayBufferFuncIsView, DontEnum, 1);
}
-JSArrayBufferConstructor* JSArrayBufferConstructor::create(VM& vm, Structure* structure, JSArrayBufferPrototype* prototype)
+JSArrayBufferConstructor* JSArrayBufferConstructor::create(VM& vm, Structure* structure, JSArrayBufferPrototype* prototype, GetterSetter* speciesSymbol)
{
JSArrayBufferConstructor* result =
new (NotNull, allocateCell<JSArrayBufferConstructor>(vm.heap))
JSArrayBufferConstructor(vm, structure);
- result->finishCreation(vm, prototype);
+ result->finishCreation(vm, prototype, speciesSymbol);
return result;
}
@@ -92,14 +94,19 @@ static EncodedJSValue JSC_HOST_CALL constructArrayBuffer(ExecState* exec)
RefPtr<ArrayBuffer> buffer = ArrayBuffer::create(length, 1);
if (!buffer)
- return throwVMError(exec, createOutOfMemoryError(constructor->globalObject()));
-
- JSArrayBuffer* result = JSArrayBuffer::create(
- exec->vm(), constructor->globalObject()->arrayBufferStructure(), buffer);
+ return throwVMError(exec, createOutOfMemoryError(exec));
+
+ Structure* arrayBufferStructure = InternalFunction::createSubclassStructure(exec, exec->newTarget(), constructor->globalObject()->arrayBufferStructure());
+ JSArrayBuffer* result = JSArrayBuffer::create(exec->vm(), arrayBufferStructure, buffer.release());
return JSValue::encode(result);
}
+static EncodedJSValue JSC_HOST_CALL callArrayBuffer(ExecState* exec)
+{
+ return JSValue::encode(throwConstructorCannotBeCalledAsFunctionTypeError(exec, "ArrayBuffer"));
+}
+
ConstructType JSArrayBufferConstructor::getConstructData(
JSCell*, ConstructData& constructData)
{
@@ -109,7 +116,7 @@ ConstructType JSArrayBufferConstructor::getConstructData(
CallType JSArrayBufferConstructor::getCallData(JSCell*, CallData& callData)
{
- callData.native.function = constructArrayBuffer;
+ callData.native.function = callArrayBuffer;
return CallTypeHost;
}