Skip to content

Commit d4164ed

Browse files
committed
refactor: Remove tox_types.h; use struct tags instead.
This header was a nice idea but causes a *lot* of pain with C++ modules.
1 parent d408c98 commit d4164ed

File tree

11 files changed

+13
-82
lines changed

11 files changed

+13
-82
lines changed

BUILD.bazel

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ genrule(
1212
"//c-toxcore/toxcore:tox_events.h",
1313
"//c-toxcore/toxcore:tox_options.h",
1414
"//c-toxcore/toxcore:tox_private.h",
15-
"//c-toxcore/toxcore:tox_types.h",
1615
"//c-toxcore/toxencryptsave:toxencryptsave.h",
1716
],
1817
outs = [
@@ -22,7 +21,6 @@ genrule(
2221
"tox/tox_events.h",
2322
"tox/tox_options.h",
2423
"tox/tox_private.h",
25-
"tox/tox_types.h",
2624
"tox/toxencryptsave.h",
2725
],
2826
cmd = """
@@ -32,7 +30,6 @@ genrule(
3230
cp $(location //c-toxcore/toxcore:tox_events.h) $(GENDIR)/c-toxcore/tox/tox_events.h
3331
cp $(location //c-toxcore/toxcore:tox_options.h) $(GENDIR)/c-toxcore/tox/tox_options.h
3432
cp $(location //c-toxcore/toxcore:tox_private.h) $(GENDIR)/c-toxcore/tox/tox_private.h
35-
cp $(location //c-toxcore/toxcore:tox_types.h) $(GENDIR)/c-toxcore/tox/tox_types.h
3633
cp $(location //c-toxcore/toxencryptsave:toxencryptsave.h) $(GENDIR)/c-toxcore/tox/toxencryptsave.h
3734
""",
3835
visibility = ["//visibility:public"],

CMakeLists.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -354,8 +354,6 @@ set(toxcore_SOURCES
354354
toxcore/tox_private.h
355355
toxcore/tox_pack.c
356356
toxcore/tox_pack.h
357-
toxcore/tox_types.c
358-
toxcore/tox_types.h
359357
toxcore/tox_unpack.c
360358
toxcore/tox_unpack.h
361359
toxcore/util.c
@@ -375,8 +373,7 @@ set(toxcore_API_HEADERS
375373
${toxcore_SOURCE_DIR}/toxcore/tox.h^tox
376374
${toxcore_SOURCE_DIR}/toxcore/tox_dispatch.h^tox
377375
${toxcore_SOURCE_DIR}/toxcore/tox_events.h^tox
378-
${toxcore_SOURCE_DIR}/toxcore/tox_options.h^tox
379-
${toxcore_SOURCE_DIR}/toxcore/tox_types.h^tox)
376+
${toxcore_SOURCE_DIR}/toxcore/tox_options.h^tox)
380377
if(EXPERIMENTAL_API)
381378
set(toxcore_API_HEADERS ${toxcore_API_HEADERS}
382379
${toxcore_SOURCE_DIR}/toxcore/tox_private.h^tox)

other/docker/pkgsrc/pkgsrc.patch

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@ diff --git a/chat/toxcore/PLIST b/chat/toxcore/PLIST
1414
index f0a5e4f04..4122b0867 100644
1515
--- a/chat/toxcore/PLIST
1616
+++ b/chat/toxcore/PLIST
17-
@@ -4,11 +4,13 @@ bin/tox-bootstrapd
17+
@@ -4,11 +4,12 @@ bin/tox-bootstrapd
1818
include/tox/tox.h
1919
include/tox/tox_dispatch.h
2020
include/tox/tox_events.h
2121
+include/tox/tox_options.h
22-
+include/tox/tox_types.h
2322
include/tox/toxav.h
2423
include/tox/toxencryptsave.h
2524
lib/libtoxcore.a

toxcore/BUILD.bazel

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ exports_files(
88
"tox_events.h",
99
"tox_options.h",
1010
"tox_private.h",
11-
"tox_types.h",
1211
],
1312
visibility = ["//c-toxcore:__subpackages__"],
1413
)
@@ -1074,23 +1073,13 @@ cc_library(
10741073
],
10751074
)
10761075

1077-
cc_library(
1078-
name = "tox_types",
1079-
srcs = ["tox_types.c"],
1080-
hdrs = ["tox_types.h"],
1081-
visibility = ["//c-toxcore:__subpackages__"],
1082-
)
1083-
10841076
cc_library(
10851077
name = "tox_options",
10861078
srcs = ["tox_options.c"],
10871079
hdrs = ["tox_options.h"],
10881080
copts = ["-UTOX_HIDE_DEPRECATED"],
10891081
visibility = ["//c-toxcore:__subpackages__"],
1090-
deps = [
1091-
":ccompat",
1092-
":tox_types",
1093-
],
1082+
deps = [":ccompat"],
10941083
)
10951084

10961085
cc_library(
@@ -1126,7 +1115,6 @@ cc_library(
11261115
":onion_client",
11271116
":state",
11281117
":tox_options",
1129-
":tox_types",
11301118
":util",
11311119
"//c-toxcore/toxencryptsave:defines",
11321120
"@pthread",

toxcore/Makefile.inc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ lib_LTLIBRARIES += libtoxcore.la
22

33
libtoxcore_la_include_HEADERS = \
44
../toxcore/tox.h \
5-
../toxcore/tox_options.h \
6-
../toxcore/tox_types.h
5+
../toxcore/tox_options.h
76

87
libtoxcore_la_includedir = $(includedir)/tox
98

@@ -145,8 +144,6 @@ libtoxcore_la_SOURCES = ../third_party/cmp/cmp.c \
145144
../toxcore/tox_private.c \
146145
../toxcore/tox_private.h \
147146
../toxcore/tox_struct.h \
148-
../toxcore/tox_types.c \
149-
../toxcore/tox_types.h \
150147
../toxcore/tox_unpack.c \
151148
../toxcore/tox_unpack.h \
152149
../toxcore/tox.c \

toxcore/tox.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@
103103
#include <stdint.h>
104104

105105
#include "tox_options.h" // IWYU pragma: export
106-
#include "tox_types.h" // IWYU pragma: export
107106

108107
#ifdef __cplusplus
109108
extern "C" {
@@ -120,7 +119,7 @@ extern "C" {
120119
* device is limited. Note that this is not just a per-process limit, since the
121120
* limiting factor is the number of usable ports on a device.
122121
*/
123-
struct Tox;
122+
typedef struct Tox Tox;
124123

125124
/** @{
126125
* @name API version

toxcore/tox_options.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
#include <stddef.h>
1111
#include <stdint.h>
1212

13-
#include "tox_types.h" // IWYU pragma: export
14-
1513
#ifdef __cplusplus
1614
extern "C" {
1715
#endif
1816

17+
struct Tox;
18+
1919
/** @{
2020
* @name Startup options
2121
*/
@@ -117,8 +117,9 @@ const char *tox_log_level_to_string(Tox_Log_Level value);
117117
* @param message The log message.
118118
* @param user_data The user data pointer passed to tox_new in options.
119119
*/
120-
typedef void tox_log_cb(Tox *tox, Tox_Log_Level level, const char *file, uint32_t line,
121-
const char *func, const char *message, void *user_data);
120+
typedef void tox_log_cb(struct Tox *tox, Tox_Log_Level level, const char *file,
121+
uint32_t line, const char *func, const char *message,
122+
void *user_data);
122123

123124
/**
124125
* @brief This struct contains all the startup options for Tox.
@@ -135,7 +136,7 @@ typedef void tox_log_cb(Tox *tox, Tox_Log_Level level, const char *file, uint32_
135136
* members. The struct will become opaque (i.e. the definition will become
136137
* private) in v0.3.0.
137138
*/
138-
struct Tox_Options;
139+
typedef struct Tox_Options Tox_Options;
139140

140141
#ifndef TOX_HIDE_DEPRECATED
141142
struct Tox_Options {

toxcore/tox_private.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
#include "DHT.h"
1414
#include "TCP_server.h"
15-
#include "attributes.h"
1615
#include "ccompat.h"
1716
#include "crypto_core.h"
1817
#include "group_chats.h"
@@ -23,7 +22,7 @@
2322
#include "net_profile.h"
2423
#include "network.h"
2524
#include "tox.h"
26-
#include "tox_struct.h"
25+
#include "tox_struct.h" // IWYU pragma: keep
2726

2827
#define SET_ERROR_PARAMETER(param, x) \
2928
do { \

toxcore/tox_private.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <stdint.h>
1212

1313
#include "tox.h"
14-
#include "tox_types.h"
14+
#include "tox_options.h"
1515

1616
#ifdef __cplusplus
1717
extern "C" {

toxcore/tox_types.c

Lines changed: 0 additions & 6 deletions
This file was deleted.

toxcore/tox_types.h

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)