Skip to content

Commit

Permalink
c-headers: produce method map
Browse files Browse the repository at this point in the history
  • Loading branch information
indutny committed Mar 20, 2018
1 parent 28472a4 commit 5a00fdd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
12 changes: 11 additions & 1 deletion src/llhttp/c-headers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,17 @@ export class CHeaders {
res += this.buildEnum('http_parser_type', 'HTTP',
enumToMap(constants.TYPE));
res += '\n';
res += this.buildEnum('http_method', 'HTTP', enumToMap(constants.METHODS));

const methodMap = enumToMap(constants.METHODS);
res += this.buildEnum('http_method', 'HTTP', methodMap);

res += '\n';

res += '#define HTTP_METHOD_MAP(XX) \\\n';
Object.keys(methodMap).forEach((method) => {
res += ` XX(${methodMap[method]!}, ${method}, ${method}) \\\n`;
});
res += '\n';

res += '\n';

Expand Down
4 changes: 2 additions & 2 deletions src/native/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ void http_parser_set_type(http_parser_t* parser, enum http_parser_type type) {


void http_parser_set_settings(http_parser_t* parser,
http_parser_settings_t* settings) {
parser->settings = settings;
const http_parser_settings_t* settings) {
parser->settings = (void*) settings;
}


Expand Down
2 changes: 1 addition & 1 deletion src/native/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ int http_should_keep_alive(const http_parser_t* parser);

void http_parser_set_type(http_parser_t* parser, enum http_parser_type type);
void http_parser_set_settings(http_parser_t* parser,
http_parser_settings_t* settings);
const http_parser_settings_t* settings);
void http_parser_settings_init(http_parser_settings_t* settings);

#ifdef __cplusplus
Expand Down

0 comments on commit 5a00fdd

Please sign in to comment.