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

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

Issue 9369062: Ensure 'raises' clauses on operations are saved in IDL database. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 10 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 | client/dom/scripts/fremontcutbuilder.py » ('j') | 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) 2012, the Dart project authors. Please see the AUTHORS file 2 # Copyright (c) 2012, 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 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 442
443 # Collect interfaces 443 # Collect interfaces
444 interfaces = [] 444 interfaces = []
445 for interface in database.GetInterfaces(): 445 for interface in database.GetInterfaces():
446 if not _MatchSourceFilter(source_filter, interface): 446 if not _MatchSourceFilter(source_filter, interface):
447 # Skip this interface since it's not present in the required source 447 # Skip this interface since it's not present in the required source
448 _logger.info('Omitting interface - %s' % interface.id) 448 _logger.info('Omitting interface - %s' % interface.id)
449 continue 449 continue
450 interfaces.append(interface) 450 interfaces.append(interface)
451 451
452 # TODO(sra): Use this list of exception names to generate information to
453 # tell Frog which exceptions can be passed from JS to Dart code.
454 exceptions = self._CollectExceptions(interfaces)
455
452 # Render all interfaces into Dart and save them in files. 456 # Render all interfaces into Dart and save them in files.
453 for interface in self._PreOrderInterfaces(interfaces): 457 for interface in self._PreOrderInterfaces(interfaces):
454 458
455 super_interface = None 459 super_interface = None
456 super_name = interface.id 460 super_name = interface.id
457 461
458 if super_name in super_map: 462 if super_name in super_map:
459 super_name = super_map[super_name] 463 super_name = super_map[super_name]
460 464
461 if (super_database is not None and 465 if (super_database is not None and
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 if self._database.HasInterface(parent.type.id): 627 if self._database.HasInterface(parent.type.id):
624 parent_interface = self._database.GetInterface(parent.type.id) 628 parent_interface = self._database.GetInterface(parent.type.id)
625 result.append(parent_interface) 629 result.append(parent_interface)
626 walk(parent_interface.parents) 630 walk(parent_interface.parents)
627 631
628 result = [] 632 result = []
629 walk(interface.parents[1:]) 633 walk(interface.parents[1:])
630 return result; 634 return result;
631 635
632 636
637 def _CollectExceptions(self, interfaces):
638 """Returns the names of all exception classes raised."""
639 exceptions = set()
640 for interface in interfaces:
641 for attribute in interface.attributes:
642 if attribute.get_raises:
643 exceptions.add(attribute.get_raises.id)
644 if attribute.set_raises:
645 exceptions.add(attribute.set_raises.id)
646 for operation in interface.operations:
647 if operation.raises:
648 exceptions.add(operation.raises.id)
649 return exceptions
650
651
633 def Flush(self): 652 def Flush(self):
634 """Write out all pending files.""" 653 """Write out all pending files."""
635 _logger.info('Flush...') 654 _logger.info('Flush...')
636 self._emitters.Flush() 655 self._emitters.Flush()
637 656
638 657
639 def _ComputeInheritanceClosure(self): 658 def _ComputeInheritanceClosure(self):
640 def Collect(interface, seen, collected): 659 def Collect(interface, seen, collected):
641 name = interface.id 660 name = interface.id
642 if '<' in name: 661 if '<' in name:
(...skipping 1782 matching lines...) Expand 10 before | Expand all | Expand 10 after
2425 INDENT=indent, 2444 INDENT=indent,
2426 NATIVENAME=native_name, 2445 NATIVENAME=native_name,
2427 ARGS=argument_expressions) 2446 ARGS=argument_expressions)
2428 2447
2429 self._members_emitter.Emit(' $TYPE $NATIVE_NAME($PARAMS) native ' 2448 self._members_emitter.Emit(' $TYPE $NATIVE_NAME($PARAMS) native '
2430 '"$(INTERFACE)$(NATIVE_NAME)_Callback";\n', 2449 '"$(INTERFACE)$(NATIVE_NAME)_Callback";\n',
2431 NATIVE_NAME=native_name, 2450 NATIVE_NAME=native_name,
2432 TYPE=info.type_name, 2451 TYPE=info.type_name,
2433 PARAMS=', '.join(arg_names), 2452 PARAMS=', '.join(arg_names),
2434 INTERFACE=self._interface.id) 2453 INTERFACE=self._interface.id)
OLDNEW
« no previous file with comments | « no previous file | client/dom/scripts/fremontcutbuilder.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698