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

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: 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
Index: client/dom/scripts/dartgenerator.py
diff --git a/client/dom/scripts/dartgenerator.py b/client/dom/scripts/dartgenerator.py
index 4f1f278b42a7a29472ead11ff24ac75bc3aa06ee..7eb98b57a9896239727a99e3afe8a62d095dadce 100755
--- a/client/dom/scripts/dartgenerator.py
+++ b/client/dom/scripts/dartgenerator.py
@@ -137,6 +137,33 @@ _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.
sra1 2012/01/09 22:20:06 Do you think this approach will work if we make al
vsm 2012/01/10 00:42:00 It feels like it should. It's legal dart to overr
+#
+_unexpandable_types = {
+ # (type name, ols getter, ols setter)
+ 'Storage': (
+'''
+ 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.');
+''',
+'''
+ 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.');
+'''),
+}
+
def _MatchSourceFilter(filter, thing):
if not filter:
return True
@@ -1866,10 +1893,25 @@ class FrogInterfaceGenerator(object):
if not base:
# Emit shared base functionality here as we have no common base type.
+ if interface_name in _unexpandable_types.keys():
sra1 2012/01/09 22:20:06 I believe 'in' just works on the keys of a dict()
vsm 2012/01/10 00:42:00 Done.
+ (getter, setter) = _unexpandable_types[interface_name]
+ self._base_emitter.Emit(
+ '\n'
+ ' var get dartObjectLocalStorage() native """')
+ self._base_emitter.Emit(getter)
+ self._base_emitter.Emit(
+ '""";\n'
+ '\n'
+ ' void set dartObjectLocalStorage(var value) native """')
+ self._base_emitter.Emit(setter)
+ self._base_emitter.Emit(
+ '""";\n')
+ 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):
« client/dom/frog/dom_frog.dart ('K') | « 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