summaryrefslogtreecommitdiffstats
path: root/tools/json_schema_compiler
diff options
context:
space:
mode:
authorcduvall@chromium.org <cduvall@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-12 02:22:21 +0000
committercduvall@chromium.org <cduvall@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-12 02:22:21 +0000
commit15a28fd05ef7f31a705078b35539cc62a4cf603b (patch)
tree3e2f777c5a7c1492f73b808b5545894f4bf51e1a /tools/json_schema_compiler
parent797510b8b3b3e68457476680ea1fdb40eb23ab45 (diff)
downloadchromium_src-15a28fd05ef7f31a705078b35539cc62a4cf603b.zip
chromium_src-15a28fd05ef7f31a705078b35539cc62a4cf603b.tar.gz
chromium_src-15a28fd05ef7f31a705078b35539cc62a4cf603b.tar.bz2
Files generated by the JSON schema compiler are named incorrectly
Files are now named like "file_name.h" instead of "fileName.h" or "file.name.h", and all the JSON files have been renamed. BUG=125669 TEST=All previous tests for the renamed files Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=135077 Review URL: https://chromiumcodereview.appspot.com/10272021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@136747 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/json_schema_compiler')
-rw-r--r--tools/json_schema_compiler/cc_generator.py2
-rwxr-xr-xtools/json_schema_compiler/compiler.py28
-rwxr-xr-xtools/json_schema_compiler/cpp_type_generator_test.py16
-rw-r--r--tools/json_schema_compiler/test/additional_properties.json (renamed from tools/json_schema_compiler/test/additionalProperties.json)0
-rw-r--r--tools/json_schema_compiler/test/additional_properties_unittest.cc2
-rw-r--r--tools/json_schema_compiler/test/browser_action.json (renamed from tools/json_schema_compiler/test/browserAction.json)0
-rw-r--r--tools/json_schema_compiler/test/dependency_tester.json (renamed from tools/json_schema_compiler/test/dependencyTester.json)0
-rw-r--r--tools/json_schema_compiler/test/font_settings.json (renamed from tools/json_schema_compiler/test/fontSettings.json)0
-rw-r--r--tools/json_schema_compiler/test/functions_on_types.json (renamed from tools/json_schema_compiler/test/functionsOnTypes.json)0
-rw-r--r--tools/json_schema_compiler/test/functions_on_types_unittest.cc2
-rw-r--r--tools/json_schema_compiler/test/json_schema_compiler_tests.gyp4
11 files changed, 36 insertions, 18 deletions
diff --git a/tools/json_schema_compiler/cc_generator.py b/tools/json_schema_compiler/cc_generator.py
index 508e0f2..4ba5b37 100644
--- a/tools/json_schema_compiler/cc_generator.py
+++ b/tools/json_schema_compiler/cc_generator.py
@@ -33,7 +33,7 @@ class CCGenerator(object):
.Append()
.Append(self._util_cc_helper.GetIncludePath())
.Append('#include "%s/%s.h"' %
- (self._namespace.source_file_dir, self._namespace.name))
+ (self._namespace.source_file_dir, self._namespace.unix_name))
)
includes = self._cpp_type_generator.GenerateIncludes()
if not includes.IsEmpty():
diff --git a/tools/json_schema_compiler/compiler.py b/tools/json_schema_compiler/compiler.py
index 1d08841..593f687 100755
--- a/tools/json_schema_compiler/compiler.py
+++ b/tools/json_schema_compiler/compiler.py
@@ -38,12 +38,16 @@ def load_schema(schema):
else:
sys.exit("Did not recognize file extension %s for schema %s" %
(schema_extension, schema))
+ if len(api_defs) != 1:
+ sys.exit("File %s has multiple schemas. Files are only allowed to contain a"
+ " single schema." % schema)
return api_defs
def handle_single_schema(filename, dest_dir, root, root_namespace):
schema = os.path.normpath(filename)
schema_filename, schema_extension = os.path.splitext(schema)
+ path, short_filename = os.path.split(schema_filename)
api_defs = load_schema(schema)
api_model = model.Model()
@@ -68,9 +72,13 @@ def handle_single_schema(filename, dest_dir, root, root_namespace):
if not namespace:
continue
+ if short_filename != namespace.unix_name:
+ sys.exit("Filename %s is illegal. Name files using unix_hacker style." %
+ filename)
+
# The output filename must match the input filename for gyp to deal with it
# properly.
- out_file = namespace.name
+ out_file = namespace.unix_name
type_generator = cpp_type_generator.CppTypeGenerator(
root_namespace, namespace, namespace.unix_name)
for referenced_namespace in api_model.namespaces.values():
@@ -78,7 +86,7 @@ def handle_single_schema(filename, dest_dir, root, root_namespace):
continue
type_generator.AddNamespace(
referenced_namespace,
- referenced_namespace.name)
+ referenced_namespace.unix_name)
h_code = (h_generator.HGenerator(namespace, type_generator)
.Generate().Render())
@@ -113,14 +121,24 @@ def handle_bundle_schema(filenames, dest_dir, root, root_namespace):
api_model = model.Model()
relpath = os.path.relpath(os.path.normpath(filenames[0]), root)
- for target_namespace in api_defs:
- api_model.AddNamespace(target_namespace, relpath)
+
+ for target_namespace, schema_filename in zip(api_defs, filenames):
+ namespace = api_model.AddNamespace(target_namespace, relpath)
+ path, filename = os.path.split(schema_filename)
+ short_filename, extension = os.path.splitext(filename)
+
+ # Filenames are checked against the unix_names of the namespaces they
+ # generate because the gyp uses the names of the JSON files to generate
+ # the names of the .cc and .h files. We want these to be using unix_names.
+ if namespace.unix_name != short_filename:
+ sys.exit("Filename %s is illegal. Name files using unix_hacker style." %
+ schema_filename)
type_generator = cpp_type_generator.CppTypeGenerator(root_namespace)
for referenced_namespace in api_model.namespaces.values():
type_generator.AddNamespace(
referenced_namespace,
- referenced_namespace.name)
+ referenced_namespace.unix_name)
generator = schema_bundle_generator.SchemaBundleGenerator(
api_model, api_defs, type_generator)
diff --git a/tools/json_schema_compiler/cpp_type_generator_test.py b/tools/json_schema_compiler/cpp_type_generator_test.py
index 46b10a2..70d3e74 100755
--- a/tools/json_schema_compiler/cpp_type_generator_test.py
+++ b/tools/json_schema_compiler/cpp_type_generator_test.py
@@ -23,17 +23,17 @@ class CppTypeGeneratorTest(unittest.TestCase):
self.model.AddNamespace(self.tabs_json[0],
'path/to/tabs.json')
self.tabs = self.model.namespaces.get('tabs')
- self.browser_action_json = CachedLoad('test/browserAction.json')
+ self.browser_action_json = CachedLoad('test/browser_action.json')
self.model.AddNamespace(self.browser_action_json[0],
- 'path/to/browserAction.json')
+ 'path/to/browser_action.json')
self.browser_action = self.model.namespaces.get('browserAction')
- self.font_settings_json = CachedLoad('test/fontSettings.json')
+ self.font_settings_json = CachedLoad('test/font_settings.json')
self.model.AddNamespace(self.font_settings_json[0],
- 'path/to/fontSettings.json')
+ 'path/to/font_settings.json')
self.font_settings = self.model.namespaces.get('fontSettings')
- self.dependency_tester_json = CachedLoad('test/dependencyTester.json')
+ self.dependency_tester_json = CachedLoad('test/dependency_tester.json')
self.model.AddNamespace(self.dependency_tester_json[0],
- 'path/to/dependencyTester.json')
+ 'path/to/dependency_tester.json')
self.dependency_tester = self.model.namespaces.get('dependencyTester')
def testGenerateIncludesAndForwardDeclarations(self):
@@ -82,9 +82,9 @@ class CppTypeGeneratorTest(unittest.TestCase):
def testGenerateIncludesAndForwardDeclarationsDependencies(self):
m = model.Model()
browser_action_namespace = m.AddNamespace(self.browser_action_json[0],
- 'path/to/browserAction.json')
+ 'path/to/browser_action.json')
font_settings_namespace = m.AddNamespace(self.font_settings_json[0],
- 'path/to/fontSettings.json')
+ 'path/to/font_settings.json')
manager = CppTypeGenerator('', self.dependency_tester,
self.dependency_tester.unix_name)
manager.AddNamespace(browser_action_namespace,
diff --git a/tools/json_schema_compiler/test/additionalProperties.json b/tools/json_schema_compiler/test/additional_properties.json
index 03bbef8..03bbef8 100644
--- a/tools/json_schema_compiler/test/additionalProperties.json
+++ b/tools/json_schema_compiler/test/additional_properties.json
diff --git a/tools/json_schema_compiler/test/additional_properties_unittest.cc b/tools/json_schema_compiler/test/additional_properties_unittest.cc
index 978d6ff..ef0ab29 100644
--- a/tools/json_schema_compiler/test/additional_properties_unittest.cc
+++ b/tools/json_schema_compiler/test/additional_properties_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "tools/json_schema_compiler/test/additionalProperties.h"
+#include "tools/json_schema_compiler/test/additional_properties.h"
#include "testing/gtest/include/gtest/gtest.h"
diff --git a/tools/json_schema_compiler/test/browserAction.json b/tools/json_schema_compiler/test/browser_action.json
index 6288fab..6288fab 100644
--- a/tools/json_schema_compiler/test/browserAction.json
+++ b/tools/json_schema_compiler/test/browser_action.json
diff --git a/tools/json_schema_compiler/test/dependencyTester.json b/tools/json_schema_compiler/test/dependency_tester.json
index aec4c15..aec4c15 100644
--- a/tools/json_schema_compiler/test/dependencyTester.json
+++ b/tools/json_schema_compiler/test/dependency_tester.json
diff --git a/tools/json_schema_compiler/test/fontSettings.json b/tools/json_schema_compiler/test/font_settings.json
index be68083..be68083 100644
--- a/tools/json_schema_compiler/test/fontSettings.json
+++ b/tools/json_schema_compiler/test/font_settings.json
diff --git a/tools/json_schema_compiler/test/functionsOnTypes.json b/tools/json_schema_compiler/test/functions_on_types.json
index e8c8220..e8c8220 100644
--- a/tools/json_schema_compiler/test/functionsOnTypes.json
+++ b/tools/json_schema_compiler/test/functions_on_types.json
diff --git a/tools/json_schema_compiler/test/functions_on_types_unittest.cc b/tools/json_schema_compiler/test/functions_on_types_unittest.cc
index 41a276c..0694cb3 100644
--- a/tools/json_schema_compiler/test/functions_on_types_unittest.cc
+++ b/tools/json_schema_compiler/test/functions_on_types_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "tools/json_schema_compiler/test/functionsOnTypes.h"
+#include "tools/json_schema_compiler/test/functions_on_types.h"
#include "testing/gtest/include/gtest/gtest.h"
diff --git a/tools/json_schema_compiler/test/json_schema_compiler_tests.gyp b/tools/json_schema_compiler/test/json_schema_compiler_tests.gyp
index ecfd81a..f48809c 100644
--- a/tools/json_schema_compiler/test/json_schema_compiler_tests.gyp
+++ b/tools/json_schema_compiler/test/json_schema_compiler_tests.gyp
@@ -11,12 +11,12 @@
'chromium_code': 1,
'json_schema_files': [
'any.json',
- 'additionalProperties.json',
+ 'additional_properties.json',
'arrays.json',
'choices.json',
'crossref.json',
'enums.json',
- 'functionsOnTypes.json',
+ 'functions_on_types.json',
'objects.json',
'simple_api.json',
],