-
Notifications
You must be signed in to change notification settings - Fork 32
Description
I was comparing concoredocker.hpp against concoredocker.py (similar to what I did for the Java side in #197) and found a few functions that don't actually work correctly. This file was added in PR #143 and the author mentioned it wasn't tested, looks like a few things slipped through.
1.safe_literal_eval() always returns the default value
std::unordered_map<std::string, std::string> safe_literal_eval(const std::string& filename, std::unordered_map<std::string, std::string> defaultValue) {
std::ifstream file(filename);
if (!file) {
std::cerr << "Error reading " << filename << "\n";
return defaultValue;
}
return defaultValue; // returns default even when the file opens fine
}
The file is opened but the content is never read or parsed. So iport and oport are always empty {}, which means port mappings are completely ignored.
-
load_params() never populates the params map
The function reads concore.params, transforms the string with regex, but never actually inserts anything into this->params. The transformed string is just discarded. So tryparam() always returns the default. -
read() doesn't parse the data or track simtime
Python's read() does:
-
Parse the list with literal_eval
-
Extract simtime from inval[0]
-
Return inval[1:] (data without simtime)
The C++ version just returns the raw string {ins} without any parsing. Simtime is never updated from reads.
- Missing initval()
Both concoredocker.py and concoredocker.java have initval() which parses a string like "[0.0, 0.0]", sets simtime from the first element, and returns the rest. This function doesn't exist in the .hpp file at all.
Where, All in concoredocker.hpp. I can put up a fix that brings these in line with the Python version.