IPCCompiler: Add include parsing for endpoints
This will find all lines at the start of the file beginning with # and copy them straight through.
This commit is contained in:
parent
128e504de6
commit
83fb97c301
Notes:
sideshowbarker
2024-07-18 11:04:45 +09:00
Author: https://github.com/timmot Commit: https://github.com/SerenityOS/serenity/commit/83fb97c3015 Pull-request: https://github.com/SerenityOS/serenity/pull/8400
1 changed files with 33 additions and 3 deletions
|
@ -58,6 +58,7 @@ struct Message {
|
|||
};
|
||||
|
||||
struct Endpoint {
|
||||
Vector<String> includes;
|
||||
String name;
|
||||
u32 magic;
|
||||
Vector<Message> messages;
|
||||
|
@ -197,9 +198,30 @@ int main(int argc, char** argv)
|
|||
}
|
||||
};
|
||||
|
||||
auto parse_include = [&] {
|
||||
String include;
|
||||
consume_whitespace();
|
||||
include = lexer.consume_while([](char ch) { return ch != '\n'; });
|
||||
consume_whitespace();
|
||||
|
||||
endpoints.last().includes.append(move(include));
|
||||
};
|
||||
|
||||
auto parse_includes = [&] {
|
||||
for (;;) {
|
||||
consume_whitespace();
|
||||
if (lexer.peek() != '#')
|
||||
break;
|
||||
parse_include();
|
||||
consume_whitespace();
|
||||
}
|
||||
};
|
||||
|
||||
auto parse_endpoint = [&] {
|
||||
endpoints.empend();
|
||||
consume_whitespace();
|
||||
parse_includes();
|
||||
consume_whitespace();
|
||||
lexer.consume_specific("endpoint");
|
||||
consume_whitespace();
|
||||
endpoints.last().name = lexer.consume_while([](char ch) { return !isspace(ch); });
|
||||
|
@ -241,9 +263,17 @@ int main(int argc, char** argv)
|
|||
StringBuilder builder;
|
||||
SourceGenerator generator { builder };
|
||||
|
||||
generator.append(R"~~~(
|
||||
#pragma once
|
||||
#include <AK/MemoryStream.h>
|
||||
generator.append("#pragma once\n");
|
||||
|
||||
// This must occur before LibIPC/Decoder.h
|
||||
for (auto& endpoint : endpoints) {
|
||||
for (auto& include : endpoint.includes) {
|
||||
generator.append(include);
|
||||
generator.append("\n");
|
||||
}
|
||||
}
|
||||
|
||||
generator.append(R"~~~(#include <AK/MemoryStream.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <AK/Result.h>
|
||||
#include <AK/URL.h>
|
||||
|
|
Loading…
Add table
Reference in a new issue