forked from irungentoo/toxcore
-
Notifications
You must be signed in to change notification settings - Fork 300
refactor: Explicitly pass dependencies to constructors. #2862
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
iphydf
wants to merge
1
commit into
TokTok:master
Choose a base branch
from
iphydf:getters
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45d8e7d
to
e0f5168
Compare
ce14a79
to
1a89f24
Compare
robinlinden
approved these changes
Oct 6, 2025
@iphydf needs restyled: diff --git a/toxcore/announce.h b/toxcore/announce.h
index f263584..2c1183c 100644
--- a/toxcore/announce.h
+++ b/toxcore/announce.h
@@ -24,7 +24,8 @@ uint8_t announce_response_of_request_type(uint8_t request_type);
typedef struct Announcements Announcements;
-Announcements *_Nullable new_announcements(const Logger *_Nonnull log, const Memory *_Nonnull mem, const Random *_Nonnull rng, const Mono_Time *_Nonnull mono_time, Forwarding *_Nonnull forwarding, DHT *_Nonnull dht, Networking_Core *_Nonnull net);
+Announcements *_Nullable new_announcements(const Logger *_Nonnull log, const Memory *_Nonnull mem, const Random *_Nonnull rng, const Mono_Time *_Nonnull mono_time, Forwarding *_Nonnull forwarding,
+ DHT *_Nonnull dht, Networking_Core *_Nonnull net);
/**
* @brief If data is stored, run `on_retrieve_callback` on it.
diff --git a/toxcore/forwarding.c b/toxcore/forwarding.c
index 776d2de..5b29c8e 100644
--- a/toxcore/forwarding.c
+++ b/toxcore/forwarding.c
@@ -344,7 +344,7 @@ void set_callback_forward_reply(Forwarding *forwarding, forward_reply_cb *functi
}
Forwarding *_Nullable new_forwarding(const Logger *log, const Memory *mem, const Random *rng, const Mono_Time *mono_time, DHT *dht,
- Networking_Core *net)
+ Networking_Core *net)
{
if (log == nullptr || mono_time == nullptr || dht == nullptr) {
return nullptr;
diff --git a/toxcore/forwarding.h b/toxcore/forwarding.h
index bdb8499..8cef884 100644
--- a/toxcore/forwarding.h
+++ b/toxcore/forwarding.h
@@ -99,7 +99,7 @@ typedef bool forward_reply_cb(void *_Nullable object, const uint8_t *_Nullable s
*/
void set_callback_forward_reply(Forwarding *_Nonnull forwarding, forward_reply_cb *_Nullable function, void *_Nullable object);
Forwarding *_Nullable new_forwarding(const Logger *_Nonnull log, const Memory *_Nonnull mem, const Random *_Nonnull rng, const Mono_Time *_Nonnull mono_time, DHT *_Nonnull dht,
- Networking_Core *_Nonnull net);
+ Networking_Core *_Nonnull net);
void kill_forwarding(Forwarding *_Nullable forwarding);
#ifdef __cplusplus
diff --git a/toxcore/friend_connection.h b/toxcore/friend_connection.h
index aba378f..a6d09f0 100644
--- a/toxcore/friend_connection.h
+++ b/toxcore/friend_connection.h
@@ -146,7 +146,7 @@ void set_friend_request_callback(Friend_Connections *_Nonnull fr_c, fr_request_c
/** Create new friend_connections instance. */
Friend_Connections *_Nullable new_friend_connections(const Logger *_Nonnull logger, const Memory *_Nonnull mem, const Mono_Time *_Nonnull mono_time, const Network *_Nonnull ns,
Onion_Client *_Nonnull onion_c, DHT *_Nonnull dht, Net_Crypto *_Nonnull net_crypto, Networking_Core *_Nonnull net,
- bool local_discovery_enabled);
+ bool local_discovery_enabled);
/** main friend_connections loop. */
void do_friend_connections(Friend_Connections *_Nonnull fr_c, void *_Nonnull userdata);
diff --git a/toxcore/net_crypto.h b/toxcore/net_crypto.h
index b484078..f3270ad 100644
--- a/toxcore/net_crypto.h
+++ b/toxcore/net_crypto.h
@@ -368,7 +368,8 @@ void load_secret_key(Net_Crypto *_Nonnull c, const uint8_t *_Nonnull sk);
/** @brief Create new instance of Net_Crypto.
* Sets all the global connection variables to their default values.
*/
-Net_Crypto *_Nullable new_net_crypto(const Logger *_Nonnull log, const Memory *_Nonnull mem, const Random *_Nonnull rng, const Network *_Nonnull ns, Mono_Time *_Nonnull mono_time, Networking_Core *_Nonnull net, DHT *_Nonnull dht,
+Net_Crypto *_Nullable new_net_crypto(const Logger *_Nonnull log, const Memory *_Nonnull mem, const Random *_Nonnull rng, const Network *_Nonnull ns, Mono_Time *_Nonnull mono_time,
+ Networking_Core *_Nonnull net, DHT *_Nonnull dht,
const TCP_Proxy_Info *_Nonnull proxy_info, Net_Profile *_Nonnull tcp_np);
/** return the optimal interval in ms for running do_net_crypto. */
diff --git a/toxcore/onion_announce.h b/toxcore/onion_announce.h
index 6082be9..fca6798 100644
--- a/toxcore/onion_announce.h
+++ b/toxcore/onion_announce.h
@@ -125,7 +125,7 @@ typedef int pack_extra_data_cb(void *_Nonnull object, const Logger *_Nonnull log
void onion_announce_extra_data_callback(Onion_Announce *_Nonnull onion_a, uint16_t extra_data_max_size, pack_extra_data_cb *_Nonnull extra_data_callback, void *_Nonnull extra_data_object);
Onion_Announce *_Nullable new_onion_announce(const Logger *_Nonnull log, const Memory *_Nonnull mem, const Random *_Nonnull rng, const Mono_Time *_Nonnull mono_time, DHT *_Nonnull dht,
- Networking_Core *_Nonnull net);
+ Networking_Core *_Nonnull net);
void kill_onion_announce(Onion_Announce *_Nullable onion_a);
#endif /* C_TOXCORE_TOXCORE_ONION_ANNOUNCE_H */
diff --git a/toxcore/onion_client.h b/toxcore/onion_client.h
index 4b95572..a61e9ac 100644
--- a/toxcore/onion_client.h
+++ b/toxcore/onion_client.h
@@ -191,7 +191,8 @@ typedef bool onion_group_announce_cb(Onion_Client *_Nonnull onion_c, uint32_t se
void onion_group_announce_register(Onion_Client *_Nonnull onion_c, onion_group_announce_cb *_Nullable func, void *_Nullable user_data);
void do_onion_client(Onion_Client *_Nonnull onion_c);
-Onion_Client *_Nullable new_onion_client(const Logger *_Nonnull logger, const Memory *_Nonnull mem, const Random *_Nonnull rng, const Mono_Time *_Nonnull mono_time, Net_Crypto *_Nonnull c, DHT *_Nonnull dht, Networking_Core *_Nonnull net);
+Onion_Client *_Nullable new_onion_client(const Logger *_Nonnull logger, const Memory *_Nonnull mem, const Random *_Nonnull rng, const Mono_Time *_Nonnull mono_time, Net_Crypto *_Nonnull c,
+ DHT *_Nonnull dht, Networking_Core *_Nonnull net);
void kill_onion_client(Onion_Client *_Nullable onion_c);
typedef enum Onion_Connection_Status { |
Instead of transitively loading them from dependencies, we should be explicit about what each object needs. The downside of this is that it's not clear whether the object and its dependency use the same common dependency. The upside is that we don't expose those getters of internal dependencies.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Instead of transitively loading them from dependencies, we should be explicit about what each object needs. The downside of this is that it's not clear whether the object and its dependency use the same common dependency. The upside is that we don't expose those getters of internal dependencies.
This change is