Added single automatic connection dialog + bugfixes

This commit is contained in:
Borna Rajković committed 2022-06-05 19:02:44 +02:00
1 parent 3172d7e4cf
commit 9b7ede933a
18 files changed
+253 -117

No files matched your search

+4
View File
@@ -59,4 +59,8 @@ namespace domain {
return popup;
}
void Attribute::setPupup(std::optional<Popup> popup) {
this->popup = popup;
}
} // namespace domain
+2 -1
View File
@@ -54,7 +54,7 @@ namespace domain {
void setEnumeration(std::vector<Enumeration> enums) {
enumerated = true;
enumeration = std::move(enums);
enumeration = enums;
}
};
@@ -71,6 +71,7 @@ namespace domain {
Value getDefault();
std::optional<Popup> getPopup();
void setPupup(std::optional<Popup> popup);
};
} // namespace domain
+1 -1
View File
@@ -62,7 +62,7 @@ namespace domain {
return false;
}
std::vector<Attribute> Component::getAttributes() {
std::vector<Attribute>& Component::getAttributes() {
return attributes;
}
+1 -1
View File
@@ -60,7 +60,7 @@ namespace domain {
Pin getPin(std::string pin);
std::vector<Attribute> getAttributes();
std::vector<Attribute>& getAttributes();
Attribute getAttribute(std::string attribute);
+1 -1
View File
@@ -20,7 +20,7 @@ namespace domain {
return bus;
}
std::vector<Attribute> Connection::getAttributes() {
std::vector<Attribute>& Connection::getAttributes() {
return attributes;
}
+1 -1
View File
@@ -60,7 +60,7 @@ namespace domain {
std::string getBus();
std::vector<Attribute> getAttributes();
std::vector<Attribute>& getAttributes();
std::vector<Value> getWires();
+19 -5
View File
@@ -438,7 +438,9 @@ namespace domain {
} else if (attributes[0].getDefault().getType() != Value::STRING) {
errors.emplace_back(node.attributes[0].span, "@attribute must be of type string");
} else {
attributes[0].getPopup()->setEnumeration(createWireEnumeration(firstWires));
domain::Popup popup = *attributes[0].getPopup();
popup.setEnumeration(createWireEnumeration(firstWires));
attributes[0].setPupup(popup);
}
if (!attributes[1].getPopup().has_value()) {
@@ -446,7 +448,9 @@ namespace domain {
} else if (attributes[1].getDefault().getType() != Value::STRING) {
errors.emplace_back(node.attributes[1].span, "@attribute must be of type string");
} else {
attributes[1].getPopup()->setEnumeration(createWireEnumeration(secondWires));
domain::Popup popup = *attributes[1].getPopup();
popup.setEnumeration(createWireEnumeration(secondWires));
attributes[1].setPupup(popup);
}
}
@@ -935,12 +939,22 @@ namespace domain {
auto attribute = connection->getAttribute(attr.name.value);
auto value = toType(attr.value);
bool valueFound = false;
// all connection attributes must be of type enumeration
for (auto &en: attribute.getPopup()->getEnumeration()) {
if (en.getValue().asReference() == value.asReference()) {
value = Value::fromReference(value.asReference(), Value::WIRE_REFERENCE);
if (en.getValue().equals(value)) {
valueFound = true;
break;
} else if(value.isType(Value::UNDEFINED)) {
if(en.getValue().isType(Value::WIRE_REFERENCE) && en.getValue().asReference() == value.asReference()) {
value = Value::fromReference(value.asReference(), Value::WIRE_REFERENCE);
valueFound = true;
break;
}
}
}
if (value.isType(Value::UNDEFINED)) {
if (!valueFound) {
errors.emplace_back(attr.span, "invalid value");
}