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

Unified Diff: tools/json_schema_compiler/h_generator.py

Issue 1100333006: Make the JSON Schema compiler handle enums declared in other namespaces. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: typo Created 5 years, 8 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 | « tools/json_schema_compiler/cc_generator.py ('k') | tools/json_schema_compiler/test/crossref.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/json_schema_compiler/h_generator.py
diff --git a/tools/json_schema_compiler/h_generator.py b/tools/json_schema_compiler/h_generator.py
index 566df071cd83b49026e454bd08353b5b8530b263..facd5e4e6a560263cbc46a810c1cc8a4f1f680cd 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,
« no previous file with comments | « tools/json_schema_compiler/cc_generator.py ('k') | tools/json_schema_compiler/test/crossref.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698