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

Unified Diff: tools/json_schema_compiler/model.py

Issue 11826048: Revert 176015 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 11 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/compiler.py ('k') | tools/json_schema_compiler/schema_bundle_generator.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/json_schema_compiler/model.py
===================================================================
--- tools/json_schema_compiler/model.py (revision 176046)
+++ tools/json_schema_compiler/model.py (working copy)
@@ -26,12 +26,10 @@
def __init__(self):
self.namespaces = {}
- def AddNamespace(self, json, source_file, include_compiler_options=False):
+ def AddNamespace(self, json, source_file):
"""Add a namespace's json to the model and returns the namespace.
"""
- namespace = Namespace(json,
- source_file,
- include_compiler_options=include_compiler_options)
+ namespace = Namespace(json, source_file)
self.namespaces[namespace.name] = namespace
return namespace
@@ -44,28 +42,21 @@
- |source_file| the file that contained the namespace definition
- |source_file_dir| the directory component of |source_file|
- |source_file_filename| the filename component of |source_file|
- - |platforms| if not None, the list of platforms that the namespace is
- available to
- |types| a map of type names to their model.Type
- |functions| a map of function names to their model.Function
- |events| a map of event names to their model.Function
- |properties| a map of property names to their model.Property
- - |compiler_options| the compiler_options dict, only present if
- |include_compiler_options| is True
"""
- def __init__(self, json, source_file, include_compiler_options=False):
+ def __init__(self, json, source_file):
self.name = json['namespace']
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.parent = None
- self.platforms = _GetPlatforms(json)
_AddTypes(self, json, self)
_AddFunctions(self, json, self)
_AddEvents(self, json, self)
_AddProperties(self, json, self)
- if include_compiler_options:
- self.compiler_options = json.get('compiler_options', {})
class Type(object):
"""A Type defined in the json.
@@ -136,15 +127,13 @@
Properties:
- |name| the function name
- - |platforms| if not None, the list of platforms that the function is
- available to
- |params| a list of parameters to the function (order matters). A separate
- parameter is used for each choice of a 'choices' parameter
+ parameter is used for each choice of a 'choices' parameter.
- |description| a description of the function (if provided)
- |callback| the callback parameter to the function. There should be exactly
- one
+ one
- |optional| whether the Function is "optional"; this only makes sense to be
- present when the Function is representing a callback property
+ present when the Function is representing a callback property.
- |simple_name| the name of this Function without a namespace
"""
def __init__(self,
@@ -155,7 +144,6 @@
from_client=False):
self.name = json['name']
self.simple_name = _StripNamespace(self.name, namespace)
- self.platforms = _GetPlatforms(json)
self.params = []
self.description = json.get('description')
self.callback = None
@@ -369,37 +357,23 @@
unix_name = property(GetUnixName, SetUnixName)
-class _Enum(object):
- """Superclass for enum types with a "name" field, setting up repr/eq/ne.
- Enums need to do this so that equality/non-equality work over pickling.
+class _PropertyTypeInfo(object):
+ """This class is not an inner class of |PropertyType| so it can be pickled.
"""
-
- @staticmethod
- def GetAll(cls):
- """Yields all _Enum objects declared in |cls|.
- """
- for prop_key in dir(cls):
- prop_value = getattr(cls, prop_key)
- if isinstance(prop_value, _Enum):
- yield prop_value
-
- def __init__(self, name):
+ def __init__(self, is_fundamental, name):
+ self.is_fundamental = is_fundamental
self.name = name
- def __repr(self):
+ def __repr__(self):
return self.name
def __eq__(self, other):
- return type(other) == type(self) and other.name == self.name
+ return isinstance(other, _PropertyTypeInfo) and self.name == other.name
def __ne__(self, other):
+ # Yes. You seriously do need this.
return not (self == other)
-class _PropertyTypeInfo(_Enum):
- def __init__(self, is_fundamental, name):
- _Enum.__init__(self, name)
- self.is_fundamental = is_fundamental
-
class PropertyType(object):
"""Enum of different types of properties/parameters.
"""
@@ -487,27 +461,3 @@
namespace,
from_json=from_json,
from_client=from_client)
-
-class _PlatformInfo(_Enum):
- def __init__(self, name):
- _Enum.__init__(self, name)
-
-class Platforms(object):
- """Enum of the possible platforms.
- """
- CHROMEOS = _PlatformInfo("chromeos")
- CHROMEOS_TOUCH = _PlatformInfo("chromeos_touch")
- LINUX = _PlatformInfo("linux")
- MAC = _PlatformInfo("mac")
- WIN = _PlatformInfo("win")
-
-def _GetPlatforms(json):
- if 'platforms' not in json:
- return None
- platforms = []
- for platform_name in json['platforms']:
- for platform_enum in _Enum.GetAll(Platforms):
- if platform_name == platform_enum.name:
- platforms.append(platform_enum)
- break
- return platforms
« no previous file with comments | « tools/json_schema_compiler/compiler.py ('k') | tools/json_schema_compiler/schema_bundle_generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698