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

Method emitReq

tools/ipc_codegen/ipc_codegen.cpp:899–919  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

897 }
898
899 void emitReq(const Interface& iface, const Method& method) {
900 const std::vector<Field> fields = fieldsFor(method, Dir::In, false);
901 const std::string cls = method.name + "Req";
902 out_ << "class " << cls << " {\n"
903 "public:\n"
904 << " explicit " << cls << "(CUtlBuffer* buffer) : " << cls
905 << "(detail::BufferBytes(buffer)) {}\n"
906 << " explicit " << cls << "(std::span<uint8> bytes) : request_(bytes), call_(request_.body()) {}\n"
907 " bool ok() const { return request_.ok() && request_.command() == EIPCCommand::InterfaceCall && call_.ok() && call_.interfaceID() == kInterface && detail::Fits(call_.body(), bodySize()); }\n"
908 " uint32 fencepost() const { return call_.fencepost(); }\n"
909 " void set_fencepost(uint32 value) { call_.set_fencepost(value); }\n";
910 emitFieldAccessors(fields, fields, {});
911 emitDebugString(cls, fields);
912 out_ << "private:\n"
913 << " size_t bodySize() const { return " << sumExpr(fields, fields, {}, false) << "; }\n"
914 " std::span<uint8> body() { return call_.body(); }\n"
915 " std::span<const uint8> body() const { return call_.body(); }\n"
916 " IPCRequest request_;\n"
917 " IPCInterfaceCall call_;\n"
918 "};\n\n";
919 }
920
921 void emitResp(const Method& method) {
922 std::vector<Field> fields = fieldsFor(method, Dir::Out, true);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected