aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/codegen
diff options
context:
space:
mode:
authorGravatar Muxi Yan <mxyan@google.com>2017-10-06 18:47:09 -0700
committerGravatar Muxi Yan <mxyan@google.com>2017-10-06 18:47:09 -0700
commit03fc857a6f3ad1ee0a6f46cd19b5c96e56c6fd3b (patch)
tree38e03428954c3abdf2c88cafa9ffbd205789976b /tools/codegen
parent63602748415fb836afd7a9685fbe5e85bf5ebfed (diff)
parent03bd5daf5cd36373152cb6b06a5f259db1331e87 (diff)
Merge remote-tracking branch 'upstream/master' into fix-stream-compression-config-interface
Diffstat (limited to 'tools/codegen')
-rwxr-xr-xtools/codegen/core/gen_static_metadata.py10
-rwxr-xr-xtools/codegen/core/gen_stats_data.py14
2 files changed, 20 insertions, 4 deletions
diff --git a/tools/codegen/core/gen_static_metadata.py b/tools/codegen/core/gen_static_metadata.py
index 74e5131852..81846818cb 100755
--- a/tools/codegen/core/gen_static_metadata.py
+++ b/tools/codegen/core/gen_static_metadata.py
@@ -306,7 +306,7 @@ else:
C = open(
os.path.join(
os.path.dirname(sys.argv[0]),
- '../../../src/core/lib/transport/static_metadata.c'), 'w')
+ '../../../src/core/lib/transport/static_metadata.cc'), 'w')
D = open(
os.path.join(
os.path.dirname(sys.argv[0]),
@@ -356,6 +356,10 @@ an explanation of what's going on.
print >> H, '#ifndef GRPC_CORE_LIB_TRANSPORT_STATIC_METADATA_H'
print >> H, '#define GRPC_CORE_LIB_TRANSPORT_STATIC_METADATA_H'
print >> H
+print >> H, '#ifdef __cplusplus'
+print >> H, 'extern "C" {'
+print >> H, '#endif'
+print >> H
print >> H, '#include "src/core/lib/transport/metadata.h"'
print >> H
@@ -591,6 +595,10 @@ print >> C, '};'
print >> H, '#define GRPC_MDELEM_ACCEPT_STREAM_ENCODING_FOR_ALGORITHMS(algs) (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[grpc_static_accept_stream_encoding_metadata[(algs)]], GRPC_MDELEM_STORAGE_STATIC))'
+print >> H, '#ifdef __cplusplus'
+print >> H, '}'
+print >> H, '#endif'
+
print >> H, '#endif /* GRPC_CORE_LIB_TRANSPORT_STATIC_METADATA_H */'
H.close()
diff --git a/tools/codegen/core/gen_stats_data.py b/tools/codegen/core/gen_stats_data.py
index 10ad0cc831..072a677615 100755
--- a/tools/codegen/core/gen_stats_data.py
+++ b/tools/codegen/core/gen_stats_data.py
@@ -147,8 +147,7 @@ def gen_bucket_code(histogram):
shift_data = find_ideal_shift(code_bounds[first_nontrivial:], 256 * histogram.buckets)
#print first_nontrivial, shift_data, bounds
#if shift_data is not None: print [hex(x >> shift_data[0]) for x in code_bounds[first_nontrivial:]]
- code = '\n/* Automatically generated by tools/codegen/core/gen_stats_data.py */\n'
- code += 'value = GPR_CLAMP(value, 0, %d);\n' % histogram.max
+ code = 'value = GPR_CLAMP(value, 0, %d);\n' % histogram.max
map_table = gen_map_table(code_bounds[first_nontrivial:], shift_data)
if first_nontrivial is None:
code += ('GRPC_STATS_INC_HISTOGRAM((exec_ctx), GRPC_STATS_HISTOGRAM_%s, value);\n'
@@ -209,6 +208,10 @@ with open('src/core/lib/debug/stats_data.h', 'w') as H:
print >>H, "#include <inttypes.h>"
print >>H, "#include \"src/core/lib/iomgr/exec_ctx.h\""
print >>H
+ print >>H, "#ifdef __cplusplus"
+ print >>H, "extern \"C\" {"
+ print >>H, "#endif"
+ print >>H
for typename, instances in sorted(inst_map.items()):
print >>H, "typedef enum {"
@@ -254,9 +257,13 @@ with open('src/core/lib/debug/stats_data.h', 'w') as H:
print >>H, "extern void (*const grpc_stats_inc_histogram[%d])(grpc_exec_ctx *exec_ctx, int x);" % len(inst_map['Histogram'])
print >>H
+ print >>H, "#ifdef __cplusplus"
+ print >>H, "}"
+ print >>H, "#endif"
+ print >>H
print >>H, "#endif /* GRPC_CORE_LIB_DEBUG_STATS_DATA_H */"
-with open('src/core/lib/debug/stats_data.c', 'w') as C:
+with open('src/core/lib/debug/stats_data.cc', 'w') as C:
# copy-paste copyright notice from this file
with open(sys.argv[0]) as my_source:
copyright = []
@@ -408,3 +415,4 @@ with open('src/core/lib/debug/stats_data_bq_schema.sql', 'w') as S:
for counter in inst_map['Counter']:
columns.append(('%s_per_iteration' % counter.name, 'FLOAT'))
print >>S, ',\n'.join('%s:%s' % x for x in columns)
+