Skip to content

Commit

Permalink
reconfigure for upstream changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mck1117 committed Jan 3, 2025
1 parent 59468f1 commit 34005e8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,11 @@ private int handleYaml(Map<String, Object> data) throws IOException {

if (outputNames.length == 0) {
outputChannelWriter.writeOutputChannels(parseState, null);
sdLogWriter.writeSdLogs(parseState);
sdLogWriter.writeSdLogs(parseState, null);
} else {
for (String outputName : outputNames) {
outputChannelWriter.writeOutputChannels(parseState, outputName);
sdLogWriter.writeSdLogs(parseState, outputName);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,22 @@
import java.io.PrintStream;

public class OutputChannelVisitorBase extends ILayoutVisitor {
protected final NameReplacer nameReplacer;
private NameReplacer nameReplacer = null;

public OutputChannelVisitorBase() { }

public OutputChannelVisitorBase(String nameReplace) {
setNameReplacer(nameReplace);
}

public void setNameReplacer(String nameReplace) {
this.nameReplacer = new NameReplacer(nameReplace);
}

public String buildDatalogName(String name, String comment) {
String text = (comment == null || comment.isEmpty()) ? name : nameReplacer.replace(comment);
String text = (comment == null || comment.isEmpty() || nameReplacer == null)
? name
: nameReplacer.replace(comment);

// Delete anything after a newline
return text.split("\\\\n")[0];
Expand All @@ -34,7 +42,7 @@ public void visit(StructLayout struct, PrintStream ps, StructNamePrefixer prefix
}
}

protected class NameReplacer {
private class NameReplacer {
public final String name;

public NameReplacer(String name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,19 @@ public void endFile() {
ps.println("static_assert(TS_TOTAL_OUTPUT_SIZE == " + recordLength + ");");
}

public void writeSdLogs(ParseState parser) {
public void writeSdLogs(ParseState parser, String namePrefix) {
// Assume the last struct is the one we want...
Struct s = parser.getStructs().get(parser.getStructs().size() - 1);

StructLayout sl = new StructLayout(0, "root", s);

StructNamePrefixer prefixer = new StructNamePrefixer('_');

if (namePrefix != null) {
prefixer.push(namePrefix.replace(" ", "_"));
}

visitor.setNameReplacer(namePrefix);
visitor.visit(sl, ps, prefixer, 0, new int[0]);
}
}

0 comments on commit 34005e8

Please sign in to comment.