Added display name

This commit is contained in:
Borna Rajković committed 2022-06-14 21:27:40 +02:00
1 parent 7be3a1b5bc
commit eaa115d115
15 files changed
+120 -40

No files matched your search

+9 -2
View File
@@ -44,8 +44,15 @@ namespace domain {
}
Attribute::Attribute(std::string name, Value defaultValue, std::optional<Popup> popup)
: name(name), defaultValue(defaultValue), popup(popup) {}
Attribute::Attribute(std::string name, std::optional<std::string> displayName, Value defaultValue, std::optional<Popup> popup)
: name(name), displayName(displayName), defaultValue(defaultValue), popup(popup) {}
std::string Attribute::getDisplayName() {
if(displayName.has_value()) {
return *displayName;
}
return name;
}
std::string Attribute::getName() {
return name;
+4 -1
View File
@@ -61,13 +61,16 @@ namespace domain {
class Attribute {
std::string name;
std::optional<std::string> displayName;
Value defaultValue;
std::optional<Popup> popup;
public:
Attribute(std::string name, Value defaultValue, std::optional<Popup> popup = std::nullopt);
Attribute(std::string name, std::optional<std::string> displayName, Value defaultValue, std::optional<Popup> popup = std::nullopt);
std::string getName();
std::string getDisplayName();
Value getDefault();
std::optional<Popup> getPopup();
+10 -2
View File
@@ -35,14 +35,21 @@ namespace domain {
return type;
}
Bus::Bus(std::string name, std::string instanceName, std::string tooltip, BusType type, std::pair<int, int> count, std::vector<Wire> wires,
Bus::Bus(std::string name, std::optional<std::string> displayName, std::string instanceName, std::string tooltip, BusType type, std::pair<int, int> count, std::vector<Wire> wires,
std::optional<ui::Bus> displayBus)
: name(name), instanceName(instanceName), tooltip(tooltip), type(type), count(count), wires(wires), displayBus(displayBus) {}
: name(name), displayName(displayName), instanceName(instanceName), tooltip(tooltip), type(type), count(count), wires(wires), displayBus(displayBus) {}
std::string Bus::getName() {
return name;
}
std::string Bus::getDisplayName() {
if(displayName.has_value()) {
return *displayName;
}
return name;
}
std::string Bus::getTooltip() {
return tooltip;
}
@@ -62,4 +69,5 @@ namespace domain {
std::optional<ui::Bus> Bus::getDisplayBus() {
return displayBus;
}
} // namespace domain
+4 -1
View File
@@ -54,6 +54,7 @@ namespace domain {
};
private:
std::string name;
std::optional<std::string> displayName;
std::string instanceName;
std::string tooltip;
BusType type;
@@ -63,11 +64,13 @@ namespace domain {
std::vector<Wire> wires;
public:
Bus(std::string name, std::string instanceName, std::string tooltip, BusType type, std::pair<int, int> count, std::vector<Wire> wires,
Bus(std::string name, std::optional<std::string> displayName, std::string instanceName, std::string tooltip, BusType type, std::pair<int, int> count, std::vector<Wire> wires,
std::optional<ui::Bus> display = std::nullopt);
std::string getName();
std::string getDisplayName();
std::string getInstanceName();
std::string getTooltip();
+9 -3
View File
@@ -2,16 +2,23 @@
namespace domain {
Component::Component(string name, string tooltip, string source, ComponentType type,
Component::Component(string name, optional<string> displayName, string tooltip, string source, ComponentType type,
vector<Rule> rules, string instanceName, pair<int, int> count, Display display,
vector<Pin> pins, vector<Attribute> attributes)
: name(name), tooltip(tooltip), source(source), type(type), rules(rules), instanceName(instanceName),
: name(name), displayName(displayName), tooltip(tooltip), source(source), type(type), rules(rules), instanceName(instanceName),
count(count), display(display), pins(pins), attributes(attributes) {}
std::string Component::getName() {
return name;
}
std::string Component::getDisplayName() {
if(displayName.has_value()) {
return displayName.value();
}
return name;
}
std::string Component::getTooltip() {
return tooltip;
}
@@ -94,5 +101,4 @@ namespace domain {
return false;
}
} // namespace domain
+4 -1
View File
@@ -23,6 +23,7 @@ namespace domain {
private:
std::string name;
std::optional<std::string> displayName;
std::string tooltip;
std::string source;
ComponentType type;
@@ -36,12 +37,14 @@ namespace domain {
public:
Component(string name, string tooltip, string source, ComponentType type,
Component(string name, optional<string> displayName, string tooltip, string source, ComponentType type,
vector<Rule> rules, string instanceName, pair<int, int> count, Display display,
vector<Pin> pins, vector<Attribute> attributes);
std::string getName();
std::string getDisplayName();
std::string getTooltip();
std::string getSource();
+23 -7
View File
@@ -199,6 +199,11 @@ namespace domain {
std::optional<Bus> SchemaCreator::loadBus(BusNode node) {
std::string busName = node.name.value;
std::optional<std::string> displayName = nullopt;
if(node.displayName.has_value()) {
displayName = node.displayName->asString();
}
if (!node.instanceName) {
errors.emplace_back(node.span, "missing @instanceName");
return nullopt;
@@ -261,7 +266,7 @@ namespace domain {
return nullopt;
}
return Bus(busName, instanceName, tooltip, type, count, wires, displayBus);
return Bus(busName, displayName, instanceName, tooltip, type, count, wires, displayBus);
}
std::optional<AddressSpace> SchemaCreator::loadAddressSpace(AddressSpaceNode node) {
@@ -459,6 +464,11 @@ namespace domain {
std::string componentName = node.name.value;
std::optional<std::string> displayName = nullopt;
if (node.displayName.has_value()) {
displayName = node.displayName->asString();
}
if (!node.tooltip) {
errors.emplace_back(node.span, "missing @tooltip");
pop();
@@ -535,7 +545,7 @@ namespace domain {
}
pop();
return Component(componentName, tooltip, source, type, rules, instanceName, count, *display, pins, attributes);
return Component(componentName, displayName, tooltip, source, type, rules, instanceName, count, *display, pins, attributes);
}
std::optional<Wire> SchemaCreator::loadWire(WireNode node) {
@@ -721,6 +731,12 @@ namespace domain {
std::optional<Attribute> SchemaCreator::loadAttribute(AttributeNode node) {
std::string name = node.name.value;
pushAdditional(name);
std::optional<std::string> displayName = nullopt;
if (node.displayName.has_value()) {
displayName = node.displayName->asString();
}
Value value;
if (current().inComponent) {
@@ -754,7 +770,7 @@ namespace domain {
}
}
current().attributes.emplace_back(name, value);
current().attributes.emplace_back(name, nullopt, value);
std::optional<Popup> popup;
if (node.popup) {
@@ -762,7 +778,7 @@ namespace domain {
}
pop();
return Attribute(name, value, popup);
return Attribute(name, displayName, value, popup);
}
std::optional<Popup> SchemaCreator::loadPopup(PopupNode node, std::string name, Value::ValueType type) {
@@ -771,7 +787,7 @@ namespace domain {
pushAdditional(name);
current().attributes.clear();
current().attributes.emplace_back(name, Value::ofType(type));
current().attributes.emplace_back(name, nullopt, Value::ofType(type));
if (!node.title) {
errors.emplace_back(node.span, "missing @title");
@@ -1028,7 +1044,7 @@ namespace domain {
if (std::count_if(attributes.begin(), attributes.end(),
[&attr](InstanceAttribute &attribute) { return attr.getName() == attribute.name; }) ==
0) {
errors.emplace_back(SourceError(instance.span, "missing attribute '" + attr.getName() + "'"));
errors.emplace_back(SourceError(instance.span, "missing attribute '" + attr.getDisplayName() + "'"));
}
}
}
@@ -1062,7 +1078,7 @@ namespace domain {
}
std::optional<Attribute> SchemaCreator::createMemoryAttribute() {
return Attribute("_memory", Value::fromMemoryReference(std::nullopt), createMemoryPopup());
return Attribute("_memory", nullopt, Value::fromMemoryReference(std::nullopt), createMemoryPopup());
}
std::optional<Popup> SchemaCreator::createMemoryPopup() {