Index: src/js/arraybuffer.js |
diff --git a/src/js/arraybuffer.js b/src/js/arraybuffer.js |
index 1ee68ca291b0ccc6c6affc79af5c7bcc6b90c493..1e405638d582936b83461502706d0b6b9310f920 100644 |
--- a/src/js/arraybuffer.js |
+++ b/src/js/arraybuffer.js |
@@ -12,17 +12,30 @@ |
// Imports |
var GlobalArrayBuffer = global.ArrayBuffer; |
+var GlobalObject = global.Object; |
var MakeTypeError; |
var MaxSimple; |
var MinSimple; |
+var ToPositiveInteger; |
+var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); |
utils.Import(function(from) { |
MakeTypeError = from.MakeTypeError; |
MaxSimple = from.MaxSimple; |
MinSimple = from.MinSimple; |
+ ToPositiveInteger = from.ToPositiveInteger; |
}); |
// ------------------------------------------------------------------- |
+ |
+function ArrayBufferConstructor(length) { // length = 1 |
+ if (!IS_UNDEFINED(new.target)) { |
+ var byteLength = ToPositiveInteger(length, kInvalidArrayBufferLength); |
+ %ArrayBufferInitialize(this, byteLength, kNotShared); |
+ } else { |
+ throw MakeTypeError(kConstructorNotFunction, "ArrayBuffer"); |
+ } |
+} |
function ArrayBufferGetByteLen() { |
if (!IS_ARRAYBUFFER(this)) { |
@@ -69,8 +82,28 @@ |
return result; |
} |
+function ArrayBufferIsViewJS(obj) { |
+ return %ArrayBufferIsView(obj); |
+} |
+ |
+ |
+// Set up the ArrayBuffer constructor function. |
+%SetCode(GlobalArrayBuffer, ArrayBufferConstructor); |
+%FunctionSetPrototype(GlobalArrayBuffer, new GlobalObject()); |
+ |
+// Set up the constructor property on the ArrayBuffer prototype object. |
+%AddNamedProperty( |
+ GlobalArrayBuffer.prototype, "constructor", GlobalArrayBuffer, DONT_ENUM); |
+ |
+%AddNamedProperty(GlobalArrayBuffer.prototype, |
+ toStringTagSymbol, "ArrayBuffer", DONT_ENUM | READ_ONLY); |
+ |
utils.InstallGetter(GlobalArrayBuffer.prototype, "byteLength", |
ArrayBufferGetByteLen); |
+ |
+utils.InstallFunctions(GlobalArrayBuffer, DONT_ENUM, [ |
+ "isView", ArrayBufferIsViewJS |
+]); |
utils.InstallFunctions(GlobalArrayBuffer.prototype, DONT_ENUM, [ |
"slice", ArrayBufferSlice |