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

Unified Diff: client/dom/scripts/dartgenerator.py

Issue 9138007: Frog DOM changes to support OLS on Storage objects (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Some more cleanup Created 8 years, 11 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 | « client/dom/generated/src/frog/Storage.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/dom/scripts/dartgenerator.py
diff --git a/client/dom/scripts/dartgenerator.py b/client/dom/scripts/dartgenerator.py
index 30515af01bf0d95629adce45adeb3c4d7ff95c0e..f28f8a38e801c801be21cd1c3914a6b2045a4034 100755
--- a/client/dom/scripts/dartgenerator.py
+++ b/client/dom/scripts/dartgenerator.py
@@ -136,6 +136,43 @@ _alternate_methods = {
('WheelEvent', 'initWheelEvent'): ['initWebKitWheelEvent', 'initWheelEvent']
}
+#
+# Unexpandable types require special support for
+# dartObjectLocalStorage. Normally, in the overlay dom, it is
+# implemented as an expando field. For these types, we cannot use an
+# expando. Instead, we define a specialized getter and setter.
+#
+_frog_unexpandable_types = {
+ # (type name, field name) -> Replacement text
+ ('Storage', 'dartObjectLocalStorage'): '''
+ var get dartObjectLocalStorage() native """
+
+ if (this === window.localStorage)
+ return window._dartLocalStorageLocalStorage;
+ else if (this === window.sessionStorage)
+ return window._dartSessionStorageLocalStorage;
+ else
+ throw new UnsupportedOperationException('Cannot dartObjectLocalStorage for unknown Storage object.');
+
+""" {
+ throw new UnsupportedOperationException('');
+ }
+
+ void set dartObjectLocalStorage(var value) native """
+
+ if (this === window.localStorage)
+ window._dartLocalStorageLocalStorage = value;
+ else if (this === window.sessionStorage)
+ window._dartSessionStorageLocalStorage = value;
+ else
+ throw new UnsupportedOperationException('Cannot dartObjectLocalStorage for unknown Storage object.');
+
+""" {
+ throw new UnsupportedOperationException('');
+ }
+''',
+}
+
def _MatchSourceFilter(filter, thing):
if not filter:
return True
@@ -1830,7 +1867,7 @@ class FrogInterfaceGenerator(object):
IMPLEMENTS=implements,
NATIVE=native_spec)
- if interface_name in _constructable_types.keys():
+ if interface_name in _constructable_types:
self._members_emitter.Emit(
' $NAME($PARAMS) native;\n\n',
NAME=interface_name,
@@ -1842,10 +1879,16 @@ class FrogInterfaceGenerator(object):
if not base:
# Emit shared base functionality here as we have no common base type.
+ if (interface_name, 'dartObjectLocalStorage') in _frog_unexpandable_types:
+ ols_code = _frog_unexpandable_types[(interface_name,
+ 'dartObjectLocalStorage')]
+ self._base_emitter.Emit(ols_code)
+ else:
+ self._base_emitter.Emit(
+ '\n'
+ ' var dartObjectLocalStorage;\n')
self._base_emitter.Emit(
'\n'
- ' var dartObjectLocalStorage;\n'
- '\n'
' String get typeName() native;\n')
def _ImplClassName(self, type_name):
« no previous file with comments | « client/dom/generated/src/frog/Storage.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698