Skip to content

Commit

Permalink
More const
Browse files Browse the repository at this point in the history
  • Loading branch information
ctiller committed Nov 18, 2015
1 parent 2e7687c commit 328d4b1
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 101 deletions.
179 changes: 92 additions & 87 deletions src/core/transport/static_metadata.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
* Copyright 2015, Google Inc.
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
Expand All @@ -15,7 +15,7 @@
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
Expand All @@ -31,8 +31,9 @@

/*
* WARNING: Auto-generated code.
*
* To make changes to this file, change tools/codegen/core/gen_static_metadata.py,
*
* To make changes to this file, change
* tools/codegen/core/gen_static_metadata.py,
* and then re-run it.
*/

Expand All @@ -42,86 +43,90 @@ grpc_mdstr grpc_static_mdstr_table[GRPC_STATIC_MDSTR_COUNT];

grpc_mdelem grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT];

gpr_uint8 grpc_static_metadata_elem_indices[GRPC_STATIC_MDELEM_COUNT*2] = {
9,28,8,28,10,28,10,40,11,28,12,28,13,28,14,28,15,28,16,28,17,28,18,28,19,28,20,28,21,28,22,28,23,28,24,28,25,28,26,28,27,28,29,28,30,28,31,28,32,28,38,0,41,28,44,28,45,28,46,28,47,28,48,28,49,28,50,28,51,28,52,28,53,33,53,55,54,65,54,66,56,28,57,28,58,28,59,28,60,28,61,28,62,34,62,42,62,43,63,28,64,28,67,1,67,2,67,3,67,4,67,5,67,6,67,7,68,28,69,70,71,28,72,28,73,28,74,28,75,28
};

const char *grpc_static_metadata_strings[GRPC_STATIC_MDSTR_COUNT] = {
"0",
"200",
"204",
"206",
"304",
"400",
"404",
"500",
"accept",
"accept-charset",
"accept-encoding",
"accept-language",
"accept-ranges",
"access-control-allow-origin",
"age",
"allow",
":authority",
"authorization",
"cache-control",
"content-disposition",
"content-encoding",
"content-language",
"content-length",
"content-location",
"content-range",
"content-type",
"cookie",
"date",
"",
"etag",
"expect",
"expires",
"from",
"GET",
"grpc",
"grpc-accept-encoding",
"grpc-encoding",
"grpc-message",
"grpc-status",
"grpc-timeout",
"gzip, deflate",
"host",
"http",
"https",
"if-match",
"if-modified-since",
"if-none-match",
"if-range",
"if-unmodified-since",
"last-modified",
"link",
"location",
"max-forwards",
":method",
":path",
"POST",
"proxy-authenticate",
"proxy-authorization",
"range",
"referer",
"refresh",
"retry-after",
":scheme",
"server",
"set-cookie",
"/",
"/index.html",
":status",
"strict-transport-security",
"te",
"trailers",
"transfer-encoding",
"user-agent",
"vary",
"via",
"www-authenticate"
};
const gpr_uint8 grpc_static_metadata_elem_indices[GRPC_STATIC_MDELEM_COUNT *
2] = {
9, 28, 8, 28, 10, 28, 10, 40, 11, 28, 12, 28, 13, 28, 14, 28, 15, 28, 16,
28, 17, 28, 18, 28, 19, 28, 20, 28, 21, 28, 22, 28, 23, 28, 24, 28, 25, 28,
26, 28, 27, 28, 29, 28, 30, 28, 31, 28, 32, 28, 38, 0, 41, 28, 44, 28, 45,
28, 46, 28, 47, 28, 48, 28, 49, 28, 50, 28, 51, 28, 52, 28, 53, 33, 53, 55,
54, 65, 54, 66, 56, 28, 57, 28, 58, 28, 59, 28, 60, 28, 61, 28, 62, 34, 62,
42, 62, 43, 63, 28, 64, 28, 67, 1, 67, 2, 67, 3, 67, 4, 67, 5, 67, 6,
67, 7, 68, 28, 69, 70, 71, 28, 72, 28, 73, 28, 74, 28, 75, 28};

const char *const grpc_static_metadata_strings[GRPC_STATIC_MDSTR_COUNT] = {
"0",
"200",
"204",
"206",
"304",
"400",
"404",
"500",
"accept",
"accept-charset",
"accept-encoding",
"accept-language",
"accept-ranges",
"access-control-allow-origin",
"age",
"allow",
":authority",
"authorization",
"cache-control",
"content-disposition",
"content-encoding",
"content-language",
"content-length",
"content-location",
"content-range",
"content-type",
"cookie",
"date",
"",
"etag",
"expect",
"expires",
"from",
"GET",
"grpc",
"grpc-accept-encoding",
"grpc-encoding",
"grpc-message",
"grpc-status",
"grpc-timeout",
"gzip, deflate",
"host",
"http",
"https",
"if-match",
"if-modified-since",
"if-none-match",
"if-range",
"if-unmodified-since",
"last-modified",
"link",
"location",
"max-forwards",
":method",
":path",
"POST",
"proxy-authenticate",
"proxy-authorization",
"range",
"referer",
"refresh",
"retry-after",
":scheme",
"server",
"set-cookie",
"/",
"/index.html",
":status",
"strict-transport-security",
"te",
"trailers",
"transfer-encoding",
"user-agent",
"vary",
"via",
"www-authenticate"};
24 changes: 14 additions & 10 deletions src/core/transport/static_metadata.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
* Copyright 2015, Google Inc.
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
Expand All @@ -15,7 +15,7 @@
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
Expand All @@ -31,8 +31,9 @@

