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

Unified Diff: Source/bindings/scripts/aggregate_generated_dictionaries.py

Issue 386963003: [WIP][NotForLand] IDL dictionary support (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: sequence and array support Created 6 years, 5 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 | « Source/bindings/core/v8/generated.gypi ('k') | Source/bindings/scripts/code_generator_v8.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/scripts/aggregate_generated_dictionaries.py
diff --git a/Source/bindings/scripts/aggregate_generated_dictionaries.py b/Source/bindings/scripts/aggregate_generated_dictionaries.py
new file mode 100644
index 0000000000000000000000000000000000000000..c736b4bb3dd25d54570a7eef2aa5458f5f258d04
--- /dev/null
+++ b/Source/bindings/scripts/aggregate_generated_dictionaries.py
@@ -0,0 +1,61 @@
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Aggregate generated dictionary impl classes.
+
+Usage:
+aggregate_generated_dictionaries.py COMPONENT_DIR INTERFACES_INFO OUTPUT_FILE
+
+COMPONENT_DIR is the name of a component, i.e., 'core' or 'modules'.
+INTERFACES_INFO is a pickle file generated by compute_interfaces_info_overall.py.
+OUTPUT_FILE is the filename of output.
+"""
+
+import cPickle as pickle
+import posixpath
+import sys
+from utilities import write_file
+
+
+COPYRIGHT = """// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+"""
+
+
+def generate_path(interface_name, interface_info):
+ return posixpath.join(interface_info['relative_dir'],
+ '%s.cpp' % interface_name)
+
+
+def generate_content(generated_paths):
+ output = [COPYRIGHT,
+ '#define NO_IMPLICIT_ATOMICSTRING\n\n']
+ output.extend('#include "%s"\n' % generated_path
+ for generated_path in sorted(generated_paths))
+ return ''.join(output)
+
+
+def main(args):
+ # FIXME: we might want to accept multiple output files.
+ if len(args) != 4:
+ raise Exception('Expected 3 arguments.')
+ component_dir = args[1]
+ interfaces_info_file_name = args[2]
+ output_file_name = args[3]
+ with open(interfaces_info_file_name) as interfaces_info_file:
+ interfaces_info = pickle.load(interfaces_info_file)
+
+ generated_paths = [
+ generate_path(interface_name, interface_info)
+ for interface_name, interface_info in interfaces_info.iteritems()
+ if (interface_info['component_dir'] == component_dir and
+ interface_info['is_dictionary'])]
+ contents = generate_content(generated_paths)
+ write_file(contents, output_file_name, only_if_changed=True)
+
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv))
« no previous file with comments | « Source/bindings/core/v8/generated.gypi ('k') | Source/bindings/scripts/code_generator_v8.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698