From 25b5e4943c2611a02cba5d717a6a3aa212505add Mon Sep 17 00:00:00 2001 From: rusefi Date: Mon, 3 Apr 2017 21:09:04 -0400 Subject: [PATCH] #382 improvements to generator to support simple string constants --- java_tools/ConfigDefinition.jar | Bin 32357 -> 32879 bytes .../src/com/rusefi/ConfigField.java | 3 ++- .../src/com/rusefi/VariableRegistry.java | 17 ++++++++++++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/java_tools/ConfigDefinition.jar b/java_tools/ConfigDefinition.jar index 7ce6969b9295f69d6e42aed5a325d68ac2ecef2f..22711af658c71546d48b5538053558e1325cae0c 100644 GIT binary patch delta 11147 zcmeI&)mPMUlmKu*x&)*f>6Y%4M!F;g>F$mnB`x8A#7KiQf`by$NW;JY(mB%L3=NX& zp0oR~`w#5H@_o54-}629>7IK(_q%nAii|`f(A9i`j*EhVjekkS63W__(oSYSKwlL_)_9udWkQDenqZmRT4 zru?=~%I5A=_XfeqjtJvP*J^{x;ST-H^2}DOb~Q{1eMxgeZ-KfOW)&^U$92!QMEi;R zo0BmQ-u2TZAq~T_Iqt*7vymQ~1j}46!SG6W4!i{(&`(1a$Ptl$v|M&Y-w(!UH;J1Y zZBW+sGzw!V>01&;;7 z({0qguVacI0nVAgk)W~NAMnY-HCqtSn|{_EjpgV2Ikd z%35%x(JS!gJP+{`CwyYv`i;(Ix7z+t6g?a8W}>@u28dwO4$(!aDRy#kViA~MTN6sB zR`*BtX)6Z2ZK!fww|*F!>{(sie0lWg^-x*XpJkhaIhs8>yTTRYb>Q49kSWa)B0@hSNONtl|(?S9CGjGej(!u$*MViF5S;7Z@=r_9P zxWr{jC4i6SYYI&D`hD1lc&>mRWGIL-TMSqEaNuAU_TBKrsU43n@5N|box5dH120Z% z(UK>%twWFZJa65woq30wfiW~H*ZBKvxs#-&nz=)DrU>3kV`m-$3Z&T-uxBx7!^Gb$ zpjnyirU`Ge#=ZDNC30#^y-Lk<@3q7BoT zB~Ud$4iK~b8nd9N^}5JQ5^Xj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2qD8J`zK3#Ic!VbEIq&YIF$;Pgw)w#W{3B(M>y^z{m zl^z0(GD&H3+@skC*8gBqKc!u&yz&qd3&fx0HJ#PuC41sEl{AAXJ2p&xuH>7NYy(jg z-ZZ+H$D3~oB-`Do|7paT;>cVXR*U8~*CaZ!+a>T#+8dI>(wf_C=VNa1|0P4z=OD)V zQ%`oHdP(_nnma7K!@@f(yu-pfEWE?QJ1o4z!aFRy!@@f(yu-pfEWE?QJ1o4z!aFRy z!@@f({Qr)Hf<%P>xtgIk{iXkXGOV}r561sraJU^{Mc~GPQhr8_inpUcxdig#e?lb( z>f*nBNWkUo;U$S%r`j Kk^22R%6|cGT704a diff --git a/java_tools/configuration_definition/src/com/rusefi/ConfigField.java b/java_tools/configuration_definition/src/com/rusefi/ConfigField.java index b728253c54..bc4c7ea050 100644 --- a/java_tools/configuration_definition/src/com/rusefi/ConfigField.java +++ b/java_tools/configuration_definition/src/com/rusefi/ConfigField.java @@ -29,6 +29,7 @@ public class ConfigField { public static final int LENGTH = 24; private static final char TS_COMMENT_TAG = '+'; + public static final String ENUM_SUFFIX = "_enum"; /** * field name without structure name @@ -224,7 +225,7 @@ public class ConfigField { writeJavaFieldName(javaFieldsWriter, nameWithPrefix, tsPosition); javaFieldsWriter.write("FieldType.FLOAT);" + EOL); } else { - String enumOptions = VariableRegistry.INSTANCE.get(type + "_enum"); + String enumOptions = VariableRegistry.INSTANCE.get(type + ENUM_SUFFIX); if (enumOptions != null && !javaEnums.contains(type)) { javaEnums.add(type); diff --git a/java_tools/configuration_definition/src/com/rusefi/VariableRegistry.java b/java_tools/configuration_definition/src/com/rusefi/VariableRegistry.java index c942271799..fd711748a2 100644 --- a/java_tools/configuration_definition/src/com/rusefi/VariableRegistry.java +++ b/java_tools/configuration_definition/src/com/rusefi/VariableRegistry.java @@ -24,6 +24,7 @@ public class VariableRegistry extends TreeMap { private final StringBuilder cAllDefinitions = new StringBuilder("//\n// generated by ConfigDefinition.jar tool based on rusefi_config.txt\n//\n\n"); private final StringBuilder javaNumbericDefinitions = new StringBuilder(); + private final StringBuilder javaStringDefinitions = new StringBuilder(); private VariableRegistry() { super(String.CASE_INSENSITIVE_ORDER); @@ -64,9 +65,23 @@ public class VariableRegistry extends TreeMap { javaNumbericDefinitions.append("\tpublic static final int " + var + " = " + intValue + ";" + EOL); } catch (NumberFormatException e) { System.out.println("Not an integer: " + value); + + if (isQuoted(value) && !var.trim().endsWith(ConfigField.ENUM_SUFFIX)) { + // quoted and not with enum suffix means plain string define statement + javaStringDefinitions.append("\tpublic static final String " + var + " = " + value + ";" + EOL); + } } } + private boolean isQuoted(String value) { + if (value == null) + return false; + value = value.trim(); + if (value.isEmpty()) + return false; + return value.charAt(0) == '"' && value.charAt(value.length() - 1) == '"'; + } + public void register(String var, int i) { register(var, Integer.toString(i)); register(var + "_hex", Integer.toString(i, 16)); @@ -82,6 +97,6 @@ public class VariableRegistry extends TreeMap { } public String getJavaConstants() { - return javaNumbericDefinitions.toString(); + return javaNumbericDefinitions.toString() + javaStringDefinitions.toString(); } }