Added support for @componentHeader

This commit is contained in:
Borna Rajković committed 2022-05-16 01:02:34 +02:00
1 parent 59b19062ff
commit e2e0506041
10 files changed
+29 -7

No files matched your search

+7 -3
View File
@@ -63,11 +63,11 @@ std::set<std::string> createImports(Schema *schema);
std::map<string, string> generateWires(Schema *schema, ostream &ostream);
void generateSubComponents(Schema *schema, map <string, string> &wires, ostream &buffer);
void generateSubComponents(Schema *schema, map <string, string> &wires, ostream &buffer);
void generateDisplay(Schema *schema, ostream &buffer);
void generateDisplay(Schema *schema, ostream &buffer);
void generateComdelFile(Schema *schema, Library &library, std::ostream &buffer) {
void generateComdelFile(Schema *schema, Library &library, std::ostream &buffer) {
buffer << library.getHeader() << std::endl;
std::set<std::string> imports = createImports(schema);
@@ -80,6 +80,10 @@ std::map<string, string> generateWires(Schema *schema, ostream &ostream);
buffer << "component System" << std::endl << "{" << std::endl;
if(library.getComponentHeader().has_value()) {
buffer << library.getComponentHeader().value() << endl;
}
auto wires = generateWires(schema, buffer);
generateSubComponents(schema, wires, buffer);
+5 -2
View File
@@ -2,9 +2,9 @@
namespace domain {
Library::Library(string name, string libraryInfo, string header, string componentDirectory,
Library::Library(string name, string libraryInfo, string header, string componentDirectory, std::optional<std::string> componentHeader,
vector<AddressSpace> addressSpaces, vector<Component> components, vector<Bus> buses, vector<Connection> connections, map<string, string> messages)
: name(name), libraryInfo(libraryInfo), header(header), componentDirectory(componentDirectory), addressSpaces(addressSpaces),
: name(name), libraryInfo(libraryInfo), header(header), componentDirectory(componentDirectory), componentHeader(componentHeader), addressSpaces(addressSpaces),
components(components), buses(buses), connections(connections), messages(messages)
{}
@@ -20,6 +20,9 @@ std::string Library::getHeader() {
std::string Library::getComponentDirectory() {
return componentDirectory;
}
std::optional<std::string> Library::getComponentHeader() {
return componentHeader;
}
std::vector<AddressSpace> Library::getAddressSpaces() {
return addressSpaces;
+3 -1
View File
@@ -21,6 +21,7 @@ class Library
std::string libraryInfo;
std::string header;
std::string componentDirectory;
std::optional<std::string> componentHeader;
std::vector<AddressSpace> addressSpaces;
std::vector<Component> components;
@@ -30,13 +31,14 @@ class Library
std::map<std::string, std::string> messages;
public:
Library(string name, string libraryInfo, string header, string componentDirectory,
Library(string name, string libraryInfo, string header, string componentDirectory, std::optional<string> componentHeader,
vector<AddressSpace> addressSpaces, vector<Component> components, vector<Bus> buses, vector<Connection> connection, map<string, string> messages);
std::string getName();
std::string getLibraryInfo();
std::string getHeader();
std::string getComponentDirectory();
std::optional<std::string> getComponentHeader();
std::vector<AddressSpace> getAddressSpaces();
std::vector<Component> getComponents();
+5 -1
View File
@@ -128,6 +128,10 @@ std::optional<Library> SchemaCreator::loadLibrary(LibraryNode node)
name = node.name->asString();
}
if(node.componentHeader.has_value()) {
componentHeader = node.componentHeader->asString();
}
if(!node.componentDirectory) {
errors.emplace_back(node.span, "missing @componentDirectory");
return nullopt;
@@ -173,7 +177,7 @@ std::optional<Library> SchemaCreator::loadLibrary(LibraryNode node)
}
}
return Library(name, libraryInfo, header, componentDirectory, addressSpaces, components, buses, connections, messages);
return Library(name, libraryInfo, header, componentDirectory, componentHeader, addressSpaces, components, buses, connections, messages);
}
std::optional<Bus> SchemaCreator::loadBus(BusNode node)
+1
View File
@@ -53,6 +53,7 @@ class SchemaCreator
std::string libraryInfo;
std::string header;
std::string componentDirectory;
std::optional<std::string> componentHeader = nullopt;
std::vector<AddressSpace> addressSpaces;
std::vector<Component> components;
std::vector<Bus> buses;