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

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

Issue 9110016: Remove 'browser analysis' from dartgenerator.py (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 | « no previous file | 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 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 info = self._RecognizeCallback(interface) 620 info = self._RecognizeCallback(interface)
621 if info: 621 if info:
622 self._ProcessCallback(interface, info) 622 self._ProcessCallback(interface, info)
623 else: 623 else:
624 if 'Callback' in interface.ext_attrs: 624 if 'Callback' in interface.ext_attrs:
625 _logger.info('Malformed callback: %s' % interface.id) 625 _logger.info('Malformed callback: %s' % interface.id)
626 self._ProcessInterface(interface, super_interface, 626 self._ProcessInterface(interface, super_interface,
627 source_filter, common_prefix) 627 source_filter, common_prefix)
628 processed_interfaces.append(interface) 628 processed_interfaces.append(interface)
629 629
630 self._GenerateBrowserAnalysis(processed_interfaces, output_dir)
631
632
633 # Libraries 630 # Libraries
634 if lib_dir: 631 if lib_dir:
635 # New version: Monkey-patching interface library. 632 # New version: Monkey-patching interface library.
636 self.GenerateLibFile('template_monkey_dom.darttemplate', 633 self.GenerateLibFile('template_monkey_dom.darttemplate',
637 os.path.join(lib_dir, 'monkey_dom.dart'), 634 os.path.join(lib_dir, 'monkey_dom.dart'),
638 self._dart_interface_file_paths + 635 self._dart_interface_file_paths +
639 self._dart_callback_file_paths) 636 self._dart_callback_file_paths)
640 637
641 # New version: Wrapping implementation combined interface and 638 # New version: Wrapping implementation combined interface and
642 # implementation library. 639 # implementation library.
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
1245 props.add(name + '$setter') 1242 props.add(name + '$setter')
1246 1243
1247 # Define members. 1244 # Define members.
1248 operations = [op.ext_attrs.get('DartName', op.id) 1245 operations = [op.ext_attrs.get('DartName', op.id)
1249 for op in interface.operations] 1246 for op in interface.operations]
1250 members = sorted(set(operations)) 1247 members = sorted(set(operations))
1251 for name in members: 1248 for name in members:
1252 props.add(name + '$member') 1249 props.add(name + '$member')
1253 1250
1254 1251
1255 def _GenerateBrowserAnalysis(self, interfaces, output_dir):
1256 """Generate a JavaScript file that provides info from the browser.
1257 """
1258 js_file_name = os.path.join(output_dir, 'browser_analysis.html')
1259 code = self._emitters.FileEmitter(js_file_name)
1260
1261 template = """<head>
1262 <script>
1263 function addText(e, text) {
1264 var node = document.createElement('text');
1265 node.innerHTML = String(text);
1266 e.appendChild(node);
1267 }
1268 function check() {
1269 var supported = [];
1270 var missing = [];
1271 $!CHECKS
1272 addText(document.getElementById('agent'), navigator.userAgent);
1273
1274 function fill(tag, elems) {
1275 addText(document.getElementById(tag + '_count'), elems.length);
1276 for (var i = 0; i < elems.length; ++i) {
1277 var e = document.createElement('div');
1278 e.innerHTML = '&nbsp;&nbsp;"' + elems[i] + '",'
1279 document.getElementById(tag).appendChild(e);
1280 }
1281 }
1282 fill('supported', supported);
1283 fill('missing', missing);
1284 }
1285 window.onload = check;
1286 </script>
1287 </head>
1288 <div>
1289 { 'userAgent': '<span id='agent'></span>',
1290 </div>
1291 <div>
1292 'supported': [ // (<span id='supported_count'></span>)
1293 <div id='supported' style='font-size: -2;'></div>
1294 ],</div>
1295 <div>
1296 'missing': [ // (<span id='missing_count'></span>)
1297 <div id='missing' style='font-size: -2;'></div>
1298 ]}</div>
1299
1300 """
1301 checks = code.Emit(template)
1302 names = sorted(interface.id for interface in interfaces)
1303 for id in names:
1304 checks.Emit(
1305 ' if (typeof $ID == "undefined")\n'
1306 ' missing.push("$ID");\n'
1307 ' else\n'
1308 ' supported.push("$ID");\n',
1309 ID=id);
1310
1311
1312 class OperationInfo(object): 1252 class OperationInfo(object):
1313 """Holder for various derived information from a set of overloaded operations. 1253 """Holder for various derived information from a set of overloaded operations.
1314 1254
1315 Attributes: 1255 Attributes:
1316 overloads: A list of IDL operation overloads with the same name. 1256 overloads: A list of IDL operation overloads with the same name.
1317 name: A string, the simple name of the operation. 1257 name: A string, the simple name of the operation.
1318 type_name: A string, the name of the return type of the operation. 1258 type_name: A string, the name of the return type of the operation.
1319 arg_declarations: A list of strings, Dart argument declarations for the 1259 arg_declarations: A list of strings, Dart argument declarations for the
1320 member that implements the set of overloads. Each string is of the form 1260 member that implements the set of overloads. Each string is of the form
1321 "T arg" or "T arg = null". 1261 "T arg" or "T arg = null".
(...skipping 1167 matching lines...) Expand 10 before | Expand all | Expand 10 after
2489 Arguments: 2429 Arguments:
2490 info: An OperationInfo object. 2430 info: An OperationInfo object.
2491 """ 2431 """
2492 # TODO(vsm): Handle overloads. 2432 # TODO(vsm): Handle overloads.
2493 self._members_emitter.Emit( 2433 self._members_emitter.Emit(
2494 '\n' 2434 '\n'
2495 ' $TYPE $NAME($ARGS) native;\n', 2435 ' $TYPE $NAME($ARGS) native;\n',
2496 TYPE=info.type_name, 2436 TYPE=info.type_name,
2497 NAME=info.name, 2437 NAME=info.name,
2498 ARGS=info.arg_implementation_declaration) 2438 ARGS=info.arg_implementation_declaration)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698