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

Unified Diff: core/scripts/in_file.py

Issue 22498002: Roll IDL to multivm@1329 (Closed) Base URL: https://dart.googlecode.com/svn/third_party/WebCore
Patch Set: Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/scripts/action_useragentstylesheets.py ('k') | core/scripts/list_idl_files_with_partial_interface.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/scripts/in_file.py
diff --git a/core/scripts/in_file.py b/core/scripts/in_file.py
index 39a016b26b9a40f875bbd4688c08849fed390947..d8d8235704b8f142d6e4fccbaa22ce1b0cb4b41b 100644
--- a/core/scripts/in_file.py
+++ b/core/scripts/in_file.py
@@ -75,6 +75,7 @@ class InFile(object):
def _parse(self, lines):
parsing_parameters = True
+ indices = {}
for line in lines:
if _is_comment(line):
continue
@@ -84,7 +85,40 @@ class InFile(object):
if parsing_parameters:
self._parse_parameter(line)
else:
- self.name_dictionaries.append(self._parse_line(line))
+ entry = self._parse_line(line)
+ name = entry['name']
+ if name in indices:
+ entry = self._merge_entries(entry, self.name_dictionaries[indices[name]])
+ entry['name'] = name
+ self.name_dictionaries[indices[name]] = entry
+ else:
+ indices[name] = len(self.name_dictionaries)
+ self.name_dictionaries.append(entry)
+
+
+ def _merge_entries(self, one, two):
+ merged = {}
+ for key in one:
+ if key not in two:
+ self._fatal("Expected key '%s' not found in entry: %s" % (key, two))
+ if one[key] and two[key]:
+ val_one = one[key]
+ val_two = two[key]
+ if isinstance(val_one, list) and isinstance(val_two, list):
+ val = val_one + val_two
+ elif isinstance(val_one, list):
+ val = val_one + [val_two]
+ elif isinstance(val_two, list):
+ val = [val_one] + val_two
+ else:
+ val = [val_one, val_two]
+ merged[key] = val
+ elif one[key]:
+ merged[key] = one[key]
+ else:
+ merged[key] = two[key]
+ return merged
+
def _parse_parameter(self, line):
if '=' in line:
« no previous file with comments | « core/scripts/action_useragentstylesheets.py ('k') | core/scripts/list_idl_files_with_partial_interface.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698