summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authordtseng@chromium.org <dtseng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-09 10:45:09 +0000
committerdtseng@chromium.org <dtseng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-09 10:45:09 +0000
commit70e263e2fbd7c254a0bf462cd8e409a0102eec10 (patch)
treeb6ddf2f54e160abe97adebf6c87ca232744a660d /tools
parent36c70f67d90318f5d13735b9a88188a0f186515c (diff)
downloadchromium_src-70e263e2fbd7c254a0bf462cd8e409a0102eec10.zip
chromium_src-70e263e2fbd7c254a0bf462cd8e409a0102eec10.tar.gz
chromium_src-70e263e2fbd7c254a0bf462cd8e409a0102eec10.tar.bz2
Generate ax enums from idl.
This cl lays the groundwork for sharing all ax enums between platfrom accessibility and extension accessibility. BUG= Review URL: https://codereview.chromium.org/143473003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@249993 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools')
-rw-r--r--tools/json_schema_compiler/cc_generator.py3
-rwxr-xr-xtools/json_schema_compiler/compiler.py11
-rw-r--r--tools/json_schema_compiler/cpp_type_generator.py5
-rw-r--r--tools/json_schema_compiler/cpp_util.py8
-rw-r--r--tools/json_schema_compiler/idl_schema.py3
-rw-r--r--tools/json_schema_compiler/model.py2
6 files changed, 19 insertions, 13 deletions
diff --git a/tools/json_schema_compiler/cc_generator.py b/tools/json_schema_compiler/cc_generator.py
index 68152b5..04d951b 100644
--- a/tools/json_schema_compiler/cc_generator.py
+++ b/tools/json_schema_compiler/cc_generator.py
@@ -46,7 +46,7 @@ class _Generator(object):
.Append('#include "base/strings/string_number_conversions.h"')
.Append('#include "base/strings/utf_string_conversions.h"')
.Append('#include "%s/%s.h"' %
- (self._namespace.source_file_dir, self._namespace.unix_name))
+ (self._namespace.source_file_dir, self._namespace.short_filename))
.Cblock(self._type_helper.GenerateIncludes(include_soft=True))
.Append()
.Concat(cpp_util.OpenNamespace(self._cpp_namespace))
@@ -91,6 +91,7 @@ class _Generator(object):
(c.Concat(self._type_helper.GetNamespaceEnd())
.Cblock(cpp_util.CloseNamespace(self._cpp_namespace))
)
+ c.Append()
return c
def _GenerateType(self, cpp_namespace, type_):
diff --git a/tools/json_schema_compiler/compiler.py b/tools/json_schema_compiler/compiler.py
index 21281fc..c79beaec 100755
--- a/tools/json_schema_compiler/compiler.py
+++ b/tools/json_schema_compiler/compiler.py
@@ -71,13 +71,6 @@ def GenerateSchema(generator,
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)
-
# Construct the type generator with all the namespaces in this model.
type_generator = CppTypeGenerator(api_model,
schema_loader,
@@ -99,8 +92,8 @@ def GenerateSchema(generator,
elif generator == 'cpp':
cpp_generator = CppGenerator(type_generator, root_namespace)
generators = [
- ('%s.h' % namespace.unix_name, cpp_generator.h_generator),
- ('%s.cc' % namespace.unix_name, cpp_generator.cc_generator)
+ ('%s.h' % short_filename, cpp_generator.h_generator),
+ ('%s.cc' % short_filename, cpp_generator.cc_generator)
]
elif generator == 'dart':
generators = [
diff --git a/tools/json_schema_compiler/cpp_type_generator.py b/tools/json_schema_compiler/cpp_type_generator.py
index d485b46..244cbda 100644
--- a/tools/json_schema_compiler/cpp_type_generator.py
+++ b/tools/json_schema_compiler/cpp_type_generator.py
@@ -64,8 +64,9 @@ class CppTypeGenerator(object):
e.g VAR_STRING
"""
- value = '%s_%s' % (self.FollowRef(type_).unix_name.upper(),
- cpp_util.Classname(enum_value.name.upper()))
+ value = cpp_util.Classname(enum_value.name.upper())
+ if not type_.cpp_omit_enum_type:
+ value = '%s_%s' % (self.FollowRef(type_).unix_name.upper(), value)
# To avoid collisions with built-in OS_* preprocessor definitions, we add a
# trailing slash to enum names that start with OS_.
if value.startswith("OS_"):
diff --git a/tools/json_schema_compiler/cpp_util.py b/tools/json_schema_compiler/cpp_util.py
index 1e7c370..e7c29ac 100644
--- a/tools/json_schema_compiler/cpp_util.py
+++ b/tools/json_schema_compiler/cpp_util.py
@@ -110,6 +110,10 @@ def OpenNamespace(namespace):
"""Get opening root namespace declarations.
"""
c = Code()
+ # In lieu of GYP supporting None for the namespace variable the '' namespace
+ # implies there is no root namespace.
+ if namespace == '':
+ return c
for component in namespace.split('::'):
c.Append('namespace %s {' % component)
return c
@@ -119,6 +123,10 @@ def CloseNamespace(namespace):
"""Get closing root namespace declarations.
"""
c = Code()
+ # In lieu of GYP supporting None for the namespace variable the '' namespace
+ # implies there is no root namespace.
+ if namespace == '':
+ return c
for component in reversed(namespace.split('::')):
c.Append('} // namespace %s' % component)
return c
diff --git a/tools/json_schema_compiler/idl_schema.py b/tools/json_schema_compiler/idl_schema.py
index 62d31ed..bc8b2bf 100644
--- a/tools/json_schema_compiler/idl_schema.py
+++ b/tools/json_schema_compiler/idl_schema.py
@@ -309,7 +309,8 @@ class Enum(object):
'description': self.description,
'type': 'string',
'enum': enum}
- for property_name in ('inline_doc', 'noinline_doc', 'nodoc'):
+ for property_name in (
+ 'inline_doc', 'noinline_doc', 'nodoc', 'cpp_omit_enum_type',):
if self.node.GetProperty(property_name):
result[property_name] = True
if self.node.GetProperty('deprecated'):
diff --git a/tools/json_schema_compiler/model.py b/tools/json_schema_compiler/model.py
index e0dabb1..967e9ab 100644
--- a/tools/json_schema_compiler/model.py
+++ b/tools/json_schema_compiler/model.py
@@ -107,6 +107,7 @@ class Namespace(object):
self.unix_name = UnixName(self.name)
self.source_file = source_file
self.source_file_dir, self.source_file_filename = os.path.split(source_file)
+ self.short_filename = os.path.basename(source_file).split('.')[0]
self.parent = None
self.platforms = _GetPlatforms(json)
toplevel_origin = Origin(from_client=True, from_json=True)
@@ -189,6 +190,7 @@ class Type(object):
elif 'enum' in json and json_type == 'string':
self.property_type = PropertyType.ENUM
self.enum_values = [EnumValue(value) for value in json['enum']]
+ self.cpp_omit_enum_type = 'cpp_omit_enum_type' in json
elif json_type == 'any':
self.property_type = PropertyType.ANY
elif json_type == 'binary':