gov.llnl.babel.backend.writers
Class LanguageWriter

java.lang.Object
  extended by gov.llnl.babel.backend.writers.PrettyWriter
      extended by gov.llnl.babel.backend.writers.LanguageWriter
All Implemented Interfaces:
CodeConstants
Direct Known Subclasses:
LanguageWriterForC, LanguageWriterForFortran, LanguageWriterForJava, LanguageWriterForMakefiles, LanguageWriterForMatlab, LanguageWriterForPython, LanguageWriterForSidl

public abstract class LanguageWriter
extends PrettyWriter
implements CodeConstants

Abstract class LanguageWriter extends the pretty writer class with additional features for backend code generation. The language writer manages block comments and file headers. Language-specific writers manage formatting for a particular language.


Field Summary
protected  Context d_context
           
 
Fields inherited from interface gov.llnl.babel.backend.CodeConstants
C_AUTO_GEN_SPLICER, C_AUTO_GEN_WARNING, C_BACKSLASH, C_BEGIN_UNREFERENCED_METHODS, C_COMMENT_CLOSE, C_COMMENT_DOC_OPEN, C_COMMENT_F77, C_COMMENT_F90, C_COMMENT_HASH, C_COMMENT_OPEN, C_COMMENT_SLASH, C_COMMENT_SUBSEQUENT, C_DEFINE, C_DESC_CJNI_PREFIX, C_DESC_HEADER_PREFIX, C_DESC_IMPL_PREFIX, C_DESC_IOR_PREFIX, C_DESC_SJNI_PREFIX, C_DESC_SKEL_PREFIX, C_DESC_STUB_PREFIX, C_END_UNREFERENCED_METHODS, C_F77_IMPL_EXTENSION, C_F77_IMPL_METHOD_SUFFIX, C_F77_METHOD_SUFFIX, C_F77_VERSION, C_F7731_IMPL_EXTENSION, C_F90_ALT_SUFFIX, C_F90_IMPL_EXTENSION, C_F90_IMPL_METHOD_SUFFIX, C_F90_METHOD_SUFFIX, C_F90_VERSION, C_FORTRAN_DESC_STUB_PREFIX, C_FORTRAN_IMPL_MODULE_PREFIX, C_FORTRAN_MODULE_PREFIX, C_FORTRAN_TYPE_MODULE_PREFIX, C_GUARD_CLOSE, C_GUARD_OPEN, C_HASH, C_IFDEFINE_CLOSE, C_IFDEFINE_CXX, C_IFDEFINE_OPEN, C_INCLUDE, C_INSERT_HERE, C_INT_BACKSLASH, C_IS_IMPL, C_IS_NOT_IMPL, C_SLASH, C_UNREFERENCED_COMMENT1, C_UNREFERENCED_COMMENT2, C_UNREFERENCED_COMMENT3, MATLAB_COMMENT_OPEN
 
Constructor Summary
LanguageWriter(java.io.PrintWriter writer, Context context)
          Create a LanguageWriter instance that will send output to the specified print writer object.
 
Method Summary
abstract  void beginBlockComment(boolean is_doc)
          Abstract method to begin a block comment.
abstract  void endBlockComment(boolean is_doc)
          Abstract method to end a block comment.
 java.lang.String processHTML(java.lang.String str)
          Convert HTML/XML entities as appropriate.
 java.lang.String safeCommentString(java.lang.String string)
          Convert a string into a string that is safe to include inside a comment.
 void writeBanner(Symbol symbol, java.lang.String file, boolean is_Impl, java.lang.String desc)
          Write a file banner for automatically generated files.
 void writeComment(Comment comment, boolean is_doc)
          Write a comment for a sidl Comment to the pretty writer stream.
 void writeComment(Comment comment, java.lang.String alt)
          Write a comment with an alternative string.
 void writeComment(Method method, boolean is_doc)
          Write a comment for a sidl method to the pretty writer stream.
 void writeComment(Method method, boolean is_doc, boolean add_default)
          Write a comment for a sidl method to the pretty writer stream.
 void writeComment(java.lang.String s, boolean is_doc)
           Write a single-line block comment to the pretty writer stream.
 void writeComment(Symbol symbol, boolean is_doc)
          Write a comment for a sidl symbol to the pretty writer stream.
 void writeComment(Symbol symbol, boolean is_doc, boolean output_sym)
          Write a comment for a sidl symbol to the pretty writer stream.
