diff options
author | Clifford Wolf <clifford@clifford.at> | 2018-06-21 16:16:58 +0200 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2018-06-21 16:16:58 +0200 |
commit | 4fefdbd57c52d6373456bd379e3e54df770e1945 (patch) | |
tree | 668c93671338f4482b163c2e8f40298cbedcb2c0 | |
parent | 417e67938c12be20a1c314d42386ede0ad8993a7 (diff) | |
download | nextpnr-4fefdbd57c52d6373456bd379e3e54df770e1945.tar.gz nextpnr-4fefdbd57c52d6373456bd379e3e54df770e1945.tar.bz2 nextpnr-4fefdbd57c52d6373456bd379e3e54df770e1945.zip |
Cleanup parse_json_file API, some other cleanups
Signed-off-by: Clifford Wolf <clifford@clifford.at>
-rw-r--r-- | common/pybindings.cc | 3 | ||||
-rw-r--r-- | dummy/arch.cc | 2 | ||||
-rw-r--r-- | frontend/json/jsonparse.cc | 37 | ||||
-rw-r--r-- | frontend/json/jsonparse.h | 2 | ||||
-rw-r--r-- | gui/ice40/worker.cc | 2 | ||||
-rw-r--r-- | ice40/main.cc | 2 |
6 files changed, 17 insertions, 31 deletions
diff --git a/common/pybindings.cc b/common/pybindings.cc index 26e8bf69..02dc2395 100644 --- a/common/pybindings.cc +++ b/common/pybindings.cc @@ -52,8 +52,7 @@ void parse_json_shim(std::string filename, Context &d) std::ifstream inf(filename); if (!inf) throw std::runtime_error("failed to open file " + filename); - std::istream *ifp = &inf; - parse_json_file(ifp, filename, &d); + parse_json_file(inf, filename, &d); } // Create a new Chip and load design from json file diff --git a/dummy/arch.cc b/dummy/arch.cc index fa9ca473..0ed0f11e 100644 --- a/dummy/arch.cc +++ b/dummy/arch.cc @@ -102,7 +102,7 @@ PipId Arch::getPipByName(IdString name) const { return PipId(); } IdString Arch::getPipName(PipId pip) const { return IdString(); } -uint32_t Arch::getWireChecksum(WireId wire) const { return 0; } +uint32_t Arch::getPipChecksum(PipId wire) const { return 0; } void Arch::bindPip(PipId pip, IdString net) {} diff --git a/frontend/json/jsonparse.cc b/frontend/json/jsonparse.cc index 277e602a..7d9e9dcf 100644 --- a/frontend/json/jsonparse.cc +++ b/frontend/json/jsonparse.cc @@ -795,39 +795,26 @@ void json_import(Context *ctx, string modname, JsonNode *node) } check_all_nets_driven(ctx); } +}; // End Namespace JsonParser -struct JsonFrontend +void parse_json_file(std::istream &f, std::string &filename, Context *ctx) { - // JsonFrontend() : Frontend("json", "read JSON file") { } - JsonFrontend(void) {} - virtual void help() {} - virtual void execute(std::istream *&f, std::string &filename, Context *ctx) - { - // log_header(ctx, "Executing JSON frontend.\n"); + using namespace JsonParser; - JsonNode root(*f); + JsonNode root(f); - if (root.type != 'D') - log_error("JSON root node is not a dictionary.\n"); + if (root.type != 'D') + log_error("JSON root node is not a dictionary.\n"); - if (root.data_dict.count("modules") != 0) { - JsonNode *modules = root.data_dict.at("modules"); + if (root.data_dict.count("modules") != 0) { + JsonNode *modules = root.data_dict.at("modules"); - if (modules->type != 'D') - log_error("JSON modules node is not a dictionary.\n"); + if (modules->type != 'D') + log_error("JSON modules node is not a dictionary.\n"); - for (auto &it : modules->data_dict) - json_import(ctx, it.first, it.second); - } + for (auto &it : modules->data_dict) + json_import(ctx, it.first, it.second); } -}; // JsonFrontend; - -}; // End Namespace JsonParser - -void parse_json_file(std::istream *&f, std::string &filename, Context *ctx) -{ - auto *parser = new JsonParser::JsonFrontend(); - parser->execute(f, filename, ctx); log_info("Checksum: 0x%08x\n", ctx->checksum()); log_break(); diff --git a/frontend/json/jsonparse.h b/frontend/json/jsonparse.h index ee3d19ca..351b6558 100644 --- a/frontend/json/jsonparse.h +++ b/frontend/json/jsonparse.h @@ -26,7 +26,7 @@ NEXTPNR_NAMESPACE_BEGIN -extern void parse_json_file(std::istream *&, std::string &, Context *); +extern void parse_json_file(std::istream &, std::string &, Context *); NEXTPNR_NAMESPACE_END diff --git a/gui/ice40/worker.cc b/gui/ice40/worker.cc index 5a8ff0e9..bd22f552 100644 --- a/gui/ice40/worker.cc +++ b/gui/ice40/worker.cc @@ -18,7 +18,7 @@ Worker::Worker(Context *_ctx) : ctx(_ctx) void Worker::parsejson(const std::string &filename) { std::string fn = filename; - std::istream *f = new std::ifstream(fn); + std::ifstream f(fn); parse_json_file(f, fn, ctx); if (!pack_design(ctx)) diff --git a/ice40/main.cc b/ice40/main.cc index e86cd5b1..76c059b8 100644 --- a/ice40/main.cc +++ b/ice40/main.cc @@ -283,7 +283,7 @@ int main(int argc, char *argv[]) if (vm.count("json")) { std::string filename = vm["json"].as<std::string>(); - std::istream *f = new std::ifstream(filename); + std::ifstream f(filename); parse_json_file(f, filename, &ctx); |