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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 2 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
3 # for details. All rights reserved. Use of this source code is governed by a 3 # for details. All rights reserved. Use of this source code is governed by a
4 # BSD-style license that can be found in the LICENSE file. 4 # BSD-style license that can be found in the LICENSE file.
5 5
6 """This module generates Dart APIs from the IDL database.""" 6 """This module generates Dart APIs from the IDL database."""
7 7
8 import emitter 8 import emitter
9 import idlnode 9 import idlnode
10 import logging 10 import logging
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 # browsers, but are otherwise identical. The alternates are tried in order and 130 # browsers, but are otherwise identical. The alternates are tried in order and
131 # the first one defined is used. 131 # the first one defined is used.
132 # 132 #
133 # This can be probably be removed when Chrome renames initWebKitWheelEvent to 133 # This can be probably be removed when Chrome renames initWebKitWheelEvent to
134 # initWheelEvent. 134 # initWheelEvent.
135 # 135 #
136 _alternate_methods = { 136 _alternate_methods = {
137 ('WheelEvent', 'initWheelEvent'): ['initWebKitWheelEvent', 'initWheelEvent'] 137 ('WheelEvent', 'initWheelEvent'): ['initWebKitWheelEvent', 'initWheelEvent']
138 } 138 }
139 139
140 #
141 # Unexpandable types require special support for
142 # dartObjectLocalStorage. Normally, in the overlay dom, it is
143 # implemented as an expando field. For these types, we cannot use an
144 # 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
145 #
146 _unexpandable_types = {
147 # (type name, ols getter, ols setter)
148 'Storage': (
149 '''
150 if (this === window.localStorage)
151 return window._dartLocalStorageLocalStorage;
152 else if (this === window.sessionStorage)
153 return window._dartSessionStorageLocalStorage;
154 else
155 throw new UnsupportedOperationException('Cannot dartObjectLocalStorage for unknown Storage object.');
156 ''',
157 '''
158 if (this === window.localStorage)
159 window._dartLocalStorageLocalStorage = value;
160 else if (this === window.sessionStorage)
161 window._dartSessionStorageLocalStorage = value;
162 else
163 throw new UnsupportedOperationException('Cannot dartObjectLocalStorage for unknown Storage object.');
164 '''),
165 }
166
140 def _MatchSourceFilter(filter, thing): 167 def _MatchSourceFilter(filter, thing):
141 if not filter: 168 if not filter:
142 return True 169 return True
143 else: 170 else:
144 return any(token in thing.annotations for token in filter) 171 return any(token in thing.annotations for token in filter)
145 172
146 def _IsDartListType(type): 173 def _IsDartListType(type):
147 return type == 'List' or type.startswith('List<') 174 return type == 'List' or type.startswith('List<')
148 175
149 def _IsDartCollectionType(type): 176 def _IsDartCollectionType(type):
(...skipping 1709 matching lines...) Expand 10 before | Expand all | Expand 10 after
1859 ' $NAME($PARAMS) native;\n\n', 1886 ' $NAME($PARAMS) native;\n\n',
1860 NAME=interface_name, 1887 NAME=interface_name,
1861 PARAMS=_constructable_types[interface_name]) 1888 PARAMS=_constructable_types[interface_name])
1862 1889
1863 element_type = MaybeTypedArrayElementType(interface) 1890 element_type = MaybeTypedArrayElementType(interface)
1864 if element_type: 1891 if element_type:
1865 self.AddTypedArrayConstructors(element_type) 1892 self.AddTypedArrayConstructors(element_type)
1866 1893
1867 if not base: 1894 if not base:
1868 # Emit shared base functionality here as we have no common base type. 1895 # Emit shared base functionality here as we have no common base type.
1896 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.
1897 (getter, setter) = _unexpandable_types[interface_name]
1898 self._base_emitter.Emit(
1899 '\n'
1900 ' var get dartObjectLocalStorage() native """')
1901 self._base_emitter.Emit(getter)
1902 self._base_emitter.Emit(
1903 '""";\n'
1904 '\n'
1905 ' void set dartObjectLocalStorage(var value) native """')
1906 self._base_emitter.Emit(setter)
1907 self._base_emitter.Emit(
1908 '""";\n')
1909 else:
1910 self._base_emitter.Emit(
1911 '\n'
1912 ' var dartObjectLocalStorage;\n')
1869 self._base_emitter.Emit( 1913 self._base_emitter.Emit(
1870 '\n' 1914 '\n'
1871 ' var dartObjectLocalStorage;\n'
1872 '\n'
1873 ' String get typeName() native;\n') 1915 ' String get typeName() native;\n')
1874 1916
1875 def _ImplClassName(self, type_name): 1917 def _ImplClassName(self, type_name):
1876 return type_name 1918 return type_name
1877 1919
1878 def FinishInterface(self): 1920 def FinishInterface(self):
1879 """.""" 1921 """."""
1880 pass 1922 pass
1881 1923
1882 def AddConstant(self, constant): 1924 def AddConstant(self, constant):
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1976 Arguments: 2018 Arguments:
1977 info: An OperationInfo object. 2019 info: An OperationInfo object.
1978 """ 2020 """
1979 # TODO(vsm): Handle overloads. 2021 # TODO(vsm): Handle overloads.
1980 self._members_emitter.Emit( 2022 self._members_emitter.Emit(
1981 '\n' 2023 '\n'
1982 ' $TYPE $NAME($ARGS) native;\n', 2024 ' $TYPE $NAME($ARGS) native;\n',
1983 TYPE=info.type_name, 2025 TYPE=info.type_name,
1984 NAME=info.name, 2026 NAME=info.name,
1985 ARGS=info.arg_implementation_declaration) 2027 ARGS=info.arg_implementation_declaration)
OLDNEW
« 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