diff options
author | rdevlin.cronin <rdevlin.cronin@chromium.org> | 2015-04-06 10:19:18 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-06 17:35:43 +0000 |
commit | 00f1fc22bfcc653b47d62778170af3eee9855720 (patch) | |
tree | 2386d4a7e984d7db6f9cfa0c07409a715832993e /tools/json_schema_compiler/model.py | |
parent | 86b507da14efeb641795641b24c49f57a07ae879 (diff) | |
download | chromium_src-00f1fc22bfcc653b47d62778170af3eee9855720.zip chromium_src-00f1fc22bfcc653b47d62778170af3eee9855720.tar.gz chromium_src-00f1fc22bfcc653b47d62778170af3eee9855720.tar.bz2 |
[Extensions API] Remove inline enums
Remove all inlined enums from extension APIs.
BUG=472279
TBR=derat@chromium.org (mechanical changes to chrome/browser/chromeos/app_mode/kiosk_app_update_service.cc and chrome/browser/ui/ash/ash_keyboard_controller_proxy.cc)
Review URL: https://codereview.chromium.org/1055673002
Cr-Commit-Position: refs/heads/master@{#323912}
Diffstat (limited to 'tools/json_schema_compiler/model.py')
-rw-r--r-- | tools/json_schema_compiler/model.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/tools/json_schema_compiler/model.py b/tools/json_schema_compiler/model.py index 3f7b2fe..642e818 100644 --- a/tools/json_schema_compiler/model.py +++ b/tools/json_schema_compiler/model.py @@ -24,7 +24,8 @@ class Model(object): Properties: - |namespaces| a map of a namespace name to its model.Namespace """ - def __init__(self): + def __init__(self, allow_inline_enums=True): + self._allow_inline_enums = allow_inline_enums self.namespaces = {} def AddNamespace(self, @@ -37,7 +38,8 @@ class Model(object): namespace = Namespace(json, source_file, include_compiler_options=include_compiler_options, - environment=environment) + environment=environment, + allow_inline_enums=self._allow_inline_enums) self.namespaces[namespace.name] = namespace return namespace @@ -104,7 +106,8 @@ class Namespace(object): json, source_file, include_compiler_options=False, - environment=None): + environment=None, + allow_inline_enums=True): self.name = json['namespace'] if 'description' not in json: # TODO(kalman): Go back to throwing an error here. @@ -118,6 +121,7 @@ class Namespace(object): 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.allow_inline_enums = allow_inline_enums self.platforms = _GetPlatforms(json) toplevel_origin = Origin(from_client=True, from_json=True) self.types = _GetTypes(self, json, self, toplevel_origin) @@ -198,6 +202,11 @@ class Type(object): self.property_type = PropertyType.REF self.ref_type = json['$ref'] elif 'enum' in json and json_type == 'string': + if not namespace.allow_inline_enums and not isinstance(parent, Namespace): + raise ParseException( + self, + 'Inline enum "%s" found in namespace "%s". These are not allowed. ' + 'See crbug.com/472279' % (name, namespace.name)) self.property_type = PropertyType.ENUM self.enum_values = [EnumValue(value) for value in json['enum']] self.cpp_enum_prefix_override = json.get('cpp_enum_prefix_override', None) |