From 52c0cd7dc9173da5b60c9d4b9bd2683ad452f8c6 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Sat, 21 Sep 2019 00:49:35 +0200 Subject: [PATCH] quic: remove `typedef enum` Using `typedef enum` is a C-ism. PR-URL: https://github.com/nodejs/quic/pull/126 Reviewed-By: Daniel Bevenius Reviewed-By: James M Snell --- src/node_quic_crypto.h | 4 ++-- src/node_quic_session.h | 20 ++++++++++---------- src/node_quic_socket.h | 8 ++++---- src/node_quic_state.h | 4 ++-- src/node_quic_stream.h | 12 ++++++------ src/node_quic_util.h | 8 ++++---- 6 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/node_quic_crypto.h b/src/node_quic_crypto.h index 8862bd284a..8d0b096a6f 100644 --- a/src/node_quic_crypto.h +++ b/src/node_quic_crypto.h @@ -59,7 +59,7 @@ struct CryptoContext { }; // TODO(@jasnell): Remove once we move to ngtcp2_crypto -typedef enum ngtcp2_crypto_side { +enum ngtcp2_crypto_side { /** * ``NGTCP2_CRYPTO_SIDE_CLIENT`` indicates that the application is * client. @@ -70,7 +70,7 @@ typedef enum ngtcp2_crypto_side { * server. */ NGTCP2_CRYPTO_SIDE_SERVER -} ngtcp2_crypto_side; +}; BIO_METHOD* CreateBIOMethod(); diff --git a/src/node_quic_session.h b/src/node_quic_session.h index e064df18d8..fede3d21bb 100644 --- a/src/node_quic_session.h +++ b/src/node_quic_session.h @@ -93,7 +93,7 @@ class QuicSessionConfig { // QuicServerSession. These are set on the QuicSocket when // the listen() function is called and are passed to the // constructor of the QuicServerSession. -typedef enum QuicServerSessionOptions : uint32_t { +enum QuicServerSessionOptions : uint32_t { // When set, instructs the QuicServerSession to reject // client authentication certs that cannot be verified. QUICSERVERSESSION_OPTION_REJECT_UNAUTHORIZED = 0x1, @@ -101,12 +101,12 @@ typedef enum QuicServerSessionOptions : uint32_t { // When set, instructs the QuicServerSession to request // a client authentication cert QUICSERVERSESSION_OPTION_REQUEST_CERT = 0x2 -} QuicServerSessionOptions; +}; // Options to alter the behavior of various functions on the // QuicClientSession. These are set on the QuicClientSession // constructor. -typedef enum QuicClientSessionOptions : uint32_t { +enum QuicClientSessionOptions : uint32_t { // When set, instructs the QuicClientSession to include an // OCSP request in the initial TLS handshake QUICCLIENTSESSION_OPTION_REQUEST_OCSP = 0x1, @@ -120,14 +120,14 @@ typedef enum QuicClientSessionOptions : uint32_t { // When set, instructs the QuicClientSession to perform // additional checks on TLS session resumption. QUICCLIENTSESSION_OPTION_RESUME = 0x4 -} QuicClientSessionOptions; +}; // The QuicSessionState enums are used with the QuicSession's // private state_ array. This is exposed to JavaScript via an // aliased buffer and is used to communicate various types of // state efficiently across the native/JS boundary. -typedef enum QuicSessionState : int { +enum QuicSessionState : int { // Communicates whether a 'keylog' event listener has been // registered on the JavaScript QuicSession object. The // value will be either 1 or 0. When set to 1, the native @@ -165,7 +165,7 @@ typedef enum QuicSessionState : int { // Just the number of session state enums for use when // creating the AliasedBuffer. IDX_QUIC_SESSION_STATE_COUNT -} QuicSessionState; +}; // The QuicSession class is an virtual class that serves as // the basis for both QuicServerSession and QuicClientSession. @@ -744,7 +744,7 @@ class QuicSession : public AsyncWrap, void StopRetransmitTimer(); void StopIdleTimer(); - typedef enum QuicSessionFlags : uint32_t { + enum QuicSessionFlags : uint32_t { // Initial state when a QuicSession is created but nothing yet done. QUICSESSION_FLAG_INITIAL = 0x1, @@ -777,7 +777,7 @@ class QuicSession : public AsyncWrap, // Set if the QuicSession is in the middle of a silent close // (that is, a CONNECTION_CLOSE should not be sent) QUICSESSION_FLAG_SILENT_CLOSE = 0x200 - } QuicSessionFlags; + }; void SetFlag(QuicSessionFlags flag, bool on = true) { if (on) @@ -1022,11 +1022,11 @@ class QuicSession : public AsyncWrap, class QuicServerSession : public QuicSession { public: - typedef enum InitialPacketResult : int { + enum InitialPacketResult : int { PACKET_OK, PACKET_IGNORE, PACKET_VERSION - } InitialPacketResult; + }; static InitialPacketResult Accept( ngtcp2_pkt_hd* hd, diff --git a/src/node_quic_socket.h b/src/node_quic_socket.h index 852378f0b8..0a092b8664 100644 --- a/src/node_quic_socket.h +++ b/src/node_quic_socket.h @@ -31,7 +31,7 @@ namespace quic { static constexpr size_t MAX_VALIDATE_ADDRESS_LRU = 10; -typedef enum QuicSocketOptions : uint32_t { +enum QuicSocketOptions : uint32_t { // When enabled the QuicSocket will validate the address // using a RETRY packet to the peer. QUICSOCKET_OPTIONS_VALIDATE_ADDRESS = 0x1, @@ -41,7 +41,7 @@ typedef enum QuicSocketOptions : uint32_t { // validated addresses. Address validation will be skipped // if the address is currently in the cache. QUICSOCKET_OPTIONS_VALIDATE_ADDRESS_LRU = 0x2, -} QuicSocketOptions; +}; class QuicSocket : public HandleWrap, public mem::Tracker { @@ -205,7 +205,7 @@ class QuicSocket : public HandleWrap, // Fields and TypeDefs typedef uv_udp_t HandleType; - typedef enum QuicSocketFlags : uint32_t { + enum QuicSocketFlags : uint32_t { QUICSOCKET_FLAGS_NONE = 0x0, // Indicates that the QuicSocket has entered a graceful @@ -214,7 +214,7 @@ class QuicSocket : public HandleWrap, QUICSOCKET_FLAGS_PENDING_CLOSE = 0x2, QUICSOCKET_FLAGS_SERVER_LISTENING = 0x4, QUICSOCKET_FLAGS_SERVER_BUSY = 0x8, - } QuicSocketFlags; + }; void SetFlag(QuicSocketFlags flag, bool on = true) { if (on) diff --git a/src/node_quic_state.h b/src/node_quic_state.h index d191df45ad..2772c763ec 100644 --- a/src/node_quic_state.h +++ b/src/node_quic_state.h @@ -7,7 +7,7 @@ namespace node { -typedef enum QuicSessionConfigIndex : int { +enum QuicSessionConfigIndex : int { IDX_QUIC_SESSION_ACTIVE_CONNECTION_ID_LIMIT, IDX_QUIC_SESSION_MAX_STREAM_DATA_BIDI_LOCAL, IDX_QUIC_SESSION_MAX_STREAM_DATA_BIDI_REMOTE, @@ -22,7 +22,7 @@ typedef enum QuicSessionConfigIndex : int { IDX_QUIC_SESSION_MAX_ACK_DELAY, IDX_QUIC_SESSION_MAX_CRYPTO_BUFFER, IDX_QUIC_SESSION_CONFIG_COUNT -} QuicSessionConfigIndex; +}; class QuicState { public: diff --git a/src/node_quic_stream.h b/src/node_quic_stream.h index 723d02fab4..68a90d31f9 100644 --- a/src/node_quic_stream.h +++ b/src/node_quic_stream.h @@ -95,7 +95,7 @@ class QuicStream : public AsyncWrap, public StreamBase, public std::enable_shared_from_this { public: - typedef enum QuicStreamStates : uint32_t { + enum QuicStreamStates : uint32_t { // QuicStream is fully open. Readable and Writable QUICSTREAM_FLAG_INITIAL = 0x0, @@ -125,24 +125,24 @@ class QuicStream : public AsyncWrap, // QuicStream has been destroyed QUICSTREAM_FLAG_DESTROYED = 0x40 - } QuicStreamStates; + }; - typedef enum QuicStreamDirection { + enum QuicStreamDirection { // The QuicStream is readable and writable in both directions QUIC_STREAM_BIRECTIONAL, // The QuicStream is writable and readable in only one direction. // The direction depends on the QuicStreamOrigin. QUIC_STREAM_UNIDIRECTIONAL - } QuicStreamDirection; + }; - typedef enum QuicStreamOrigin { + enum QuicStreamOrigin { // The QuicStream was created by the server. QUIC_STREAM_SERVER, // The QuicStream was created by the client. QUIC_STREAM_CLIENT - } QuicStreamOrigin; + }; static void Initialize( diff --git a/src/node_quic_util.h b/src/node_quic_util.h index 0a0e59b464..b0c0957fed 100644 --- a/src/node_quic_util.h +++ b/src/node_quic_util.h @@ -41,12 +41,12 @@ constexpr uint64_t DEFAULT_MAX_STREAMS_UNI = 3; constexpr uint64_t DEFAULT_IDLE_TIMEOUT = 10 * 1000; constexpr uint64_t DEFAULT_RETRYTOKEN_EXPIRATION = 10ULL; -typedef enum SelectPreferredAddressPolicy : int { +enum SelectPreferredAddressPolicy : int { // Ignore the server-provided preferred address QUIC_PREFERRED_ADDRESS_IGNORE, // Accept the server-provided preferred address QUIC_PREFERRED_ADDRESS_ACCEPT -} SelectPreferredAddressPolicy; +}; // Fun hash combine trick based on a variadic template that // 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) { // look at the ALPN identifier to determine exactly what it // means. Connection (Session) and Crypto errors, on the other // hand, share the same meaning regardless of the ALPN. -typedef enum QuicErrorFamily : int { +enum QuicErrorFamily : int { QUIC_ERROR_SESSION, QUIC_ERROR_CRYPTO, QUIC_ERROR_APPLICATION -} QuicErrorFamily; +}; struct QuicError { QuicErrorFamily family;