@@ -56,15 +56,31 @@ std::string bin_pack_name_from_type(const std::string& type) {
5656 return " bin_pack_u8" ;
5757 } else if (type == " bool" ) {
5858 return " bin_pack_bool" ;
59- // only unpack is special TODO(Green-Sky): should we change that?
60- // } else if (type == "Tox_User_Status") {
61- // return "tox_pack_user_status";
62- // } else if (type == "Tox_Conference_Type") {
63- // return "tox_pack_conference_type";
59+ } else if (type == " Tox_User_Status" ) {
60+ return " tox_user_status_pack" ;
61+ } else if (type == " Tox_Conference_Type" ) {
62+ return " tox_conference_type_pack" ;
63+ } else if (type == " Tox_Message_Type" ) {
64+ return " tox_message_type_pack" ;
65+ } else if (type == " Tox_File_Control" ) {
66+ return " tox_file_control_pack" ;
67+ } else if (type == " Tox_Connection" ) {
68+ return " tox_connection_pack" ;
69+ } else if (type == " Tox_Group_Privacy_State" ) {
70+ return " tox_group_privacy_state_pack" ;
71+ } else if (type == " Tox_Group_Voice_State" ) {
72+ return " tox_group_voice_state_pack" ;
73+ } else if (type == " Tox_Group_Topic_Lock" ) {
74+ return " tox_group_topic_lock_pack" ;
75+ } else if (type == " Tox_Group_Join_Fail" ) {
76+ return " tox_group_join_fail_pack" ;
77+ } else if (type == " Tox_Group_Mod_Event" ) {
78+ return " tox_group_mod_event_pack" ;
79+ } else if (type == " Tox_Group_Exit_Type" ) {
80+ return " tox_group_exit_type_pack" ;
6481 } else {
65- // std::cerr << "unknown type " << type << "\n";
66- // exit(1);
67- // assume enum -> u32
82+ std::cerr << " unknown type " << type << " \n " ;
83+ exit (1 );
6884 return " bin_pack_u32" ;
6985 }
7086}
@@ -164,6 +180,7 @@ void generate_event_impl(const std::string& event_name, const std::vector<EventT
164180#include "../tox_events.h")" ;
165181 if (need_tox_unpack_h) {
166182 f << R"(
183+ #include "../tox_pack.h"
167184#include "../tox_unpack.h")" ;
168185 }
169186 f << R"(
@@ -310,7 +327,6 @@ void generate_event_impl(const std::string& event_name, const std::vector<EventT
310327 // pack
311328 f << " bool tox_event_" << event_name_l << " _pack(\n " ;
312329 f << " const Tox_Event_" << event_name << " *event, Bin_Pack *bp)\n {\n " ;
313- f << " assert(event != nullptr);\n " ;
314330
315331 bool return_started = false ;
316332
@@ -330,7 +346,11 @@ void generate_event_impl(const std::string& event_name, const std::vector<EventT
330346 overloaded{
331347 [&](const EventTypeTrivial& t) {
332348 f << bin_pack_name_from_type (t.type );
333- f << " (bp, event->" << t.name << " )" ;
349+ if (t.type .rfind (" Tox_" , 0 ) == 0 ) {
350+ f << " (event->" << t.name << " , bp)" ;
351+ } else {
352+ f << " (bp, event->" << t.name << " )" ;
353+ }
334354 },
335355 [&](const EventTypeByteRange& t) {
336356 f << " bin_pack_bin(bp, event->" << t.name_data << " , event->" << t.name_length << " )" ;
@@ -361,7 +381,11 @@ void generate_event_impl(const std::string& event_name, const std::vector<EventT
361381 overloaded{
362382 [&](const EventTypeTrivial& t) {
363383 f << bin_unpack_name_from_type (t.type );
364- f << " (bu, &event->" << t.name << " )" ;
384+ if (t.type .rfind (" Tox_" , 0 ) == 0 ) {
385+ f << " (&event->" << t.name << " , bu)" ;
386+ } else {
387+ f << " (bu, &event->" << t.name << " )" ;
388+ }
365389 },
366390 [&](const EventTypeByteRange& t) {
367391 f << " bin_unpack_bin(bu, &event->" << t.name_data << " , &event->" << t.name_length << " )" ;
0 commit comments