helping kinetis
This commit is contained in:
parent
e589ba629f
commit
292b699f9a
Binary file not shown.
|
@ -5,6 +5,7 @@ import com.rusefi.ConfigFieldImpl;
|
|||
import com.rusefi.ReaderState;
|
||||
import com.rusefi.TypesHelper;
|
||||
import com.rusefi.core.Tuple;
|
||||
import com.rusefi.output.variables.VariableRecord;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
@ -37,7 +38,7 @@ public class GetConfigValueConsumer implements ConfigurationConsumer {
|
|||
static final String GET_METHOD_FOOTER = "\treturn EFI_ERROR_CODE;\n" + "}\n";
|
||||
private static final String SET_METHOD_HEADER = "void setConfigValueByName(const char *name, float value) {\n";
|
||||
private static final String SET_METHOD_FOOTER = "}\n";
|
||||
private final List<Tuple<String>> variables = new ArrayList<>();
|
||||
private final List<VariableRecord> variables = new ArrayList<>();
|
||||
private final String outputFileName;
|
||||
private final String mdOutputFileName;
|
||||
|
||||
|
@ -93,7 +94,7 @@ public class GetConfigValueConsumer implements ConfigurationConsumer {
|
|||
if (javaName.startsWith(CONFIG_ENGINE_CONFIGURATION))
|
||||
javaName = "engineConfiguration->" + javaName.substring(CONFIG_ENGINE_CONFIGURATION.length());
|
||||
|
||||
variables.add(new Tuple<>(userName, javaName + cf.getName(), cf.getType()));
|
||||
variables.add(new VariableRecord(userName, javaName + cf.getName(), cf.getType(), null));
|
||||
|
||||
mdContent.append("### " + userName + "\n");
|
||||
mdContent.append(cf.getComment() + "\n\n");
|
||||
|
@ -127,7 +128,7 @@ public class GetConfigValueConsumer implements ConfigurationConsumer {
|
|||
public String getCompleteGetterBody() {
|
||||
StringBuilder switchBody = new StringBuilder();
|
||||
|
||||
StringBuilder getterBody = GetOutputValueConsumer.getGetters(switchBody, variables, null);
|
||||
StringBuilder getterBody = GetOutputValueConsumer.getGetters(switchBody, variables);
|
||||
|
||||
String fullSwitch = wrapSwitchStatement(switchBody);
|
||||
|
||||
|
@ -142,20 +143,20 @@ public class GetConfigValueConsumer implements ConfigurationConsumer {
|
|||
StringBuilder setterBody = new StringBuilder();
|
||||
HashMap<Integer, AtomicInteger> hashConflicts = getHashConflicts(variables);
|
||||
|
||||
for (Tuple<String> pair : variables) {
|
||||
for (VariableRecord pair : variables) {
|
||||
|
||||
String cast = TypesHelper.isFloat(pair.third) ? "" : "(int)";
|
||||
String cast = TypesHelper.isFloat(pair.type) ? "" : "(int)";
|
||||
|
||||
|
||||
int hash = HashUtil.hash(pair.first);
|
||||
String str = getAssignment(cast, pair.second);
|
||||
int hash = HashUtil.hash(pair.getUserName());
|
||||
String str = getAssignment(cast, pair.getFullName());
|
||||
if (hashConflicts.get(hash).get() == 1) {
|
||||
switchBody.append("\t\tcase " + hash + ":\n");
|
||||
switchBody.append(str);
|
||||
|
||||
} else {
|
||||
|
||||
setterBody.append(getCompareName(pair.first));
|
||||
setterBody.append(getCompareName(pair.getUserName()));
|
||||
setterBody.append(str);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.rusefi.ConfigField;
|
|||
import com.rusefi.ReaderState;
|
||||
import com.rusefi.TypesHelper;
|
||||
import com.rusefi.core.Pair;
|
||||
import com.rusefi.output.variables.VariableRecord;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -24,7 +25,7 @@ import static com.rusefi.output.GetConfigValueConsumer.getCompareName;
|
|||
*/
|
||||
@SuppressWarnings("StringConcatenationInsideStringBufferAppend")
|
||||
public class GetOutputValueConsumer implements ConfigurationConsumer {
|
||||
private final List<Pair<String, String>> getterPairs = new ArrayList<>();
|
||||
private final List<VariableRecord> getterPairs = new ArrayList<>();
|
||||
private final String fileName;
|
||||
|
||||
public String currentSectionPrefix = "engine->outputChannels";
|
||||
|
@ -56,7 +57,7 @@ public class GetOutputValueConsumer implements ConfigurationConsumer {
|
|||
String userName = prefix + cf.getName();
|
||||
String javaName = currentSectionPrefix + "." + prefix;
|
||||
|
||||
getterPairs.add(new Pair<>(userName, javaName + cf.getName()));
|
||||
getterPairs.add(new VariableRecord(userName, javaName + cf.getName(), null, conditional));
|
||||
|
||||
|
||||
return "";
|
||||
|
@ -70,7 +71,7 @@ public class GetOutputValueConsumer implements ConfigurationConsumer {
|
|||
public String getContent() {
|
||||
StringBuilder switchBody = new StringBuilder();
|
||||
|
||||
StringBuilder getterBody = getGetters(switchBody, getterPairs, conditional);
|
||||
StringBuilder getterBody = getGetters(switchBody, getterPairs);
|
||||
|
||||
String fullSwitch = wrapSwitchStatement(switchBody);
|
||||
|
||||
|
@ -90,24 +91,25 @@ public class GetOutputValueConsumer implements ConfigurationConsumer {
|
|||
}
|
||||
|
||||
@NotNull
|
||||
static StringBuilder getGetters(StringBuilder switchBody, List<? extends Pair<String, String>> getterPairs, String conditional) {
|
||||
static StringBuilder getGetters(StringBuilder switchBody, List<VariableRecord> getterPairs) {
|
||||
HashMap<Integer, AtomicInteger> hashConflicts = getHashConflicts(getterPairs);
|
||||
|
||||
StringBuilder getterBody = new StringBuilder();
|
||||
for (Pair<String, String> pair : getterPairs) {
|
||||
String returnLine = "\t\treturn " + pair.second + ";\n";
|
||||
for (VariableRecord pair : getterPairs) {
|
||||
String returnLine = "\t\treturn " + pair.getFullName() + ";\n";
|
||||
String conditional = pair.getConditional();
|
||||
|
||||
String before = conditional == null ? "" : "#if " + conditional + "\n";
|
||||
String after = conditional == null ? "" : "#endif\n";
|
||||
|
||||
int hash = HashUtil.hash(pair.first);
|
||||
int hash = HashUtil.hash(pair.getUserName());
|
||||
if (hashConflicts.get(hash).get() == 1) {
|
||||
switchBody.append(before);
|
||||
switchBody.append("\t\tcase " + hash + ":\n");
|
||||
switchBody.append("\t" + returnLine);
|
||||
switchBody.append(after);
|
||||
} else {
|
||||
getterBody.append(getCompareName(pair.first));
|
||||
getterBody.append(getCompareName(pair.getUserName()));
|
||||
getterBody.append(returnLine);
|
||||
}
|
||||
}
|
||||
|
@ -115,10 +117,10 @@ public class GetOutputValueConsumer implements ConfigurationConsumer {
|
|||
}
|
||||
|
||||
@NotNull
|
||||
static HashMap<Integer, AtomicInteger> getHashConflicts(List<? extends Pair<String, String>> getterPairs1) {
|
||||
static HashMap<Integer, AtomicInteger> getHashConflicts(List<VariableRecord> getterPairs) {
|
||||
HashMap<Integer, AtomicInteger> hashConflicts = new HashMap<>();
|
||||
for (Pair<String, String> pair : getterPairs1) {
|
||||
hashConflicts.computeIfAbsent(HashUtil.hash(pair.first), integer -> new AtomicInteger(0)).incrementAndGet();
|
||||
for (VariableRecord pair : getterPairs) {
|
||||
hashConflicts.computeIfAbsent(HashUtil.hash(pair.getUserName()), integer -> new AtomicInteger(0)).incrementAndGet();
|
||||
}
|
||||
return hashConflicts;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
package com.rusefi.output.variables;
|
||||
|
||||
import com.rusefi.core.Pair;
|
||||
|
||||
public class VariableRecord {
|
||||
public final String type;
|
||||
private final String humanName;
|
||||
private final String fullName;
|
||||
private final String conditional;
|
||||
|
||||
|
||||
public VariableRecord(String humanName, String fullName, String type, String conditional) {
|
||||
this.humanName = humanName;
|
||||
this.fullName = fullName;
|
||||
this.type = type;
|
||||
this.conditional = conditional;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return humanName;
|
||||
}
|
||||
|
||||
public String getFullName() {
|
||||
return fullName;
|
||||
}
|
||||
|
||||
public String getConditional() {
|
||||
return conditional;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue