mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:17:34 +00:00
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
1 changed files with 33 additions and 3 deletions
|
@ -58,6 +58,7 @@ struct Message {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Endpoint {
|
struct Endpoint {
|
||||||
|
Vector<String> includes;
|
||||||
String name;
|
String name;
|
||||||
u32 magic;
|
u32 magic;
|
||||||
Vector<Message> messages;
|
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 = [&] {
|
auto parse_endpoint = [&] {
|
||||||
endpoints.empend();
|
endpoints.empend();
|
||||||
consume_whitespace();
|
consume_whitespace();
|
||||||
|
parse_includes();
|
||||||
|
consume_whitespace();
|
||||||
lexer.consume_specific("endpoint");
|
lexer.consume_specific("endpoint");
|
||||||
consume_whitespace();
|
consume_whitespace();
|
||||||
endpoints.last().name = lexer.consume_while([](char ch) { return !isspace(ch); });
|
endpoints.last().name = lexer.consume_while([](char ch) { return !isspace(ch); });
|
||||||
|
@ -241,9 +263,17 @@ int main(int argc, char** argv)
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
SourceGenerator generator { builder };
|
SourceGenerator generator { builder };
|
||||||
|
|
||||||
generator.append(R"~~~(
|
generator.append("#pragma once\n");
|
||||||
#pragma once
|
|
||||||
#include <AK/MemoryStream.h>
|
// 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/OwnPtr.h>
|
||||||
#include <AK/Result.h>
|
#include <AK/Result.h>
|
||||||
#include <AK/URL.h>
|
#include <AK/URL.h>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue