summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authorteravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-27 19:05:05 +0000
committerteravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-27 19:05:05 +0000
commitd4eca59b36fc7957334f425de843022176b7dcfd (patch)
tree5a72050644995dcb54855b5801ba3905919df3af /ppapi
parent17a1e2c3614b1e0915df40b380d814ce51ce0a0d (diff)
downloadchromium_src-d4eca59b36fc7957334f425de843022176b7dcfd.zip
chromium_src-d4eca59b36fc7957334f425de843022176b7dcfd.tar.gz
chromium_src-d4eca59b36fc7957334f425de843022176b7dcfd.tar.bz2
Pepper: Simplify IDLVisitor.
This change cleans up some unnecessary code in IDLVisitor and IDLLabelResolver. I was poking around in here as part of supporting "dev channel" API versions, and figured it's worth cleaning up. For testing, I ran idl_tests.py, and confirmed that generator.py gave the same output as before. BUG= R=bbudge@chromium.org Review URL: https://codereview.chromium.org/91763003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@237609 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/generators/idl_ast.py13
-rwxr-xr-xppapi/generators/idl_parser.py1
-rw-r--r--ppapi/generators/idl_visitor.py42
3 files changed, 4 insertions, 52 deletions
diff --git a/ppapi/generators/idl_ast.py b/ppapi/generators/idl_ast.py
index 3c2b32d..ce5dc38 100644
--- a/ppapi/generators/idl_ast.py
+++ b/ppapi/generators/idl_ast.py
@@ -27,16 +27,6 @@ BuiltIn = set(['int8_t', 'int16_t', 'int32_t', 'int64_t', 'uint8_t',
# The mapping is applied to the File nodes within the AST.
#
class IDLLabelResolver(IDLVisitor):
- def Arrive(self, node, ignore):
- # If we are entering a File, clear the visitor local mapping
- if node.IsA('File'):
- self.release_map = None
- self.filenode = node
- # For any non AST node, the filenode is the last known file
- if not node.IsA('AST'):
- node.filenode = self.filenode
- return ignore
-
def Depart(self, node, ignore, childdata):
# Build list of Release=Version
if node.IsA('LabelItem'):
@@ -46,8 +36,7 @@ class IDLLabelResolver(IDLVisitor):
# name of the label matches the generation label.
if node.IsA('Label') and node.GetName() == GetOption('label'):
try:
- self.release_map = IDLReleaseMap(childdata)
- node.parent.release_map = self.release_map
+ node.parent.release_map = IDLReleaseMap(childdata)
except Exception as err:
node.Error('Unable to build release map: %s' % str(err))
diff --git a/ppapi/generators/idl_parser.py b/ppapi/generators/idl_parser.py
index 2c526fb..6f0ea12 100755
--- a/ppapi/generators/idl_parser.py
+++ b/ppapi/generators/idl_parser.py
@@ -35,7 +35,6 @@ from idl_lexer import IDLLexer
from idl_node import IDLAttribute, IDLFile, IDLNode
from idl_option import GetOption, Option, ParseOptions
from idl_lint import Lint
-from idl_visitor import IDLVisitor
from ply import lex
from ply import yacc
diff --git a/ppapi/generators/idl_visitor.py b/ppapi/generators/idl_visitor.py
index 1ea1c9c..7945f61 100644
--- a/ppapi/generators/idl_visitor.py
+++ b/ppapi/generators/idl_visitor.py
@@ -19,30 +19,22 @@
class IDLVisitor(object):
def __init__(self):
- self.depth = 0
+ pass
# Return TRUE if the node should be visited
def VisitFilter(self, node, data):
return True
- # Return TRUE if data should be added to the childdata list
- def AgrigateFilter(self, data):
- return data is not None
-
def Visit(self, node, data):
- self.depth += 1
if not self.VisitFilter(node, data): return None
childdata = []
newdata = self.Arrive(node, data)
for child in node.GetChildren():
ret = self.Visit(child, newdata)
- if self.AgrigateFilter(ret):
+ if ret is not None:
childdata.append(ret)
- out = self.Depart(node, newdata, childdata)
-
- self.depth -= 1
- return out
+ return self.Depart(node, newdata, childdata)
def Arrive(self, node, data):
__pychecker__ = 'unusednames=node'
@@ -51,31 +43,3 @@ class IDLVisitor(object):
def Depart(self, node, data, childdata):
__pychecker__ = 'unusednames=node,childdata'
return data
-
-
-#
-# IDLVersionVisitor
-#
-# The IDLVersionVisitor will only visit nodes with intervals that include the
-# version. It will also optionally filter based on a class list
-#
-class IDLVersionVisitor(object):
- def __init__(self, version, classList):
- self.version = version
- self.classes = classes
-
- def Filter(self, node, data):
- if self.classList and node.cls not in self.classList: return False
- if not node.IsVersion(self.version): return False
- return True
-
-class IDLRangeVisitor(object):
- def __init__(self, vmin, vmax, classList):
- self.vmin = vmin
- self.vmax = vmax
- self.classList = classList
-
- def Filter(self, node, data):
- if self.classList and node.cls not in self.classList: return False
- if not node.IsVersion(self.version): return False
- return True