From 883eaeb10a68acfb1d72cf2fe925e46624440927 Mon Sep 17 00:00:00 2001 From: Borna Rajkovic Date: Sat, 9 Apr 2022 20:03:43 +0200 Subject: [PATCH] Updated naming --- CMakeLists.txt | 2 +- SchemeEditor.pro | 6 +-- SchemeEditor.pro.user | 2 +- ...{comdelgenerator.cpp => schemacreator.cpp} | 41 ++++++++++--------- .../{comdelgenerator.h => schemacreator.h} | 4 +- main.cpp | 2 - mainwindow.cpp | 8 ++-- mainwindow.ui | 30 ++++++++++++++ 8 files changed, 61 insertions(+), 34 deletions(-) rename comdel/domain/{comdelgenerator.cpp => schemacreator.cpp} (95%) rename comdel/domain/{comdelgenerator.h => schemacreator.h} (97%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9ef8dac..39c83b0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,7 +27,7 @@ add_executable(SchemeEditor comdel/domain/instanceattribute.cpp comdel/domain/connection.cpp comdel/domain/instance.cpp - comdel/domain/comdelgenerator.cpp + comdel/domain/schemacreator.cpp comdel/parser/comdelparser.cpp comdel/parser/token.cpp comdel/parser/parser_util.cpp diff --git a/SchemeEditor.pro b/SchemeEditor.pro index 33e478e..c70655c 100644 --- a/SchemeEditor.pro +++ b/SchemeEditor.pro @@ -15,7 +15,7 @@ SOURCES += \ comdel/domain/addressspace.cpp \ comdel/domain/attribute.cpp \ comdel/domain/bus.cpp \ - comdel/domain/comdelgenerator.cpp \ + comdel/domain/schemacreator.cpp \ comdel/domain/component.cpp \ comdel/domain/connection.cpp \ comdel/domain/connectioninstance.cpp \ @@ -29,7 +29,6 @@ SOURCES += \ comdel/domain/schema.cpp \ comdel/domain/value.cpp \ comdel/domain/wireinstance.cpp \ - comdel/parser/assert.cpp \ comdel/parser/astnode.cpp \ comdel/parser/comdellexer.cpp \ comdel/parser/comdelparser.cpp \ @@ -48,7 +47,7 @@ HEADERS += \ comdel/domain/addressspace.h \ comdel/domain/attribute.h \ comdel/domain/bus.h \ - comdel/domain/comdelgenerator.h \ + comdel/domain/schemacreator.h \ comdel/domain/component.h \ comdel/domain/connection.h \ comdel/domain/connectioninstance.h \ @@ -62,7 +61,6 @@ HEADERS += \ comdel/domain/schema.h \ comdel/domain/value.h \ comdel/domain/wireinstance.h \ - comdel/parser/assert.h \ comdel/parser/astnode.h \ comdel/parser/comdellexer.h \ comdel/parser/comdelparser.h \ diff --git a/SchemeEditor.pro.user b/SchemeEditor.pro.user index 1b72d71..2670782 100644 --- a/SchemeEditor.pro.user +++ b/SchemeEditor.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/comdel/domain/comdelgenerator.cpp b/comdel/domain/schemacreator.cpp similarity index 95% rename from comdel/domain/comdelgenerator.cpp rename to comdel/domain/schemacreator.cpp index 30f4792..d9f127f 100644 --- a/comdel/domain/comdelgenerator.cpp +++ b/comdel/domain/schemacreator.cpp @@ -1,4 +1,4 @@ -#include "comdelgenerator.h" +#include "schemacreator.h" #include @@ -99,11 +99,11 @@ Popup::PopupType toType(PopupNode::PopupType type) return Popup::ON_DEMAND; } -ComdelGenerator::ComdelGenerator(std::vector signatures) +SchemaCreator::SchemaCreator(std::vector signatures) : signatures(signatures) {} -std::optional ComdelGenerator::loadLibrary(LibraryNode node) +std::optional SchemaCreator::loadLibrary(LibraryNode node) { // library fields if(!node.name) { @@ -161,7 +161,7 @@ std::optional ComdelGenerator::loadLibrary(LibraryNode node) return Library(name, libraryInfo, header, componentDirectory, addressSpaces, components, buses, connections, messages); } -std::optional ComdelGenerator::loadBus(BusNode node) +std::optional SchemaCreator::loadBus(BusNode node) { std::string name = node.name.value; @@ -215,12 +215,12 @@ std::optional ComdelGenerator::loadBus(BusNode node) } -std::optional ComdelGenerator::loadAddressSpace(AddressSpaceNode node) +std::optional SchemaCreator::loadAddressSpace(AddressSpaceNode node) { return AddressSpace(node.name.value, node.start.value, node.end.value); } -std::optional ComdelGenerator::loadConnection(ConnectionNode node) +std::optional SchemaCreator::loadConnection(ConnectionNode node) { push(ComdelContext("connection", false, true, false)); @@ -369,9 +369,10 @@ std::optional ComdelGenerator::loadConnection(ConnectionNode node) pop(); errors.emplace_back(node.span, "unsupported connection type"); + return std::nullopt; } -std::optional ComdelGenerator::loadComponent(ComponentNode node) +std::optional SchemaCreator::loadComponent(ComponentNode node) { push(ComdelContext(node.name.value, true, false, false)); @@ -453,7 +454,7 @@ std::optional ComdelGenerator::loadComponent(ComponentNode node) return Component(name, tooltip, source, type, rules, instanceName, count, *display, pins, attributes); } -std::optional ComdelGenerator::loadWire(WireNode node) { +std::optional SchemaCreator::loadWire(WireNode node) { return Wire( node.name.value, toType(node.type), @@ -464,7 +465,7 @@ std::optional ComdelGenerator::loadWire(WireNode node) { ); } -optional ComdelGenerator::loadPin(PinNode node) +optional SchemaCreator::loadPin(PinNode node) { std::string name = node.name.value; Pin::PinType type = toType(node.type); @@ -519,7 +520,7 @@ int getIntProperty(DisplayItemNode &node, std::string property) { throw std::exception(); } -std::optional ComdelGenerator::loadDisplay(DisplayNode node) +std::optional SchemaCreator::loadDisplay(DisplayNode node) { std::vector items; for(auto &item: node.items) { @@ -555,14 +556,14 @@ std::optional ComdelGenerator::loadDisplay(DisplayNode node) } -PinConnection ComdelGenerator::loadPinConnection(PinConnectionNode node) +PinConnection SchemaCreator::loadPinConnection(PinConnectionNode node) { std::string message = node.message.asString(); PinConnection::ConnectionType type = toType(node.type); return PinConnection(message, type); } -std::optional ComdelGenerator::loadAttribute(AttributeNode node) +std::optional SchemaCreator::loadAttribute(AttributeNode node) { std::string name = node.name.value; pushAdditional(name); @@ -603,7 +604,7 @@ std::optional ComdelGenerator::loadAttribute(AttributeNode node) return Attribute(name, value, popup); } -std::optional ComdelGenerator::loadPopup(PopupNode node, std::string name, Value::ValueType type) +std::optional SchemaCreator::loadPopup(PopupNode node, std::string name, Value::ValueType type) { auto popupType = toType(*node.type); @@ -670,7 +671,7 @@ std::optional ComdelGenerator::loadPopup(PopupNode node, std::string name return Popup(title, text, popupType, rules, enumeration); } -std::optional ComdelGenerator::loadRule(RuleNode node) +std::optional SchemaCreator::loadRule(RuleNode node) { std::vector statements; @@ -686,7 +687,7 @@ std::optional ComdelGenerator::loadRule(RuleNode node) return Rule(statements); } -std::optional ComdelGenerator::loadCondition(ConditionNode node) +std::optional SchemaCreator::loadCondition(ConditionNode node) { std::string function = node.functionName.value; @@ -727,7 +728,7 @@ std::optional ComdelGenerator::loadCondition(ConditionNode node) } -std::optional ComdelGenerator::loadSchema(SchemaNode node, Library &library) +std::optional SchemaCreator::loadSchema(SchemaNode node, Library &library) { Schema schema; @@ -792,7 +793,7 @@ std::optional ComdelGenerator::loadSchema(SchemaNode node, Library &libr continue; } } else { - ConnectionComponent firstConn{firstComponent->name, conn.first.pin.value}; + ConnectionComponent firstConn{firstComponent->component.getName(), conn.first.pin.value}; if(library.hasConnection(firstConn, bus->bus.getName())) { @@ -845,7 +846,7 @@ std::optional ComdelGenerator::loadSchema(SchemaNode node, Library &libr return schema; } -ComponentInstance *ComdelGenerator::loadComponentInstance(InstanceNode instance, Library &library) { +ComponentInstance *SchemaCreator::loadComponentInstance(InstanceNode instance, Library &library) { auto name = instance.name.value; auto position = std::make_pair(instance.position->first.value, instance.position->second.value); @@ -865,7 +866,7 @@ ComponentInstance *ComdelGenerator::loadComponentInstance(InstanceNode instance, return new ComponentInstance(name, attributes, position, component); } -BusInstance *ComdelGenerator::loadBusInstance(InstanceNode instance, Library &library) { +BusInstance *SchemaCreator::loadBusInstance(InstanceNode instance, Library &library) { auto name = instance.name.value; auto position = std::make_pair(instance.position->first.value, instance.position->second.value); @@ -880,7 +881,7 @@ BusInstance *ComdelGenerator::loadBusInstance(InstanceNode instance, Library &li return new BusInstance(name, position, bus, size); } -std::optional ComdelGenerator::loadWireInstance(WireInstanceNode node) { +std::optional SchemaCreator::loadWireInstance(WireInstanceNode node) { if(!node.display) { errors.push_back(SourceError{node.span, "missing @text"}); diff --git a/comdel/domain/comdelgenerator.h b/comdel/domain/schemacreator.h similarity index 97% rename from comdel/domain/comdelgenerator.h rename to comdel/domain/schemacreator.h index de3cdf8..7766d1b 100644 --- a/comdel/domain/comdelgenerator.h +++ b/comdel/domain/schemacreator.h @@ -44,7 +44,7 @@ struct ComdelContext { }; -class ComdelGenerator +class SchemaCreator { std::vector context; @@ -130,7 +130,7 @@ class ComdelGenerator } public: - ComdelGenerator(std::vector signatures); + SchemaCreator(std::vector signatures); std::vector getErrors() { return errors; diff --git a/main.cpp b/main.cpp index b126258..fd3e533 100644 --- a/main.cpp +++ b/main.cpp @@ -4,8 +4,6 @@ int main(int argc, char *argv[]) { - - QApplication a(argc, argv); MainWindow w; w.show(); diff --git a/mainwindow.cpp b/mainwindow.cpp index 1c75f7f..b3759e1 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -6,7 +6,7 @@ #include #include -#include +#include #include @@ -59,7 +59,7 @@ void MainWindow::onTestModal() { auto schemaNode = loadSchemaFromFile(&parseContext, filename.toStdString().c_str(), std::cout); if(schemaNode) { - domain::ComdelGenerator generator(signatures); + domain::SchemaCreator generator(signatures); library = generator.loadLibrary(*schemaNode->library); for (auto& error : generator.getErrors()) { @@ -91,7 +91,7 @@ void MainWindow::onLoadLibrary() { ParseContext parseContext; auto libraryNode = loadLibraryFromFile(&parseContext, filename.toStdString().c_str(), std::cout); if(libraryNode) { - domain::ComdelGenerator generator(signatures); + domain::SchemaCreator generator(signatures); library = generator.loadLibrary(*libraryNode); for (auto& error : generator.getErrors()) { @@ -116,7 +116,7 @@ void MainWindow::onLoadSchema() { auto schemaNode = loadSchemaFromFile(&parseContext, filename.toStdString().c_str(), std::cout); if(schemaNode) { - domain::ComdelGenerator generator(signatures); + domain::SchemaCreator generator(signatures); library = generator.loadLibrary(*schemaNode->library); for (auto& error : generator.getErrors()) { diff --git a/mainwindow.ui b/mainwindow.ui index 8a2a626..5095e83 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -23,6 +23,21 @@ 23 + + + File + + + + + + + Edit + + + + + @@ -36,6 +51,21 @@ false + + + Save schema + + + + + Export schema + + + + + Validate + +