Commit Graph

26 Commits

Author SHA1 Message Date
iphydf 30e71fe974 refactor: Generate event dispatch functions and add tox_events_dispatch. 2026-01-25 19:12:11 +00:00
iphydf 8fdbb0b50e style: Format parameter lists in event handlers. 2026-01-25 16:28:15 +00:00
iphydf a2c1773969 refactor: Harden event system and improve type safety.
- Use MessagePack strings for IP addresses and other text fields.
- Mark dynamic event fields as nullable in getters.
- Add overflow checks for event list capacity.
2026-01-24 14:03:07 +00:00
iphydf a2581e700d refactor(toxcore): generate Friend_Request and Dht_Nodes_Response
Update `generate_event_c.cpp` to support `EventTypeByteArray` and custom C
types for byte ranges.
2026-01-10 01:59:15 +00:00
iphydf 2aaa11770e refactor(toxcore): use Tox_Memory in generated events
Update event generator to use mem_balloc/mem_delete for byte arrays in
events, ensuring consistency with Tox memory management. Also fix struct
initialization to use compound literals compliant with tokstyle.
2026-01-09 23:05:37 +00:00
iphydf 8e8b352abc refactor: Add nullable annotations to struct members.
Also add a bunch of casts where needed. I've tried to model everything
in such a way that it minimises casts. The casts *should* be safe, but
it's not always obvious. In the obvious cases, we should have a linter
that validates it. In the non-obvious cases, that linter should warn and
require that we add a null check. I've added some null checks in some
cases but not all.

Also, refactored some of the constructor functions to never assign a
maybe-null value to a non-null struct member, instead using a temporary
local variable to check if construction/allocation succeeded.
2026-01-04 23:38:38 +00:00
iphydf 40b3f0b463 refactor: Use clang's nullability qualifiers instead of attributes. 2025-07-13 00:26:24 +00:00
iphydf f81e30679b refactor: Use per-parameter nullability annotations.
This is less error-prone.
2025-07-12 09:20:18 +00:00
iphydf e092ecd124 cleanup: Use tox memory allocator in some more places. 2025-01-14 17:34:21 +00:00
iphydf bc43cec062 chore: Happy new year! 2025-01-05 23:24:52 +00:00
Green Sky 4067628450 fix: events leak that can occur if allocation fails
rare in practice, found by fuzzing
2024-11-08 14:50:34 +01:00
Green Sky 0199c0f17f cleanup: apply the same scheme to types 2024-03-08 18:15:02 +01:00
Green Sky aebbfabe26 cleanup: event length naming inconsistencies 2024-03-08 17:51:34 +01:00
jfreegman 7b1db6adc1 feat: add message IDs to private group messages 2024-03-07 10:39:39 -05:00
iphydf 4e2dba4d9f chore: Reformat sources with astyle.
Restyled astyle is fixed now.
2024-02-02 01:31:32 +00:00
iphydf 511bfe39c8 cleanup: Use Bazel modules to enforce proper #include hygiene. 2024-01-30 23:51:43 +00:00
iphydf bdd42b5452 refactor: Add common msgpack array packer with callback.
There will be more object arrays that need to be packed. This function
takes care of NULL (creating an empty array), and putting the correct
array size and calling the per-element callback the right amount of
times.
2024-01-18 13:52:35 +00:00
iphydf e7fb91ddb8 refactor: Allow NULL pointers for byte arrays in events.
Some events, notably the file chunk recv one, can give NULL pointers to
the client. Not sure they should, but that's what happens, so we support
it.
2024-01-17 09:13:07 +00:00
iphydf e2c01e457b refactor: Use enum-specific pack functions for enum values.
It's more obvious this way.
2024-01-15 21:47:13 +00:00
iphydf 6caa7ce4b1 cleanup: Move the 2-element array pack out of individual events.
It's common across all events. No need to repeat it.

Co-authored-by: Green Sky <green@g-s.xyz>
2024-01-15 19:04:45 +00:00
iphydf b4d8826228 cleanup: Remove old type-ordered event getters.
These are quite expensive, because they go through all events to index
in a typed array that no longer exists. Clients should index in the
union array and find the event they want themselves, or use dispatch.
2024-01-15 17:29:43 +00:00
Green Sky 8c35e0fefb feat: add ngc events 2024-01-15 16:32:10 +00:00
iphydf 97bdd83937 refactor: Make event dispatch ordered by receive time. 2024-01-15 16:32:10 +00:00
Green Sky 41dfb1c1c0 fix: unpack enum function names in event impl generator 2023-12-24 14:34:34 +01:00
Green Sky 22cd38ad50 adopt event impl generation tool to #2392 2023-12-20 12:13:45 +01:00
Green Sky f31ea1088a add the event impl generation tool 2023-12-20 10:46:59 +01:00