Chromium Code Reviews| Index: src/collection.js |
| diff --git a/src/collection.js b/src/collection.js |
| index d36fe18fa00dcd5fdae1210e5f9470c53cbc41f3..f8e3594bb67a8623d8ce63a97f04412710f43a8d 100644 |
| --- a/src/collection.js |
| +++ b/src/collection.js |
| @@ -88,6 +88,15 @@ function SetDelete(key) { |
| } |
| +function SetSize() { |
|
Michael Starzinger
2012/11/06 09:32:40
I think "SetGetSize" or "SetSizeGetter" would be a
arv (Not doing code reviews)
2012/11/06 16:02:33
Done.
|
| + if (!IS_SET(this)) { |
| + throw MakeTypeError('incompatible_method_receiver', |
| + ['Set.prototype.size', this]); |
| + } |
| + return %SetSize(this); |
| +} |
| + |
| + |
| function MapConstructor() { |
| if (%_IsConstructCall()) { |
| %MapInitialize(this); |
| @@ -145,6 +154,15 @@ function MapDelete(key) { |
| } |
| +function MapSize() { |
|
Michael Starzinger
2012/11/06 09:32:40
Likewise for "MapGetSize" or "MapSizeGetter".
|
| + if (!IS_MAP(this)) { |
| + throw MakeTypeError('incompatible_method_receiver', |
| + ['Map.prototype.size', this]); |
| + } |
| + return %MapSize(this); |
| +} |
| + |
| + |
| function WeakMapConstructor() { |
| if (%_IsConstructCall()) { |
| %WeakMapInitialize(this); |
| @@ -214,7 +232,16 @@ function WeakMapDelete(key) { |
| %SetProperty($Set.prototype, "constructor", $Set, DONT_ENUM); |
| %SetProperty($Map.prototype, "constructor", $Map, DONT_ENUM); |
| + function DefineGetter(object, name, fun) { |
|
Michael Starzinger
2012/11/06 09:32:40
Can we move this into v8natives.js near the implem
arv (Not doing code reviews)
2012/11/06 16:02:33
Done.
I also used a lower level abstraction.
|
| + %FunctionSetName(fun, name); |
| + var desc = new PropertyDescriptor(); |
| + desc.setGet(fun); |
| + desc.setConfigurable(true); |
| + DefineObjectProperty(object, name, desc, false); |
| + } |
| + |
| // Set up the non-enumerable functions on the Set prototype object. |
| + DefineGetter($Set.prototype, "size", SetSize); |
| InstallFunctions($Set.prototype, DONT_ENUM, $Array( |
| "add", SetAdd, |
| "has", SetHas, |
| @@ -222,6 +249,7 @@ function WeakMapDelete(key) { |
| )); |
| // Set up the non-enumerable functions on the Map prototype object. |
| + DefineGetter($Map.prototype, "size", MapSize); |
| InstallFunctions($Map.prototype, DONT_ENUM, $Array( |
| "get", MapGet, |
| "set", MapSet, |