Commit c0d84d74 authored by tedchoc@chromium.org's avatar tedchoc@chromium.org

Do not wrap preprocessor lines in the generated JNI.

For classes with long package/class names, this can extend over 80 characters
when preceded by a #ifndef, etc..

BUG=


Review URL: https://chromiumcodereview.appspot.com/10850030

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149780 0039d316-1c4b-4281-b951-d872f2087c98
parent 3695fe3f
...@@ -880,7 +880,8 @@ jclass g_${JAVA_CLASS}_clazz = NULL;""") ...@@ -880,7 +880,8 @@ jclass g_${JAVA_CLASS}_clazz = NULL;""")
def WrapOutput(output): def WrapOutput(output):
ret = [] ret = []
for line in output.splitlines(): for line in output.splitlines():
if len(line) < 80: # Do not wrap lines under 80 characters or preprocessor directives.
if len(line) < 80 or line.lstrip()[:1] == '#':
stripped = line.rstrip() stripped = line.rstrip()
if len(ret) == 0 or len(ret[-1]) or len(stripped): if len(ret) == 0 or len(ret[-1]) or len(stripped):
ret.append(stripped) ret.append(stripped)
......
...@@ -1491,5 +1491,22 @@ static bool RegisterNativesImpl(JNIEnv* env) { ...@@ -1491,5 +1491,22 @@ static bool RegisterNativesImpl(JNIEnv* env) {
content, 'org/chromium/example/jni_generator/SampleForTests') content, 'org/chromium/example/jni_generator/SampleForTests')
self.assertTextEquals(golden_content, jni_from_java.GetContent()) self.assertTextEquals(golden_content, jni_from_java.GetContent())
def testNoWrappingPreprocessorLines(self):
test_data = """
package com.google.lookhowextremelylongiam.snarf.icankeepthisupallday;
class ReallyLongClassNamesAreAllTheRage {
private static native int nativeTest();
}
"""
jni_from_java = jni_generator.JNIFromJavaSource(
test_data, ('com/google/lookhowextremelylongiam/snarf/'
'icankeepthisupallday/ReallyLongClassNamesAreAllTheRage'))
jni_lines = jni_from_java.GetContent().split('\n')
line = filter(lambda line: line.lstrip().startswith('#ifndef'),
jni_lines)[0]
self.assertTrue(len(line) > 80,
('Expected #ifndef line to be > 80 chars: ', line))
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment