| Index: Source/bindings/scripts/dump_ir.py
|
| diff --git a/Source/core/scripts/make_internal_runtime_flags.py b/Source/bindings/scripts/dump_ir.py
|
| similarity index 50%
|
| copy from Source/core/scripts/make_internal_runtime_flags.py
|
| copy to Source/bindings/scripts/dump_ir.py
|
| index 522e00f596228c1d322600fc4e5d1036962e66bc..83b73ffd891800cf015ec04c2177d1c83a475a90 100755
|
| --- a/Source/core/scripts/make_internal_runtime_flags.py
|
| +++ b/Source/bindings/scripts/dump_ir.py
|
| @@ -1,4 +1,4 @@
|
| -#!/usr/bin/env python
|
| +#!/usr/bin/python
|
| # Copyright (C) 2013 Google Inc. All rights reserved.
|
| #
|
| # Redistribution and use in source and binary forms, with or without
|
| @@ -27,38 +27,52 @@
|
| # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
| +"""Dump Blink IR to JSON and pickle
|
| +
|
| +This is for testing IDL parser, and generating parsed files so
|
| +code generator can be developed before parser lands.
|
| +"""
|
| +
|
| +import optparse
|
| import os.path
|
| +# import pickle
|
| import sys
|
|
|
| -import in_generator
|
| -import make_runtime_features
|
| -import template_expander
|
| +from blink_idl_lexer import BlinkIDLLexer
|
| +from blink_idl_parser import BlinkIDLParser
|
| +import ast_to_ir
|
| +import ir
|
|
|
| +# Base parser is in Chromium src/tools/idl_parser
|
| +module_path, module_name = os.path.split(__file__)
|
| +tools_dir = os.path.join(module_path, os.pardir, os.pardir, os.pardir, os.pardir, os.pardir, 'tools')
|
| +sys.path.append(tools_dir)
|
|
|
| -# We want exactly the same parsing as RuntimeFeatureWriter
|
| -# but generate different files.
|
| -class InternalRuntimeFlagsWriter(make_runtime_features.RuntimeFeatureWriter):
|
| - class_name = "InternalRuntimeFlags"
|
| +from idl_parser.idl_parser import ParseFile
|
|
|
| - def __init__(self, in_file_path, enabled_conditions):
|
| - super(InternalRuntimeFlagsWriter, self).__init__(in_file_path, enabled_conditions)
|
| - self._outputs = {(self.class_name + ".idl"): self.generate_idl,
|
| - (self.class_name + ".h"): self.generate_header,
|
| - }
|
|
|
| - @template_expander.use_jinja(class_name + ".idl.tmpl")
|
| - def generate_idl(self):
|
| - return {
|
| - 'features': self._features,
|
| - }
|
| +def main():
|
| + parser = optparse.OptionParser()
|
| + parser.add_option('--debug', action='store_true')
|
| + options, args = parser.parse_args()
|
| + idl_filename = args[0]
|
| + idl_basename = os.path.basename(idl_filename)
|
| + interface_name, _ = os.path.splitext(idl_basename)
|
| + json_filename = 'JSON/%s.json' % interface_name
|
| + # pickle_filename = 'PKL/%s.pkl' % interface_name
|
|
|
| - @template_expander.use_jinja(class_name + ".h.tmpl")
|
| - def generate_header(self):
|
| - return {
|
| - 'features': self._features,
|
| - 'feature_sets': self._feature_sets(),
|
| - }
|
| + if idl_basename == 'InspectorInstrumentation.idl':
|
| + # Non-conformant pseudo-IDL file
|
| + return
|
|
|
| + parser = BlinkIDLParser(BlinkIDLLexer(), debug=options.debug)
|
| + filenode = ParseFile(parser, idl_filename)
|
| + blink_ir = ast_to_ir.web_idl_ast_to_blink_ir(filenode)
|
| + json_string = ir.ir_to_json(blink_ir, debug=options.debug)
|
| + with open(json_filename, 'w') as json_file:
|
| + json_file.write(json_string)
|
| + # with open(pickle_filename, 'wb') as pickle_file:
|
| + # pickle.dump(blink_ir, pickle_file)
|
|
|
| -if __name__ == "__main__":
|
| - in_generator.Maker(InternalRuntimeFlagsWriter).main(sys.argv)
|
| +if __name__ == '__main__':
|
| + sys.exit(main())
|
|
|