Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(567)

Unified Diff: lib/dom/templates/html/impl/impl_Storage.darttemplate

Issue 9956076: Make Storage implement Map. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Marked underlying Storage methods as private Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/dom/scripts/systemhtml.py ('k') | lib/dom/templates/html/interface/interface_Storage.darttemplate » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/dom/templates/html/impl/impl_Storage.darttemplate
diff --git a/lib/dom/templates/html/impl/impl_Storage.darttemplate b/lib/dom/templates/html/impl/impl_Storage.darttemplate
new file mode 100644
index 0000000000000000000000000000000000000000..e55d4ede8422605a0b009c9e206422c8e251fe62
--- /dev/null
+++ b/lib/dom/templates/html/impl/impl_Storage.darttemplate
@@ -0,0 +1,54 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
+
+ // TODO(nweiz): update this when maps support lazy iteration
+ bool containsValue(String value) => getValues().some((e) => e == value);
+
+ bool containsKey(String key) => $dom_getItem(key) != null;
+
+ String operator [](String key) => $dom_getItem(key);
+
+ void operator []=(String key, String value) => $dom_setItem(key, value);
+
+ String putIfAbsent(String key, String ifAbsent()) {
+ if (!containsKey(key)) this[key] = ifAbsent();
+ return this[key];
+ }
+
+ String remove(String key) {
+ final value = this[key];
+ $dom_removeItem(key);
+ return value;
+ }
+
+ void clear() => $dom_clear();
+
+ void forEach(void f(String key, String value)) {
+ for (var i = 0; true; i++) {
+ final key = $dom_key(i);
+ if (key == null) return;
+
+ f(key, this[key]);
+ }
+ }
+
+ Collection<String> getKeys() {
+ final keys = [];
+ forEach((k, v) => keys.add(k));
+ return keys;
+ }
+
+ Collection<String> getValues() {
+ final values = [];
+ forEach((k, v) => values.add(v));
+ return values;
+ }
+
+ int get length() => $dom_length;
+
+ bool isEmpty() => $dom_key(0) == null;
+$!MEMBERS
+}
« no previous file with comments | « lib/dom/scripts/systemhtml.py ('k') | lib/dom/templates/html/interface/interface_Storage.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698