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

Unified Diff: bindings/scripts/blink_idl_lexer.py

Issue 581453002: Dartium Roll 38 roll (Closed) Base URL: https://dart.googlecode.com/svn/third_party/WebCore
Patch Set: Sync'd w/ r 182210 Created 6 years, 3 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 | « bindings/scripts/aggregate_generated_bindings.py ('k') | bindings/scripts/blink_idl_parser.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bindings/scripts/blink_idl_lexer.py
diff --git a/bindings/scripts/blink_idl_lexer.py b/bindings/scripts/blink_idl_lexer.py
index bbde34268b44c0b97fd797d19523eef48f586005..ba68c6c7dce1f27fee35f768d536401abfe5520b 100644
--- a/bindings/scripts/blink_idl_lexer.py
+++ b/bindings/scripts/blink_idl_lexer.py
@@ -69,6 +69,7 @@ tools_dir = os.path.join(third_party, os.pardir, 'tools')
sys.path.append(tools_dir)
from idl_parser.idl_lexer import IDLLexer
+LEXTAB = 'lextab'
REMOVE_TOKENS = ['COMMENT']
@@ -88,7 +89,8 @@ class BlinkIDLLexer(IDLLexer):
for token in tokens:
self._RemoveToken(token)
- def __init__(self, debug=False, optimize=True, outputdir=None):
+ def __init__(self, debug=False, optimize=True, outputdir=None,
+ rewrite_tables=False):
if debug:
# Turn off optimization and caching to help debugging
optimize = False
@@ -98,6 +100,16 @@ class BlinkIDLLexer(IDLLexer):
# as a Python module
sys.path.append(outputdir)
+ if rewrite_tables:
+ tablefile_root = os.path.join(outputdir, LEXTAB)
+ # Also remove the .pyc/.pyo files, or they'll be used even if
+ # the .py file doesn't exist.
+ for ext in ('.py', '.pyc', '.pyo'):
+ try:
+ os.unlink(tablefile_root + ext)
+ except OSError:
+ pass
+
IDLLexer.__init__(self)
# Overrides to parent class
self._RemoveTokens(REMOVE_TOKENS)
@@ -108,6 +120,7 @@ class BlinkIDLLexer(IDLLexer):
self._lexobj = lex.lex(object=self,
debug=debug,
optimize=optimize,
+ lextab=LEXTAB,
outputdir=outputdir)
@@ -120,7 +133,10 @@ def main(argv):
except IndexError as err:
print 'Usage: %s OUTPUT_DIR' % argv[0]
return 1
- lexer = BlinkIDLLexer(outputdir=outputdir)
+ # Important: rewrite_tables=True causes the cache file to be deleted if it
+ # exists, thus making sure that PLY doesn't load it instead of regenerating
+ # the parse table.
+ lexer = BlinkIDLLexer(outputdir=outputdir, rewrite_tables=True)
if __name__ == '__main__':
« no previous file with comments | « bindings/scripts/aggregate_generated_bindings.py ('k') | bindings/scripts/blink_idl_parser.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698