update codegen. add python code gen
This commit is contained in:
@ -1,14 +1,29 @@
|
||||
import java.io.OutputStreamWriter;
|
||||
|
||||
public class IndentHelper {
|
||||
public IndentHelper(OutputStreamWriter writer) {
|
||||
public IndentHelper(OutputStreamWriter writer, CommonHelper.LangType lang_type) {
|
||||
mIndent = 0;
|
||||
mLangType = lang_type;
|
||||
mWriter = writer;
|
||||
}
|
||||
|
||||
private int mIndent;
|
||||
private CommonHelper.LangType mLangType;
|
||||
private OutputStreamWriter mWriter;
|
||||
|
||||
private void rawIndent() throws Exception {
|
||||
for (int i = 0; i < mIndent; ++i) {
|
||||
switch (mLangType) {
|
||||
case CPP:
|
||||
mWriter.write("\t");
|
||||
break;
|
||||
case Python:
|
||||
mWriter.write(" ");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void inc() {
|
||||
++mIndent;
|
||||
}
|
||||
@ -19,9 +34,7 @@ public class IndentHelper {
|
||||
|
||||
public void indent() throws Exception {
|
||||
mWriter.write("\n");
|
||||
for (int i = 0; i < mIndent; ++i) {
|
||||
mWriter.write("\t");
|
||||
}
|
||||
rawIndent();
|
||||
}
|
||||
|
||||
public void puts(String data) throws Exception {
|
||||
@ -38,28 +51,57 @@ public class IndentHelper {
|
||||
* Write standard Doxygen document comment.
|
||||
* <p>
|
||||
* Usually be called before writing content.
|
||||
*
|
||||
* @param comment
|
||||
* @throws Exception
|
||||
*/
|
||||
public void briefComment(String comment) throws Exception {
|
||||
if (comment == null)
|
||||
return;
|
||||
puts("/**");
|
||||
puts(comment);
|
||||
puts(" */");
|
||||
|
||||
switch (mLangType) {
|
||||
case CPP:
|
||||
rawIndent();
|
||||
puts("/**");
|
||||
|
||||
puts(comment);
|
||||
|
||||
rawIndent();
|
||||
puts(" */");
|
||||
break;
|
||||
case Python:
|
||||
rawIndent();
|
||||
puts("\"\"\"!");
|
||||
|
||||
puts(comment);
|
||||
|
||||
rawIndent();
|
||||
puts("\"\"\"");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write suffix style Doxygen document comment.
|
||||
* <p>
|
||||
* Usually be called after writing content.
|
||||
*
|
||||
* @param comment
|
||||
* @throws Exception
|
||||
*/
|
||||
public void afterMemberComment(String comment) throws Exception {
|
||||
if (comment == null)
|
||||
return;
|
||||
mWriter.write(String.format("\t/**< %s */", CommonHelper.removeEol(comment)));
|
||||
|
||||
switch (mLangType) {
|
||||
case CPP:
|
||||
mWriter.write(String.format("\t/**< %s */", CommonHelper.removeEol(comment)));
|
||||
break;
|
||||
case Python:
|
||||
mWriter.write(String.format(" ##< %s", CommonHelper.removeEol(comment)));
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user