commit
5ed687d013
50 changed files with 887 additions and 419 deletions
@ -1,5 +1,5 @@ |
||||
{ |
||||
"sdk": { |
||||
"version": "1.0.0-preview2-003121" |
||||
"version": "1.0.0-preview2-003131" |
||||
} |
||||
} |
@ -0,0 +1,75 @@ |
||||
/*
|
||||
* Copyright 2017, 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 |
||||
* copyright notice, this list of conditions and the following disclaimer |
||||
* in the documentation and/or other materials provided with the |
||||
* distribution. |
||||
* * 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 |
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
*/ |
||||
|
||||
/*
|
||||
* Automatically generated by tools/codegen/core/gen_settings_ids.py |
||||
*/ |
||||
|
||||
#include "src/core/ext/transport/chttp2/transport/http2_settings.h" |
||||
|
||||
#include <grpc/support/useful.h> |
||||
#include "src/core/lib/transport/http2_errors.h" |
||||
|
||||
const uint16_t grpc_setting_id_to_wire_id[] = {1, 2, 3, 4, 5, 6, 65027}; |
||||
|
||||
bool grpc_wire_id_to_setting_id(uint32_t wire_id, grpc_chttp2_setting_id *out) { |
||||
uint32_t i = wire_id - 1; |
||||
uint32_t x = i % 256; |
||||
uint32_t y = i / 256; |
||||
uint32_t h = x; |
||||
switch (y) { |
||||
case 254: |
||||
h += 4; |
||||
break; |
||||
} |
||||
*out = (grpc_chttp2_setting_id)h; |
||||
return h < GPR_ARRAY_SIZE(grpc_setting_id_to_wire_id) && |
||||
grpc_setting_id_to_wire_id[h] == wire_id; |
||||
} |
||||
|
||||
const grpc_chttp2_setting_parameters |
||||
grpc_chttp2_settings_parameters[GRPC_CHTTP2_NUM_SETTINGS] = { |
||||
{"HEADER_TABLE_SIZE", 4096u, 0u, 4294967295u, |
||||
GRPC_CHTTP2_CLAMP_INVALID_VALUE, GRPC_HTTP2_PROTOCOL_ERROR}, |
||||
{"ENABLE_PUSH", 1u, 0u, 1u, GRPC_CHTTP2_DISCONNECT_ON_INVALID_VALUE, |
||||
GRPC_HTTP2_PROTOCOL_ERROR}, |
||||
{"MAX_CONCURRENT_STREAMS", 4294967295u, 0u, 4294967295u, |
||||
GRPC_CHTTP2_DISCONNECT_ON_INVALID_VALUE, GRPC_HTTP2_PROTOCOL_ERROR}, |
||||
{"INITIAL_WINDOW_SIZE", 65535u, 0u, 2147483647u, |
||||
GRPC_CHTTP2_DISCONNECT_ON_INVALID_VALUE, |
||||
GRPC_HTTP2_FLOW_CONTROL_ERROR}, |
||||
{"MAX_FRAME_SIZE", 16384u, 16384u, 16777215u, |
||||
GRPC_CHTTP2_DISCONNECT_ON_INVALID_VALUE, GRPC_HTTP2_PROTOCOL_ERROR}, |
||||
{"MAX_HEADER_LIST_SIZE", 16777216u, 0u, 16777216u, |
||||
GRPC_CHTTP2_CLAMP_INVALID_VALUE, GRPC_HTTP2_PROTOCOL_ERROR}, |
||||
{"GRPC_ALLOW_TRUE_BINARY_METADATA", 0u, 0u, 1u, |
||||
GRPC_CHTTP2_CLAMP_INVALID_VALUE, GRPC_HTTP2_PROTOCOL_ERROR}, |
||||
}; |
@ -0,0 +1,74 @@ |
||||
/*
|
||||
* Copyright 2017, 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 |
||||
* copyright notice, this list of conditions and the following disclaimer |
||||
* in the documentation and/or other materials provided with the |
||||
* distribution. |
||||
* * 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 |
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
*/ |
||||
|
||||
/*
|
||||
* Automatically generated by tools/codegen/core/gen_settings_ids.py |
||||
*/ |
||||
|
||||
#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HTTP2_SETTINGS_H |
||||
#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HTTP2_SETTINGS_H |
||||
|
||||
#include <stdbool.h> |
||||
#include <stdint.h> |
||||
|
||||
typedef enum { |
||||
GRPC_CHTTP2_SETTINGS_HEADER_TABLE_SIZE = 0, /* wire id 1 */ |
||||
GRPC_CHTTP2_SETTINGS_ENABLE_PUSH = 1, /* wire id 2 */ |
||||
GRPC_CHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS = 2, /* wire id 3 */ |
||||
GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE = 3, /* wire id 4 */ |
||||
GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE = 4, /* wire id 5 */ |
||||
GRPC_CHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE = 5, /* wire id 6 */ |
||||
GRPC_CHTTP2_SETTINGS_GRPC_ALLOW_TRUE_BINARY_METADATA = 6, /* wire id 65027 */ |
||||
} grpc_chttp2_setting_id; |
||||
|
||||
#define GRPC_CHTTP2_NUM_SETTINGS 7 |
||||
extern const uint16_t grpc_setting_id_to_wire_id[]; |
||||
|
||||
bool grpc_wire_id_to_setting_id(uint32_t wire_id, grpc_chttp2_setting_id *out); |
||||
|
||||
typedef enum { |
||||
GRPC_CHTTP2_CLAMP_INVALID_VALUE, |
||||
GRPC_CHTTP2_DISCONNECT_ON_INVALID_VALUE |
||||
} grpc_chttp2_invalid_value_behavior; |
||||
|
||||
typedef struct { |
||||
const char *name; |
||||
uint32_t default_value; |
||||
uint32_t min_value; |
||||
uint32_t max_value; |
||||
grpc_chttp2_invalid_value_behavior invalid_value_behavior; |
||||
uint32_t error_value; |
||||
} grpc_chttp2_setting_parameters; |
||||
|
||||
extern const grpc_chttp2_setting_parameters |
||||
grpc_chttp2_settings_parameters[GRPC_CHTTP2_NUM_SETTINGS]; |
||||
|
||||
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HTTP2_SETTINGS_H */ |
@ -1,35 +0,0 @@ |
||||
{ |
||||
"version": "1.3.0-dev", |
||||
"title": "gRPC C# Auth", |
||||
"authors": [ "Google Inc." ], |
||||
"copyright": "Copyright 2015, Google Inc.", |
||||
"packOptions": { |
||||
"summary": "Auth library for C# implementation of gRPC - an RPC library and framework", |
||||
"description": "Auth library for C# implementation of gRPC - an RPC library and framework. See project site for more info.", |
||||
"owners": [ "grpc-packages" ], |
||||
"licenseUrl": "https://github.com/grpc/grpc/blob/master/LICENSE", |
||||
"projectUrl": "https://github.com/grpc/grpc", |
||||
"requireLicenseAcceptance": false, |
||||
"tags": [ "gRPC RPC Protocol HTTP/2 Auth OAuth2" ], |
||||
}, |
||||
"buildOptions": { |
||||
"define": [ "SIGNED" ], |
||||
"keyFile": "../keys/Grpc.snk", |
||||
"xmlDoc": true, |
||||
"compile": { |
||||
"includeFiles": [ "../Grpc.Core/Version.cs" ] |
||||
} |
||||
}, |
||||
"dependencies": { |
||||
"Grpc.Core": "1.3.0-dev", |
||||
"Google.Apis.Auth": "1.21.0" |
||||
}, |
||||
"frameworks": { |
||||
"net45": { }, |
||||
"netstandard1.5": { |
||||
"dependencies": { |
||||
"NETStandard.Library": "1.6.0" |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,39 +0,0 @@ |
||||
{ |
||||
"version": "1.3.0-dev", |
||||
"title": "gRPC C# Core Testing", |
||||
"authors": [ "Google Inc." ], |
||||
"copyright": "Copyright 2017, Google Inc.", |
||||
"packOptions": { |
||||
"summary": "Testing support for gRPC C#", |
||||
"description": "Useful when testing code that uses gRPC.", |
||||
"owners": [ "grpc-packages" ], |
||||
"licenseUrl": "https://github.com/grpc/grpc/blob/master/LICENSE", |
||||
"projectUrl": "https://github.com/grpc/grpc", |
||||
"requireLicenseAcceptance": false, |
||||
"tags": [ "gRPC test testing" ] |
||||
}, |
||||
"buildOptions": { |
||||
"define": [ "SIGNED" ], |
||||
"keyFile": "../keys/Grpc.snk", |
||||
"xmlDoc": true, |
||||
"compile": { |
||||
"includeFiles": [ "../Grpc.Core/Version.cs" ] |
||||
} |
||||
}, |
||||
"dependencies": { |
||||
"Grpc.Core": "1.3.0-dev" |
||||
}, |
||||
"frameworks": { |
||||
"net45": { |
||||
"frameworkAssemblies": { |
||||
"System.Runtime": "", |
||||
"System.IO": "" |
||||
} |
||||
}, |
||||
"netstandard1.5": { |
||||
"dependencies": { |
||||
"NETStandard.Library": "1.6.0" |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,35 +0,0 @@ |
||||
{ |
||||
"version": "1.3.0-dev", |
||||
"title": "gRPC C# Healthchecking", |
||||
"authors": [ "Google Inc." ], |
||||
"copyright": "Copyright 2015, Google Inc.", |
||||
"packOptions": { |
||||
"summary": "Implementation of gRPC health service", |
||||
"description": "Example implementation of grpc.health.v1 service that can be used for health-checking.", |
||||
"owners": [ "grpc-packages" ], |
||||
"licenseUrl": "https://github.com/grpc/grpc/blob/master/LICENSE", |
||||
"projectUrl": "https://github.com/grpc/grpc", |
||||
"requireLicenseAcceptance": false, |
||||
"tags": [ "gRPC health check" ] |
||||
}, |
||||
"buildOptions": { |
||||
"define": [ "SIGNED" ], |
||||
"keyFile": "../keys/Grpc.snk", |
||||
"xmlDoc": true, |
||||
"compile": { |
||||
"includeFiles": [ "../Grpc.Core/Version.cs" ] |
||||
} |
||||
}, |
||||
"dependencies": { |
||||
"Grpc.Core": "1.3.0-dev", |
||||
"Google.Protobuf": "3.2.0" |
||||
}, |
||||
"frameworks": { |
||||
"net45": {}, |
||||
"netstandard1.5": { |
||||
"dependencies": { |
||||
"NETStandard.Library": "1.6.0" |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,35 +0,0 @@ |
||||
{ |
||||
"version": "1.3.0-dev", |
||||
"title": "gRPC C# Reflection", |
||||
"authors": [ "Google Inc." ], |
||||
"copyright": "Copyright 2016, Google Inc.", |
||||
"packOptions": { |
||||
"summary": "Implementation of gRPC reflection service", |
||||
"description": "Provides information about services running on a gRPC C# server.", |
||||
"owners": [ "grpc-packages" ], |
||||
"licenseUrl": "https://github.com/grpc/grpc/blob/master/LICENSE", |
||||
"projectUrl": "https://github.com/grpc/grpc", |
||||
"requireLicenseAcceptance": false, |
||||
"tags": [ "gRPC reflection" ] |
||||
}, |
||||
"buildOptions": { |
||||
"define": [ "SIGNED" ], |
||||
"keyFile": "../keys/Grpc.snk", |
||||
"xmlDoc": true, |
||||
"compile": { |
||||
"includeFiles": [ "../Grpc.Core/Version.cs" ] |
||||
} |
||||
}, |
||||
"dependencies": { |
||||
"Grpc.Core": "1.3.0-dev", |
||||
"Google.Protobuf": "3.2.0" |
||||
}, |
||||
"frameworks": { |
||||
"net45": {}, |
||||
"netstandard1.5": { |
||||
"dependencies": { |
||||
"NETStandard.Library": "1.6.0" |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,5 @@ |
||||
{ |
||||
"sdk": { |
||||
"version": "1.0.0-preview2-003131" |
||||
} |
||||
} |
@ -0,0 +1,184 @@ |
||||
#!/usr/bin/env python2.7 |
||||
|
||||
# Copyright 2017, 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 |
||||
# copyright notice, this list of conditions and the following disclaimer |
||||
# in the documentation and/or other materials provided with the |
||||
# distribution. |
||||
# * 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 |
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
|
||||
import collections |
||||
import perfection |
||||
import sys |
||||
|
||||
_MAX_HEADER_LIST_SIZE = 16 * 1024 * 1024 |
||||
|
||||
Setting = collections.namedtuple('Setting', 'id default min max on_error') |
||||
OnError = collections.namedtuple('OnError', 'behavior code') |
||||
clamp_invalid_value = OnError('CLAMP_INVALID_VALUE', 'PROTOCOL_ERROR') |
||||
disconnect_on_invalid_value = lambda e: OnError('DISCONNECT_ON_INVALID_VALUE', e) |
||||
DecoratedSetting = collections.namedtuple('DecoratedSetting', 'enum name setting') |
||||
|
||||
_SETTINGS = { |
||||
'HEADER_TABLE_SIZE': Setting(1, 4096, 0, 0xffffffff, clamp_invalid_value), |
||||
'ENABLE_PUSH': Setting(2, 1, 0, 1, disconnect_on_invalid_value('PROTOCOL_ERROR')), |
||||
'MAX_CONCURRENT_STREAMS': Setting(3, 0xffffffff, 0, 0xffffffff, disconnect_on_invalid_value('PROTOCOL_ERROR')), |
||||
'INITIAL_WINDOW_SIZE': Setting(4, 65535, 0, 0x7fffffff, disconnect_on_invalid_value('FLOW_CONTROL_ERROR')), |
||||
'MAX_FRAME_SIZE': Setting(5, 16384, 16384, 16777215, disconnect_on_invalid_value('PROTOCOL_ERROR')), |
||||
'MAX_HEADER_LIST_SIZE': Setting(6, _MAX_HEADER_LIST_SIZE, 0, _MAX_HEADER_LIST_SIZE, clamp_invalid_value), |
||||
'GRPC_ALLOW_TRUE_BINARY_METADATA': Setting(0xfe03, 0, 0, 1, clamp_invalid_value), |
||||
} |
||||
|
||||
H = open('src/core/ext/transport/chttp2/transport/http2_settings.h', 'w') |
||||
C = open('src/core/ext/transport/chttp2/transport/http2_settings.c', 'w') |
||||
|
||||
# utility: print a big comment block into a set of files |
||||
def put_banner(files, banner): |
||||
for f in files: |
||||
print >>f, '/*' |
||||
for line in banner: |
||||
print >>f, ' * %s' % line |
||||
print >>f, ' */' |
||||
print >>f |
||||
|
||||
# copy-paste copyright notice from this file |
||||
with open(sys.argv[0]) as my_source: |
||||
copyright = [] |
||||
for line in my_source: |
||||
if line[0] != '#': break |
||||
for line in my_source: |
||||
if line[0] == '#': |
||||
copyright.append(line) |
||||
break |
||||
for line in my_source: |
||||
if line[0] != '#': |
||||
break |
||||
copyright.append(line) |
||||
put_banner([H,C], [line[2:].rstrip() for line in copyright]) |
||||
|
||||
put_banner([H,C], ["Automatically generated by tools/codegen/core/gen_settings_ids.py"]) |
||||
|
||||
print >>H, "#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HTTP2_SETTINGS_H" |
||||
print >>H, "#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HTTP2_SETTINGS_H" |
||||
print >>H |
||||
print >>H, "#include <stdint.h>" |
||||
print >>H, "#include <stdbool.h>" |
||||
print >>H |
||||
|
||||
print >>C, "#include \"src/core/ext/transport/chttp2/transport/http2_settings.h\"" |
||||
print >>C |
||||
print >>C, "#include <grpc/support/useful.h>" |
||||
print >>C, "#include \"src/core/lib/transport/http2_errors.h\"" |
||||
print >>C |
||||
|
||||
p = perfection.hash_parameters(sorted(x.id for x in _SETTINGS.values())) |
||||
print p |
||||
|
||||
def hash(i): |
||||
i += p.offset |
||||
x = i % p.t |
||||
y = i / p.t |
||||
return x + p.r[y] |
||||
|
||||
decorated_settings = [DecoratedSetting(hash(setting.id), name, setting) |
||||
for name, setting in _SETTINGS.iteritems()] |
||||
|
||||
print >>H, 'typedef enum {' |
||||
for decorated_setting in sorted(decorated_settings): |
||||
print >>H, ' GRPC_CHTTP2_SETTINGS_%s = %d, /* wire id %d */' % ( |
||||
decorated_setting.name, decorated_setting.enum, decorated_setting.setting.id) |
||||
print >>H, '} grpc_chttp2_setting_id;' |
||||
print >>H |
||||
print >>H, '#define GRPC_CHTTP2_NUM_SETTINGS %d' % (max(x.enum for x in decorated_settings) + 1) |
||||
|
||||
print >>H, 'extern const uint16_t grpc_setting_id_to_wire_id[];' |
||||
print >>C, 'const uint16_t grpc_setting_id_to_wire_id[] = {%s};' % ','.join( |
||||
'%d' % s for s in p.slots) |
||||
print >>H |
||||
print >>H, "bool grpc_wire_id_to_setting_id(uint32_t wire_id, grpc_chttp2_setting_id *out);" |
||||
cgargs = { |
||||
'r': ','.join('%d' % (r if r is not None else 0) for r in p.r), |
||||
't': p.t, |
||||
'offset': abs(p.offset), |
||||
'offset_sign': '+' if p.offset > 0 else '-' |
||||
} |
||||
print >>C, """ |
||||
bool grpc_wire_id_to_setting_id(uint32_t wire_id, grpc_chttp2_setting_id *out) { |
||||
uint32_t i = wire_id %(offset_sign)s %(offset)d; |
||||
uint32_t x = i %% %(t)d; |
||||
uint32_t y = i / %(t)d; |
||||
uint32_t h = x; |
||||
switch (y) { |
||||
""" % cgargs |
||||
for i, r in enumerate(p.r): |
||||
if not r: continue |
||||
if r < 0: print >>C, 'case %d: h -= %d; break;' % (i, -r) |
||||
else: print >>C, 'case %d: h += %d; break;' % (i, r) |
||||
print >>C, """ |
||||
} |
||||
*out = (grpc_chttp2_setting_id)h; |
||||
return h < GPR_ARRAY_SIZE(grpc_setting_id_to_wire_id) && grpc_setting_id_to_wire_id[h] == wire_id; |
||||
} |
||||
""" % cgargs |
||||
|
||||
print >>H, """ |
||||
typedef enum { |
||||
GRPC_CHTTP2_CLAMP_INVALID_VALUE, |
||||
GRPC_CHTTP2_DISCONNECT_ON_INVALID_VALUE |
||||
} grpc_chttp2_invalid_value_behavior; |
||||
|
||||
typedef struct { |
||||
const char *name; |
||||
uint32_t default_value; |
||||
uint32_t min_value; |
||||
uint32_t max_value; |
||||
grpc_chttp2_invalid_value_behavior invalid_value_behavior; |
||||
uint32_t error_value; |
||||
} grpc_chttp2_setting_parameters; |
||||
|
||||
extern const grpc_chttp2_setting_parameters grpc_chttp2_settings_parameters[GRPC_CHTTP2_NUM_SETTINGS]; |
||||
""" |
||||
print >>C, "const grpc_chttp2_setting_parameters grpc_chttp2_settings_parameters[GRPC_CHTTP2_NUM_SETTINGS] = {" |
||||
i = 0 |
||||
for decorated_setting in sorted(decorated_settings): |
||||
while i < decorated_setting.enum: |
||||
print >>C, "{NULL, 0, 0, 0, GRPC_CHTTP2_DISCONNECT_ON_INVALID_VALUE, GRPC_HTTP2_PROTOCOL_ERROR}," |
||||
i += 1 |
||||
print >>C, "{\"%s\", %du, %du, %du, GRPC_CHTTP2_%s, GRPC_HTTP2_%s}," % ( |
||||
decorated_setting.name, |
||||
decorated_setting.setting.default, |
||||
decorated_setting.setting.min, |
||||
decorated_setting.setting.max, |
||||
decorated_setting.setting.on_error.behavior, |
||||
decorated_setting.setting.on_error.code, |
||||
) |
||||
i += 1 |
||||
print >>C, "};" |
||||
|
||||
print >>H |
||||
print >>H, "#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HTTP2_SETTINGS_H */" |
||||
|
||||
H.close() |
||||
C.close() |
Loading…
Reference in new issue