Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions auto_tests/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ cc_library(
deps = [
":check_compat",
"//c-toxcore/testing:misc_tools",
"//c-toxcore/toxcore",
"//c-toxcore/toxcore:DHT",
"//c-toxcore/toxcore:Messenger",
"//c-toxcore/toxcore:mono_time",
"//c-toxcore/toxcore:net_crypto",
"//c-toxcore/toxcore:tox",
"//c-toxcore/toxcore:tox_dispatch",
"//c-toxcore/toxcore:tox_events",
"//c-toxcore/toxcore:tox_log_level",
],
)
Expand Down Expand Up @@ -59,6 +59,7 @@ extra_data = {
":check_compat",
"//c-toxcore/testing:misc_tools",
"//c-toxcore/toxav",
"//c-toxcore/toxcore",
"//c-toxcore/toxcore:Messenger",
"//c-toxcore/toxcore:TCP_client",
"//c-toxcore/toxcore:TCP_common",
Expand All @@ -81,8 +82,6 @@ extra_data = {
"//c-toxcore/toxcore:os_random",
"//c-toxcore/toxcore:tox",
"//c-toxcore/toxcore:tox_dispatch",
"//c-toxcore/toxcore:tox_events",
"//c-toxcore/toxcore:tox_unpack",
"//c-toxcore/toxcore:util",
"//c-toxcore/toxencryptsave",
"@libsodium",
Expand Down
4 changes: 2 additions & 2 deletions auto_tests/scenarios/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ cc_library(
deps = [
"//c-toxcore/auto_tests:check_compat",
"//c-toxcore/testing:misc_tools",
"//c-toxcore/toxcore",
"//c-toxcore/toxcore:attributes",
"//c-toxcore/toxcore:ccompat",
"//c-toxcore/toxcore:mono_time",
"//c-toxcore/toxcore:network",
"//c-toxcore/toxcore:tox",
"//c-toxcore/toxcore:tox_dispatch",
"//c-toxcore/toxcore:tox_events",
],
)

Expand All @@ -26,7 +26,7 @@ cc_library(
deps = [
":scenario_framework",
"//c-toxcore/toxav",
"//c-toxcore/toxcore",
"//c-toxcore/toxcore:tox",
"//c-toxcore/toxcore:tox_events",
],
) for src in glob(["scenario_*_test.c"])]
2 changes: 0 additions & 2 deletions auto_tests/scenarios/framework/framework.c
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,6 @@ ToxNode *tox_scenario_add_node_ex(ToxScenario *s, const char *alias, tox_node_sc
}

node->dispatch = tox_dispatch_new(nullptr);
tox_events_init(node->tox);
mono_time_set_current_time_callback(node->tox->mono_time, get_scenario_clock, s);

// Initial mirror population
Expand Down Expand Up @@ -784,7 +783,6 @@ void tox_node_reload(ToxNode *node)

ck_assert_msg(new_tox != nullptr, "tox_new said OK but returned NULL");
Tox_Dispatch *new_dispatch = tox_dispatch_new(nullptr);
tox_events_init(new_tox);
mono_time_set_current_time_callback(new_tox->mono_time, get_scenario_clock, s);

pthread_mutex_lock(&s->mutex);
Expand Down
1 change: 0 additions & 1 deletion auto_tests/tox_dispatch_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ static void test_tox_events(void)
for (uint32_t i = 0; i < 2; ++i) {
index[i] = i + 1;
toxes[i] = tox_new_log(nullptr, nullptr, &index[i]);
tox_events_init(toxes[i]);
ck_assert_msg(toxes[i] != nullptr, "failed to create tox instances %u", i);
}

Expand Down
2 changes: 1 addition & 1 deletion other/docker/esp32/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ cc_binary(
"main/tox_main.h",
],
deps = [
"//c-toxcore/toxcore",
"//c-toxcore/toxcore:ccompat",
"//c-toxcore/toxcore:tox",
"//c-toxcore/toxcore:tox_events",
],
)
4 changes: 2 additions & 2 deletions other/docker/modules/check
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ class BuildContext:
def bzl_exports_files(self, *args: Any, **kwargs: Any) -> None:
pass

def bzl_alias(self, *args: Any, **kwargs: Any) -> None:
pass
def bzl_alias(self, name: str, actual: str, **kwargs: Any) -> None:
self._add_target(name, (), (), (actual, ))

def bzl_sh_library(self, *args: Any, **kwargs: Any) -> None:
pass
Expand Down
9 changes: 4 additions & 5 deletions other/event_tooling/generate_event_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,10 +583,9 @@ void generate_event_impl(const std::string& event_name, const std::vector<EventT

)";
f << "void tox_events_handle_" << event_name_l << "(\n";
f << " Tox *tox";

