IPCCompiler: Encode/decode string lengths as native size_t, not int

This commit is contained in:
joshua stein 2020-02-02 00:56:39 -06:00 committed by Andreas Kling
parent c3a32108b2
commit 519bc758f1
Notes: sideshowbarker 2024-07-19 09:36:31 +09:00

View file

@ -310,16 +310,16 @@ int main(int argc, char** argv)
dbg() << " " << parameter.type << " " << parameter.name << " = " << initial_value << ";";
if (parameter.type == "String") {
dbg() << " int " << parameter.name << "_length = 0;";
dbg() << " size_t " << parameter.name << "_length = 0;";
dbg() << " stream >> " << parameter.name << "_length;";
dbg() << " if (" << parameter.name << "_length == 0) {";
dbg() << " " << parameter.name << " = String::empty();";
dbg() << " } else if (" << parameter.name << "_length == -1) {";
dbg() << " } else if ((ssize_t)" << parameter.name << "_length == -1) {";
dbg() << " " << parameter.name << " = String();";
dbg() << " } else {";
dbg() << " char* " << parameter.name << "_buffer = nullptr;";
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() << " for (size_t i = 0; i < " << parameter.name << "_length; ++i) {";
dbg() << " stream >> " << parameter.name << "_buffer[i];";
dbg() << " }";
dbg() << " " << parameter.name << " = *" << parameter.name << "_impl;";
@ -395,7 +395,7 @@ int main(int argc, char** argv)
for (auto& parameter : parameters) {
if (parameter.type == "String") {
dbg() << " if (m_" << parameter.name << ".is_null()) {";
dbg() << " stream << (i32)-1;";
dbg() << " stream << (ssize_t)-1;";
dbg() << " } else {";
dbg() << " stream << m_" << parameter.name << ".length();";
dbg() << " stream << m_" << parameter.name << ";";