new parse: write C structs (#2852)

* fix offsets inside struct arrays

* style

* fix index writing for arrays of structs

* write TS context comments

* cleanup

* ts writer copies all lines input -> output

* Add _hex and _char definitions

* definition tostring

* replace variables

* wire up firing order replacement

* c struct writer

Co-authored-by: Matthew Kennedy <makenne@microsoft.com>
This commit is contained in:
Matthew Kennedy 2021-06-24 16:43:56 -07:00 committed by GitHub
parent 12bd5bdf2b
commit 3f99110467
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 6 deletions

View File

@ -2,6 +2,7 @@ package com.rusefi;
import com.rusefi.generated.*;
import com.rusefi.newparse.ParseState;
import com.rusefi.newparse.outputs.CStructWriter;
import com.rusefi.newparse.outputs.TsWriter;
import com.rusefi.newparse.parsing.Definition;
import com.rusefi.output.*;
@ -278,12 +279,8 @@ public class ConfigDefinition {
}
// Write C structs
// PrintStream cPrintStream = new PrintStream(new FileOutputStream(destCHeaderFileName));
// for (Struct s : listener.getStructs()) {
// StructLayout sl = new StructLayout(0, "root", s);
// sl.writeCLayoutRoot(cPrintStream);
// }
// cPrintStream.close();
// CStructWriter cStructs = new CStructWriter();
// cStructs.writeCStructs(listener, destCHeaderFileName + ".test");
// Write tunerstudio layout
// TsWriter writer = new TsWriter();

View File

@ -0,0 +1,30 @@
package com.rusefi.newparse.outputs;
import com.rusefi.newparse.ParseState;
import com.rusefi.newparse.layout.StructLayout;
import com.rusefi.newparse.parsing.Struct;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
public class CStructWriter {
public void writeCStructs(ParseState parser, String outputFile) throws FileNotFoundException {
PrintStream ps = new PrintStream(new FileOutputStream(outputFile));
ps.println(
"// begin\n" +
"#pragma once\n" +
"#include \"rusefi_types.h\""
);
for (Struct s : parser.getStructs()) {
StructLayout sl = new StructLayout(0, "root", s);
sl.writeCLayoutRoot(ps);
}
ps.println("// end");
ps.close();
}
}