Fix header file for multi-target output with pointers to varying in exported functions.

This commit is contained in:
james.brodman
2013-12-12 13:27:23 -05:00
parent d10c0d9545
commit 01432670fd
4 changed files with 270 additions and 76 deletions

View File

@@ -2869,13 +2869,55 @@ FunctionType::GetCDeclaration(const std::string &fname) const {
CastType<ArrayType>(pt->GetBaseType()) != NULL) {
type = new ArrayType(pt->GetBaseType(), 0);
}
if (paramNames[i] != "")
ret += type->GetCDeclaration(paramNames[i]);
ret += type->GetCDeclaration(paramNames[i]);
else
ret += type->GetString();
ret += type->GetString();
if (i != paramTypes.size() - 1)
ret += ", ";
ret += ", ";
}
ret += ")";
return ret;
}
std::string
FunctionType::GetCDeclarationForDispatch(const std::string &fname) const {
std::string ret;
ret += returnType->GetCDeclaration("");
ret += " ";
ret += fname;
ret += "(";
for (unsigned int i = 0; i < paramTypes.size(); ++i) {
const Type *type = paramTypes[i];
// Convert pointers to arrays to unsized arrays, which are more clear
// to print out for multidimensional arrays (i.e. "float foo[][4] "
// versus "float (foo *)[4]").
const PointerType *pt = CastType<PointerType>(type);
if (pt != NULL &&
CastType<ArrayType>(pt->GetBaseType()) != NULL) {
type = new ArrayType(pt->GetBaseType(), 0);
}
// Change pointers to varying thingies to void *
if (pt != NULL && pt->GetBaseType()->IsVaryingType()) {
PointerType *t = PointerType::Void;
if (paramNames[i] != "")
ret += t->GetCDeclaration(paramNames[i]);
else
ret += t->GetString();
}
else {
if (paramNames[i] != "")
ret += type->GetCDeclaration(paramNames[i]);
else
ret += type->GetString();
}
if (i != paramTypes.size() - 1)
ret += ", ";
}
ret += ")";
return ret;