string toAndroidType(Interface& ext, string& androidPackageName, string& ctype, bool autoBox, bool constant, bool bytecode) { int ptrDepth = 0; string extractedType = extractPointerType(ctype, ptrDepth); if (ptrDepth > 0) { if (bytecode) { return POINTER_CLASS; } else { string prefix = ""; string suffix = ""; for (int i = 0; i < ptrDepth; i++) { prefix.append("Pointer<"); suffix.append(">"); } return prefix + toAndroidType(ext, androidPackageName, extractedType, true, constant, bytecode) + suffix; } } else { extractedType = resolveTypedef(ext, extractedType); if (extractedType == "NCString" || extractedType == "MAString") { if (bytecode) { return constant ? JAVA_STRING_CLASS : CSTRING_CLASS; } else { return constant ? "String" : "CString"; } } if (autoBox) { if (extractedType == "int") return "Integer"; if (extractedType == "char") return "Byte"; if (extractedType == "double") return "Double"; if (extractedType == "float") return "Float"; if (extractedType == "long long") return "Long"; } else { if (extractedType == "int") return (bytecode ? "I" : "int"); if (extractedType == "double") return (bytecode ? "D" : "double"); if (extractedType == "float") return (bytecode ? "F" : "float"); if (extractedType == "void") return (bytecode ? "V" : "void"); if (extractedType == "long long") return (bytecode ? "J" : "long"); if (extractedType == "char") return (bytecode ? "B" : "byte"); // S - short, Z - boolean } // The rest are structs return bytecode ? getBytecodeStructClass(androidPackageName, extractedType) : extractedType; } }
inline const T* resolveTypedefT(const z::Ast::TypeSpec& typeSpec) { const z::Ast::TypeSpec* ts = resolveTypedef(typeSpec); const T* td = dynamic_cast<const T*>(ts); return td; }
inline const z::Ast::TypeSpec& resolveTypedefR(const z::Ast::TypeSpec& typeSpec) { const z::Ast::TypeSpec* ts = resolveTypedef(typeSpec); return z::ref(ts); }