Class CppEnumGen

  extended by net.sf.farrago.catalog.codegen.CppEnumGen

public class CppEnumGen
extends Object

CppEnumGen is a tool for generating a C++ enumeration based on the public static final data members of a Java class.

$Id: //open/dev/farrago/src/net/sf/farrago/catalog/codegen/ $
John V. Sichi

Field Summary
private  PrintWriter pw
Constructor Summary
CppEnumGen(PrintWriter pw)
          Creates a new CppEnumGen.
Method Summary
 void generateEnumForClass(String enumName, Class enumClass, Class enumSymbolType)
          Generates a single enumeration.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail


private PrintWriter pw
Constructor Detail


public CppEnumGen(PrintWriter pw)
Creates a new CppEnumGen.

pw - PrintWriter to which enumeration definitions should be written
Method Detail


public void generateEnumForClass(String enumName,
                                 Class enumClass,
                                 Class enumSymbolType)
                          throws Exception
Generates a single enumeration. Enumeration values (and their names) is based on the subset of non-inherited public static final data members contained by enumClass and having exact type enumSymbolType. Enumeration order (and hence implied ordinals) is on the current locale's collation order for the enum field names. This ordering may not hold in the future, so no C++ code should be written which depends on the current deterministic ordering.

TODO: Support integer ordinals. Also, we'd prefer to preserve the original metamodel ordering in order to relax the ordering condition above.

enumName - name to give C++ enum
enumClass - Java class to be interpreted as an enumeration; this class's name is used as the enumeration name
enumSymbolType - Java class used to determine enumeration membership