Merge changes I21f54c67,I41f6e493,I6f2ae636

* changes:
  Allow more symbol file tags at top level.
  Add a new tag to NDK symbol files: future.
  Don't warn for TODOish comments.
This commit is contained in:
Treehugger Robot 2016-08-01 23:06:54 +00:00 committed by Gerrit Code Review
commit 3a5af487f2
2 changed files with 35 additions and 8 deletions

View File

@ -65,12 +65,34 @@ class Stack(object):
return self.stack[-1]
def get_tags(line):
"""Returns a list of all tags on this line."""
_, _, all_tags = line.strip().partition('#')
return re.split(r'\s+', all_tags)
def version_is_private(version):
"""Returns True if the version name should be treated as private."""
return version.endswith('_PRIVATE') or version.endswith('_PLATFORM')
def enter_version(scope, line, version_file):
def should_omit_version(name, tags, arch, api):
"""Returns True if the version section should be ommitted.
We want to omit any sections that do not have any symbols we'll have in the
stub library. Sections that contain entirely future symbols or only symbols
for certain architectures.
"""
if version_is_private(name):
return True
if not symbol_in_arch(tags, arch):
return True
if not symbol_in_version(tags, arch, api):
return True
return False
def enter_version(scope, line, version_file, arch, api):
"""Enters a new version block scope."""
if scope.top != Scope.Top:
raise RuntimeError('Encountered nested version block.')
@ -78,7 +100,8 @@ def enter_version(scope, line, version_file):
# Entering a new version block. By convention symbols with versions ending
# with "_PRIVATE" or "_PLATFORM" are not included in the NDK.
version_name = line.split('{')[0].strip()
if version_is_private(version_name):
tags = get_tags(line)
if should_omit_version(version_name, tags, arch, api):
scope.push(Scope.Private)
else:
scope.push(Scope.Global) # By default symbols are visible.
@ -116,10 +139,10 @@ def leave_visibility(scope):
assert scope.top == Scope.Top
def handle_top_scope(scope, line, version_file):
def handle_top_scope(scope, line, version_file, arch, api):
"""Processes a line in the top level scope."""
if '{' in line:
enter_version(scope, line, version_file)
enter_version(scope, line, version_file, arch, api)
else:
raise RuntimeError('Unexpected contents at top level: ' + line)
@ -166,6 +189,11 @@ def symbol_in_version(tags, arch, version):
elif tag.startswith('introduced-' + arch + '='):
introduced_tag = tag
arch_specific = True
elif tag == 'future':
# This symbol is not in any released API level.
# TODO(danalbert): These need to be emitted for version == current.
# That's not a construct we have yet, so just skip it for now.
return False
if introduced_tag is None:
# We found no "introduced" tags, so the symbol has always been
@ -194,8 +222,7 @@ def handle_global_scope(scope, line, src_file, version_file, arch, api):
# Line is now in the format "<symbol-name>; # tags"
# Tags are whitespace separated.
symbol_name, _, rest = line.strip().partition(';')
_, _, all_tags = rest.partition('#')
tags = re.split(r'\s+', all_tags)
tags = get_tags(line)
if not symbol_in_arch(tags, arch):
return
@ -217,7 +244,7 @@ def generate(symbol_file, src_file, version_file, arch, api):
if line.strip() == '' or line.strip().startswith('#'):
version_file.write(line)
elif scope.top == Scope.Top:
handle_top_scope(scope, line, version_file)
handle_top_scope(scope, line, version_file, arch, api)
elif scope.top == Scope.Private:
handle_private_scope(scope, line, version_file)
elif scope.top == Scope.Local:

View File

@ -38,7 +38,7 @@ load-plugins=
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W"
disable=design
disable=design,fixme
[REPORTS]