int prevPart = FilePart.COMMENT; // Suppresse newline before copyright
String text;
Iterator it = inputFile.getPartIterator();
while (it.hasNext()) {
FilePart fp = (FilePart) (it.next());
if (!foundCopyright
&& (FilePart.DIRECTIVE == fp.getType()
|| FilePart.ENUM == fp.getType()
|| FilePart.PROTOTYPE == fp.getType())) {
outputFile.write("#ifndef " + define);
outputFile.newLine();
outputFile.write("#define " + define);
outputFile.newLine();
foundCopyright = true;
}
switch (fp.getType()) {
case FilePart.COMMENT :
if (FilePart.COMMENT != prevPart)
outputFile.newLine();
prevPart = fp.getType();
text = fp.toString().trim();
StringTokenizer tkzr = new StringTokenizer(text, "\n\r");
while (tkzr.hasMoreTokens()) {
String line = tkzr.nextToken();
if (-1 == line.indexOf("@author")) {
outputFile.write(line);
outputFile.newLine();
}
}
break;
case FilePart.DIRECTIVE :
if (FilePart.DIRECTIVE != prevPart)
outputFile.newLine();
prevPart = fp.getType();
generateDirective(fp, outputFile, inputFile.getName());
break;
case FilePart.TYPEDEF :
prevPart = fp.getType();
generateTypedef(fp, outputFile);
break;
case FilePart.METHOD :
case FilePart.PROTOTYPE :
if (FilePart.COMMENT != prevPart
&& FilePart.METHOD != prevPart
&& FilePart.PROTOTYPE != prevPart)
outputFile.newLine();
prevPart = fp.getType();
generateFunctionPrototype(fp, outputFile);
break;
case FilePart.ENUM :
Utils.rude(
"Enums should be wrappered with a typedef so "
+ "they appear the same in C and C++",
inputFile.getName(),
0,
fp.toString());
break;
// do nothing for other file parts
}
}