core: use original name for files

This commit is contained in:
Vaxry 2024-04-20 01:16:27 +01:00
parent 5dc55d5230
commit 18e561ff2c

View file

@ -99,6 +99,7 @@ std::string camelize(std::string snake) {
struct {
std::string name;
std::string nameOriginal;
std::string fileName;
} PROTO_DATA;
void parseXML(pugi::xml_document& doc) {
@ -277,7 +278,7 @@ void parseSource() {
#include "{}.hpp"
#undef private
)#",
PROTO_DATA.name);
PROTO_DATA.fileName);
// reference interfaces
@ -535,19 +536,20 @@ int main(int argc, char** argv, char** envp) {
PROTO_DATA.nameOriginal = doc.child("protocol").attribute("name").as_string();
PROTO_DATA.name = camelize(PROTO_DATA.nameOriginal);
PROTO_DATA.fileName = protopath.substr(protopath.find_last_of('/') + 1, protopath.length() - (protopath.find_last_of('/') + 1) - 4);
const auto COPYRIGHT =
std::format("// Generated with hyprwayland-scanner {}. Made with vaxry's keyboard and ❤️.\n// {}\n\n/*\n This protocol's authors' copyright notice is:\n\n{}\n*/\n\n", SCANNER_VERSION,
PROTO_DATA.nameOriginal, std::string{doc.child("protocol").child("copyright").child_value()});
std::format("// Generated with hyprwayland-scanner {}. Made with vaxry's keyboard and ❤️.\n// {}\n\n/*\n This protocol's authors' copyright notice is:\n\n{}\n*/\n\n",
SCANNER_VERSION, PROTO_DATA.nameOriginal, std::string{doc.child("protocol").child("copyright").child_value()});
parseXML(doc);
parseHeader();
parseSource();
std::ofstream header(outpath + "/" + PROTO_DATA.name + ".hpp", std::ios::trunc);
std::ofstream header(outpath + "/" + PROTO_DATA.fileName + ".hpp", std::ios::trunc);
header << COPYRIGHT << HEADER;
header.close();
std::ofstream source(outpath + "/" + PROTO_DATA.name + ".cpp", std::ios::trunc);
std::ofstream source(outpath + "/" + PROTO_DATA.fileName + ".cpp", std::ios::trunc);
source << COPYRIGHT << SOURCE;
source.close();