Index: ppapi/generators/idl_outfile.py |
diff --git a/ppapi/generators/idl_outfile.py b/ppapi/generators/idl_outfile.py |
index 61b678c18af3c2bd73406149c00c46cbcb9398a9..8ae7e0b1c631a107d3680e7f1ff0d012a3640428 100755 |
--- a/ppapi/generators/idl_outfile.py |
+++ b/ppapi/generators/idl_outfile.py |
@@ -8,6 +8,7 @@ |
import difflib |
import os |
import time |
+import subprocess |
import sys |
from idl_log import ErrOut, InfoOut, WarnOut |
@@ -90,6 +91,14 @@ class IDLOutFile(object): |
raise RuntimeError('Could not write to closed file %s.' % self.filename) |
self.outlist.append(string) |
+ # Run clang-format on the buffered file contents. |
+ def ClangFormat(self): |
+ clang_format = subprocess.Popen(['clang-format', '-style=Chromium'], |
+ stdin=subprocess.PIPE, |
+ stdout=subprocess.PIPE) |
+ (new_output, err) = clang_format.communicate("".join(self.outlist)) |
teravest
2014/04/16 15:19:16
Since you don't use the error output, this is more
dmichael (off chromium)
2014/04/16 21:59:15
Oops, thanks. That was a holdover from my guess-an
|
+ self.outlist = [new_output] |
+ |
# Close the file, flushing it to disk |
def Close(self): |
filename = os.path.realpath(self.filename) |
@@ -123,6 +132,7 @@ class IDLOutFile(object): |
if not GetOption('test'): |
outfile = open(filename, 'wb') |
outfile.write(outtext) |
+ outfile.close(); |
InfoOut.Log('Output %s written.' % self.filename) |
return True |