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

Side by Side Diff: tools/dom/scripts/database.py

Issue 13704011: Map enums to strings. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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 | « tools/dom/scripts/dartgenerator.py ('k') | tools/dom/scripts/databasebuilder.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) 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 """Module to manage IDL files.""" 6 """Module to manage IDL files."""
7 7
8 import copy 8 import copy
9 import pickle 9 import pickle
10 import logging 10 import logging
(...skipping 24 matching lines...) Expand all
35 Args: 35 Args:
36 root_dir -- a directory. If directory does not exist, it will 36 root_dir -- a directory. If directory does not exist, it will
37 be created. 37 be created.
38 """ 38 """
39 self._root_dir = root_dir 39 self._root_dir = root_dir
40 if not os.path.exists(root_dir): 40 if not os.path.exists(root_dir):
41 _logger.debug('creating root directory %s' % root_dir) 41 _logger.debug('creating root directory %s' % root_dir)
42 os.makedirs(root_dir) 42 os.makedirs(root_dir)
43 self._all_interfaces = {} 43 self._all_interfaces = {}
44 self._interfaces_to_delete = [] 44 self._interfaces_to_delete = []
45 self._enums = {}
45 self._idlparser = idlparser.IDLParser(idlparser.FREMONTCUT_SYNTAX) 46 self._idlparser = idlparser.IDLParser(idlparser.FREMONTCUT_SYNTAX)
46 47
47 def Clone(self): 48 def Clone(self):
48 new_database = Database(self._root_dir) 49 new_database = Database(self._root_dir)
49 new_database._all_interfaces = copy.deepcopy(self._all_interfaces) 50 new_database._all_interfaces = copy.deepcopy(self._all_interfaces)
50 new_database._interfaces_to_delete = copy.deepcopy( 51 new_database._interfaces_to_delete = copy.deepcopy(
51 self._interfaces_to_delete) 52 self._interfaces_to_delete)
53 new_database._enums = copy.deepcopy(self._enums)
52 return new_database 54 return new_database
53 55
54 def Delete(self): 56 def Delete(self):
55 """Deletes the database by deleting its directory""" 57 """Deletes the database by deleting its directory"""
56 if os.path.exists(self._root_dir): 58 if os.path.exists(self._root_dir):
57 shutil.rmtree(self._root_dir) 59 shutil.rmtree(self._root_dir)
58 # reset in-memory constructs 60 # reset in-memory constructs
59 self._all_interfaces = {} 61 self._all_interfaces = {}
60 62
61 def _ScanForInterfaces(self): 63 def _ScanForInterfaces(self):
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 os.remove(file_path) 229 os.remove(file_path)
228 230
229 def Hierarchy(self, interface): 231 def Hierarchy(self, interface):
230 yield interface 232 yield interface
231 for parent in interface.parents: 233 for parent in interface.parents:
232 parent_name = parent.type.id 234 parent_name = parent.type.id
233 if not self.HasInterface(parent.type.id): 235 if not self.HasInterface(parent.type.id):
234 continue 236 continue
235 for parent_interface in self.Hierarchy(self.GetInterface(parent.type.id)): 237 for parent_interface in self.Hierarchy(self.GetInterface(parent.type.id)):
236 yield parent_interface 238 yield parent_interface
239
240 def HasEnum(self, enum_name):
241 return enum_name in self._enums
242
243 def GetEnum(self, enum_name):
244 return self._enums[enum_name]
245
246 def AddEnum(self, enum):
247 self._enums[enum.id] = enum
OLDNEW
« no previous file with comments | « tools/dom/scripts/dartgenerator.py ('k') | tools/dom/scripts/databasebuilder.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698