diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-11-23 21:44:00 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-11-23 21:44:00 +0100 |
commit | dc9d44d7b119e7ba55a7946c39afe7b23d17a767 (patch) | |
tree | ff5017befa6864fda434143e4fecef6d4594d34a /DevTools/IPCCompiler/main.cpp | |
parent | 20c957ef6102fb7de070ae234812ba7c8fcef570 (diff) | |
download | serenity-dc9d44d7b119e7ba55a7946c39afe7b23d17a767.zip |
IPCCompiler: Add support for String parameters in messages
Diffstat (limited to 'DevTools/IPCCompiler/main.cpp')
-rw-r--r-- | DevTools/IPCCompiler/main.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/DevTools/IPCCompiler/main.cpp b/DevTools/IPCCompiler/main.cpp index 27cc6e3395..d6f795386a 100644 --- a/DevTools/IPCCompiler/main.cpp +++ b/DevTools/IPCCompiler/main.cpp @@ -276,7 +276,19 @@ int main(int argc, char** argv) if (parameter.type == "bool") initial_value = "false"; dbg() << " " << parameter.type << " " << parameter.name << " = " << initial_value << ";"; - dbg() << " stream >> " << parameter.name << ";"; + + if (parameter.type == "String") { + dbg() << " int " << parameter.name << "_length = 0;"; + dbg() << " char* " << parameter.name << "_buffer = nullptr;"; + dbg() << " stream >> " << parameter.name << "_length;"; + dbg() << " auto " << parameter.name << "_impl = StringImpl::create_uninitialized(" << parameter.name << "_length, " << parameter.name << "_buffer);"; + dbg() << " for (int i = 0; i < " << parameter.name << "_length; ++i) {"; + dbg() << " stream >> " << parameter.name << "_buffer[i];"; + dbg() << " }"; + dbg() << " " << parameter.name << " = *" << parameter.name << "_impl;"; + } else { + dbg() << " stream >> " << parameter.name << ";"; + } dbg() << " if (stream.handle_read_failure()) {"; dbg() << " return nullptr;"; dbg() << " }"; @@ -300,7 +312,12 @@ int main(int argc, char** argv) dbg() << " stream << endpoint_magic();"; dbg() << " stream << (int)MessageID::" << name << ";"; for (auto& parameter : parameters) { - dbg() << " stream << m_" << parameter.name << ";"; + if (parameter.type == "String") { + dbg() << " stream << m_" << parameter.name << ".length();"; + dbg() << " stream << m_" << parameter.name << ";"; + } else { + dbg() << " stream << m_" << parameter.name << ";"; + } } dbg() << " stream.snip();"; dbg() << " return buffer;"; |