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

Unified Diff: testing/gmock/scripts/generator/cpp/gmock_class.py

Issue 140003: Upgrade gtest to r267 and gmock to r173. (Closed)
Patch Set: final fileset. Created 11 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 | « testing/gmock/scripts/generator/cpp/ast.py ('k') | testing/gmock/scripts/generator/cpp/gmock_class_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: testing/gmock/scripts/generator/cpp/gmock_class.py
diff --git a/testing/gmock/scripts/generator/cpp/gmock_class.py b/testing/gmock/scripts/generator/cpp/gmock_class.py
index 2920424758f61d83b624e906e68345baaa4a364f..3ad0bcdd3631f8b93739ec9df14d90dafe1c61f1 100755
--- a/testing/gmock/scripts/generator/cpp/gmock_class.py
+++ b/testing/gmock/scripts/generator/cpp/gmock_class.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2008 Google Inc.
+# Copyright 2008 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -73,7 +73,13 @@ def _GenerateMethods(output_lines, source, class_node):
# of the first parameter to the end of the last parameter.
start = node.parameters[0].start
end = node.parameters[-1].end
- args = re.sub(' +', ' ', source[start:end].replace('\n', ''))
+ # Remove // comments.
+ args_strings = re.sub(r'//.*', '', source[start:end])
+ # Condense multiple spaces and eliminate newlines putting the
+ # parameters together on a single line. Ensure there is a
+ # space in an argument which is split by a newline without
+ # intervening whitespace, e.g.: int\nBar
+ args = re.sub(' +', ' ', args_strings.replace('\n', ' '))
# Create the prototype.
indent = ' ' * _INDENT
@@ -120,8 +126,6 @@ def _GenerateMocks(filename, source, ast_list, desired_class_names):
lines.append('} // namespace %s' % class_node.namespace[i])
lines.append('') # Add an extra newline.
- sys.stdout.write('\n'.join(lines))
-
if desired_class_names:
missing_class_name_list = list(desired_class_names - processed_class_names)
if missing_class_name_list:
@@ -129,7 +133,9 @@ def _GenerateMocks(filename, source, ast_list, desired_class_names):
sys.stderr.write('Class(es) not found in %s: %s\n' %
(filename, ', '.join(missing_class_name_list)))
elif not processed_class_names:
- sys.stderr.write('No class found in %s\n' % filename)
+ sys.stderr.write('No class found in %s\n' % filename)
+
+ return lines
def main(argv=sys.argv):
@@ -164,7 +170,8 @@ def main(argv=sys.argv):
# An error message was already printed since we couldn't parse.
pass
else:
- _GenerateMocks(filename, source, entire_ast, desired_class_names)
+ lines = _GenerateMocks(filename, source, entire_ast, desired_class_names)
+ sys.stdout.write('\n'.join(lines))
if __name__ == '__main__':
« no previous file with comments | « testing/gmock/scripts/generator/cpp/ast.py ('k') | testing/gmock/scripts/generator/cpp/gmock_class_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698