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

Unified Diff: Source/bindings/scripts/idl-to-json.pl

Issue 15959019: Rewrite generate-bindings.pl in Python (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 7 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/scripts/generate_bindings.py ('k') | Source/bindings/scripts/interface_merger.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/scripts/idl-to-json.pl
diff --git a/Source/core/scripts/make_internal_runtime_flags.py b/Source/bindings/scripts/idl-to-json.pl
similarity index 61%
copy from Source/core/scripts/make_internal_runtime_flags.py
copy to Source/bindings/scripts/idl-to-json.pl
index dc333235ff3fcbe1567e2fbb2a1bc08961476568..daed93ab68caaf8689a65ed515a45ee9ef37a281 100755
--- a/Source/core/scripts/make_internal_runtime_flags.py
+++ b/Source/bindings/scripts/idl-to-json.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/perl -w -I../../core/scripts
# Copyright (C) 2013 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -27,32 +27,43 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-import os.path
-import sys
-import in_generator
-import make_runtime_features
+# Wrapper script to parse a file and dump to stdout as JSON
+use strict;
+use warnings;
-# We want exactly the same parsing as RuntimeFeatureWriter
-# but generate different files.
-class InternalRuntimeFlagsWriter(make_runtime_features.RuntimeFeatureWriter):
- class_name = "InternalRuntimeFlags"
+use Cwd;
+use Getopt::Long;
+use JSON -convert_blessed_universally; # IDLParser returns blessed objects
- def generate_idl(self):
- return {
- 'features': self._features,
- }
+use IDLParser;
- def generate_header(self):
- return {
- 'features': self._features,
- 'feature_sets': self._feature_sets(),
- }
+# Get options
+my $defines;
+my $preprocessor;
+my $verbose;
- def generate_implementation(self):
- return None
+GetOptions('defines=s' => \$defines,
+ 'preprocessor=s' => \$preprocessor,
+ 'verbose' => \$verbose);
+my $targetIdlFile = $ARGV[0];
-if __name__ == "__main__":
- in_generator.Maker(InternalRuntimeFlagsWriter).main(sys.argv)
+$defines = "" unless defined($defines);
+die('Must specify input file.') unless defined($targetIdlFile);
+$targetIdlFile = Cwd::realpath($targetIdlFile);
+
+if ($verbose) {
+ print "$targetIdlFile\n";
+}
+
+# Parse file
+my $targetParser = IDLParser->new(!$verbose);
+my $targetDocument = $targetParser->Parse($targetIdlFile, $defines, $preprocessor);
+
+# Convert to JSON
+my $json = JSON->new->utf8;
+$json = $json->allow_blessed->convert_blessed();
+my $json_text= $json->encode($targetDocument);
+print $json_text . "\n";
« no previous file with comments | « Source/bindings/scripts/generate_bindings.py ('k') | Source/bindings/scripts/interface_merger.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698