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 2596583002: [Schema Compiler] Separate out SchemaLoader and namespace resolving (Closed)
Patch Set: . Created 4 years 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 | « no previous file | tools/json_schema_compiler/cpp_type_generator.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 c626f2f96c20570980c9b2637dcdae96c5128271..257a0de96b3c0655b5a727e856d41f0f49594792 100755
--- a/tools/json_schema_compiler/compiler.py
+++ b/tools/json_schema_compiler/compiler.py
@@ -29,6 +29,7 @@ from js_interface_generator import JsInterfaceGenerator
import json_schema
from cpp_namespace_environment import CppNamespaceEnvironment
from model import Model
+from namespace_resolver import NamespaceResolver
from schema_loader import SchemaLoader
# Names of supported code generators, as specified on the command-line.
@@ -49,12 +50,7 @@ def GenerateSchema(generator_name,
api_defs = []
for file_path in file_paths:
schema = os.path.relpath(file_path, root)
- schema_loader = SchemaLoader(
- root,
- os.path.dirname(schema),
- include_rules,
- cpp_namespace_pattern)
- api_def = schema_loader.LoadSchema(schema)
+ api_def = SchemaLoader(root).LoadSchema(schema)
# If compiling the C++ model code, delete 'nocompile' nodes.
if generator_name == 'cpp':
@@ -96,8 +92,11 @@ def GenerateSchema(generator_name,
filename_base, _ = os.path.splitext(filename)
# Construct the type generator with all the namespaces in this model.
+ schema_dir = os.path.dirname(os.path.relpath(file_paths[0], root))
+ namespace_resolver = NamespaceResolver(root, schema_dir,
+ include_rules, cpp_namespace_pattern)
type_generator = CppTypeGenerator(api_model,
- schema_loader,
+ namespace_resolver,
default_namespace)
if generator_name in ('cpp-bundle-registration', 'cpp-bundle-schema'):
cpp_bundle_generator = CppBundleGenerator(root,
« no previous file with comments | « no previous file | tools/json_schema_compiler/cpp_type_generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698