Skip to content

Commit

Permalink
Fixed blob symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
KiritoDv committed Feb 20, 2024
1 parent 0a7123c commit 04e4e9d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/factories/BlobFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,23 @@
#include <iomanip>

void BlobCodeExporter::Export(std::ostream &write, std::shared_ptr<IParsedData> raw, std::string& entryName, YAML::Node &node, std::string* replacement ) {
auto symbol = GetSafeNode(node, "symbol", entryName);
auto data = std::static_pointer_cast<RawBuffer>(raw)->mBuffer;

write << "u8 " << entryName << "[] = {\n" << tab;
if(node["ctype"]) {
write << node["ctype"].as<std::string>() << " " << symbol << "[] = {\n" << tab;
} else {
write << "u8 " << symbol << "[] = {\n" << tab;
}

for (int i = 0; i < data.size(); i++) {
if ((i % 15 == 0) && i != 0) {
write << "\n" << tab;
}

write << "0x" << std::hex << std::setw(2) << std::setfill('0') << (int) data[i] << ", ";
}
write << "\n};\n";
write << "\n};\n\n";
}

void BlobBinaryExporter::Export(std::ostream &write, std::shared_ptr<IParsedData> raw, std::string& entryName, YAML::Node &node, std::string* replacement ) {
Expand Down

0 comments on commit 04e4e9d

Please sign in to comment.