clangformat

This commit is contained in:
Miodrag Milanovic 2018-08-08 18:17:34 +02:00
parent ecc21caa77
commit fc5cee6fb8
11 changed files with 31 additions and 34 deletions

View File

@ -35,8 +35,8 @@
#include "design_utils.h" #include "design_utils.h"
#include "jsonparse.h" #include "jsonparse.h"
#include "log.h" #include "log.h"
#include "timing.h"
#include "version.h" #include "version.h"
#include <timing.h>
NEXTPNR_NAMESPACE_BEGIN NEXTPNR_NAMESPACE_BEGIN
@ -244,7 +244,7 @@ int CommandHandler::exec()
if (executeBeforeContext()) if (executeBeforeContext())
return 0; return 0;
std::unique_ptr<Context> ctx; std::unique_ptr<Context> ctx;
if (vm.count("load")) { if (vm.count("load")) {
ctx = project.load(vm["load"].as<std::string>()); ctx = project.load(vm["load"].as<std::string>());

View File

@ -17,12 +17,12 @@
* *
*/ */
#include "project.h"
#include <boost/filesystem/convenience.hpp> #include <boost/filesystem/convenience.hpp>
#include <boost/property_tree/json_parser.hpp> #include <boost/property_tree/json_parser.hpp>
#include "project.h"
#include "log.h"
#include "jsonparse.h"
#include <fstream> #include <fstream>
#include "jsonparse.h"
#include "log.h"
NEXTPNR_NAMESPACE_BEGIN NEXTPNR_NAMESPACE_BEGIN
@ -34,10 +34,10 @@ void ProjectHandler::save(Context *ctx, std::string filename)
root.put("project.name", boost::filesystem::basename(filename)); root.put("project.name", boost::filesystem::basename(filename));
root.put("project.arch.name", ctx->archId().c_str(ctx)); root.put("project.arch.name", ctx->archId().c_str(ctx));
root.put("project.arch.type", ctx->archArgsToId(ctx->archArgs()).c_str(ctx)); root.put("project.arch.type", ctx->archArgsToId(ctx->archArgs()).c_str(ctx));
/* root.put("project.input.json", );*/ /* root.put("project.input.json", );*/
root.put("project.params.freq", int(ctx->target_freq / 1e6)); root.put("project.params.freq", int(ctx->target_freq / 1e6));
root.put("project.params.seed", ctx->rngstate); root.put("project.params.seed", ctx->rngstate);
saveArch(ctx,root); saveArch(ctx, root);
pt::write_json(f, root); pt::write_json(f, root);
} }
@ -55,7 +55,6 @@ std::unique_ptr<Context> ProjectHandler::load(std::string filename)
if (version != 1) if (version != 1)
log_error("Wrong project format version.\n"); log_error("Wrong project format version.\n");
ctx = createContext(root); ctx = createContext(root);
std::string arch_name = root.get<std::string>("project.arch.name"); std::string arch_name = root.get<std::string>("project.arch.name");
@ -77,7 +76,7 @@ std::unique_ptr<Context> ProjectHandler::load(std::string filename)
if (params.count("seed")) if (params.count("seed"))
ctx->rngseed(params.get<uint64_t>("seed")); ctx->rngseed(params.get<uint64_t>("seed"));
} }
loadArch(ctx.get(),root, proj.parent_path().string()); loadArch(ctx.get(), root, proj.parent_path().string());
} catch (...) { } catch (...) {
log_error("Error loading project file.\n"); log_error("Error loading project file.\n");
} }

View File

@ -17,11 +17,11 @@
* *
*/ */
#include "project.h"
#include <boost/filesystem/convenience.hpp> #include <boost/filesystem/convenience.hpp>
#include <boost/property_tree/json_parser.hpp> #include <boost/property_tree/json_parser.hpp>
#include "project.h"
#include "log.h"
#include <fstream> #include <fstream>
#include "log.h"
NEXTPNR_NAMESPACE_BEGIN NEXTPNR_NAMESPACE_BEGIN
@ -50,8 +50,6 @@ std::unique_ptr<Context> ProjectHandler::createContext(pt::ptree &root)
return std::unique_ptr<Context>(new Context(chipArgs)); return std::unique_ptr<Context>(new Context(chipArgs));
} }
void ProjectHandler::loadArch(Context *ctx, pt::ptree &root, std::string path) void ProjectHandler::loadArch(Context *ctx, pt::ptree &root, std::string path) {}
{
}
NEXTPNR_NAMESPACE_END NEXTPNR_NAMESPACE_END

