Chromium Code Reviews| Index: src/weakmap.js |
| diff --git a/src/weakmap.js b/src/weakmap.js |
| index b209776829e37c49fd5e1ab5ed4f87bfa6ff78fa..bf473ab4e8480339b9d7c4981fca0a838359aabe 100644 |
| --- a/src/weakmap.js |
| +++ b/src/weakmap.js |
| @@ -58,13 +58,36 @@ function WeakMapSet(key, value) { |
| return %WeakMapSet(this, key, value); |
| } |
| + |
| +function WeakMapHas(key) { |
| + if (!IS_SPEC_OBJECT(key)) { |
| + throw %MakeTypeError('invalid_weakmap_key', [this, key]); |
| + } |
| + return !IS_UNDEFINED(%WeakMapGet(this, key)); |
| +} |
| + |
| + |
| +function WeakMapDelete(key) { |
| + if (!IS_SPEC_OBJECT(key)) { |
| + throw %MakeTypeError('invalid_weakmap_key', [this, key]); |
| + } |
| + if (!IS_UNDEFINED(%WeakMapGet(this, key))) { |
| + %WeakMapSet(this, key, global.undefined); |
|
rossberg
2011/08/04 11:05:09
Better use `void 0' to get undefined.
Michael Starzinger
2011/08/04 11:12:41
Done.
|
| + return true; |
| + } else { |
| + return false; |
| + } |
| +} |
| + |
| // ------------------------------------------------------------------- |
| function SetupWeakMap() { |
| // Setup the non-enumerable functions on the WeakMap prototype object. |
| InstallFunctionsOnHiddenPrototype($WeakMap.prototype, DONT_ENUM, $Array( |
| "get", WeakMapGet, |
| - "set", WeakMapSet |
| + "set", WeakMapSet, |
| + "has", WeakMapHas, |
| + "delete", WeakMapDelete |
| )); |
| } |