Chromium Code Reviews| Index: src/js/typedarray.js |
| diff --git a/src/js/typedarray.js b/src/js/typedarray.js |
| index b3e1c829dd62b9926a3c335f952a20a233dc22db..4cc871fbef402bf72b99e82ef4b884cc3887a518 100644 |
| --- a/src/js/typedarray.js |
| +++ b/src/js/typedarray.js |
| @@ -263,6 +263,13 @@ function NAMEConstructor(arg1, arg2, arg3) { |
| } |
| } |
| +function NAME_GetLength() { |
| + if (!(%_ClassOf(this) === 'NAME')) { |
| + throw MakeTypeError(kIncompatibleMethodReceiver, "NAME.length", this); |
| + } |
| + return %_TypedArrayGetLength(this); |
| +} |
| + |
| function NAMESubArray(begin, end) { |
| var beginInt = TO_INTEGER(begin); |
| if (!IS_UNDEFINED(end)) { |
| @@ -829,6 +836,8 @@ macro SETUP_TYPED_ARRAY(ARRAY_ID, NAME, ELEMENT_SIZE) |
| %AddNamedProperty(GlobalNAME.prototype, |
| "BYTES_PER_ELEMENT", ELEMENT_SIZE, |
| READ_ONLY | DONT_ENUM | DONT_DELETE); |
| + utils.InstallGetter(GlobalNAME.prototype, "length", NAME_GetLength, |
|
adamk
2016/01/25 19:21:22
Please add a comment here too.
|
| + DONT_ENUM | DONT_DELETE); |
| endmacro |
| TYPED_ARRAYS(SETUP_TYPED_ARRAY) |