OLD | NEW |
| (Empty) |
1 #!/usr/bin/python | |
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 | |
4 # BSD-style license that can be found in the LICENSE file. | |
5 | |
6 import database | |
7 import databasebuilder | |
8 import idlparser | |
9 import os.path | |
10 import logging.config | |
11 import sys | |
12 | |
13 | |
14 def main(): | |
15 """This code reconstructs the FremontCut IDL database from W3C, | |
16 WebKit and Dart IDL files.""" | |
17 current_dir = os.path.dirname(__file__) | |
18 logging.config.fileConfig(os.path.join(current_dir, "logging.conf")) | |
19 | |
20 db = database.Database(os.path.join(current_dir, '..', 'database')) | |
21 | |
22 # Delete all existing IDLs in the DB. | |
23 db.Delete() | |
24 | |
25 builder = databasebuilder.DatabaseBuilder(db) | |
26 | |
27 # Import WebKit IDL files: | |
28 webkit_dirs = [ | |
29 'Modules/speech', | |
30 'Modules/indexeddb', | |
31 'css', | |
32 'dom', | |
33 'fileapi', | |
34 'Modules/filesystem', | |
35 'html', | |
36 'html/canvas', | |
37 'inspector', | |
38 'loader', | |
39 'loader/appcache', | |
40 'Modules/mediastream', | |
41 'Modules/geolocation', | |
42 'notifications', | |
43 'page', | |
44 'plugins', | |
45 'storage', | |
46 'Modules/webdatabase', | |
47 'svg', | |
48 'Modules/webaudio', | |
49 'Modules/websockets', | |
50 'workers', | |
51 'xml', | |
52 ] | |
53 | |
54 # TODO(vsm): Move this to a README. | |
55 # This is the Dart SVN revision. | |
56 webkit_revision = '1060' | |
57 | |
58 # TODO(vsm): Reconcile what is exposed here and inside WebKit code | |
59 # generation. We need to recheck this periodically for now. | |
60 webkit_defines = [ | |
61 'LANGUAGE_DART', | |
62 'LANGUAGE_JAVASCRIPT', | |
63 | |
64 # Enabled Chrome WebKit build. | |
65 'ENABLE_3D_PLUGIN', | |
66 'ENABLE_3D_RENDERING', | |
67 'ENABLE_ACCELERATED_2D_CANVAS', | |
68 'ENABLE_BLOB', | |
69 'ENABLE_BLOB_SLICE', | |
70 'ENABLE_CHANNEL_MESSAGING', | |
71 'ENABLE_CLIENT_BASED_GEOLOCATION', | |
72 'ENABLE_DATA_TRANSFER_ITEMS', | |
73 'ENABLE_DETAILS', | |
74 'ENABLE_DEVICE_ORIENTATION', | |
75 'ENABLE_DIRECTORY_UPLOAD', | |
76 'ENABLE_DOWNLOAD_ATTRIBUTE', | |
77 'ENABLE_FILE_SYSTEM', | |
78 'ENABLE_FILTERS', | |
79 'ENABLE_FULLSCREEN_API', | |
80 'ENABLE_GAMEPAD', | |
81 'ENABLE_GEOLOCATION', | |
82 'ENABLE_GESTURE_EVENTS', | |
83 'ENABLE_GESTURE_RECOGNIZER', | |
84 'ENABLE_INDEXED_DATABASE', | |
85 'ENABLE_INPUT_SPEECH', | |
86 'ENABLE_JAVASCRIPT_DEBUGGER', | |
87 'ENABLE_JAVASCRIPT_I18N_API', | |
88 'ENABLE_LINK_PREFETCH', | |
89 'ENABLE_MEDIA_SOURCE', | |
90 'ENABLE_MEDIA_STATISTICS', | |
91 'ENABLE_MEDIA_STREAM', | |
92 'ENABLE_METER_TAG', | |
93 'ENABLE_MHTML', | |
94 'ENABLE_MOUSE_LOCK_API', | |
95 'ENABLE_NOTIFICATIONS', | |
96 'ENABLE_PAGE_VISIBILITY_API', | |
97 'ENABLE_PROGRESS_TAG', | |
98 'ENABLE_QUOTA', | |
99 'ENABLE_REGISTER_PROTOCOL_HANDLER', | |
100 'ENABLE_REQUEST_ANIMATION_FRAME', | |
101 'ENABLE_RUBY', | |
102 'ENABLE_SANDBOX', | |
103 'ENABLE_SCRIPTED_SPEECH', | |
104 'ENABLE_SHADOW_DOM', | |
105 'ENABLE_SHARED_WORKERS', | |
106 'ENABLE_SMOOTH_SCROLLING', | |
107 'ENABLE_SPEECH_RECOGNITION', | |
108 'ENABLE_SQL_DATABASE', | |
109 'ENABLE_SVG', | |
110 'ENABLE_SVG_FONTS', | |
111 'ENABLE_TOUCH_EVENTS', | |
112 'ENABLE_V8_SCRIPT_DEBUG_SERVER', | |
113 'ENABLE_VIDEO', | |
114 'ENABLE_VIDEO_TRACK', | |
115 'ENABLE_WEBGL', | |
116 'ENABLE_WEB_AUDIO', | |
117 'ENABLE_WEB_SOCKETS', | |
118 'ENABLE_WEB_TIMING', | |
119 'ENABLE_WORKERS', | |
120 'ENABLE_XHR_RESPONSE_BLOB', | |
121 'ENABLE_XSLT', | |
122 ] | |
123 webkit_options = databasebuilder.DatabaseBuilderOptions( | |
124 idl_syntax=idlparser.WEBKIT_SYNTAX, | |
125 # TODO(vsm): What else should we define as on when processing IDL? | |
126 idl_defines=webkit_defines, | |
127 source='WebKit', | |
128 source_attributes={'revision': webkit_revision}, | |
129 type_rename_map={ | |
130 # Some of these are typos in the IDL. | |
131 'float': 'double', | |
132 'BarInfo': 'BarProp', | |
133 'DedicatedWorkerContext': 'DedicatedWorkerGlobalScope', | |
134 'DOMApplicationCache': 'ApplicationCache', | |
135 'DOMCoreException': 'DOMException', | |
136 'DOMExceptionJSC': 'DOMException', # Node.replaceChild | |
137 'DomException': 'DOMException', # Navigator.registerProtocolHandler | |
138 'DOMFormData': 'FormData', | |
139 'DOMObject': 'object', | |
140 'DOMSelection': 'Selection', | |
141 'DOMWindow': 'Window', | |
142 'Exception': 'DOMException', # NotificationCenter.createNotification | |
143 'SharedWorkerContext': 'SharedWorkerGlobalScope', | |
144 'WorkerContext': 'WorkerGlobalScope', | |
145 }) | |
146 | |
147 optional_argument_whitelist = [ | |
148 ('CSSStyleDeclaration', 'setProperty', 'priority'), | |
149 ('IDBDatabase', 'transaction', 'mode'), | |
150 ] | |
151 | |
152 for dir_name in webkit_dirs: | |
153 dir_path = os.path.join(current_dir, '..', '..', '..', '..', | |
154 'third_party', 'WebKit', 'Source', 'WebCore', dir_name) | |
155 builder.import_idl_directory(dir_path, webkit_options) | |
156 | |
157 webkit_supplemental_options = databasebuilder.DatabaseBuilderOptions( | |
158 idl_syntax=idlparser.FREMONTCUT_SYNTAX, | |
159 source='WebKit', | |
160 rename_operation_arguments_on_merge=True) | |
161 builder.import_idl_file( | |
162 os.path.join(current_dir, '..', 'idl', 'dart', 'webkit-supplemental.idl'), | |
163 webkit_supplemental_options) | |
164 | |
165 # Import Dart idl: | |
166 dart_options = databasebuilder.DatabaseBuilderOptions( | |
167 idl_syntax=idlparser.FREMONTCUT_SYNTAX, | |
168 source='Dart', | |
169 rename_operation_arguments_on_merge=True) | |
170 | |
171 builder.import_idl_file( | |
172 os.path.join(current_dir, '..', 'idl', 'dart', 'dart.idl'), | |
173 dart_options) | |
174 | |
175 builder.set_same_signatures({ | |
176 'EventListener': 'Function', | |
177 'int': 'long', | |
178 }) | |
179 | |
180 # Merging: | |
181 builder.merge_imported_interfaces(optional_argument_whitelist) | |
182 | |
183 builder.fix_displacements('WebKit') | |
184 | |
185 # Cleanup: | |
186 builder.normalize_annotations(['WebKit', 'Dart']) | |
187 | |
188 db.Save() | |
189 | |
190 if __name__ == '__main__': | |
191 sys.exit(main()) | |
OLD | NEW |