View File

@ -17,16 +17,14 @@
* *
*/ */
#include <boost/filesystem/convenience.hpp>
#include "project.h" #include "project.h"
#include "log.h" #include <boost/filesystem/convenience.hpp>
#include <fstream> #include <fstream>
#include "log.h"
NEXTPNR_NAMESPACE_BEGIN NEXTPNR_NAMESPACE_BEGIN
void ProjectHandler::saveArch(Context *ctx, pt::ptree &root) void ProjectHandler::saveArch(Context *ctx, pt::ptree &root) {}
{
}
std::unique_ptr<Context> ProjectHandler::createContext(pt::ptree &root) std::unique_ptr<Context> ProjectHandler::createContext(pt::ptree &root)
{ {
@ -34,8 +32,6 @@ std::unique_ptr<Context> ProjectHandler::createContext(pt::ptree &root)
return std::unique_ptr<Context>(new Context(chipArgs)); return std::unique_ptr<Context>(new Context(chipArgs));
} }
void ProjectHandler::loadArch(Context *ctx, pt::ptree &root, std::string path) void ProjectHandler::loadArch(Context *ctx, pt::ptree &root, std::string path) {}
{
}
NEXTPNR_NAMESPACE_END NEXTPNR_NAMESPACE_END

View File

@ -463,5 +463,4 @@ void BaseMainWindow::save_proj()
} }
} }
NEXTPNR_NAMESPACE_END NEXTPNR_NAMESPACE_END

View File

@ -49,6 +49,7 @@ class BaseMainWindow : public QMainWindow
virtual ~BaseMainWindow(); virtual ~BaseMainWindow();
Context *getContext() { return ctx.get(); } Context *getContext() { return ctx.get(); }
void updateJsonLoaded(); void updateJsonLoaded();
protected: protected:
void createMenusAndBars(); void createMenusAndBars();
void disableActions(); void disableActions();

View File

