diff options
author | kalman <kalman@chromium.org> | 2015-04-23 17:33:29 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-24 00:33:39 +0000 |
commit | 16a9133a26d076f649a7bf402a88c5aa709a45da (patch) | |
tree | eb4467b4564f010ad8046fe69945f5172a5cb735 /tools/json_schema_compiler/h_generator.py | |
parent | 83e6f6f8603ab57e1a4d16a7d6e7802e4b8ffc2b (diff) | |
download | chromium_src-16a9133a26d076f649a7bf402a88c5aa709a45da.zip chromium_src-16a9133a26d076f649a7bf402a88c5aa709a45da.tar.gz chromium_src-16a9133a26d076f649a7bf402a88c5aa709a45da.tar.bz2 |
Make the JSON Schema compiler handle enums declared in other namespaces.
BUG=477457
R=rdevlin.cronin@chromium.org
Review URL: https://codereview.chromium.org/1100333006
Cr-Commit-Position: refs/heads/master@{#326703}
Diffstat (limited to 'tools/json_schema_compiler/h_generator.py')
-rw-r--r-- | tools/json_schema_compiler/h_generator.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/tools/json_schema_compiler/h_generator.py b/tools/json_schema_compiler/h_generator.py index 566df07..facd5e4 100644 --- a/tools/json_schema_compiler/h_generator.py +++ b/tools/json_schema_compiler/h_generator.py @@ -41,6 +41,12 @@ class _Generator(object): output_file = os.path.splitext(self._namespace.source_file)[0] + '.h' ifndef_name = cpp_util.GenerateIfndefName(output_file) + # Hack: tabs and windows have circular references, so only generate hard + # references for them (i.e. anything that can't be forward declared). In + # other cases, generate soft dependencies so that they can include + # non-optional types from other namespaces. + include_soft = self._namespace.name not in ('tabs', 'windows') + (c.Append('#ifndef %s' % ifndef_name) .Append('#define %s' % ifndef_name) .Append() @@ -53,15 +59,14 @@ class _Generator(object): .Append('#include "base/memory/linked_ptr.h"') .Append('#include "base/memory/scoped_ptr.h"') .Append('#include "base/values.h"') - .Cblock(self._type_helper.GenerateIncludes()) + .Cblock(self._type_helper.GenerateIncludes(include_soft=include_soft)) .Append() ) - # TODO(calamity): These forward declarations should be #includes to allow - # $ref types from other files to be used as required params. This requires - # some detangling of windows and tabs which will currently lead to circular - # #includes. - c.Cblock(self._type_helper.GenerateForwardDeclarations()) + # Hack: we're not generating soft includes for tabs and windows, so we need + # to generate forward declarations for them. + if not include_soft: + c.Cblock(self._type_helper.GenerateForwardDeclarations()) cpp_namespace = cpp_util.GetCppNamespace( self._namespace.environment.namespace_pattern, |