abstract  void writeCommentLine(java.lang.String comment)
           Abstract method to output a comment to the pretty writer stream.
abstract  void writeSplicerTagLine(java.lang.String tagLine)
          Write the splicer tag as a language-specific comment.
 
Methods inherited from class gov.llnl.babel.backend.writers.PrettyWriter
backTab, changeTabLevel, close, defineBlockComment, disableBlockComment, disableLineBreak, enableBlockComment, enableLineBreak, enableLineBreak, flushPrintWriter, getPrintWriter, popLineBreak, print, printAligned, println, println, printlnUnformatted, printSpaces, printUnformatted, pushLineBreak, restoreFirstTabStop, setFirstTabStop, setLineBreakString, setStrictBreaking, setTabSpacing, setTemporaryFirstTabStop, tab
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

d_context

protected Context d_context
Constructor Detail

LanguageWriter

public LanguageWriter(java.io.PrintWriter writer,
                      Context context)
Create a LanguageWriter instance that will send output to the specified print writer object.

Method Detail

beginBlockComment

public abstract void beginBlockComment(boolean is_doc)
Abstract method to begin a block comment. If the documentation flag is true, then the block comment is a documentation comment. The precise form of the block comment for a specific language is set by the language writer subclass.


endBlockComment

public abstract void endBlockComment(boolean is_doc)
Abstract method to end a block comment. If the documentation flag is true, then the block comment is a documentation comment. The precise form of the block comment for a specific language is set by the language writer subclass.


writeSplicerTagLine

public abstract void writeSplicerTagLine(java.lang.String tagLine)
Write the splicer tag as a language-specific comment.


writeCommentLine

public abstract void writeCommentLine(java.lang.String comment)

Abstract method to output a comment to the pretty writer stream. The comment is not written in a comment block but only on one line of the output stream. The comment should not contain any new line characters. If the comment is null, then nothing is output.

It is assumed that comment is safe for inclusion in a comment for any language.

Parameters:
comment - a single line comment to include in the output
See Also:
safeCommentString(java.lang.String)

writeComment

public void writeComment(java.lang.String s,
                         boolean is_doc)

Write a single-line block comment to the pretty writer stream. If the string is null or contains no characters, then no comment is written. The documentation flag determines whether this is a documentation comment.

It is assumed that comment is safe for inclusion in a comment for any language.

Parameters:
s - the comment string to include in the output
is_doc - true means that the comment should be treated as a document-style comment in languages that have such things.
See Also:
safeCommentString(java.lang.String)

safeCommentString

public java.lang.String safeCommentString(java.lang.String string)
Convert a string into a string that is safe to include inside a comment. The set of characters that are safe inside a string is language dependent, so this can be overridden. To motivate this method, let me just say that having a */ in side a C or Java comment would prematurely end the comment.

Parameters:
string - the string to make safe for inclusion inside a comment.
Returns:
a string that can safely be included inside a comment.

processHTML

public java.lang.String processHTML(java.lang.String str)
Convert HTML/XML entities as appropriate.


writeComment

public void writeComment(Comment comment,
                         boolean is_doc)
Write a comment for a sidl Comment to the pretty writer stream.


writeComment

public void writeComment(Symbol symbol,
                         boolean is_doc,
                         boolean output_sym)
Write a comment for a sidl symbol to the pretty writer stream. Optionally output the symbol name and version first.


writeComment

public void writeComment(Symbol symbol,
                         boolean is_doc)
Write a comment for a sidl symbol to the pretty writer stream. If the symbol does not have a comment associated with it, then only the symbol name and version will be printed to the output stream.


writeComment

public void writeComment(Method method,
                         boolean is_doc,
                         boolean add_default)
Write a comment for a sidl method to the pretty writer stream. Optionally write the method name if the symbol does not have an associated comment.


writeComment

public void writeComment(Method method,
                         boolean is_doc)
Write a comment for a sidl method to the pretty writer stream. If the symbol does not have a comment associated with it, then only the method name will be printed to the output stream.


writeComment

public void writeComment(Comment comment,
                         java.lang.String alt)
Write a comment with an alternative string. Does nothing if both are null.

Parameters:
comment - a comment or null
alt - an alternate string if comment==null, or null itself

writeBanner

public void writeBanner(Symbol symbol,
                        java.lang.String file,
                        boolean is_Impl,
                        java.lang.String desc)
Write a file banner for automatically generated files. The banner is a comment block that provides basic information about the symbol.