mirror of
https://github.com/hyprwm/hyprwayland-scanner.git
synced 2024-11-26 01:45:57 +01:00
core: use original name for files
This commit is contained in:
parent
5dc55d5230
commit
18e561ff2c
1 changed files with 7 additions and 5 deletions
12
src/main.cpp
12
src/main.cpp
|
@ -99,6 +99,7 @@ std::string camelize(std::string snake) {
|
||||||
struct {
|
struct {
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string nameOriginal;
|
std::string nameOriginal;
|
||||||
|
std::string fileName;
|
||||||
} PROTO_DATA;
|
} PROTO_DATA;
|
||||||
|
|
||||||
void parseXML(pugi::xml_document& doc) {
|
void parseXML(pugi::xml_document& doc) {
|
||||||
|
@ -277,7 +278,7 @@ void parseSource() {
|
||||||
#include "{}.hpp"
|
#include "{}.hpp"
|
||||||
#undef private
|
#undef private
|
||||||
)#",
|
)#",
|
||||||
PROTO_DATA.name);
|
PROTO_DATA.fileName);
|
||||||
|
|
||||||
// reference interfaces
|
// 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.nameOriginal = doc.child("protocol").attribute("name").as_string();
|
||||||
PROTO_DATA.name = camelize(PROTO_DATA.nameOriginal);
|
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 =
|
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,
|
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",
|
||||||
PROTO_DATA.nameOriginal, std::string{doc.child("protocol").child("copyright").child_value()});
|
SCANNER_VERSION, PROTO_DATA.nameOriginal, std::string{doc.child("protocol").child("copyright").child_value()});
|
||||||
|
|
||||||
parseXML(doc);
|
parseXML(doc);
|
||||||
parseHeader();
|
parseHeader();
|
||||||
parseSource();
|
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 << COPYRIGHT << HEADER;
|
||||||
header.close();
|
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 << COPYRIGHT << SOURCE;
|
||||||
source.close();
|
source.close();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue