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

Unified Diff: tools/json_schema_compiler/compiler.py

Issue 9600050: Add IDL capability to json_schema_compiler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Patch Set TWO Created 8 years, 9 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 | « chrome/common/extensions/api/experimental.dns.idl ('k') | tools/json_schema_compiler/idl_schema.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/json_schema_compiler/compiler.py
diff --git a/tools/json_schema_compiler/compiler.py b/tools/json_schema_compiler/compiler.py
index fb84a6ca461d72964a9e618aa05de265722f1871..f782f724f1d4e091c0341166b79ab4f443c1e22c 100644
--- a/tools/json_schema_compiler/compiler.py
+++ b/tools/json_schema_compiler/compiler.py
@@ -19,7 +19,8 @@ Usage example:
import cc_generator
import cpp_type_generator
import h_generator
-from json_schema import LoadJSON
+import idl_schema
+import json_schema
import model
import optparse
import os.path
@@ -47,17 +48,24 @@ if __name__ == '__main__':
api_model = model.Model()
-
# Actually generate for source file.
- api_defs = LoadJSON(schema)
+ schema_filename, schema_extension = os.path.splitext(schema)
+ if schema_extension == '.json':
+ api_defs = json_schema.Load(schema)
+ elif schema_extension == '.idl':
+ api_defs = idl_schema.Load(schema)
+ else:
+ sys.exit("Did not recognize file extension %s for schema %s" %
+ (schema_extension, schema))
for target_namespace in api_defs:
referenced_schemas = target_namespace.get('dependencies', [])
# Load type dependencies into the model.
+ # TODO(miket): do we need this in IDL?
for referenced_schema in referenced_schemas:
referenced_schema_path = os.path.join(
os.path.dirname(schema), referenced_schema + '.json')
- referenced_api_defs = LoadJSON(referenced_schema_path)
+ referenced_api_defs = json_schema.Load(referenced_schema_path)
for namespace in referenced_api_defs:
api_model.AddNamespace(namespace,
« no previous file with comments | « chrome/common/extensions/api/experimental.dns.idl ('k') | tools/json_schema_compiler/idl_schema.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698