Skip to content

Commit

Permalink
Parse defines as lists
Browse files Browse the repository at this point in the history
  • Loading branch information
karniv00l committed Dec 29, 2023
1 parent cc51114 commit 0197ab6
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 79 deletions.
3 changes: 1 addition & 2 deletions lib/ini_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class INIParser {
final String raw;
final List<String> lines = [];
final List<String> settings = [];
final Map<String, String> defines = {};
final Map<String, List<String>> defines = {};

// assume that top level definitions are in the TunerStudio section (see FOME)
String _currentSection = 'TunerStudio';
Expand All @@ -40,7 +40,6 @@ class INIParser {
lines.addAll(preProcessor.lines);
settings.addAll(preProcessor.settings);
defines.addAll(preProcessor.defines);
_config.defines = defines;

for (final line in lines) {
_parseSections(line);
Expand Down
2 changes: 0 additions & 2 deletions lib/models/ini_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1198,7 +1198,6 @@ class FrontPage {

class INIConfig {
Header header = Header();
Map<String, String> defines = {};
List<SettingGroup> settingGroups = [];
List<PcVariable> pcVariables = [];
Constants constants = Constants();
Expand All @@ -1217,7 +1216,6 @@ class INIConfig {
Map<String, dynamic> toJson() {
return {
'header': header.toJson(),
'defines': defines,
'settingGroups': settingGroups.map((c) => c.toJson()).toList(),
'pcVariables': pcVariables.map((c) => c.toJson()).toList(),
'constants': constants.toJson(),
Expand Down
8 changes: 5 additions & 3 deletions lib/pre_processor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class PreProcessor {
late final String raw;
late final List<String> settings;
final List<String> lines = [];
final Map<String, String> defines = {};
final Map<String, List<String>> defines = {};

/// Pre-process INI:
/// - remove comments
Expand Down Expand Up @@ -88,9 +88,11 @@ class PreProcessor {
if (line.startsWith('#define')) {
final parts = line.substring(7).trim().split('=');
final key = parts[0].sanitize();
final value = parts[1].sanitize();
final values = parts[1].sanitize().split(',').map((e) => e.sanitize());

defines.addAll({key: value});
defines.addAll({
key: values.toList(),
});

continue;
}
Expand Down
1 change: 0 additions & 1 deletion test/data/fome/json/fome_proteus_f4.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"iniSpecVersion": null,
"hyperTunerCloudUrl": "tunes.fome.tech"
},
"defines": {},
"settingGroups": [],
"pcVariables": [
{
Expand Down
Loading

0 comments on commit 0197ab6

Please sign in to comment.