for (int i = 0; i < methParams.size(); i++) {
// Check for params with driver class types and exchange it
// with its remote interface
- String paramType = checkAndGetParamClass(methPrmTypes.get(i));
- String paramComplete = checkAndGetCplusArray(paramType, methParams.get(i));
- //print(paramType + " " + methParams.get(i));
- print(paramComplete);
+ String paramType = checkAndGetParamClass(methPrmTypes.get(i), false);
+ print(paramType + " " + methParams.get(i));
// Check if this is the last element (don't print a comma)
if (i != methParams.size() - 1) {
print(", ");
DeclarationHandler decHandler = mapIntDeclHand.get(intface);
InterfaceDecl intDecl = (InterfaceDecl) decHandler.getInterfaceDecl(intface);
List<String> methods = intDecl.getMethods();
+
+ // DEBUGGG
Set<String> includeClasses = getIncludeClasses(methods, intDecl);
+
printIncludeStatements(includeClasses);
println("");
println("using namespace std;");
for (int i = 0; i < methParams.size(); i++) {
// Check for params with driver class types and exchange it
// with its remote interface
- String paramType = checkAndGetParamClass(methPrmTypes.get(i));
+ String paramType = checkAndGetParamClass(methPrmTypes.get(i), true);
paramType = checkAndGetCplusType(paramType);
// Check for arrays - translate into vector in C++
String paramComplete = checkAndGetCplusArray(paramType, methParams.get(i));
print("public " + intDecl.getMethodType(method) + " " +
intDecl.getMethodId(method) + "(");
for (int i = 0; i < methParams.size(); i++) {
- print(methPrmTypes.get(i) + " " + methParams.get(i));
+ String paramType = checkAndGetParamClass(methPrmTypes.get(i), false);
+ print(paramType + " " + methParams.get(i));
+ //print(methPrmTypes.get(i) + " " + methParams.get(i));
// Check if this is the last element (don't print a comma)
if (i != methParams.size() - 1) {
print(", ");
print("virtual " + convertType(intDecl.getMethodType(method)) + " " +
intDecl.getMethodId(method) + "(");
for (int i = 0; i < methParams.size(); i++) {
-
- String methPrmType = checkAndGetCplusType(methPrmTypes.get(i));
+ String methPrmType = checkAndGetParamClass(methPrmTypes.get(i), true);
+ methPrmType = checkAndGetCplusType(methPrmType);
String methParamComplete = checkAndGetCplusArray(methPrmType, methParams.get(i));
- //print(methPrmType + " " + methParam);
print(methParamComplete);
// Check if this is the last element (don't print a comma)
if (i != methParams.size() - 1) {
List<String> methParams = intDecl.getMethodParams(method);
List<String> methPrmTypes = intDecl.getMethodParamTypes(method);
-
- //System.out.println("\n\nMethod param: " + intDecl.getMethodParams(method));
- //System.out.println("\n\nMethod param type: " + intDecl.getMethodParamTypes(method));
- //System.out.println("\n\n");
-
print(convertType(intDecl.getMethodType(method)) + " " +
intDecl.getMethodId(method) + "(");
for (int i = 0; i < methParams.size(); i++) {
String methPrmType = checkAndGetCplusType(methPrmTypes.get(i));
String methParamComplete = checkAndGetCplusArray(methPrmType, methParams.get(i));
- //print(methPrmType + " " + methParam);
print(methParamComplete);
// Check if this is the last element (don't print a comma)
if (i != methParams.size() - 1) {
methType.equals("double")) {
return "1";
- } else if ( methType.equals("String") ||
- methType.equals("byte")) {
+ } else if ( methType.equals("String")) {
return "\"a\"";
- } else if ( methType.equals("char")) {
+ } else if ( methType.equals("char") ||
+ methType.equals("byte")) {
return "\'a\'";
} else if ( methType.equals("boolean")) {
String simpleType = getSimpleType(methPrmTypes.get(i));
String param = methParams.get(i);
if (getParamCategory(simpleType) == ParamCategory.NONPRIMITIVES) {
- includeClasses.add(getNonPrimitiveCplusClass(simpleType));
+ includeClasses.add("<" + getNonPrimitiveCplusClass(simpleType) + ">");
+ } else if (getParamCategory(simpleType) == ParamCategory.USERDEFINED) {
+ includeClasses.add("\"" + exchangeParamType(simpleType) + ".hpp\"");
} else if (param.contains("[]")) {
// Check if this is array for C++; translate into vector
- includeClasses.add("vector");
+ includeClasses.add("<vector>");
}
}
}
private void printIncludeStatements(Set<String> includeClasses) {
for(String cls : includeClasses) {
- println("#include <" + cls + ">");
+ println("#include " + cls);
}
}
// Get simple types, e.g. HashSet for HashSet<...>
// Basically strip off the "<...>"
- private String checkAndGetParamClass(String paramType) {
+ private String checkAndGetParamClass(String paramType, boolean needPtr) {
// Check if this is generics
if(getParamCategory(paramType) == ParamCategory.USERDEFINED) {
- return exchangeParamType(paramType);
+ // If true then return with pointer (C++)
+ if (needPtr)
+ return exchangeParamType(paramType) + "*";
+ else // Java, so no pointer needed
+ return exchangeParamType(paramType);
} else
return paramType;
}