CodeGen
Class Gen

java.lang.Object
  extended by CodeGen.Gen
Direct Known Subclasses:
GenCI, GenDebug, GenLocal, GenRI

public abstract class Gen
extends java.lang.Object

Abstract code generator interface


Field Summary
 ClassInfo cinfo
           
protected  Konstruktor[] constr
           
protected  boolean isCTLI
           
protected  boolean isForwardDecl
           
protected  Methode[] methods
           
protected  java.lang.String modifiers
           
protected  java.lang.String name
           
protected  java.lang.String pkg
           
protected  java.lang.String prfx
           
protected  java.lang.String supername
           
 
Constructor Summary
Gen(java.lang.String klass)
          Constructor for a class from the javaSys package.
Gen(java.lang.String pkg, java.lang.String klass)
          Constructor for a class from a custom package.
 
Method Summary
protected static java.lang.String __putRefCount()
          Generate a stub for putRefCount()
protected static java.lang.String arrayConversion(java.lang.String type)
          Generated code for the conversion of an array
protected  java.lang.String classNamer(ClassInfo cinfo, java.lang.String suffix)
           
protected static java.lang.String classNameToDotJavaFile(java.lang.String klas)
          Convert a class name to a Java source code filename
protected static java.lang.String convertArray(MethodInfo minfo)
          Wrapper around convertArray(String)
protected static java.lang.String convertArray(java.lang.String klass)
          Generate an array conversion expression for the given class
protected  void gen(java.io.OutputStreamWriter ostr)
           
protected  java.lang.String genAccept()
           
protected static void genArgList(java.lang.StringBuffer buf, java.lang.String p, int i, int j, boolean is_constr, java.lang.annotation.Annotation[] anot)
          Handles one function parameter and takes care of possible array types.
protected  java.lang.String genConstructors()
           
protected  void generate()
           
protected  java.lang.String genHead()
          Generate the header of the class
protected static java.lang.String[] genValue(java.lang.String retVal)
          Generate a *Value() call for a certain type
protected  java.lang.String genWrappers()
           
protected  java.lang.String getFQCN()
          Retrieve the full-qualified name of the class we are generating code for
protected static java.lang.String getImports(java.lang.String klas)
          Retrieve all imported classes/packages as String
protected static void getImports(java.lang.StringBuffer buf, java.lang.String klas)
          Retrieve the import statements from a Java source code file
protected  boolean isCC()
           
protected  java.lang.String linkErr()
          Generate code for linkage error message
protected static java.lang.String newMethod(java.lang.String clname, java.lang.String funcname, int len)
           
protected static java.lang.String newMethod(java.lang.String clname, java.lang.String funcname, int len, boolean returnme)
          Generate code for a new Method call
protected static java.lang.String newObj(java.lang.String clname, java.lang.String arglist)
          See above
protected static java.lang.String newObj(java.lang.String clname, java.lang.String arglist, boolean have_proc)
          Generate code for allocating a new RI object
protected static void prettyPrint(java.io.File file)
          Use an external pretty printer
protected static void writeTo(java.io.OutputStreamWriter out, java.lang.String str)
          Write a string to an output stream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cinfo

public ClassInfo cinfo

constr

protected Konstruktor[] constr

methods

protected Methode[] methods

name

protected java.lang.String name

pkg

protected java.lang.String pkg

prfx

protected java.lang.String prfx

supername

protected java.lang.String supername

modifiers

protected java.lang.String modifiers

isForwardDecl

protected boolean isForwardDecl

isCTLI

protected boolean isCTLI
Constructor Detail

Gen

public Gen(java.lang.String klass)
    throws java.lang.ClassNotFoundException
Constructor for a class from the javaSys package.

Parameters:
klass - Class name
Throws:
java.lang.ClassNotFoundException

Gen

public Gen(java.lang.String pkg,
           java.lang.String klass)
    throws java.lang.ClassNotFoundException
Constructor for a class from a custom package.

Parameters:
pkg - Package name
klass - Class name
Throws:
java.lang.ClassNotFoundException
Method Detail

writeTo

protected static void writeTo(java.io.OutputStreamWriter out,
                              java.lang.String str)
                       throws java.io.IOException
Write a string to an output stream

