Chromium Code Reviews| Index: tools/json_schema_compiler/schema_loader.py |
| diff --git a/tools/json_schema_compiler/schema_loader.py b/tools/json_schema_compiler/schema_loader.py |
| index a42f4c4c5673fd1f2c09d6a45356f1a32f53d2c3..3054560eb25ad1c84425ea39a512a9798f50315a 100644 |
| --- a/tools/json_schema_compiler/schema_loader.py |
| +++ b/tools/json_schema_compiler/schema_loader.py |
| @@ -50,13 +50,7 @@ class SchemaLoader(object): |
| self._include_rules = [(real_path, cpp_namespace_pattern)] |
| self._include_rules.extend(include_rules) |
| - def ResolveType(self, full_name, default_namespace): |
| - name_parts = full_name.rsplit('.', 1) |
| - if len(name_parts) == 1: |
| - if full_name not in default_namespace.types: |
| - return None |
| - return default_namespace |
| - full_namespace, type_name = full_name.rsplit('.', 1) |
| + def ResolveNamespace(self, full_namespace): |
| filenames = GenerateFilenames(full_namespace) |
| for path, namespace in self._include_rules: |
| for filename in reversed(filenames): |
| @@ -66,21 +60,30 @@ class SchemaLoader(object): |
| self.LoadSchema(filepath)[0], |
| os.path.join(self._display_path, filepath), |
| environment=CppNamespaceEnvironment(namespace)) |
| - if type_name in namespace.types: |
| - return namespace |
| + return namespace |
|
not at google - send to devlin
2014/08/28 19:41:35
(I know the code is already like this but...) |nam
lfg
2014/08/28 23:14:59
Done.
|
| + return None |
| + |
| + def ResolveType(self, full_name, default_namespace): |
| + name_parts = full_name.rsplit('.', 1) |
| + if len(name_parts) == 1: |
| + if full_name not in default_namespace.types: |
| + return None |
| + return default_namespace |
| + full_namespace, type_name = full_name.rsplit('.', 1) |
| + namespace = self.ResolveNamespace(full_namespace) |
| + if namespace and type_name in namespace.types: |
| + return namespace |
| return None |
| def LoadSchema(self, schema): |
| '''Load a schema definition. The schema parameter must be a file name |
| - without any path component - the file is loaded from the path defined by |
| - the real_path argument passed to the constructor.''' |
| + with the full path.''' |
| schema_filename, schema_extension = os.path.splitext(schema) |
| - schema_path = os.path.join(self._real_path, schema); |
| if schema_extension == '.json': |
| - api_defs = json_schema.Load(schema_path) |
| + api_defs = json_schema.Load(schema) |
| elif schema_extension == '.idl': |
| - api_defs = idl_schema.Load(schema_path) |
| + api_defs = idl_schema.Load(schema) |
| else: |
| sys.exit('Did not recognize file extension %s for schema %s' % |
| (schema_extension, schema)) |