org.sourceflow.c
Class CFunction

java.lang.Object
  extended byorg.sourceflow.CodeElement
      extended byorg.sourceflow.c.CFunction
All Implemented Interfaces:
java.lang.Comparable

public class CFunction
extends CodeElement

A class generating a C function declaration.


Field Summary
static int STATIC
          The static modifier constant.
 
Constructor Summary
CFunction(int modifiers, java.lang.String name, java.lang.String args, java.lang.String returnType)
          Creates a new function with the specified arguments.
CFunction(java.lang.String name)
          Creates a new function with the specified name.
CFunction(java.lang.String name, java.lang.String args)
          Creates a new function with the specified name and arguments.
CFunction(java.lang.String name, java.lang.String args, java.lang.String returnType)
          Creates a new function with the specified name, arguments and return type.
 
Method Summary
 void addCode(java.lang.String codeLines)
          Adds one or more lines of actual code.
 void addComment(CComment comment)
          Sets a comment for this function.
 boolean canPrintCode()
          Checks if the method source code can the printed.
 int category()
          Returns a numeric category number for the code element.
 void print(java.io.PrintWriter out, CodeStyle style, int indent)
          Prints the code element to the specified output stream.
 void setPrintCode(boolean value)
          Sets the print code flag.
 java.lang.String toString()
          Returns the function name.
 
Methods inherited from class org.sourceflow.CodeElement
compareTo, printSeparator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

STATIC

public static final int STATIC
The static modifier constant.

See Also:
Constant Field Values
Constructor Detail

CFunction

public CFunction(java.lang.String name)
Creates a new function with the specified name. The function will not take any arguments and will return void.

Parameters:
name - the function name

CFunction

public CFunction(java.lang.String name,
                 java.lang.String args)
Creates a new function with the specified name and arguments. The function will return void.

Parameters:
name - the function name
args - the argument list, excluding parenthesis

CFunction

public CFunction(java.lang.String name,
                 java.lang.String args,
                 java.lang.String returnType)
Creates a new function with the specified name, arguments and return type.

Parameters:
name - the function name
args - the argument list, excluding parenthesis
returnType - the return type

CFunction

public CFunction(int modifiers,
                 java.lang.String name,
                 java.lang.String args,
                 java.lang.String returnType)
Creates a new function with the specified arguments.

Parameters:
modifiers - the modifier flags to use (or zero)
name - the function name
args - the argument list, excluding parenthesis
returnType - the return type
Method Detail

toString

public java.lang.String toString()
Returns the function name.

Returns:
the function name

addCode

public void addCode(java.lang.String codeLines)
Adds one or more lines of actual code.

Parameters:
codeLines - the lines of C code to add

addComment

public void addComment(CComment comment)
Sets a comment for this function.

Parameters:
comment - the new function comment

category

public int category()
Returns a numeric category number for the code element. A lower category number implies that the code element should be placed before code elements with a higher category number within a declaration.

Specified by:
category in class CodeElement
Returns:
the category number

canPrintCode

public boolean canPrintCode()
Checks if the method source code can the printed. This method will return false if the print code flag is set.

Returns:
true if method source code can be printed, or false otherwise

setPrintCode

public void setPrintCode(boolean value)
Sets the print code flag.

Parameters:
value - the new print code flag value

print

public void print(java.io.PrintWriter out,
                  CodeStyle style,
                  int indent)
Prints the code element to the specified output stream.

Specified by:
print in class CodeElement
Parameters:
out - the output stream
style - the code style to use
indent - the indentation level