MCPcopy Create free account
hub / github.com/OpenSteam001/OpenSteamTool / emitResp

Method emitResp

tools/ipc_codegen/ipc_codegen.cpp:921–950  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

919 }
920
921 void emitResp(const Method& method) {
922 std::vector<Field> fields = fieldsFor(method, Dir::Out, true);
923 const std::vector<std::string> external = externalRefs(method, fields);
924 const std::string cls = method.name + "Resp";
925 out_ << "class " << cls << " {\n"
926 "public:\n"
927 << " explicit " << cls << "(CUtlBuffer* buffer";
928 emitCtorParams(external);
929 out_ << ") : " << cls << "(detail::BufferBytes(buffer)";
930 emitCtorArgs(external);
931 out_ << ") {}\n"
932 << " explicit " << cls << "(std::span<uint8> bytes";
933 emitCtorParams(external);
934 out_ << ") : response_(bytes)";
935 for (const auto& name : external) out_ << ", " << name << "_(" << name << ")";
936 out_ << " {}\n"
937 " bool ok() const { return response_.ok() && detail::Fits(response_.body(), minimumBodySize()); }\n"
938 " EIPCResult result() const { return response_.result(); }\n"
939 " void set_result(EIPCResult value) { response_.set_result(value); }\n";
940 emitFieldAccessors(fields, fields, external);
941 emitDebugString(cls, fields);
942 out_ << "private:\n"
943 << " size_t minimumBodySize() const { return "
944 << sumExpr(fields, fields, external, true) << "; }\n"
945 " std::span<uint8> body() { return response_.body(); }\n"
946 " std::span<const uint8> body() const { return response_.body(); }\n"
947 " IPCResponse response_;\n";
948 for (const auto& name : external) out_ << " size_t " << name << "_;\n";
949 out_ << "};\n\n";
950 }
951
952 void emitFieldAccessors(const std::vector<Field>& fields,
953 const std::vector<Field>& sideFields,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected