summaryrefslogtreecommitdiff
path: root/Meta/Lagom/Tools/CodeGenerators/IPCCompiler/main.cpp
diff options
context:
space:
mode:
authorMacDue <macdue@dueutil.tech>2022-12-06 19:43:46 +0000
committerAndreas Kling <kling@serenityos.org>2022-12-07 11:48:27 +0100
commitbbc149ebb935532c9382278ed98cf9fe8a616422 (patch)
treebf9b37fb4947579351f57de87e1377da8413e097 /Meta/Lagom/Tools/CodeGenerators/IPCCompiler/main.cpp
parentf76c7f3788242e8b486c51cd251e6c59179e33dd (diff)
downloadserenity-bbc149ebb935532c9382278ed98cf9fe8a616422.zip
Meta+Userland: Pass Gfx::Color by value
Gfx::Color is always 4 bytes (it's just a wrapper over u32) it's less work just to pass the color directly. This also updates IPCCompiler to prevent from generating Gfx::Color const &, which makes replacement easier.
Diffstat (limited to 'Meta/Lagom/Tools/CodeGenerators/IPCCompiler/main.cpp')
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/IPCCompiler/main.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/Meta/Lagom/Tools/CodeGenerators/IPCCompiler/main.cpp b/Meta/Lagom/Tools/CodeGenerators/IPCCompiler/main.cpp
index 3fc82c036b..c7efff37f9 100644
--- a/Meta/Lagom/Tools/CodeGenerators/IPCCompiler/main.cpp
+++ b/Meta/Lagom/Tools/CodeGenerators/IPCCompiler/main.cpp
@@ -66,6 +66,17 @@ static bool is_primitive_type(DeprecatedString const& type)
return type.is_one_of("u8", "i8", "u16", "i16", "u32", "i32", "u64", "i64", "bool", "double", "float", "int", "unsigned", "unsigned int");
}
+static bool is_simple_type(DeprecatedString const& type)
+{
+ // Small types that it makes sense just to pass by value.
+ return type.is_one_of("Gfx::Color");
+}
+
+static bool is_primitive_or_simple_type(DeprecatedString const& type)
+{
+ return is_primitive_type(type) || is_simple_type(type);
+}
+
static DeprecatedString message_name(DeprecatedString const& endpoint, DeprecatedString const& message, bool is_response)
{
StringBuilder builder;
@@ -477,7 +488,7 @@ void do_message_for_proxy(SourceGenerator message_generator, Endpoint const& end
auto const& parameter = parameters[i];
auto argument_generator = message_generator.fork();
argument_generator.set("argument.name", parameter.name);
- if (is_primitive_type(parameters[i].type))
+ if (is_primitive_or_simple_type(parameters[i].type))
argument_generator.append("@argument.name@");
else
argument_generator.append("move(@argument.name@)");
@@ -734,7 +745,7 @@ public:
auto make_argument_type = [](DeprecatedString const& type) {
StringBuilder builder;
- bool const_ref = !is_primitive_type(type);
+ bool const_ref = !is_primitive_or_simple_type(type);
builder.append(type);
if (const_ref)