summaryrefslogtreecommitdiff
path: root/buildscripts/idl
diff options
context:
space:
mode:
authorSara Golemon <sara.golemon@mongodb.com>2022-07-19 15:42:55 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-07-25 16:26:27 +0000
commitb6eb0136c4cb25bb437375b639738fb28ec1956d (patch)
treee199ba3f957014f042b3b94fe020e5ce01883f45 /buildscripts/idl
parentb8187fed0bfb96eeb8456100ea84b20d4731984a (diff)
downloadmongo-b6eb0136c4cb25bb437375b639738fb28ec1956d.tar.gz
SERVER-68155 Improve IDL struct command handling
Diffstat (limited to 'buildscripts/idl')
-rw-r--r--buildscripts/idl/idl/generator.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/buildscripts/idl/idl/generator.py b/buildscripts/idl/idl/generator.py
index b03a74966ae..850e41922e8 100644
--- a/buildscripts/idl/idl/generator.py
+++ b/buildscripts/idl/idl/generator.py
@@ -278,9 +278,10 @@ def _encaps(val):
if val is None:
return '""'
- for i in ["\\", '"', "'"]:
- if i in val:
- val = val.replace(i, '\\' + i)
+ for srch, repl in {"\\": "\\\\", '"': '\\"', "'": "\\'", "\n": "\\n"}.items():
+ if srch in val:
+ val = val.replace(srch, repl)
+
return '"' + val + '"'
@@ -368,11 +369,10 @@ class _CppFileWriterBase(object):
def gen_description_comment(self, description):
# type: (str) -> None
"""Generate a multiline comment with the description from the IDL."""
- self._writer.write_line(
- textwrap.dedent("""\
- /**
- * %s
- */""" % (description)))
+ self._writer.write_line("/**")
+ for desc in description.split("\n"):
+ self._writer.write_line(" * " + desc)
+ self._writer.write_line(" */")
def _with_template(self, template_params):
# type: (Mapping[str,str]) -> writer.TemplateContext
@@ -630,6 +630,11 @@ class _CppHeaderFileWriter(_CppFileWriterBase):
if isinstance(struct, ast.Command):
self._writer.write_line(
+ common.template_args(
+ 'static constexpr auto kCommandDescription = ${description}_sd;',
+ description=_encaps(struct.description)))
+
+ self._writer.write_line(
common.template_args('static constexpr auto kCommandName = "${command_name}"_sd;',
command_name=struct.command_name))