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

Unified Diff: mojo/public/tools/bindings/pylib/mojom/parse/ast.py

Issue 365993006: Mojo: bindings generator: Add AST types for attributes and attribute lists. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 6 years, 6 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 | « no previous file | mojo/public/tools/bindings/pylib/mojom/parse/parser.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/tools/bindings/pylib/mojom/parse/ast.py
diff --git a/mojo/public/tools/bindings/pylib/mojom/parse/ast.py b/mojo/public/tools/bindings/pylib/mojom/parse/ast.py
index 78017e56a645aecc25fae1e960942f9796981269..9f3088e3fc1ea7d0fa43bfbeb80b90fe6062c0e4 100644
--- a/mojo/public/tools/bindings/pylib/mojom/parse/ast.py
+++ b/mojo/public/tools/bindings/pylib/mojom/parse/ast.py
@@ -17,33 +17,6 @@ class NodeBase(object):
self.lineno = lineno
-class Ordinal(NodeBase):
- """Represents an ordinal value labeling, e.g., a struct field."""
-
- def __init__(self, value, **kwargs):
- NodeBase.__init__(self, **kwargs)
- self.value = value
-
- def __eq__(self, other):
- return self.value == other.value
-
-
-class Parameter(NodeBase):
- """Represents a method request or response parameter."""
-
- def __init__(self, typename, name, ordinal, **kwargs):
- assert isinstance(ordinal, Ordinal)
- NodeBase.__init__(self, **kwargs)
- self.typename = typename
- self.name = name
- self.ordinal = ordinal
-
- def __eq__(self, other):
- return self.typename == other.typename and \
- self.name == other.name and \
- self.ordinal == other.ordinal
-
-
class NodeListBase(NodeBase):
"""Represents a list of other nodes, all having the same type. (This is meant
to be subclassed, with subclasses defining _list_item_type to be the class of
@@ -88,6 +61,56 @@ class NodeListBase(NodeBase):
self.lineno = self.elements[0].lineno
+################################################################################
+
+
+class Attribute(NodeBase):
+ """Represents an attribute."""
+
+ def __init__(self, key, value, **kwargs):
+ assert isinstance(key, str)
+ NodeBase.__init__(self, **kwargs)
+ self.key = key
+ self.value = value
+
+ def __eq__(self, other):
+ return self.key == other.key and self.value == other.value
+
+
+class AttributeList(NodeListBase):
+ """Represents a list attributes."""
+
+ _list_item_type = Attribute
+
+
+class Ordinal(NodeBase):
+ """Represents an ordinal value labeling, e.g., a struct field."""
+
+ def __init__(self, value, **kwargs):
+ assert value is None or isinstance(value, int)
+ NodeBase.__init__(self, **kwargs)
+ self.value = value
+
+ def __eq__(self, other):
+ return self.value == other.value
+
+
+class Parameter(NodeBase):
+ """Represents a method request or response parameter."""
+
+ def __init__(self, typename, name, ordinal, **kwargs):
+ assert isinstance(ordinal, Ordinal)
+ NodeBase.__init__(self, **kwargs)
+ self.typename = typename
+ self.name = name
+ self.ordinal = ordinal
+
+ def __eq__(self, other):
+ return self.typename == other.typename and \
+ self.name == other.name and \
+ self.ordinal == other.ordinal
+
+
class ParameterList(NodeListBase):
"""Represents a list of (method request or response) parameters."""
« no previous file with comments | « no previous file | mojo/public/tools/bindings/pylib/mojom/parse/parser.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698