Skip to content
This repository was archived by the owner on Aug 11, 2020. It is now read-only.

Commit 52c0cd7

Browse files
committed
quic: remove typedef enum
Using `typedef enum` is a C-ism. PR-URL: #126 Reviewed-By: Daniel Bevenius <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent dcd4636 commit 52c0cd7

File tree

6 files changed

+28
-28
lines changed

6 files changed

+28
-28
lines changed

src/node_quic_crypto.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ struct CryptoContext {
5959
};
6060

6161
// TODO(@jasnell): Remove once we move to ngtcp2_crypto
62-
typedef enum ngtcp2_crypto_side {
62+
enum ngtcp2_crypto_side {
6363
/**
6464
* ``NGTCP2_CRYPTO_SIDE_CLIENT`` indicates that the application is
6565
* client.
@@ -70,7 +70,7 @@ typedef enum ngtcp2_crypto_side {
7070
* server.
7171
*/
7272
NGTCP2_CRYPTO_SIDE_SERVER
73-
} ngtcp2_crypto_side;
73+
};
7474

7575
BIO_METHOD* CreateBIOMethod();
7676

src/node_quic_session.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,20 +93,20 @@ class QuicSessionConfig {
9393
// QuicServerSession. These are set on the QuicSocket when
9494
// the listen() function is called and are passed to the
9595
// constructor of the QuicServerSession.
96-
typedef enum QuicServerSessionOptions : uint32_t {
96+
enum QuicServerSessionOptions : uint32_t {
9797
// When set, instructs the QuicServerSession to reject
9898
// client authentication certs that cannot be verified.
9999
QUICSERVERSESSION_OPTION_REJECT_UNAUTHORIZED = 0x1,
100100

101101
// When set, instructs the QuicServerSession to request
102102
// a client authentication cert
103103
QUICSERVERSESSION_OPTION_REQUEST_CERT = 0x2
104-
} QuicServerSessionOptions;
104+
};
105105

106106
// Options to alter the behavior of various functions on the
107107
// QuicClientSession. These are set on the QuicClientSession
108108
// constructor.
109-
typedef enum QuicClientSessionOptions : uint32_t {
109+
enum QuicClientSessionOptions : uint32_t {
110110
// When set, instructs the QuicClientSession to include an
111111
// OCSP request in the initial TLS handshake
112112
QUICCLIENTSESSION_OPTION_REQUEST_OCSP = 0x1,
@@ -120,14 +120,14 @@ typedef enum QuicClientSessionOptions : uint32_t {
120120
// When set, instructs the QuicClientSession to perform
121121
// additional checks on TLS session resumption.
122122
QUICCLIENTSESSION_OPTION_RESUME = 0x4
123-
} QuicClientSessionOptions;
123+
};
124124

125125

126126
// The QuicSessionState enums are used with the QuicSession's
127127
// private state_ array. This is exposed to JavaScript via an
128128
// aliased buffer and is used to communicate various types of
129129
// state efficiently across the native/JS boundary.
130-
typedef enum QuicSessionState : int {
130+
enum QuicSessionState : int {
131131
// Communicates whether a 'keylog' event listener has been
132132
// registered on the JavaScript QuicSession object. The
133133
// value will be either 1 or 0. When set to 1, the native
@@ -165,7 +165,7 @@ typedef enum QuicSessionState : int {
165165
// Just the number of session state enums for use when
166166
// creating the AliasedBuffer.
167167
IDX_QUIC_SESSION_STATE_COUNT
168-
} QuicSessionState;
168+
};
169169

170170
// The QuicSession class is an virtual class that serves as
171171
// the basis for both QuicServerSession and QuicClientSession.
@@ -744,7 +744,7 @@ class QuicSession : public AsyncWrap,
744744
void StopRetransmitTimer();
745745
void StopIdleTimer();
746746

747-
typedef enum QuicSessionFlags : uint32_t {
747+
enum QuicSessionFlags : uint32_t {
748748
// Initial state when a QuicSession is created but nothing yet done.
749749
QUICSESSION_FLAG_INITIAL = 0x1,
750750

@@ -777,7 +777,7 @@ class QuicSession : public AsyncWrap,
777777
// Set if the QuicSession is in the middle of a silent close
778778
// (that is, a CONNECTION_CLOSE should not be sent)
779779
QUICSESSION_FLAG_SILENT_CLOSE = 0x200
780-
} QuicSessionFlags;
780+
};
781781

782782
void SetFlag(QuicSessionFlags flag, bool on = true) {
783783
if (on)
@@ -1022,11 +1022,11 @@ class QuicSession : public AsyncWrap,
10221022

10231023
class QuicServerSession : public QuicSession {
10241024
public:
1025-
typedef enum InitialPacketResult : int {
1025+
enum InitialPacketResult : int {
10261026
PACKET_OK,
10271027
PACKET_IGNORE,
10281028
PACKET_VERSION
1029-
} InitialPacketResult;
1029+
};
10301030

10311031
static InitialPacketResult Accept(
10321032
ngtcp2_pkt_hd* hd,

src/node_quic_socket.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ namespace quic {
3131

3232
static constexpr size_t MAX_VALIDATE_ADDRESS_LRU = 10;
3333

34-
typedef enum QuicSocketOptions : uint32_t {
34+
enum QuicSocketOptions : uint32_t {
3535
// When enabled the QuicSocket will validate the address
3636
// using a RETRY packet to the peer.
3737
QUICSOCKET_OPTIONS_VALIDATE_ADDRESS = 0x1,
@@ -41,7 +41,7 @@ typedef enum QuicSocketOptions : uint32_t {
4141
// validated addresses. Address validation will be skipped
4242
// if the address is currently in the cache.
4343
QUICSOCKET_OPTIONS_VALIDATE_ADDRESS_LRU = 0x2,
44-
} QuicSocketOptions;
44+
};
4545

4646
class QuicSocket : public HandleWrap,
4747
public mem::Tracker {
@@ -205,7 +205,7 @@ class QuicSocket : public HandleWrap,
205205
// Fields and TypeDefs
206206
typedef uv_udp_t HandleType;
207207

208-
typedef enum QuicSocketFlags : uint32_t {
208+
enum QuicSocketFlags : uint32_t {
209209
QUICSOCKET_FLAGS_NONE = 0x0,
210210

211211
// Indicates that the QuicSocket has entered a graceful
@@ -214,7 +214,7 @@ class QuicSocket : public HandleWrap,
214214
QUICSOCKET_FLAGS_PENDING_CLOSE = 0x2,
215215
QUICSOCKET_FLAGS_SERVER_LISTENING = 0x4,
216216
QUICSOCKET_FLAGS_SERVER_BUSY = 0x8,
217-
} QuicSocketFlags;
217+
};
218218

219219
void SetFlag(QuicSocketFlags flag, bool on = true) {
220220
if (on)

src/node_quic_state.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace node {
99

10-
typedef enum QuicSessionConfigIndex : int {
10+
enum QuicSessionConfigIndex : int {
1111
IDX_QUIC_SESSION_ACTIVE_CONNECTION_ID_LIMIT,
1212
IDX_QUIC_SESSION_MAX_STREAM_DATA_BIDI_LOCAL,
1313
IDX_QUIC_SESSION_MAX_STREAM_DATA_BIDI_REMOTE,
@@ -22,7 +22,7 @@ typedef enum QuicSessionConfigIndex : int {
2222
IDX_QUIC_SESSION_MAX_ACK_DELAY,
2323
IDX_QUIC_SESSION_MAX_CRYPTO_BUFFER,
2424
IDX_QUIC_SESSION_CONFIG_COUNT
25-
} QuicSessionConfigIndex;
25+
};
2626

2727
class QuicState {
2828
public:

src/node_quic_stream.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class QuicStream : public AsyncWrap,
9595
public StreamBase,
9696
public std::enable_shared_from_this<QuicStream> {
9797
public:
98-
typedef enum QuicStreamStates : uint32_t {
98+
enum QuicStreamStates : uint32_t {
9999
// QuicStream is fully open. Readable and Writable
100100
QUICSTREAM_FLAG_INITIAL = 0x0,
101101

@@ -125,24 +125,24 @@ class QuicStream : public AsyncWrap,
125125

126126
// QuicStream has been destroyed
127127
QUICSTREAM_FLAG_DESTROYED = 0x40
128-
} QuicStreamStates;
128+
};
129129

130-
typedef enum QuicStreamDirection {
130+
enum QuicStreamDirection {
131131
// The QuicStream is readable and writable in both directions
132132
QUIC_STREAM_BIRECTIONAL,
133133

134134
// The QuicStream is writable and readable in only one direction.
135135
// The direction depends on the QuicStreamOrigin.
136136
QUIC_STREAM_UNIDIRECTIONAL
137-
} QuicStreamDirection;
137+
};
138138

139-
typedef enum QuicStreamOrigin {
139+
enum QuicStreamOrigin {
140140
// The QuicStream was created by the server.
141141
QUIC_STREAM_SERVER,
142142

143143
// The QuicStream was created by the client.
144144
QUIC_STREAM_CLIENT
145-
} QuicStreamOrigin;
145+
};
146146

147147

148148
static void Initialize(

src/node_quic_util.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ constexpr uint64_t DEFAULT_MAX_STREAMS_UNI = 3;
4141
constexpr uint64_t DEFAULT_IDLE_TIMEOUT = 10 * 1000;
4242
constexpr uint64_t DEFAULT_RETRYTOKEN_EXPIRATION = 10ULL;
4343

44-
typedef enum SelectPreferredAddressPolicy : int {
44+
enum SelectPreferredAddressPolicy : int {
4545
// Ignore the server-provided preferred address
4646
QUIC_PREFERRED_ADDRESS_IGNORE,
4747
// Accept the server-provided preferred address
4848
QUIC_PREFERRED_ADDRESS_ACCEPT
49-
} SelectPreferredAddressPolicy;
49+
};
5050

5151
// Fun hash combine trick based on a variadic template that
5252
// I came across a while back but can't remember where. Will add an attribution
@@ -70,11 +70,11 @@ inline void hash_combine(size_t* seed, const T& value, Args... rest) {
7070
// look at the ALPN identifier to determine exactly what it
7171
// means. Connection (Session) and Crypto errors, on the other
7272
// hand, share the same meaning regardless of the ALPN.
73-
typedef enum QuicErrorFamily : int {
73+
enum QuicErrorFamily : int {
7474
QUIC_ERROR_SESSION,
7575
QUIC_ERROR_CRYPTO,
7676
QUIC_ERROR_APPLICATION
77-
} QuicErrorFamily;
77+
};
7878

7979
struct QuicError {
8080
QuicErrorFamily family;

0 commit comments

Comments
 (0)