/*
* WARNING: Auto-generated code.
*
* To make changes to this file, change tools/codegen/core/gen_static_metadata.py,
*
* To make changes to this file, change
* tools/codegen/core/gen_static_metadata.py,
* and then re-run it.
*/

Expand Down Expand Up @@ -205,13 +206,15 @@ extern grpc_mdelem grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT];
/* "accept-encoding": "" */
#define GRPC_MDELEM_ACCEPT_ENCODING_EMPTY (&grpc_static_mdelem_table[2])
/* "accept-encoding": "gzip, deflate" */
#define GRPC_MDELEM_ACCEPT_ENCODING_GZIP_COMMA_DEFLATE (&grpc_static_mdelem_table[3])
#define GRPC_MDELEM_ACCEPT_ENCODING_GZIP_COMMA_DEFLATE \
(&grpc_static_mdelem_table[3])
/* "accept-language": "" */
#define GRPC_MDELEM_ACCEPT_LANGUAGE_EMPTY (&grpc_static_mdelem_table[4])
/* "accept-ranges": "" */
#define GRPC_MDELEM_ACCEPT_RANGES_EMPTY (&grpc_static_mdelem_table[5])
/* "access-control-allow-origin": "" */
#define GRPC_MDELEM_ACCESS_CONTROL_ALLOW_ORIGIN_EMPTY (&grpc_static_mdelem_table[6])
#define GRPC_MDELEM_ACCESS_CONTROL_ALLOW_ORIGIN_EMPTY \
(&grpc_static_mdelem_table[6])
/* "age": "" */
#define GRPC_MDELEM_AGE_EMPTY (&grpc_static_mdelem_table[7])
/* "allow": "" */
Expand Down Expand Up @@ -315,7 +318,8 @@ extern grpc_mdelem grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT];
/* ":status": "500" */
#define GRPC_MDELEM_STATUS_500 (&grpc_static_mdelem_table[57])
/* "strict-transport-security": "" */
#define GRPC_MDELEM_STRICT_TRANSPORT_SECURITY_EMPTY (&grpc_static_mdelem_table[58])
#define GRPC_MDELEM_STRICT_TRANSPORT_SECURITY_EMPTY \
(&grpc_static_mdelem_table[58])
/* "te": "trailers" */
#define GRPC_MDELEM_TE_TRAILERS (&grpc_static_mdelem_table[59])
/* "transfer-encoding": "" */
Expand All @@ -329,6 +333,6 @@ extern grpc_mdelem grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT];
/* "www-authenticate": "" */
#define GRPC_MDELEM_WWW_AUTHENTICATE_EMPTY (&grpc_static_mdelem_table[64])

gpr_uint8 grpc_static_metadata_elem_indices[GRPC_STATIC_MDELEM_COUNT*2];
const char *grpc_static_metadata_strings[GRPC_STATIC_MDSTR_COUNT];
const gpr_uint8 grpc_static_metadata_elem_indices[GRPC_STATIC_MDELEM_COUNT * 2];
const char *const grpc_static_metadata_strings[GRPC_STATIC_MDSTR_COUNT];
#endif /* GRPC_INTERNAL_CORE_TRANSPORT_STATIC_METADATA_H */
8 changes: 4 additions & 4 deletions tools/codegen/core/gen_static_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,14 @@ def str_idx(s):
if s == s2:
return i

print >>H, 'gpr_uint8 grpc_static_metadata_elem_indices[GRPC_STATIC_MDELEM_COUNT*2];'
print >>C, 'gpr_uint8 grpc_static_metadata_elem_indices[GRPC_STATIC_MDELEM_COUNT*2] = {'
print >>H, 'const gpr_uint8 grpc_static_metadata_elem_indices[GRPC_STATIC_MDELEM_COUNT*2];'
print >>C, 'const gpr_uint8 grpc_static_metadata_elem_indices[GRPC_STATIC_MDELEM_COUNT*2] = {'
print >>C, ','.join('%d' % str_idx(x) for x in itertools.chain.from_iterable([a,b] for a, b in all_elems))
print >>C, '};'
print >>C

print >>H, 'const char *grpc_static_metadata_strings[GRPC_STATIC_MDSTR_COUNT];'
print >>C, 'const char *grpc_static_metadata_strings[GRPC_STATIC_MDSTR_COUNT] = {'
print >>H, 'const char *const grpc_static_metadata_strings[GRPC_STATIC_MDSTR_COUNT];'
print >>C, 'const char *const grpc_static_metadata_strings[GRPC_STATIC_MDSTR_COUNT] = {'
print >>C, '%s' % ',\n'.join(' "%s"' % s for s in all_strs)
print >>C, '};'
print >>C
Expand Down

0 comments on commit 328d4b1

Please sign in to comment.