diff options
author | Craig Tiller <ctiller@google.com> | 2016-04-26 13:00:44 -0700 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2016-04-26 13:00:44 -0700 |
commit | 89c5cb596df9f3bbbf1d024fb59df2b799c85fba (patch) | |
tree | bb9ae905ada472eb788c485b09dd8db214fb227d /tools/codegen/core/gen_static_metadata.py | |
parent | 6c8ae9aad5f1aaaf9c043817e184ec26bee75c86 (diff) | |
parent | c3d869ef5853c4cfad57b7d3694d5260eeb7ce75 (diff) |
Merge github.com:grpc/grpc into split-me-baby-one-more-time
Diffstat (limited to 'tools/codegen/core/gen_static_metadata.py')
-rwxr-xr-x | tools/codegen/core/gen_static_metadata.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tools/codegen/core/gen_static_metadata.py b/tools/codegen/core/gen_static_metadata.py index b4ba02bbe5..b38555e355 100755 --- a/tools/codegen/core/gen_static_metadata.py +++ b/tools/codegen/core/gen_static_metadata.py @@ -205,6 +205,7 @@ all_elems = sorted(list(all_elems), key=mangle) args = sys.argv[1:] H = None C = None +D = None if args: if 'header' in args: H = sys.stdout @@ -214,11 +215,17 @@ if args: C = sys.stdout else: C = open('/dev/null', 'w') + if 'dictionary' in args: + D = sys.stdout + else: + D = open('/dev/null', 'w') else: H = open(os.path.join( os.path.dirname(sys.argv[0]), '../../../src/core/lib/transport/static_metadata.h'), 'w') C = open(os.path.join( os.path.dirname(sys.argv[0]), '../../../src/core/lib/transport/static_metadata.c'), 'w') + D = open(os.path.join( + os.path.dirname(sys.argv[0]), '../../../test/core/end2end/fuzzers/hpack.dictionary'), 'w') # copy-paste copyright notice from this file with open(sys.argv[0]) as my_source: @@ -235,6 +242,22 @@ with open(sys.argv[0]) as my_source: copyright.append(line) put_banner([H,C], [line[2:].rstrip() for line in copyright]) + +hex_bytes = [ord(c) for c in "abcdefABCDEF0123456789"] + + +def esc_dict(line): + out = "\"" + for c in line: + if 32 <= c < 127: + if c != ord('"'): + out += chr(c) + else: + out += "\\\"" + else: + out += "\\x%02X" % c + return out + "\"" + put_banner([H,C], """WARNING: Auto-generated code. @@ -263,6 +286,13 @@ print >>H print >>C, 'grpc_mdstr grpc_static_mdstr_table[GRPC_STATIC_MDSTR_COUNT];' print >>C +print >>D, '# hpack fuzzing dictionary' +for i, elem in enumerate(all_strs): + print >>D, '%s' % (esc_dict([len(elem)] + [ord(c) for c in elem])) +for i, elem in enumerate(all_elems): + print >>D, '%s' % (esc_dict([0, len(elem[0])] + [ord(c) for c in elem[0]] + + [len(elem[1])] + [ord(c) for c in elem[1]])) + print >>H, '#define GRPC_STATIC_MDELEM_COUNT %d' % len(all_elems) print >>H, 'extern grpc_mdelem grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT];' print >>H, 'extern uintptr_t grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT];' |