Updated naming

This commit is contained in:
Borna Rajkovic 2022-04-09 20:03:43 +02:00
parent c65d12a2a1
commit 883eaeb10a
8 changed files with 61 additions and 34 deletions

View File

@ -27,7 +27,7 @@ add_executable(SchemeEditor
comdel/domain/instanceattribute.cpp comdel/domain/instanceattribute.cpp
comdel/domain/connection.cpp comdel/domain/connection.cpp
comdel/domain/instance.cpp comdel/domain/instance.cpp
comdel/domain/comdelgenerator.cpp comdel/domain/schemacreator.cpp
comdel/parser/comdelparser.cpp comdel/parser/comdelparser.cpp
comdel/parser/token.cpp comdel/parser/token.cpp
comdel/parser/parser_util.cpp comdel/parser/parser_util.cpp

View File

@ -15,7 +15,7 @@ SOURCES += \
comdel/domain/addressspace.cpp \ comdel/domain/addressspace.cpp \
comdel/domain/attribute.cpp \ comdel/domain/attribute.cpp \
comdel/domain/bus.cpp \ comdel/domain/bus.cpp \
comdel/domain/comdelgenerator.cpp \ comdel/domain/schemacreator.cpp \
comdel/domain/component.cpp \ comdel/domain/component.cpp \
comdel/domain/connection.cpp \ comdel/domain/connection.cpp \
comdel/domain/connectioninstance.cpp \ comdel/domain/connectioninstance.cpp \
@ -29,7 +29,6 @@ SOURCES += \
comdel/domain/schema.cpp \ comdel/domain/schema.cpp \
comdel/domain/value.cpp \ comdel/domain/value.cpp \
comdel/domain/wireinstance.cpp \ comdel/domain/wireinstance.cpp \
comdel/parser/assert.cpp \
comdel/parser/astnode.cpp \ comdel/parser/astnode.cpp \
comdel/parser/comdellexer.cpp \ comdel/parser/comdellexer.cpp \
comdel/parser/comdelparser.cpp \ comdel/parser/comdelparser.cpp \
@ -48,7 +47,7 @@ HEADERS += \
comdel/domain/addressspace.h \ comdel/domain/addressspace.h \
comdel/domain/attribute.h \ comdel/domain/attribute.h \
comdel/domain/bus.h \ comdel/domain/bus.h \
comdel/domain/comdelgenerator.h \ comdel/domain/schemacreator.h \
comdel/domain/component.h \ comdel/domain/component.h \
comdel/domain/connection.h \ comdel/domain/connection.h \
comdel/domain/connectioninstance.h \ comdel/domain/connectioninstance.h \
@ -62,7 +61,6 @@ HEADERS += \
comdel/domain/schema.h \ comdel/domain/schema.h \
comdel/domain/value.h \ comdel/domain/value.h \
comdel/domain/wireinstance.h \ comdel/domain/wireinstance.h \
comdel/parser/assert.h \
comdel/parser/astnode.h \ comdel/parser/astnode.h \
comdel/parser/comdellexer.h \ comdel/parser/comdellexer.h \
comdel/parser/comdelparser.h \ comdel/parser/comdelparser.h \

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 6.0.2, 2022-04-08T23:43:55. --> <!-- Written by QtCreator 6.0.2, 2022-04-09T20:03:04. -->
<qtcreator> <qtcreator>
<data> <data>
<variable>EnvironmentId</variable> <variable>EnvironmentId</variable>

View File

@ -1,4 +1,4 @@
#include "comdelgenerator.h" #include "schemacreator.h"
#include<set> #include<set>
@ -99,11 +99,11 @@ Popup::PopupType toType(PopupNode::PopupType type)
return Popup::ON_DEMAND; return Popup::ON_DEMAND;
} }
ComdelGenerator::ComdelGenerator(std::vector<FunctionSignature> signatures) SchemaCreator::SchemaCreator(std::vector<FunctionSignature> signatures)
: signatures(signatures) : signatures(signatures)
{} {}
std::optional<Library> ComdelGenerator::loadLibrary(LibraryNode node) std::optional<Library> SchemaCreator::loadLibrary(LibraryNode node)
{ {
// library fields // library fields
if(!node.name) { if(!node.name) {
@ -161,7 +161,7 @@ std::optional<Library> ComdelGenerator::loadLibrary(LibraryNode node)
return Library(name, libraryInfo, header, componentDirectory, addressSpaces, components, buses, connections, messages); return Library(name, libraryInfo, header, componentDirectory, addressSpaces, components, buses, connections, messages);
} }
std::optional<Bus> ComdelGenerator::loadBus(BusNode node) std::optional<Bus> SchemaCreator::loadBus(BusNode node)
{ {
std::string name = node.name.value; std::string name = node.name.value;
@ -215,12 +215,12 @@ std::optional<Bus> ComdelGenerator::loadBus(BusNode node)
} }
std::optional<AddressSpace> ComdelGenerator::loadAddressSpace(AddressSpaceNode node) std::optional<AddressSpace> SchemaCreator::loadAddressSpace(AddressSpaceNode node)
{ {
return AddressSpace(node.name.value, node.start.value, node.end.value); return AddressSpace(node.name.value, node.start.value, node.end.value);
} }
std::optional<Connection> ComdelGenerator::loadConnection(ConnectionNode node) std::optional<Connection> SchemaCreator::loadConnection(ConnectionNode node)
{ {
push(ComdelContext("connection", false, true, false)); push(ComdelContext("connection", false, true, false));
@ -369,9 +369,10 @@ std::optional<Connection> ComdelGenerator::loadConnection(ConnectionNode node)
pop(); pop();
errors.emplace_back(node.span, "unsupported connection type"); errors.emplace_back(node.span, "unsupported connection type");
return std::nullopt;
} }
std::optional<Component> ComdelGenerator::loadComponent(ComponentNode node) std::optional<Component> SchemaCreator::loadComponent(ComponentNode node)
{ {
push(ComdelContext(node.name.value, true, false, false)); push(ComdelContext(node.name.value, true, false, false));
@ -453,7 +454,7 @@ std::optional<Component> ComdelGenerator::loadComponent(ComponentNode node)
return Component(name, tooltip, source, type, rules, instanceName, count, *display, pins, attributes); return Component(name, tooltip, source, type, rules, instanceName, count, *display, pins, attributes);
} }
std::optional<Wire> ComdelGenerator::loadWire(WireNode node) { std::optional<Wire> SchemaCreator::loadWire(WireNode node) {
return Wire( return Wire(
node.name.value, node.name.value,
toType(node.type), toType(node.type),
@ -464,7 +465,7 @@ std::optional<Wire> ComdelGenerator::loadWire(WireNode node) {
); );
} }
optional<Pin> ComdelGenerator::loadPin(PinNode node) optional<Pin> SchemaCreator::loadPin(PinNode node)
{ {
std::string name = node.name.value; std::string name = node.name.value;
Pin::PinType type = toType(node.type); Pin::PinType type = toType(node.type);
@ -519,7 +520,7 @@ int getIntProperty(DisplayItemNode &node, std::string property) {
throw std::exception(); throw std::exception();
} }
std::optional<Display> ComdelGenerator::loadDisplay(DisplayNode node) std::optional<Display> SchemaCreator::loadDisplay(DisplayNode node)
{ {
std::vector<ui::Item> items; std::vector<ui::Item> items;
for(auto &item: node.items) { for(auto &item: node.items) {
@ -555,14 +556,14 @@ std::optional<Display> ComdelGenerator::loadDisplay(DisplayNode node)
} }
PinConnection ComdelGenerator::loadPinConnection(PinConnectionNode node) PinConnection SchemaCreator::loadPinConnection(PinConnectionNode node)
{ {
std::string message = node.message.asString(); std::string message = node.message.asString();
PinConnection::ConnectionType type = toType(node.type); PinConnection::ConnectionType type = toType(node.type);
return PinConnection(message, type); return PinConnection(message, type);
} }
std::optional<Attribute> ComdelGenerator::loadAttribute(AttributeNode node) std::optional<Attribute> SchemaCreator::loadAttribute(AttributeNode node)
{ {
std::string name = node.name.value; std::string name = node.name.value;
pushAdditional(name); pushAdditional(name);
@ -603,7 +604,7 @@ std::optional<Attribute> ComdelGenerator::loadAttribute(AttributeNode node)
return Attribute(name, value, popup); return Attribute(name, value, popup);
} }
std::optional<Popup> ComdelGenerator::loadPopup(PopupNode node, std::string name, Value::ValueType type) std::optional<Popup> SchemaCreator::loadPopup(PopupNode node, std::string name, Value::ValueType type)
{ {
auto popupType = toType(*node.type); auto popupType = toType(*node.type);
@ -670,7 +671,7 @@ std::optional<Popup> ComdelGenerator::loadPopup(PopupNode node, std::string name
return Popup(title, text, popupType, rules, enumeration); return Popup(title, text, popupType, rules, enumeration);
} }
std::optional<Rule> ComdelGenerator::loadRule(RuleNode node) std::optional<Rule> SchemaCreator::loadRule(RuleNode node)
{ {
std::vector<IfStatement> statements; std::vector<IfStatement> statements;
@ -686,7 +687,7 @@ std::optional<Rule> ComdelGenerator::loadRule(RuleNode node)
return Rule(statements); return Rule(statements);
} }
std::optional<Condition> ComdelGenerator::loadCondition(ConditionNode node) std::optional<Condition> SchemaCreator::loadCondition(ConditionNode node)
{ {
std::string function = node.functionName.value; std::string function = node.functionName.value;
@ -727,7 +728,7 @@ std::optional<Condition> ComdelGenerator::loadCondition(ConditionNode node)
} }
std::optional<Schema> ComdelGenerator::loadSchema(SchemaNode node, Library &library) std::optional<Schema> SchemaCreator::loadSchema(SchemaNode node, Library &library)
{ {
Schema schema; Schema schema;
@ -792,7 +793,7 @@ std::optional<Schema> ComdelGenerator::loadSchema(SchemaNode node, Library &libr
continue; continue;
} }
} else { } else {
ConnectionComponent firstConn{firstComponent->name, conn.first.pin.value}; ConnectionComponent firstConn{firstComponent->component.getName(), conn.first.pin.value};
if(library.hasConnection(firstConn, if(library.hasConnection(firstConn,
bus->bus.getName())) { bus->bus.getName())) {
@ -845,7 +846,7 @@ std::optional<Schema> ComdelGenerator::loadSchema(SchemaNode node, Library &libr
return schema; return schema;
} }
ComponentInstance *ComdelGenerator::loadComponentInstance(InstanceNode instance, Library &library) { ComponentInstance *SchemaCreator::loadComponentInstance(InstanceNode instance, Library &library) {
auto name = instance.name.value; auto name = instance.name.value;
auto position = std::make_pair(instance.position->first.value, instance.position->second.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); 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 name = instance.name.value;
auto position = std::make_pair(instance.position->first.value, instance.position->second.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); return new BusInstance(name, position, bus, size);
} }
std::optional<WireInstance*> ComdelGenerator::loadWireInstance(WireInstanceNode node) { std::optional<WireInstance*> SchemaCreator::loadWireInstance(WireInstanceNode node) {
if(!node.display) { if(!node.display) {
errors.push_back(SourceError{node.span, "missing @text"}); errors.push_back(SourceError{node.span, "missing @text"});

View File

@ -44,7 +44,7 @@ struct ComdelContext {
}; };
class ComdelGenerator class SchemaCreator
{ {
std::vector<ComdelContext> context; std::vector<ComdelContext> context;
@ -130,7 +130,7 @@ class ComdelGenerator
} }
public: public:
ComdelGenerator(std::vector<FunctionSignature> signatures); SchemaCreator(std::vector<FunctionSignature> signatures);
std::vector<SourceError> getErrors() { std::vector<SourceError> getErrors() {
return errors; return errors;

View File

@ -4,8 +4,6 @@
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
QApplication a(argc, argv); QApplication a(argc, argv);
MainWindow w; MainWindow w;
w.show(); w.show();

View File

@ -6,7 +6,7 @@
#include <comdel/parser/parsecontext.h> #include <comdel/parser/parsecontext.h>
#include <comdel/parser/parserutil.h> #include <comdel/parser/parserutil.h>
#include <comdel/domain/comdelgenerator.h> #include <comdel/domain/schemacreator.h>
#include <iostream> #include <iostream>
@ -59,7 +59,7 @@ void MainWindow::onTestModal() {
auto schemaNode = loadSchemaFromFile(&parseContext, filename.toStdString().c_str(), std::cout); auto schemaNode = loadSchemaFromFile(&parseContext, filename.toStdString().c_str(), std::cout);
if(schemaNode) { if(schemaNode) {
domain::ComdelGenerator generator(signatures); domain::SchemaCreator generator(signatures);
library = generator.loadLibrary(*schemaNode->library); library = generator.loadLibrary(*schemaNode->library);
for (auto& error : generator.getErrors()) { for (auto& error : generator.getErrors()) {
@ -91,7 +91,7 @@ void MainWindow::onLoadLibrary() {
ParseContext parseContext; ParseContext parseContext;
auto libraryNode = loadLibraryFromFile(&parseContext, filename.toStdString().c_str(), std::cout); auto libraryNode = loadLibraryFromFile(&parseContext, filename.toStdString().c_str(), std::cout);
if(libraryNode) { if(libraryNode) {
domain::ComdelGenerator generator(signatures); domain::SchemaCreator generator(signatures);
library = generator.loadLibrary(*libraryNode); library = generator.loadLibrary(*libraryNode);
for (auto& error : generator.getErrors()) { for (auto& error : generator.getErrors()) {
@ -116,7 +116,7 @@ void MainWindow::onLoadSchema() {
auto schemaNode = loadSchemaFromFile(&parseContext, filename.toStdString().c_str(), std::cout); auto schemaNode = loadSchemaFromFile(&parseContext, filename.toStdString().c_str(), std::cout);
if(schemaNode) { if(schemaNode) {
domain::ComdelGenerator generator(signatures); domain::SchemaCreator generator(signatures);
library = generator.loadLibrary(*schemaNode->library); library = generator.loadLibrary(*schemaNode->library);
for (auto& error : generator.getErrors()) { for (auto& error : generator.getErrors()) {

View File

@ -23,6 +23,21 @@
<height>23</height> <height>23</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuFile">
<property name="title">
<string>File</string>
</property>
<addaction name="actionSave_schema"/>
<addaction name="actionExport_schema"/>
</widget>
<widget class="QMenu" name="menuEdit">
<property name="title">
<string>Edit</string>
</property>
<addaction name="actionValidate"/>
</widget>
<addaction name="menuFile"/>
<addaction name="menuEdit"/>
</widget> </widget>
<widget class="QStatusBar" name="statusbar"/> <widget class="QStatusBar" name="statusbar"/>
<widget class="QToolBar" name="toolBar"> <widget class="QToolBar" name="toolBar">
@ -36,6 +51,21 @@
<bool>false</bool> <bool>false</bool>
</attribute> </attribute>
</widget> </widget>
<action name="actionSave_schema">
<property name="text">
<string>Save schema</string>
</property>
</action>
<action name="actionExport_schema">
<property name="text">
<string>Export schema</string>
</property>
</action>
<action name="actionValidate">
<property name="text">
<string>Validate</string>
</property>
</action>
</widget> </widget>
<resources/> <resources/>
<connections/> <connections/>