Parameters:
out - OutputStreamWriter for the output stream
str - String to write
Throws:
java.io.IOException

classNameToDotJavaFile

protected static java.lang.String classNameToDotJavaFile(java.lang.String klas)
Convert a class name to a Java source code filename

Parameters:
klas - Class name
Returns:
Filename

getImports

protected static void getImports(java.lang.StringBuffer buf,
                                 java.lang.String klas)
Retrieve the import statements from a Java source code file

Parameters:
klas - Class name
buf - Buffer to write to

getImports

protected static java.lang.String getImports(java.lang.String klas)
Retrieve all imported classes/packages as String

Parameters:
klas - Name of the source class
Returns:
String

prettyPrint

protected static void prettyPrint(java.io.File file)
Use an external pretty printer

Parameters:
file - The File to modify

classNamer

protected java.lang.String classNamer(ClassInfo cinfo,
                                      java.lang.String suffix)

isCC

protected boolean isCC()

generate

protected void generate()
                 throws java.io.IOException,
                        java.lang.NoSuchMethodException
Throws:
java.io.IOException
java.lang.NoSuchMethodException

gen

protected void gen(java.io.OutputStreamWriter ostr)
            throws java.io.IOException,
                   java.lang.NoSuchMethodException
Throws:
java.io.IOException
java.lang.NoSuchMethodException

genHead

protected java.lang.String genHead()
                            throws java.io.IOException
Generate the header of the class

Returns:
Header
Throws:
java.io.IOException

genValue

protected static java.lang.String[] genValue(java.lang.String retVal)
Generate a *Value() call for a certain type

Parameters:
retVal - String representation of a type
Returns:
Array of which the first String is the *Value() function name

genAccept

protected java.lang.String genAccept()
                              throws java.io.IOException
Throws:
java.io.IOException

genConstructors

protected java.lang.String genConstructors()
                                    throws java.io.IOException
Throws:
java.io.IOException

genWrappers

protected java.lang.String genWrappers()
                                throws java.io.IOException,
                                       java.lang.NoSuchMethodException
Throws:
java.io.IOException
java.lang.NoSuchMethodException

linkErr

protected java.lang.String linkErr()
Generate code for linkage error message


newObj

protected static java.lang.String newObj(java.lang.String clname,
                                         java.lang.String arglist,
                                         boolean have_proc)
Generate code for allocating a new RI object

Parameters:
clname - Class name
arglist - Argument list
have_proc - Put proc into the argument list or not
Returns:
Code

newObj

protected static java.lang.String newObj(java.lang.String clname,
                                         java.lang.String arglist)
See above


__putRefCount

protected static java.lang.String __putRefCount()
Generate a stub for putRefCount()

Returns:
Code

genArgList

protected static void genArgList(java.lang.StringBuffer buf,
                                 java.lang.String p,
                                 int i,
                                 int j,
                                 boolean is_constr,
                                 java.lang.annotation.Annotation[] anot)
Handles one function parameter and takes care of possible array types.

Parameters:
buf - StringBuffer to write to
p - Parameter type
i - Counter
j - Counter
is_constr - Whether or not the caller is a constructor
anot - Annotations belonging to the caller

newMethod

protected static java.lang.String newMethod(java.lang.String clname,
                                            java.lang.String funcname,
                                            int len,
                                            boolean returnme)
Generate code for a new Method call

Parameters:
clname - Class name
funcname - Function name
len - Number of arguments the function takes
returnme - Whether or not to return a value
Returns:
Code

newMethod

protected static java.lang.String newMethod(java.lang.String clname,
                                            java.lang.String funcname,
                                            int len)

getFQCN

protected java.lang.String getFQCN()
Retrieve the full-qualified name of the class we are generating code for

Returns:
Name

convertArray

protected static java.lang.String convertArray(MethodInfo minfo)
Wrapper around convertArray(String)

Parameters:
minfo - The method whose return value should be converted
Returns:
Array conversion expression

convertArray

protected static java.lang.String convertArray(java.lang.String klass)
Generate an array conversion expression for the given class

Parameters:
klass - Class name
Returns:
Array conversion expression

arrayConversion

protected static java.lang.String arrayConversion(java.lang.String type)
Generated code for the conversion of an array

Parameters:
type - Type of the array
Returns:
Generated code