private String dir;
private String subdir;
+
/**
* Class constants
*/
USERDEFINED // Assumed as driver classes
}
+
/**
* Class constructors
*/
* data structures.
* Additionally, the data structure handles are
* returned from tree-parsing for further process.
- *
*/
public void setDataStructures(String origInt, ParseNode pnPol, ParseNode pnReq) {
/**
- * HELPER: writeMethodJavaLocalInterface() writes the method of the interface
+ * HELPER: writeMethodJavaLocalInterface() writes the method of the local interface
*/
private void writeMethodJavaLocalInterface(Collection<String> methods, InterfaceDecl intDecl) {
// Write interface header
println("");
println("public interface " + intface + " {");
- // Write enum if any...
- //EnumDecl enumDecl = (EnumDecl) decHandler.getEnumDecl(intface);
- //writeEnumJava(enumDecl);
- // Write struct if any...
- //StructDecl structDecl = (StructDecl) decHandler.getStructDecl(intface);
- //writeStructJava(structDecl);
// Write methods
writeMethodJavaLocalInterface(methods, intDecl);
println("}");
/**
- * HELPER: writeConstructorJavaStub() writes the constructor of the stub class
+ * HELPER: writeInitCallbackJavaStub() writes callback initialization in stub
*/
private void writeInitCallbackJavaStub(String intface, InterfaceDecl intDecl) {
/**
- * HELPER: writeLengthStructParamClassJavaStub() writes lengths of params
+ * HELPER: writeLengthStructParamClassJavaStub() writes lengths of parameters
*/
private void writeLengthStructParamClassJavaStub(List<String> methParams, List<String> methPrmTypes) {
/**
- * HELPER: writeStructRetMembersJavaStub() writes parameters of struct
+ * HELPER: writeStructRetMembersJavaStub() writes parameters of struct for return statement
*/
private void writeStructRetMembersJavaStub(String simpleType, String retType) {
/**
- * HELPER: writeStructReturnJavaStub() writes parameters if struct is present
+ * HELPER: writeStructReturnJavaStub() writes parameters if struct is present for return statement
*/
private void writeStructReturnJavaStub(String simpleType, String retType) {
println("try {");
// Check if this is single object, array, or list of objects
for (int i = 0; i < methParams.size(); i++) {
-
String paramType = methPrmTypes.get(i);
if (checkCallbackType(paramType, callbackType)) { // Check if this has callback object
String param = methParams.get(i);
/**
- * HELPER: writeMethodJavaStub() writes the method of the stub class
+ * HELPER: writeMethodJavaStub() writes the methods of the stub class
*/
private void writeMethodJavaStub(Collection<String> methods, InterfaceDecl intDecl, Set<String> callbackClasses) {
/**
* HELPER: writeCallbackJavaStubGeneration() writes the callback stub generation part
*/
- private Map<Integer,String> writeCallbackJavaStubGeneration(List<String> methParams, List<String> methPrmTypes, String callbackType) {
+ private Map<Integer,String> writeCallbackJavaStubGeneration(List<String> methParams, List<String> methPrmTypes,
+ String callbackType) {
Map<Integer,String> mapStubParam = new HashMap<Integer,String>();
// Iterate over callback objects
/**
- * HELPER: writeStructMembersJavaSkeleton() writes parameters of struct
+ * HELPER: writeStructMembersJavaSkeleton() writes member parameters of struct
*/
private void writeStructMembersJavaSkeleton(String simpleType, String paramType,
String param, String method, InterfaceDecl intDecl, int iVar) {
}
-
/**
- * HELPER: writeStructMembersInitJavaSkeleton() writes parameters of struct
+ * HELPER: writeStructMembersInitJavaSkeleton() writes member parameters initialization of struct
*/
private void writeStructMembersInitJavaSkeleton(InterfaceDecl intDecl, List<String> methParams,
List<String> methPrmTypes, String method) {
/**
- * HELPER: writeStructReturnJavaSkeleton() writes parameters if struct is present
+ * HELPER: writeStructReturnJavaSkeleton() writes struct for return statement
*/
private void writeStructReturnJavaSkeleton(String simpleType, String retType) {
/**
- * HELPER: writeMethodHelperReturnJavaSkeleton() writes the return value part in skeleton
+ * HELPER: writeMethodHelperReturnJavaSkeleton() writes return statement part in skeleton
*/
private void writeMethodHelperReturnJavaSkeleton(InterfaceDecl intDecl, List<String> methParams,
List<String> methPrmTypes, String method, boolean isCallbackMethod, String callbackType) {
/**
- * HELPER: writeMethodHelperStructSetupJavaSkeleton() writes the method helper of the struct in skeleton class
+ * HELPER: writeMethodHelperStructSetupJavaSkeleton() writes the method helper of struct setup in skeleton class
*/
private void writeMethodHelperStructSetupJavaSkeleton(Collection<String> methods,
InterfaceDecl intDecl) {
/**
- * HELPER: writeMethodHelperStructSetupJavaCallbackSkeleton() writes the method helper of the struct in skeleton class
+ * HELPER: writeMethodHelperStructSetupJavaCallbackSkeleton() writes the method helper of struct setup in callback skeleton class
*/
private void writeMethodHelperStructSetupJavaCallbackSkeleton(Collection<String> methods,
InterfaceDecl intDecl) {
/**
- * HELPER: writeInputCountVarStructSkeleton() writes counter variable of struct for skeleton
+ * HELPER: writeInputCountVarStructSkeleton() writes input counter variable of struct for skeleton
*/
private boolean writeInputCountVarStructSkeleton(String method, InterfaceDecl intDecl) {
/**
- * HELPER: writeJavaCallbackWaitRequestInvokeMethod() writes the main loop of the skeleton class
+ * HELPER: writeJavaCallbackWaitRequestInvokeMethod() writes the request invoke method of the callback skeleton class
*/
private void writeJavaCallbackWaitRequestInvokeMethod(Collection<String> methods, InterfaceDecl intDecl, boolean callbackExist) {
/**
- * HELPER: writeMethodCplusLocalInterface() writes the method of the interface
+ * HELPER: writeMethodCplusLocalInterface() writes the method of the local interface
*/
private void writeMethodCplusLocalInterface(Collection<String> methods, InterfaceDecl intDecl) {
Set<String> includeClasses = getIncludeClasses(methods, intDecl, intface, true);
printIncludeStatements(includeClasses); println("");
println("using namespace std;\n");
- // Write enum if any...
- //EnumDecl enumDecl = (EnumDecl) decHandler.getEnumDecl(intface);
- //writeEnumCplus(enumDecl);
- // Write struct if any...
- //StructDecl structDecl = (StructDecl) decHandler.getStructDecl(intface);
//writeStructCplus(structDecl);
println("class " + intface); println("{");
println("public:");
/**
- * HELPER: writeMethodCplusStub() writes the method of the stub
+ * HELPER: writeMethodCplusStub() writes the methods of the stub
*/
private void writeMethodCplusStub(Collection<String> methods, InterfaceDecl intDecl, Set<String> callbackClasses) {
/**
- * HELPER: writeStructMembersCplusStub() writes parameters of struct
+ * HELPER: writeStructMembersCplusStub() writes member parameters of struct
*/
private void writeStructMembersCplusStub(String simpleType, String paramType, String param) {
/**
- * HELPER: writeStructParamClassCplusStub() writes parameters if struct is present
+ * HELPER: writeStructParamClassCplusStub() writes member parameters of struct
*/
private void writeStructParamClassCplusStub(List<String> methParams, List<String> methPrmTypes) {
/**
- * HELPER: writeStructRetMembersCplusStub() writes parameters of struct
+ * HELPER: writeStructRetMembersCplusStub() writes member parameters of struct for return statement
*/
private void writeStructRetMembersCplusStub(String simpleType, String retType) {
/**
- * HELPER: writeStructReturnCplusStub() writes parameters if struct is present
+ * HELPER: writeStructReturnCplusStub() writes member parameters of struct for return statement
*/
private void writeStructReturnCplusStub(String simpleType, String retType) {
/**
- * HELPER: writeInitCallbackSendInfoCplusStub() writes the initialization of callback
+ * HELPER: writeInitCallbackSendInfoCplusStub() writes the initialization (send info part) of callback
*/
private void writeInitCallbackSendInfoCplusStub(InterfaceDecl intDecl) {
/**
- * HELPER: writeMethodHelperReturnCplusSkeleton() writes the return value part in skeleton
+ * HELPER: writeMethodHelperReturnCplusSkeleton() writes the return statement part in skeleton
*/
private void writeMethodInputParameters(List<String> methParams, List<String> methPrmTypes,
Set<String> callbackClasses, String methodId) {
/**
- * HELPER: writeMethodHelperReturnCplusSkeleton() writes the return value part in skeleton
+ * HELPER: writeMethodHelperReturnCplusSkeleton() writes the return statement part in skeleton
*/
private void writeMethodHelperReturnCplusSkeleton(InterfaceDecl intDecl, List<String> methParams,
List<String> methPrmTypes, String method, boolean isCallbackMethod, String callbackType,
/**
- * HELPER: writeStructMembersCplusSkeleton() writes parameters of struct
+ * HELPER: writeStructMembersCplusSkeleton() writes member parameters of struct
*/
private void writeStructMembersCplusSkeleton(String simpleType, String paramType,
String param, String method, InterfaceDecl intDecl, int iVar) {
/**
- * HELPER: writeStructMembersInitCplusSkeleton() writes parameters of struct
+ * HELPER: writeStructMembersInitCplusSkeleton() writes member parameters initialization of struct
*/
private void writeStructMembersInitCplusSkeleton(InterfaceDecl intDecl, List<String> methParams,
List<String> methPrmTypes, String method) {
/**
- * HELPER: writeStructReturnCplusSkeleton() writes parameters if struct is present
+ * HELPER: writeStructReturnCplusSkeleton() writes parameters of struct for return statement
*/
private void writeStructReturnCplusSkeleton(String simpleType, String retType) {
/**
- * HELPER: writeMethodHelperStructSetupCplusSkeleton() writes the method helper of the struct in skeleton class
+ * HELPER: writeMethodHelperStructSetupCplusSkeleton() writes the method helper of struct in skeleton class
*/
private void writeMethodHelperStructSetupCplusSkeleton(Collection<String> methods,
InterfaceDecl intDecl) {
/**
- * HELPER: writeMethodHelperStructSetupCplusCallbackSkeleton() writes the method helper of the struct in skeleton class
+ * HELPER: writeMethodHelperStructSetupCplusCallbackSkeleton() writes the method helper of struct in skeleton class
*/
private void writeMethodHelperStructSetupCplusCallbackSkeleton(Collection<String> methods,
InterfaceDecl intDecl) {
/**
- * HELPER: writeMethodHelperCplusCallbackSkeleton() writes the method helper of the callback skeleton class
+ * HELPER: writeMethodHelperCplusCallbackSkeleton() writes the method helper of callback skeleton class
*/
private void writeMethodHelperCplusCallbackSkeleton(Collection<String> methods, InterfaceDecl intDecl,
Set<String> callbackClasses) {
/**
- * HELPER: writeCplusCallbackWaitRequestInvokeMethod() writes the main loop of the skeleton class
+ * HELPER: writeCplusCallbackWaitRequestInvokeMethod() writes the request invoke method of the skeleton callback class
*/
private void writeCplusCallbackWaitRequestInvokeMethod(Collection<String> methods, InterfaceDecl intDecl,
boolean callbackExist) {
}
-
/**
* generateCplusCallbackSkeletonClass() generate callback skeletons based on the methods list in C++
*/
}
- /**
- * generateReturnStmt() generate return statement based on methType
- */
- public String generateReturnStmt(String methType) {
-
- // Generate dummy returns for now
- if (methType.equals("short")||
- methType.equals("int") ||
- methType.equals("long") ||
- methType.equals("float")||
- methType.equals("double")) {
-
- return "1";
- } else if ( methType.equals("String")) {
-
- return "\"a\"";
- } else if ( methType.equals("char") ||
- methType.equals("byte")) {
-
- return "\'a\'";
- } else if ( methType.equals("boolean")) {
-
- return "true";
- } else {
- return "null";
- }
- }
-
-
/**
* setDirectory() sets a new directory for stub files
*/
/**================
- * Helper functions
+ * Basic helper functions
**================
*/
boolean newline=true;
}
+ /**
+ * A collection of methods with print-to-file functionality
+ */
private void println(String str) {
if (newline) {
int tab = tablevel;
}
- // Return parameter category, i.e. PRIMITIVES, NONPRIMITIVES, or USERDEFINED
+ // Return parameter category, i.e. PRIMITIVES, NONPRIMITIVES, USERDEFINED, ENUM, or STRUCT
private ParamCategory getParamCategory(String paramType) {
if (mapPrimitives.containsKey(paramType)) {
// Return full class name for non-primitives to generate Java import statements
- // e.g. java.util.Set for Set, java.util.Map for Map
+ // e.g. java.util.Set for Set
private String getNonPrimitiveJavaClass(String paramNonPrimitives) {
return mapNonPrimitivesJava.get(paramNonPrimitives);
// Return full class name for non-primitives to generate Cplus include statements
- // e.g. #include <set> for Set, #include <map> for Map
+ // e.g. #include <set> for Set
private String getNonPrimitiveCplusClass(String paramNonPrimitives) {
return mapNonPrimitivesCplus.get(paramNonPrimitives);
}
- // Generate a set of standard classes for import statements
+ // Combine all classes for import statements
private List<String> getAllLibClasses(Collection<String> stdLibClasses, Collection<String> libClasses) {
List<String> allLibClasses = new ArrayList<String>(stdLibClasses);
allLibClasses.add(str);
}
}
-
return allLibClasses;
}
}
+ // Print import statements into file
private void printImportStatements(Collection<String> importClasses) {
for(String cls : importClasses) {
}
+ // Print include statements into file
private void printIncludeStatements(Collection<String> includeClasses) {
for(String cls : includeClasses) {
}
+ // Checks and gets type in C++
private String checkAndGetCplusType(String paramType) {
if (getParamCategory(paramType) == ParamCategory.PRIMITIVES) {
}
- // Is array? For return type we put the return type as input parameter
+ // Is array?
+ // For return type we use retType as input parameter
private boolean isArray(String param) {
// Check for array declaration
}
-
-