for (const auto& t : event_types) {
f << ",\n ";
f << " ";
std::visit(
overloaded{
[&](const EventTypeTrivial& t) {
Expand All @@ -601,11 +600,11 @@ void generate_event_impl(const std::string& event_name, const std::vector<EventT
},
t
);
f << ",\n";
}

f << ",\n void *user_data)\n{\n";
f << " Tox_Events_State *state = tox_events_alloc(user_data);\n";
f << " Tox_Event_" << event_name << " *" << event_name_l << " = tox_event_" << event_name_l << "_alloc(state);\n\n";
f << " Tox_Events_State *state)\n{\n";
f << " Tox_Event_" << event_name << " *" << event_name_l << " = tox_event_" << event_name_l << "_alloc(tox_events_alloc(state));\n\n";
f << " if (" << event_name_l << " == nullptr) {\n return;\n }\n\n";

for (const auto& t : event_types) {
Expand Down
9 changes: 3 additions & 6 deletions testing/fuzzing/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ cc_fuzz_test(
corpus = ["//tools/toktok-fuzzer/corpus:bootstrap_fuzz_test"],
deps = [
"//c-toxcore/testing/support",
"//c-toxcore/toxcore",
"//c-toxcore/toxcore:tox",
"//c-toxcore/toxcore:tox_dispatch",
"//c-toxcore/toxcore:tox_events",
],
)

Expand All @@ -24,10 +23,9 @@ cc_fuzz_test(
data = ["//tools/toktok-fuzzer/init:e2e_fuzz_test.dat"],
deps = [
"//c-toxcore/testing/support",
"//c-toxcore/toxcore",
"//c-toxcore/toxcore:crypto_core",
"//c-toxcore/toxcore:tox",
"//c-toxcore/toxcore:tox_dispatch",
"//c-toxcore/toxcore:tox_events",
],
)

Expand All @@ -49,9 +47,8 @@ cc_binary(
copts = ["-UNDEBUG"],
deps = [
"//c-toxcore/testing/support",
"//c-toxcore/toxcore",
"//c-toxcore/toxcore:tox",
"//c-toxcore/toxcore:tox_dispatch",
"//c-toxcore/toxcore:tox_events",
"//c-toxcore/toxcore:util",
],
)
Expand Down
2 changes: 0 additions & 2 deletions testing/fuzzing/bootstrap_fuzz_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,6 @@ void TestBootstrap(Fuzz_Data &input)
tox_bootstrap(tox, "127.0.0.2", 33446, pub_key, nullptr);
tox_add_tcp_relay(tox, "127.0.0.2", 33446, pub_key, nullptr);

tox_events_init(tox);

Tox_Dispatch *dispatch = tox_dispatch_new(nullptr);
assert(dispatch != nullptr);
setup_callbacks(dispatch);
Expand Down
2 changes: 0 additions & 2 deletions testing/fuzzing/e2e_fuzz_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,6 @@ void TestEndToEnd(Fuzz_Data &input)
assert(error_new == TOX_ERR_NEW_OK);
assert(error_new_testing == TOX_ERR_NEW_TESTING_OK);

tox_events_init(tox);

Tox_Dispatch *dispatch = tox_dispatch_new(nullptr);
assert(dispatch != nullptr);
setup_callbacks(dispatch);
Expand Down
3 changes: 0 additions & 3 deletions testing/fuzzing/protodump.cc
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,6 @@ void RecordBootstrap(const char *init, const char *bootstrap)
const bool udp_success = tox_bootstrap(tox2, "127.0.0.1", 33445, dht_key1.data(), nullptr);
assert(udp_success);

tox_events_init(tox1);
tox_events_init(tox2);

Tox_Dispatch *dispatch = tox_dispatch_new(nullptr);
setup_callbacks(dispatch);

Expand Down
4 changes: 3 additions & 1 deletion testing/support/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ cc_library(
}),
visibility = ["//visibility:public"],
deps = [
"//c-toxcore/toxcore",
"//c-toxcore/toxcore:attributes",
"//c-toxcore/toxcore:mem",
"//c-toxcore/toxcore:net",
"//c-toxcore/toxcore:network",
"//c-toxcore/toxcore:rng",
"//c-toxcore/toxcore:tox",
"//c-toxcore/toxcore:tox_events",
"//c-toxcore/toxcore:tox_options",
"@psocket",
],
Expand Down Expand Up @@ -123,6 +123,7 @@ cc_test(
srcs = ["bootstrap_scaling_test.cc"],
deps = [
":support",
"//c-toxcore/toxcore",
"//c-toxcore/toxcore:network",
"//c-toxcore/toxcore:tox",
"@com_google_googletest//:gtest",
Expand All @@ -145,6 +146,7 @@ cc_test(
srcs = ["tox_network_test.cc"],
deps = [
":support",
"//c-toxcore/toxcore",
"//c-toxcore/toxcore:attributes",
"//c-toxcore/toxcore:network",
"//c-toxcore/toxcore:tox",
Expand Down
3 changes: 0 additions & 3 deletions testing/support/src/tox_runner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ ToxRunner::ToxRunner(SimulatedNode &node, const Tox_Options *_Nullable options)
: tox_(node.create_tox(options))
, node_(node)
{
if (tox_) {
tox_events_init(tox_.get());
}
node_.simulation().register_runner();

tick_listener_id_ = node_.simulation().register_tick_listener([this](uint64_t gen) {
Expand Down
99 changes: 28 additions & 71 deletions toxcore/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -1481,12 +1481,23 @@ cc_library(
srcs = [
"tox.c",
"tox_api.c",
"tox_event.c",
"tox_events.c",
"tox_pack.c",
"tox_private.c",
],
"tox_unpack.c",
] + glob([
"events/*.c",
]),
hdrs = [
"events/events_alloc.h",
"tox.h",
"tox_event.h",
"tox_events.h",
"tox_pack.h",
"tox_private.h",
"tox_struct.h",
"tox_unpack.h",
],
visibility = ["//c-toxcore:__subpackages__"],
deps = [
Expand All @@ -1495,6 +1506,8 @@ cc_library(
":TCP_client",
":TCP_server",
":attributes",
":bin_pack",
":bin_unpack",
":ccompat",
":crypto_core",
":ev",
Expand All @@ -1518,11 +1531,24 @@ cc_library(
":tox_log_level",
":tox_options",
":util",
"//c-toxcore/third_party:cmp",
"//c-toxcore/toxencryptsave:defines",
"@pthread",
],
)

cc_library(
name = "tox_dispatch",
srcs = ["tox_dispatch.c"],
hdrs = ["tox_dispatch.h"],
visibility = ["//c-toxcore:__subpackages__"],
deps = [
":attributes",
":ccompat",
":tox",
],
)

cc_test(
name = "tox_test",
size = "small",
Expand All @@ -1540,69 +1566,13 @@ cc_test(
],
)

cc_library(
name = "tox_pack",
srcs = ["tox_pack.c"],
hdrs = ["tox_pack.h"],
visibility = ["//c-toxcore:__subpackages__"],
deps = [
":attributes",
":bin_pack",
":ccompat",
":tox",
],
)

cc_library(
name = "tox_unpack",
srcs = ["tox_unpack.c"],
hdrs = ["tox_unpack.h"],
visibility = ["//c-toxcore:__subpackages__"],
deps = [
":attributes",
":bin_unpack",
":ccompat",
":tox",
],
)

cc_library(
name = "tox_events",
srcs = [
"tox_event.c",
"tox_events.c",
] + glob([
"events/*.c",
]),
hdrs = [
"events/events_alloc.h",
"tox_event.h",
"tox_events.h",
],
visibility = ["//c-toxcore:__subpackages__"],
deps = [
":attributes",
":bin_pack",
":bin_unpack",
":ccompat",
":logger",
":mem",
":tox",
":tox_attributes",
":tox_pack",
":tox_unpack",
"//c-toxcore/third_party:cmp",
],
)

cc_test(
name = "tox_events_test",
size = "small",
srcs = ["tox_events_test.cc"],
deps = [
":crypto_core",
":tox",
":tox_events",
"//c-toxcore/testing/support",
"@com_google_googletest//:gtest",
"@com_google_googletest//:gtest_main",
Expand All @@ -1615,25 +1585,12 @@ cc_fuzz_test(
srcs = ["tox_events_fuzz_test.cc"],
corpus = ["//tools/toktok-fuzzer/corpus:tox_events_fuzz_test"],
deps = [
":tox",
":tox_dispatch",
":tox_events",
"//c-toxcore/testing/support",
],
)

cc_library(
name = "tox_dispatch",
srcs = ["tox_dispatch.c"],
hdrs = ["tox_dispatch.h"],
visibility = ["//c-toxcore:__subpackages__"],
deps = [
":attributes",
":ccompat",
":tox",
":tox_events",
],
)

alias(
name = "toxcore",
actual = ":tox_dispatch",
Expand Down
Loading
Loading