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

Side by Side Diff: client/dom/scripts/dartgenerator.py

Issue 9109032: Make most native types hidden. (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
« no previous file with comments | « client/dom/generated/src/frog/UIEvent.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 # 109 #
110 # Custom native specs for the Frog dom. 110 # Custom native specs for the Frog dom.
111 # 111 #
112 _frog_dom_custom_native_specs = { 112 _frog_dom_custom_native_specs = {
113 # Decorate the singleton Console object, if present (workers do not have a 113 # Decorate the singleton Console object, if present (workers do not have a
114 # console). 114 # console).
115 'Console': "=(typeof console == 'undefined' ? {} : console)", 115 'Console': "=(typeof console == 'undefined' ? {} : console)",
116 116
117 # DOMWindow aliased with global scope. 117 # DOMWindow aliased with global scope.
118 'DOMWindow': '@*DOMWindow', 118 'DOMWindow': '@*DOMWindow',
119
120 # Temporary hack: make these be 'hidden'.
121 'SVGPathSeg': '*SVGPathSeg',
122 } 119 }
123 120
124 # 121 #
125 # Publically visible types common across all supported browsers.
126 #
127 _BROWSER_SHARED_TYPES = [
128 'Attr',
129 'CDATASection',
130 'CSSFontFaceRule',
131 'CSSImportRule',
132 'CSSMediaRule',
133 'CSSPageRule',
134 'CSSRule',
135 'CSSRuleList',
136 'CSSStyleDeclaration',
137 'CSSStyleRule',
138 'CSSStyleSheet',
139 'CanvasRenderingContext2D',
140 'CharacterData',
141 'ClientRect',
142 'ClientRectList',
143 'Comment',
144 'DOMException',
145 'DOMImplementation',
146 'DOMParser',
147 'Document',
148 'DocumentFragment',
149 'DocumentType',
150 'Element',
151 'Event',
152 'EventException',
153 'HTMLAnchorElement',
154 'HTMLAppletElement',
155 'HTMLAreaElement',
156 'HTMLAudioElement',
157 'HTMLBRElement',
158 'HTMLBaseElement',
159 'HTMLBodyElement',
160 'HTMLButtonElement',
161 'HTMLCanvasElement',
162 'HTMLCollection',
163 'HTMLDListElement',
164 'HTMLDirectoryElement',
165 'HTMLDivElement',
166 'HTMLElement',
167 'HTMLEmbedElement',
168 'HTMLFieldSetElement',
169 'HTMLFontElement',
170 'HTMLFormElement',
171 'HTMLFrameElement',
172 'HTMLFrameSetElement',
173 'HTMLHRElement',
174 'HTMLHeadElement',
175 'HTMLHeadingElement',
176 'HTMLHtmlElement',
177 'HTMLIFrameElement',
178 'HTMLImageElement',
179 'HTMLInputElement',
180 'HTMLLIElement',
181 'HTMLLabelElement',
182 'HTMLLegendElement',
183 'HTMLLinkElement',
184 'HTMLMapElement',
185 'HTMLMediaElement',
186 'HTMLMenuElement',
187 'HTMLMetaElement',
188 'HTMLModElement',
189 'HTMLOListElement',
190 'HTMLObjectElement',
191 'HTMLOptGroupElement',
192 'HTMLOptionElement',
193 'HTMLParagraphElement',
194 'HTMLParamElement',
195 'HTMLPreElement',
196 'HTMLQuoteElement',
197 'HTMLScriptElement',
198 'HTMLSelectElement',
199 'HTMLStyleElement',
200 'HTMLTableCaptionElement',
201 'HTMLTableCellElement',
202 'HTMLTableColElement',
203 'HTMLTableElement',
204 'HTMLTableRowElement',
205 'HTMLTableSectionElement',
206 'HTMLTextAreaElement',
207 'HTMLTitleElement',
208 'HTMLUListElement',
209 'HTMLVideoElement',
210 'KeyboardEvent',
211 'MediaError',
212 'MediaList',
213 'MessageEvent',
214 'MouseEvent',
215 'MutationEvent',
216 'NamedNodeMap',
217 'Node',
218 'NodeFilter',
219 'NodeList',
220 'ProcessingInstruction',
221 'Range',
222 'RangeException',
223 'SVGAElement',
224 'SVGAngle',
225 'SVGAnimatedAngle',
226 'SVGAnimatedBoolean',
227 'SVGAnimatedEnumeration',
228 'SVGAnimatedInteger',
229 'SVGAnimatedLength',
230 'SVGAnimatedLengthList',
231 'SVGAnimatedNumber',
232 'SVGAnimatedNumberList',
233 'SVGAnimatedPreserveAspectRatio',
234 'SVGAnimatedRect',
235 'SVGAnimatedString',
236 'SVGAnimatedTransformList',
237 'SVGCircleElement',
238 'SVGClipPathElement',
239 'SVGDefsElement',
240 'SVGDescElement',
241 'SVGElement',
242 'SVGEllipseElement',
243 'SVGException',
244 'SVGGElement',
245 'SVGGradientElement',
246 'SVGImageElement',
247 'SVGLength',
248 'SVGLengthList',
249 'SVGLineElement',
250 'SVGLinearGradientElement',
251 'SVGMarkerElement',
252 'SVGMaskElement',
253 'SVGMatrix',
254 'SVGMetadataElement',
255 'SVGNumber',
256 'SVGNumberList',
257 'SVGPathElement',
258 'SVGPathSeg',
259 'SVGPathSegArcAbs',
260 'SVGPathSegArcRel',
261 'SVGPathSegClosePath',
262 'SVGPathSegCurvetoCubicAbs',
263 'SVGPathSegCurvetoCubicRel',
264 'SVGPathSegCurvetoCubicSmoothAbs',
265 'SVGPathSegCurvetoCubicSmoothRel',
266 'SVGPathSegCurvetoQuadraticAbs',
267 'SVGPathSegCurvetoQuadraticRel',
268 'SVGPathSegCurvetoQuadraticSmoothAbs',
269 'SVGPathSegCurvetoQuadraticSmoothRel',
270 'SVGPathSegLinetoAbs',
271 'SVGPathSegLinetoHorizontalAbs',
272 'SVGPathSegLinetoHorizontalRel',
273 'SVGPathSegLinetoRel',
274 'SVGPathSegLinetoVerticalAbs',
275 'SVGPathSegLinetoVerticalRel',
276 'SVGPathSegList',
277 'SVGPathSegMovetoAbs',
278 'SVGPathSegMovetoRel',
279 'SVGPatternElement',
280 'SVGPoint',
281 'SVGPointList',
282 'SVGPolygonElement',
283 'SVGPolylineElement',
284 'SVGPreserveAspectRatio',
285 'SVGRadialGradientElement',
286 'SVGRect',
287 'SVGRectElement',
288 'SVGSVGElement',
289 'SVGScriptElement',
290 'SVGStopElement',
291 'SVGStyleElement',
292 'SVGSwitchElement',
293 'SVGSymbolElement',
294 'SVGTSpanElement',
295 'SVGTextContentElement',
296 'SVGTextElement',
297 'SVGTextPathElement',
298 'SVGTextPositioningElement',
299 'SVGTitleElement',
300 'SVGTransform',
301 'SVGTransformList',
302 'SVGUnitTypes',
303 'SVGUseElement',
304 'SVGZoomEvent',
305 'Storage',
306 'StorageEvent',
307 'StyleSheet',
308 'StyleSheetList',
309 'Text',
310 'TextMetrics',
311 'UIEvent',
312 'XMLHttpRequest',
313 'XMLSerializer',
314 ]
315
316 #
317 # Simple method substitution when one method had different names on different 122 # Simple method substitution when one method had different names on different
318 # browsers, but are otherwise identical. The alternates are tried in order and 123 # browsers, but are otherwise identical. The alternates are tried in order and
319 # the first one defined is used. 124 # the first one defined is used.
320 # 125 #
321 # This can be probably be removed when Chrome renames initWebKitWheelEvent to 126 # This can be probably be removed when Chrome renames initWebKitWheelEvent to
322 # initWheelEvent. 127 # initWheelEvent.
323 # 128 #
324 _alternate_methods = { 129 _alternate_methods = {
325 ('WheelEvent', 'initWheelEvent'): ['initWebKitWheelEvent', 'initWheelEvent'] 130 ('WheelEvent', 'initWheelEvent'): ['initWebKitWheelEvent', 'initWheelEvent']
326 } 131 }
(...skipping 1678 matching lines...) Expand 10 before | Expand all | Expand 10 after
2005 base = self._ImplClassName(supertype) 1810 base = self._ImplClassName(supertype)
2006 1811
2007 if base: 1812 if base:
2008 extends = " extends " + base 1813 extends = " extends " + base
2009 else: 1814 else:
2010 extends = "" 1815 extends = ""
2011 1816
2012 if interface_name in _frog_dom_custom_native_specs: 1817 if interface_name in _frog_dom_custom_native_specs:
2013 native_spec = _frog_dom_custom_native_specs[interface_name] 1818 native_spec = _frog_dom_custom_native_specs[interface_name]
2014 else: 1819 else:
2015 # Is the type's JavaScript constructor accessible from the global scope? 1820 # Make the class 'hidden' so it is dynamically patched at runtime. This
2016 # If so, we can directly patch the prototype. We don't really want to do 1821 # is useful not only for browser compat, but to allow code that links
2017 # this yet because the dynamic patching mechanism is tricky and we want to 1822 # against dart:dom to load in a worker isolate.
2018 # test it a lot. But patching is currently broken on FireFox for non-leaf 1823 native_spec = '*' + interface_name
2019 # types, so 'hide' only the leaf types.
2020 is_hidden = interface_name not in _BROWSER_SHARED_TYPES
2021 if interface_name not in self._interfaces_with_subtypes:
2022 is_hidden = True
2023
2024 native_spec = '*' if is_hidden else ''
2025 native_spec += interface_name
2026 1824
2027 # TODO: Include all implemented interfaces, including other Lists. 1825 # TODO: Include all implemented interfaces, including other Lists.
2028 implements = '' 1826 implements = ''
2029 element_type = MaybeTypedArrayElementType(self._interface) 1827 element_type = MaybeTypedArrayElementType(self._interface)
2030 if element_type: 1828 if element_type:
2031 implements = ' implements List<' + element_type + '>' 1829 implements = ' implements List<' + element_type + '>'
2032 1830
2033 (self._members_emitter, self._base_emitter) = self._dart_code.Emit( 1831 (self._members_emitter, self._base_emitter) = self._dart_code.Emit(
2034 '\n' 1832 '\n'
2035 'class $CLASS$BASE$IMPLEMENTS native "$NATIVE" {\n' 1833 'class $CLASS$BASE$IMPLEMENTS native "$NATIVE" {\n'
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
2163 Arguments: 1961 Arguments:
2164 info: An OperationInfo object. 1962 info: An OperationInfo object.
2165 """ 1963 """
2166 # TODO(vsm): Handle overloads. 1964 # TODO(vsm): Handle overloads.
2167 self._members_emitter.Emit( 1965 self._members_emitter.Emit(
2168 '\n' 1966 '\n'
2169 ' $TYPE $NAME($ARGS) native;\n', 1967 ' $TYPE $NAME($ARGS) native;\n',
2170 TYPE=info.type_name, 1968 TYPE=info.type_name,
2171 NAME=info.name, 1969 NAME=info.name,
2172 ARGS=info.arg_implementation_declaration) 1970 ARGS=info.arg_implementation_declaration)
OLDNEW
« no previous file with comments | « client/dom/generated/src/frog/UIEvent.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698