@ -29,7 +29,8 @@ static void initMainResource() { Q_INIT_RESOURCE(nextpnr); }
NEXTPNR_NAMESPACE_BEGIN NEXTPNR_NAMESPACE_BEGIN
MainWindow::MainWindow(std::unique_ptr<Context> context, ArchArgs args, QWidget *parent) : BaseMainWindow(std::move(context), args, parent) MainWindow::MainWindow(std::unique_ptr<Context> context, ArchArgs args, QWidget *parent)
: BaseMainWindow(std::move(context), args, parent)
{ {
initMainResource(); initMainResource();
@ -50,7 +51,8 @@ void MainWindow::newContext(Context *ctx)
setWindowTitle(title.c_str()); setWindowTitle(title.c_str());
} }
void MainWindow::createMenu() { void MainWindow::createMenu()
{
// Add arch specific actions // Add arch specific actions
actionLoadBase = new QAction("Open Base Config", this); actionLoadBase = new QAction("Open Base Config", this);
actionLoadBase->setIcon(QIcon(":/icons/resources/open_base.png")); actionLoadBase->setIcon(QIcon(":/icons/resources/open_base.png"));
@ -71,7 +73,7 @@ void MainWindow::createMenu() {
menuDesign->addSeparator(); menuDesign->addSeparator();
menuDesign->addAction(actionLoadBase); menuDesign->addAction(actionLoadBase);
menuDesign->addAction(actionSaveConfig); menuDesign->addAction(actionSaveConfig);
} }
static const ChipInfoPOD *get_chip_info(const RelPtr<ChipInfoPOD> *ptr) { return ptr->get(); } static const ChipInfoPOD *get_chip_info(const RelPtr<ChipInfoPOD> *ptr) { return ptr->get(); }
@ -96,8 +98,8 @@ static QStringList getSupportedPackages(ArchArgs::ArchArgsTypes chip)
return packages; return packages;
} }
void MainWindow::new_proj()
void MainWindow::new_proj() { {
QMap<QString, int> arch; QMap<QString, int> arch;
arch.insert("Lattice ECP5 25K", ArchArgs::LFE5U_25F); arch.insert("Lattice ECP5 25K", ArchArgs::LFE5U_25F);
arch.insert("Lattice ECP5 45K", ArchArgs::LFE5U_45F); arch.insert("Lattice ECP5 45K", ArchArgs::LFE5U_45F);

View File

@ -47,6 +47,7 @@ class MainWindow : public BaseMainWindow
void newContext(Context *ctx); void newContext(Context *ctx);
void open_base(); void open_base();
void save_config(); void save_config();
private: private:
QAction *actionLoadBase; QAction *actionLoadBase;
QAction *actionSaveConfig; QAction *actionSaveConfig;

View File

@ -23,7 +23,8 @@ static void initMainResource() { Q_INIT_RESOURCE(nextpnr); }
NEXTPNR_NAMESPACE_BEGIN NEXTPNR_NAMESPACE_BEGIN
MainWindow::MainWindow(std::unique_ptr<Context> context, ArchArgs args, QWidget *parent) : BaseMainWindow(std::move(context), args, parent) MainWindow::MainWindow(std::unique_ptr<Context> context, ArchArgs args, QWidget *parent)
: BaseMainWindow(std::move(context), args, parent)
{ {
initMainResource(); initMainResource();

View File

@ -24,12 +24,12 @@
#include <QIcon> #include <QIcon>
#include <QInputDialog> #include <QInputDialog>
#include <QLineEdit> #include <QLineEdit>
#include <fstream>
#include "bitstream.h" #include "bitstream.h"
#include "design_utils.h" #include "design_utils.h"
#include "jsonparse.h" #include "jsonparse.h"
#include "log.h" #include "log.h"
#include "pcf.h" #include "pcf.h"
#include <fstream>
static void initMainResource() { Q_INIT_RESOURCE(nextpnr); } static void initMainResource() { Q_INIT_RESOURCE(nextpnr); }

View File

@ -17,10 +17,10 @@
* *
*/ */
#include <boost/filesystem/convenience.hpp>
#include "project.h" #include "project.h"
#include "log.h" #include <boost/filesystem/convenience.hpp>
#include <fstream> #include <fstream>
#include "log.h"
#include "pcf.h" #include "pcf.h"
NEXTPNR_NAMESPACE_BEGIN NEXTPNR_NAMESPACE_BEGIN
@ -28,7 +28,7 @@ NEXTPNR_NAMESPACE_BEGIN
void ProjectHandler::saveArch(Context *ctx, pt::ptree &root) void ProjectHandler::saveArch(Context *ctx, pt::ptree &root)
{ {
root.put("project.arch.package", ctx->archArgs().package); root.put("project.arch.package", ctx->archArgs().package);
// if(!pcfFilename.empty()) // if(!pcfFilename.empty())
// root.put("project.input.pcf", pcfFilename); // root.put("project.input.pcf", pcfFilename);
} }
@ -62,7 +62,7 @@ std::unique_ptr<Context> ProjectHandler::createContext(pt::ptree &root)
void ProjectHandler::loadArch(Context *ctx, pt::ptree &root, std::string path) void ProjectHandler::loadArch(Context *ctx, pt::ptree &root, std::string path)
{ {
auto input = root.get_child("project").get_child("input"); auto input = root.get_child("project").get_child("input");
boost::filesystem::path pcf = boost::filesystem::path(path) / input.get<std::string>("pcf"); boost::filesystem::path pcf = boost::filesystem::path(path) / input.get<std::string>("pcf");
std::ifstream f(pcf.string()); std::ifstream f(pcf.string());
if (!apply_pcf(ctx, f)) if (!apply_pcf(ctx, f))
log_error("Loading PCF failed.\n"); log_error("Loading PCF failed.\n");