@@ -2857,29 +2857,39 @@ void Initialize(Local<Object> target,
2857
2857
session->GetFunction ()).FromJust ();
2858
2858
2859
2859
Local<Object> constants = Object::New (isolate);
2860
- NODE_DEFINE_CONSTANT (constants, NGHTTP2_SESSION_SERVER);
2861
- NODE_DEFINE_CONSTANT (constants, NGHTTP2_SESSION_CLIENT);
2862
- NODE_DEFINE_CONSTANT (constants, NGHTTP2_STREAM_STATE_IDLE);
2863
- NODE_DEFINE_CONSTANT (constants, NGHTTP2_STREAM_STATE_OPEN);
2864
- NODE_DEFINE_CONSTANT (constants, NGHTTP2_STREAM_STATE_RESERVED_LOCAL);
2865
- NODE_DEFINE_CONSTANT (constants, NGHTTP2_STREAM_STATE_RESERVED_REMOTE);
2866
- NODE_DEFINE_CONSTANT (constants, NGHTTP2_STREAM_STATE_HALF_CLOSED_LOCAL);
2867
- NODE_DEFINE_CONSTANT (constants, NGHTTP2_STREAM_STATE_HALF_CLOSED_REMOTE);
2868
- NODE_DEFINE_CONSTANT (constants, NGHTTP2_STREAM_STATE_CLOSED);
2869
- NODE_DEFINE_CONSTANT (constants, NGHTTP2_NO_ERROR);
2870
- NODE_DEFINE_CONSTANT (constants, NGHTTP2_PROTOCOL_ERROR);
2871
- NODE_DEFINE_CONSTANT (constants, NGHTTP2_INTERNAL_ERROR);
2872
- NODE_DEFINE_CONSTANT (constants, NGHTTP2_FLOW_CONTROL_ERROR);
2873
- NODE_DEFINE_CONSTANT (constants, NGHTTP2_SETTINGS_TIMEOUT);
2874
- NODE_DEFINE_CONSTANT (constants, NGHTTP2_STREAM_CLOSED);
2875
- NODE_DEFINE_CONSTANT (constants, NGHTTP2_FRAME_SIZE_ERROR);
2876
- NODE_DEFINE_CONSTANT (constants, NGHTTP2_REFUSED_STREAM);
2877
- NODE_DEFINE_CONSTANT (constants, NGHTTP2_CANCEL);
2878
- NODE_DEFINE_CONSTANT (constants, NGHTTP2_COMPRESSION_ERROR);
2879
- NODE_DEFINE_CONSTANT (constants, NGHTTP2_CONNECT_ERROR);
2880
- NODE_DEFINE_CONSTANT (constants, NGHTTP2_ENHANCE_YOUR_CALM);
2881
- NODE_DEFINE_CONSTANT (constants, NGHTTP2_INADEQUATE_SECURITY);
2882
- NODE_DEFINE_CONSTANT (constants, NGHTTP2_HTTP_1_1_REQUIRED);
2860
+ Local<Array> name_for_error_code = Array::New (isolate);
2861
+
2862
+ #define NODE_NGHTTP2_ERROR_CODES (V ) \
2863
+ V (NGHTTP2_SESSION_SERVER); \
2864
+ V (NGHTTP2_SESSION_CLIENT); \
2865
+ V (NGHTTP2_STREAM_STATE_IDLE); \
2866
+ V (NGHTTP2_STREAM_STATE_OPEN); \
2867
+ V (NGHTTP2_STREAM_STATE_RESERVED_LOCAL); \
2868
+ V (NGHTTP2_STREAM_STATE_RESERVED_REMOTE); \
2869
+ V (NGHTTP2_STREAM_STATE_HALF_CLOSED_LOCAL); \
2870
+ V (NGHTTP2_STREAM_STATE_HALF_CLOSED_REMOTE); \
2871
+ V (NGHTTP2_STREAM_STATE_CLOSED); \
2872
+ V (NGHTTP2_NO_ERROR); \
2873
+ V (NGHTTP2_PROTOCOL_ERROR); \
2874
+ V (NGHTTP2_INTERNAL_ERROR); \
2875
+ V (NGHTTP2_FLOW_CONTROL_ERROR); \
2876
+ V (NGHTTP2_SETTINGS_TIMEOUT); \
2877
+ V (NGHTTP2_STREAM_CLOSED); \
2878
+ V (NGHTTP2_FRAME_SIZE_ERROR); \
2879
+ V (NGHTTP2_REFUSED_STREAM); \
2880
+ V (NGHTTP2_CANCEL); \
2881
+ V (NGHTTP2_COMPRESSION_ERROR); \
2882
+ V (NGHTTP2_CONNECT_ERROR); \
2883
+ V (NGHTTP2_ENHANCE_YOUR_CALM); \
2884
+ V (NGHTTP2_INADEQUATE_SECURITY); \
2885
+ V (NGHTTP2_HTTP_1_1_REQUIRED); \
2886
+
2887
+ #define V (name ) \
2888
+ NODE_DEFINE_CONSTANT (constants, name); \
2889
+ name_for_error_code->Set (static_cast <int >(name), \
2890
+ FIXED_ONE_BYTE_STRING (isolate, #name));
2891
+ NODE_NGHTTP2_ERROR_CODES (V)
2892
+ #undef V
2883
2893
2884
2894
NODE_DEFINE_HIDDEN_CONSTANT (constants, NGHTTP2_HCAT_REQUEST);
2885
2895
NODE_DEFINE_HIDDEN_CONSTANT (constants, NGHTTP2_HCAT_RESPONSE);
@@ -2944,6 +2954,9 @@ HTTP_STATUS_CODES(V)
2944
2954
target->Set (context,
2945
2955
FIXED_ONE_BYTE_STRING (isolate, " constants" ),
2946
2956
constants).FromJust ();
2957
+ target->Set (context,
2958
+ FIXED_ONE_BYTE_STRING (isolate, " nameForErrorCode" ),
2959
+ name_for_error_code).FromJust ();
2947
2960
}
2948
2961
} // namespace http2
2949
2962
} // namespace node
0 commit comments