@@ -2929,29 +2929,39 @@ void Initialize(Local<Object> target,
2929
2929
session->GetFunction ()).FromJust ();
2930
2930
2931
2931
Local<Object> constants = Object::New (isolate);
2932
- NODE_DEFINE_CONSTANT (constants, NGHTTP2_SESSION_SERVER);
2933
- NODE_DEFINE_CONSTANT (constants, NGHTTP2_SESSION_CLIENT);
2934
- NODE_DEFINE_CONSTANT (constants, NGHTTP2_STREAM_STATE_IDLE);
2935
- NODE_DEFINE_CONSTANT (constants, NGHTTP2_STREAM_STATE_OPEN);
2936
- NODE_DEFINE_CONSTANT (constants, NGHTTP2_STREAM_STATE_RESERVED_LOCAL);
2937
- NODE_DEFINE_CONSTANT (constants, NGHTTP2_STREAM_STATE_RESERVED_REMOTE);
2938
- NODE_DEFINE_CONSTANT (constants, NGHTTP2_STREAM_STATE_HALF_CLOSED_LOCAL);
2939
- NODE_DEFINE_CONSTANT (constants, NGHTTP2_STREAM_STATE_HALF_CLOSED_REMOTE);
2940
- NODE_DEFINE_CONSTANT (constants, NGHTTP2_STREAM_STATE_CLOSED);
2941
- NODE_DEFINE_CONSTANT (constants, NGHTTP2_NO_ERROR);
2942
- NODE_DEFINE_CONSTANT (constants, NGHTTP2_PROTOCOL_ERROR);
2943
- NODE_DEFINE_CONSTANT (constants, NGHTTP2_INTERNAL_ERROR);
2944
- NODE_DEFINE_CONSTANT (constants, NGHTTP2_FLOW_CONTROL_ERROR);
2945
- NODE_DEFINE_CONSTANT (constants, NGHTTP2_SETTINGS_TIMEOUT);
2946
- NODE_DEFINE_CONSTANT (constants, NGHTTP2_STREAM_CLOSED);
2947
- NODE_DEFINE_CONSTANT (constants, NGHTTP2_FRAME_SIZE_ERROR);
2948
- NODE_DEFINE_CONSTANT (constants, NGHTTP2_REFUSED_STREAM);
2949
- NODE_DEFINE_CONSTANT (constants, NGHTTP2_CANCEL);
2950
- NODE_DEFINE_CONSTANT (constants, NGHTTP2_COMPRESSION_ERROR);
2951
- NODE_DEFINE_CONSTANT (constants, NGHTTP2_CONNECT_ERROR);
2952
- NODE_DEFINE_CONSTANT (constants, NGHTTP2_ENHANCE_YOUR_CALM);
2953
- NODE_DEFINE_CONSTANT (constants, NGHTTP2_INADEQUATE_SECURITY);
2954
- NODE_DEFINE_CONSTANT (constants, NGHTTP2_HTTP_1_1_REQUIRED);
2932
+ Local<Array> name_for_error_code = Array::New (isolate);
2933
+
2934
+ #define NODE_NGHTTP2_ERROR_CODES (V ) \
2935
+ V (NGHTTP2_SESSION_SERVER); \
2936
+ V (NGHTTP2_SESSION_CLIENT); \
2937
+ V (NGHTTP2_STREAM_STATE_IDLE); \
2938
+ V (NGHTTP2_STREAM_STATE_OPEN); \
2939
+ V (NGHTTP2_STREAM_STATE_RESERVED_LOCAL); \
2940
+ V (NGHTTP2_STREAM_STATE_RESERVED_REMOTE); \
2941
+ V (NGHTTP2_STREAM_STATE_HALF_CLOSED_LOCAL); \
2942
+ V (NGHTTP2_STREAM_STATE_HALF_CLOSED_REMOTE); \
2943
+ V (NGHTTP2_STREAM_STATE_CLOSED); \
2944
+ V (NGHTTP2_NO_ERROR); \
2945
+ V (NGHTTP2_PROTOCOL_ERROR); \
2946
+ V (NGHTTP2_INTERNAL_ERROR); \
2947
+ V (NGHTTP2_FLOW_CONTROL_ERROR); \
2948
+ V (NGHTTP2_SETTINGS_TIMEOUT); \
2949
+ V (NGHTTP2_STREAM_CLOSED); \
2950
+ V (NGHTTP2_FRAME_SIZE_ERROR); \
2951
+ V (NGHTTP2_REFUSED_STREAM); \
2952
+ V (NGHTTP2_CANCEL); \
2953
+ V (NGHTTP2_COMPRESSION_ERROR); \
2954
+ V (NGHTTP2_CONNECT_ERROR); \
2955
+ V (NGHTTP2_ENHANCE_YOUR_CALM); \
2956
+ V (NGHTTP2_INADEQUATE_SECURITY); \
2957
+ V (NGHTTP2_HTTP_1_1_REQUIRED); \
2958
+
2959
+ #define V (name ) \
2960
+ NODE_DEFINE_CONSTANT (constants, name); \
2961
+ name_for_error_code->Set (static_cast <int >(name), \
2962
+ FIXED_ONE_BYTE_STRING (isolate, #name));
2963
+ NODE_NGHTTP2_ERROR_CODES (V)
2964
+ #undef V
2955
2965
2956
2966
NODE_DEFINE_HIDDEN_CONSTANT (constants, NGHTTP2_HCAT_REQUEST);
2957
2967
NODE_DEFINE_HIDDEN_CONSTANT (constants, NGHTTP2_HCAT_RESPONSE);
@@ -3016,6 +3026,9 @@ HTTP_STATUS_CODES(V)
3016
3026
target->Set (context,
3017
3027
FIXED_ONE_BYTE_STRING (isolate, " constants" ),
3018
3028
constants).FromJust ();
3029
+ target->Set (context,
3030
+ FIXED_ONE_BYTE_STRING (isolate, " nameForErrorCode" ),
3031
+ name_for_error_code).FromJust ();
3019
3032
}
3020
3033
} // namespace http2
3021
3034
} // namespace node
0 commit comments