Squashed 'external/toxcore/c-toxcore/' changes from 73d9b845a3..e2c01e457b

e2c01e457b refactor: Use enum-specific pack functions for enum values.
afc472402b refactor: Factor out union pack switch from event packer.
6caa7ce4b1 cleanup: Move the 2-element array pack out of individual events.
687af81f20 cleanup: Remove empty test doing nothing.
fcf5882428 test: Add printf log statement to group_moderation_test.
b4d8826228 cleanup: Remove old type-ordered event getters.
8c35e0fefb feat: add ngc events
97bdd83937 refactor: Make event dispatch ordered by receive time.
001d00ab30 fix: dont resolve to ipv6 addresses when its disabled
d3b935f63f fix(test): tests use ipv6 by default, even with USE_IPV6 set to 0
29fc5ea1f7 chore: add clangd files to .gitignore
d30c81acbc refactor: Move file streaming test to its own file.
acdc67387b fix(ci): window builds now build in parallel
REVERT: 73d9b845a3 cleanup: Remove old type-ordered event getters.
REVERT: b0840cc02d feat: add ngc events
REVERT: 7df9a51349 refactor: Make event dispatch ordered by receive time.

git-subtree-dir: external/toxcore/c-toxcore
git-subtree-split: e2c01e457bfb8a59537175c8fe17ca9ab1c9e3e1
This commit is contained in:
2024-01-15 23:32:23 +01:00
parent b1fe064484
commit 61accfe184
63 changed files with 632 additions and 344 deletions

View File

@ -1 +1 @@
5061f92a95ba45cfa49d78175fa8fb6e4d66a58d86634ea3fd3ae6d80cb0558a /usr/local/bin/tox-bootstrapd
0b904988d79b9576bb88c6c7316d107b5a61bd6119a0992ebd7c1fa43db70abf /usr/local/bin/tox-bootstrapd

View File

@ -56,15 +56,31 @@ std::string bin_pack_name_from_type(const std::string& type) {
return "bin_pack_u8";
} else if (type == "bool") {
return "bin_pack_bool";
// only unpack is special TODO(Green-Sky): should we change that?
//} else if (type == "Tox_User_Status") {
//return "tox_pack_user_status";
//} else if (type == "Tox_Conference_Type") {
//return "tox_pack_conference_type";
} else if (type == "Tox_User_Status") {
return "tox_user_status_pack";
} else if (type == "Tox_Conference_Type") {
return "tox_conference_type_pack";
} else if (type == "Tox_Message_Type") {
return "tox_message_type_pack";
} else if (type == "Tox_File_Control") {
return "tox_file_control_pack";
} else if (type == "Tox_Connection") {
return "tox_connection_pack";
} else if (type == "Tox_Group_Privacy_State") {
return "tox_group_privacy_state_pack";
} else if (type == "Tox_Group_Voice_State") {
return "tox_group_voice_state_pack";
} else if (type == "Tox_Group_Topic_Lock") {
return "tox_group_topic_lock_pack";
} else if (type == "Tox_Group_Join_Fail") {
return "tox_group_join_fail_pack";
} else if (type == "Tox_Group_Mod_Event") {
return "tox_group_mod_event_pack";
} else if (type == "Tox_Group_Exit_Type") {
return "tox_group_exit_type_pack";
} else {
//std::cerr << "unknown type " << type << "\n";
//exit(1);
// assume enum -> u32
std::cerr << "unknown type " << type << "\n";
exit(1);
return "bin_pack_u32";
}
}
@ -164,6 +180,7 @@ void generate_event_impl(const std::string& event_name, const std::vector<EventT
#include "../tox_events.h")";
if (need_tox_unpack_h) {
f << R"(
#include "../tox_pack.h"
#include "../tox_unpack.h")";
}
f << R"(
@ -310,20 +327,30 @@ void generate_event_impl(const std::string& event_name, const std::vector<EventT
// pack
f << "bool tox_event_" << event_name_l << "_pack(\n";
f << " const Tox_Event_" << event_name << " *event, Bin_Pack *bp)\n{\n";
f << " assert(event != nullptr);\n";
f << " return bin_pack_array(bp, 2)\n";
f << " && bin_pack_u32(bp, TOX_EVENT_" << str_toupper(event_name) << ")";
bool return_started = false;
if (event_types.size() > 1) {
f << "\n && bin_pack_array(bp, " << event_types.size() << ")";
f << " return bin_pack_array(bp, " << event_types.size() << ")";
return_started = true;
}
for (const auto& t : event_types) {
f << "\n && ";
if (return_started) {
f << "\n && ";
} else {
f << " return ";
}
std::visit(
overloaded{
[&](const EventTypeTrivial& t) {
f << bin_pack_name_from_type(t.type);
f << "(bp, event->" << t.name << ")";
if (t.type.rfind("Tox_", 0) == 0) {
f << "(event->" << t.name << ", bp)";
} else {
f << "(bp, event->" << t.name << ")";
}
},
[&](const EventTypeByteRange& t) {
f << "bin_pack_bin(bp, event->" << t.name_data << ", event->" << t.name_length << ")";
@ -354,7 +381,11 @@ void generate_event_impl(const std::string& event_name, const std::vector<EventT
overloaded{
[&](const EventTypeTrivial& t) {
f << bin_unpack_name_from_type(t.type);
f << "(bu, &event->" << t.name << ")";
if (t.type.rfind("Tox_", 0) == 0) {
f << "(&event->" << t.name << ", bu)";
} else {
f << "(bu, &event->" << t.name << ")";
}
},
[&](const EventTypeByteRange& t) {
f << "bin_unpack_bin(bu, &event->" << t.name_data << ", &event->" << t.name_length << ")";