Skip to content

Commit fdb01ea

Browse files
committed
Some more fields.
1 parent c010e16 commit fdb01ea

File tree

2 files changed

+113
-0
lines changed

2 files changed

+113
-0
lines changed

src/core/gadp-server.cc

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,54 @@ enum class TargetEventType {
124124
TET_SIGNAL = 11,
125125
};
126126

127+
namespace PCSX {
128+
129+
namespace {
130+
131+
typedef Protobuf::Message<TYPESTRING("ErrorRequest")> ErrorRequest;
132+
133+
typedef Protobuf::Field<Protobuf::Int32, TYPESTRING("code"), 1> ErrorReplyCode;
134+
typedef Protobuf::Field<Protobuf::String, TYPESTRING("message"), 2> ErrorReplyMessage;
135+
typedef Protobuf::Message<TYPESTRING("ErrorReply"), ErrorReplyCode, ErrorReplyMessage> ErrorReply;
136+
137+
typedef Protobuf::RepeatedFieldVariable<Protobuf::String, TYPESTRING("version"), 1> ConnectRequestVersion;
138+
typedef Protobuf::Message<TYPESTRING("ConnectRequest"), ConnectRequestVersion> ConnectRequest;
139+
140+
typedef Protobuf::Field<Protobuf::String, TYPESTRING("version"), 1> ConnectReplyVersion;
141+
typedef Protobuf::Field<Protobuf::String, TYPESTRING("schema_context"), 2> ConnectReplySchemaContext;
142+
typedef Protobuf::Field<Protobuf::String, TYPESTRING("root_schema"), 3> ConnectReplyRootSchema;
143+
typedef Protobuf::Message<TYPESTRING("ConnectReply"), ConnectReplyVersion, ConnectReplySchemaContext,
144+
ConnectReplyRootSchema>
145+
ConnectReply;
146+
147+
typedef Protobuf::Field<Protobuf::String, TYPESTRING("content"), 1> PingContent;
148+
typedef Protobuf::Message<TYPESTRING("PingRequest"), PingContent> PingRequest;
149+
typedef Protobuf::Message<TYPESTRING("PingReply"), PingContent> PingReply;
150+
151+
typedef Protobuf::Field<Protobuf::String, TYPESTRING("space"), 1> AddressSpace;
152+
typedef Protobuf::Field<Protobuf::UInt64, TYPESTRING("offset"), 2> AddressOffset;
153+
typedef Protobuf::Field<Protobuf::UInt32, TYPESTRING("extend"), 3> AddressExtend;
154+
typedef Protobuf::Message<TYPESTRING("Address"), AddressSpace, AddressOffset> Address;
155+
typedef Protobuf::Message<TYPESTRING("AddressRange"), AddressSpace, AddressOffset, AddressExtend> AddressRange;
156+
157+
typedef Protobuf::RepeatedFieldVariable<Protobuf::String, TYPESTRING("e"), 1> PathElement;
158+
typedef Protobuf::Message<TYPESTRING("Path"), PathElement> Path;
159+
typedef Protobuf::RepeatedFieldVariable<Path, TYPESTRING("path"), 1> PathListPath;
160+
typedef Protobuf::Message<TYPESTRING("path"), PathListPath> PathList;
161+
162+
typedef Protobuf::RepeatedFieldVariable<Protobuf::Int32, TYPESTRING("k"), 1> KindSet;
163+
typedef Protobuf::Message<TYPESTRING("BreakKindSet"), KindSet> BreakKindSet;
164+
typedef Protobuf::Message<TYPESTRING("StepKindsSet"), KindSet> StepKindsSet;
165+
166+
typedef Protobuf::RepeatedFieldVariable<Protobuf::String, TYPESTRING("s"), 1> StringListField;
167+
typedef Protobuf::Message<TYPESTRING("StringList"), StringListField> StringList;
168+
169+
typedef Protobuf::Message<TYPESTRING("AttachKindSet"), KindSet> AttachKindSet;
170+
171+
} // namespace
172+
173+
} // namespace PCSX
174+
127175
PCSX::GadpServer::GadpServer() : m_listener(g_system->m_eventBus) {
128176
m_listener.listen<Events::SettingsLoaded>([this](const auto& event) {
129177
if (g_emulator->settings.get<Emulator::SettingGadpServer>()) {

src/support/protobuf.h

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,71 @@ struct RepeatedField<FieldType, amount, irqus::typestring<C...>, fieldNumberValu
549549
}
550550
};
551551

552+
template <typename FieldType, typename name, uint64_t fieldNumberValue>
553+
struct RepeatedFieldVariable;
554+
template <typename FieldType, char... C, uint64_t fieldNumberValue>
555+
struct RepeatedFieldVariable<FieldType, irqus::typestring<C...>, fieldNumberValue> {
556+
RepeatedFieldVariable() { reset(); }
557+
static constexpr uint64_t fieldNumber = fieldNumberValue;
558+
static constexpr unsigned wireType = 2;
559+
typedef irqus::typestring<C...> fieldName;
560+
static constexpr void dumpSchema(std::ostream &stream) {
561+
stream << " repeated " << FieldType::typeName << " " << fieldName::data() << " = " << fieldNumberValue << ";"
562+
<< std::endl;
563+
}
564+
std::vector<FieldType> value;
565+
size_t count = 0;
566+
constexpr void reset() {
567+
value.clear();
568+
count = 0;
569+
}
570+
static constexpr bool matches(unsigned wireType) { return wireType == 2 || FieldType::matches(wireType); }
571+
static constexpr bool needsToSerializeHeader() { return FieldType::wireType == 2; }
572+
void serialize(OutSlice *slice) const {
573+
if (FieldType::wireType == 2) {
574+
for (const auto &v : value) {
575+
OutSlice subSlice;
576+
v.serialize(&subSlice);
577+
std::string subSliceData = subSlice.finalize();
578+
slice->putVarInt((fieldNumber << 3) | FieldType::wireType);
579+
slice->putVarInt(subSliceData.size());
580+
slice->putBytes(subSliceData);
581+
}
582+
} else {
583+
OutSlice subSlice;
584+
for (const auto &v : value) {
585+
v.serialize(&subSlice);
586+
}
587+
std::string subSliceData = subSlice.finalize();
588+
slice->putVarInt(subSliceData.size());
589+
slice->putBytes(subSliceData);
590+
}
591+
}
592+
void deserialize(InSlice *slice, unsigned wireType) {
593+
if (FieldType::wireType != wireType) {
594+
InSlice subSlice = slice->getSubSlice(slice->getVarInt());
595+
while (subSlice.bytesLeft()) {
596+
deserializeOne(&subSlice, wireType);
597+
}
598+
} else {
599+
deserializeOne(slice, wireType);
600+
}
601+
}
602+
constexpr bool hasData() const { return !value.empty(); }
603+
constexpr void commit() {}
604+
605+
private:
606+
void deserializeOne(InSlice *slice, unsigned wireType) {
607+
value.resize(count + 1);
608+
if (FieldType::wireType == 2) {
609+
InSlice subSlice = slice->getSubSlice(slice->getVarInt());
610+
value[count++].deserialize(&subSlice, FieldType::wireType);
611+
} else {
612+
value[count++].deserialize(slice, wireType);
613+
}
614+
}
615+
};
616+
552617
template <typename FieldType, size_t amount, typename name, uint64_t fieldNumberValue>
553618
struct RepeatedFieldRef;
554619
template <typename FieldType, size_t amount, char... C, uint64_t fieldNumberValue>

0 commit comments

Comments
 (0)