Skip to content

Commit

Permalink
proxygen
Browse files Browse the repository at this point in the history
Reviewed By: jermenkoo

Differential Revision: D66872470

fbshipit-source-id: 7c74aa942c9c9bc07695bb9a1ac4dac96bc6cf30
  • Loading branch information
generatedunixname89002005287564 authored and facebook-github-bot committed Dec 10, 2024
1 parent bd0a4e0 commit 4dc71c5
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions proxygen/lib/utils/gen_trace_event_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

from __future__ import absolute_import, division, print_function, unicode_literals

import optparse
import os
Expand Down Expand Up @@ -74,7 +73,7 @@ def main(argv):

# parse items from source
items = []
with open(file_name, "r") as inf:
with open(file_name) as inf:
for line in inf:
sp = re.match(r"(.*), \"(.*)\"", line, re.I)
if sp:
Expand Down Expand Up @@ -118,7 +117,7 @@ def gen_java(items, class_name, install_dir, output_scope):

for item in items:
outf.write(
' public static final String %s = "%s";\n' % (item[0], item[1])
' public static final String {} = "{}";\n'.format(item[0], item[1])
)

outf.write("}\n")
Expand Down Expand Up @@ -151,7 +150,9 @@ def gen_cpp_header(items, class_name, install_dir, output_scope):

# enum to string convert function
outf.write(
"extern const std::string& get%sString(%s);\n" % (class_name, class_name)
"extern const std::string& get{}String({});\n".format(
class_name, class_name
)
)

outf.write(
Expand All @@ -176,7 +177,7 @@ def gen_cpp_source(items, class_name, install_dir, header_path, output_scope):
with open(output_file, "w+") as outf:
outf.write("// Copyright 2015-present Facebook. All Rights Reserved.\n")
outf.write("// ** AUTOGENERATED FILE. DO NOT HAND-EDIT **\n\n")
outf.write('#include "%s/%s.h"\n\n' % (header_path, class_name))
outf.write('#include "{}/{}.h"\n\n'.format(header_path, class_name))
outf.write("#include <stdexcept>\n\n")

for ns in namespaces:
Expand All @@ -192,7 +193,9 @@ def gen_cpp_source(items, class_name, install_dir, header_path, output_scope):

# generate enum to string convert function
outf.write(
"const std::string& get%sString(%s type) {\n" % (class_name, class_name)
"const std::string& get{}String({} type) {{\n".format(
class_name, class_name
)
)

outf.write(' static const std::string k%sInvalidType = "";\n' % class_name)
Expand Down

0 comments on commit 4dc71c5

Please sign in to comment.