[cfe-commits] r48537 - in /cfe/trunk: Driver/HTMLPrint.cpp include/clang/Rewrite/HTMLRewrite.h lib/Rewrite/HTMLRewrite.cpp
Ted Kremenek
kremenek at apple.com
Tue Mar 18 23:14:37 PDT 2008
Author: kremenek
Date: Wed Mar 19 01:14:37 2008
New Revision: 48537
URL: http://llvm.org/viewvc/llvm-project?rev=48537&view=rev
Log:
Moved generation of html header/footer with builtin CSS to the rewriter library.
Modified:
cfe/trunk/Driver/HTMLPrint.cpp
cfe/trunk/include/clang/Rewrite/HTMLRewrite.h
cfe/trunk/lib/Rewrite/HTMLRewrite.cpp
Modified: cfe/trunk/Driver/HTMLPrint.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/HTMLPrint.cpp?rev=48537&r1=48536&r2=48537&view=diff
==============================================================================
--- cfe/trunk/Driver/HTMLPrint.cpp (original)
+++ cfe/trunk/Driver/HTMLPrint.cpp Wed Mar 19 01:14:37 2008
@@ -50,39 +50,7 @@
html::EscapeText(R, FileID);
html::AddLineNumbers(R, FileID);
-
- // Generate header
-
- {
- std::ostringstream os;
-
- os << "<html>\n<head>\n"
- << " <style type=\"text/css\">\n"
- << " .codeblock { width:100% }\n"
- << " .codeline { font-family: \"Monaco\", fixed; font-size:11pt }\n"
- << " .codeline { height:1.5em; line-height:1.5em }\n"
- << " .nums, .lines { float:left; height:100% }\n"
- << " .nums { background-color: #eeeeee }\n"
- << " .nums { font-family: \"Andale Mono\", fixed; font-size:smaller }\n"
- << " .nums { width:2.5em; padding-right:2ex; text-align:right }\n"
- << " .lines { padding-left: 1ex; border-left: 3px solid #ccc }\n"
- << " .lines { white-space: pre }\n"
- << " </style>\n"
- << "</head>\n"
- << "<body>";
-
- R.InsertStrBefore(StartLoc, os.str());
- }
-
- // Generate footer
-
- {
- std::ostringstream os;
-
- os << "</body></html>\n";
- R.InsertStrAfter(EndLoc, os.str());
- }
-
+ html::AddHeaderFooterInternalBuiltinCSS(R, FileID);
// Emit the HTML.
Modified: cfe/trunk/include/clang/Rewrite/HTMLRewrite.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Rewrite/HTMLRewrite.h?rev=48537&r1=48536&r2=48537&view=diff
==============================================================================
--- cfe/trunk/include/clang/Rewrite/HTMLRewrite.h (original)
+++ cfe/trunk/include/clang/Rewrite/HTMLRewrite.h Wed Mar 19 01:14:37 2008
@@ -26,6 +26,9 @@
void EscapeText(Rewriter& R, unsigned FileID, bool EscapeSpaces = false);
void AddLineNumbers(Rewriter& R, unsigned FileID);
+
+ void AddHeaderFooterInternalBuiltinCSS(Rewriter& R, unsigned FileID);
+
} // end html namespace
} // end clang namespace
Modified: cfe/trunk/lib/Rewrite/HTMLRewrite.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/HTMLRewrite.cpp?rev=48537&r1=48536&r2=48537&view=diff
==============================================================================
--- cfe/trunk/lib/Rewrite/HTMLRewrite.cpp (original)
+++ cfe/trunk/lib/Rewrite/HTMLRewrite.cpp Wed Mar 19 01:14:37 2008
@@ -118,3 +118,47 @@
R.InsertCStrAfter(SourceLocation::getFileLoc(FileID, FileEnd - FileBeg),
"</div>");
}
+
+void html::AddHeaderFooterInternalBuiltinCSS(Rewriter& R, unsigned FileID) {
+
+ const llvm::MemoryBuffer *Buf = R.getSourceMgr().getBuffer(FileID);
+ const char* FileStart = Buf->getBufferStart();
+ const char* FileEnd = Buf->getBufferEnd();
+
+ SourceLocation StartLoc = SourceLocation::getFileLoc(FileID, 0);
+ SourceLocation EndLoc = SourceLocation::getFileLoc(FileID, FileEnd-FileStart);
+
+ // Generate header
+
+ {
+ std::ostringstream os;
+
+ os << "<html>\n<head>\n"
+ << " <style type=\"text/css\">\n"
+ << " .codeblock { width:100% }\n"
+ << " .codeline { font-family: \"Andale Mono\", fixed; font-size:10pt }\n"
+ << " .codeline { height:1.5em; line-height:1.5em }\n"
+ << " .nums, .lines { float:left; height:100% }\n"
+ << " .nums { background-color: #eeeeee }\n"
+ << " .nums { font-size:smaller }\n"
+ << " .nums { width:2.5em; padding-right:2ex; text-align:right }\n"
+ << " .lines { padding-left: 1ex; border-left: 3px solid #ccc }\n"
+ << " .lines { white-space: pre }\n"
+ << " </style>\n"
+ << "</head>\n"
+ << "<body>";
+
+ R.InsertStrBefore(StartLoc, os.str());
+ }
+
+ // Generate footer
+
+ {
+ std::ostringstream os;
+
+ os << "</body></html>\n";
+ R.InsertStrAfter(EndLoc, os.str());
+ }
+}
+
+
More information about the cfe-commits
mailing list