diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2024-03-04 13:32:34 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-03-04 13:32:34 +0100 |
commit | 1598af566803f06d852b229c365aaf8a359edd8e (patch) | |
tree | 077130d18b97f82680caf9dcc689702430965c98 | |
parent | 314efe9becdc3dd07b1259fd35ce9499fdace2b5 (diff) | |
parent | 0935a99bf92a49d45ad5c6a7d0242db9247ea451 (diff) | |
download | redot-engine-1598af566803f06d852b229c365aaf8a359edd8e.tar.gz |
Merge pull request #83504 from Repiteo/c#-generator-langword-check
C#: Bindings generator langword check
-rw-r--r-- | modules/mono/editor/bindings_generator.cpp | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp index 0a9162bd28..5cb177676c 100644 --- a/modules/mono/editor/bindings_generator.cpp +++ b/modules/mono/editor/bindings_generator.cpp @@ -121,6 +121,10 @@ StringBuilder &operator<<(StringBuilder &r_sb, const char *p_cstring) { // This must be kept in sync with `ignored_types` in csharp_script.cpp const Vector<String> ignored_types = {}; +// Special [code] keywords to wrap with <see langword="code"/> instead of <c>code</c>. +// Don't check against all C# reserved words, as many cases are GDScript-specific. +const Vector<String> langword_check = { "true", "false", "null" }; + void BindingsGenerator::TypeInterface::postsetup_enum_type(BindingsGenerator::TypeInterface &r_enum_itype) { // C interface for enums is the same as that of 'uint32_t'. Remember to apply // any of the changes done here to the 'uint32_t' type interface as well. @@ -670,11 +674,24 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf pos = brk_end + 1; tag_stack.push_front(tag); } else if (tag == "code" || tag.begins_with("code ")) { - xml_output.append("<c>"); + int end = bbcode.find("[", brk_end); + if (end == -1) { + end = bbcode.length(); + } + String code = bbcode.substr(brk_end + 1, end - brk_end - 1); + if (langword_check.has(code)) { + xml_output.append("<see langword=\""); + xml_output.append(code); + xml_output.append("\"/>"); - code_tag = true; - pos = brk_end + 1; - tag_stack.push_front("code"); + pos = brk_end + code.length() + 8; + } else { + xml_output.append("<c>"); + + code_tag = true; + pos = brk_end + 1; + tag_stack.push_front("code"); + } } else if (tag == "codeblock" || tag.begins_with("codeblock ")) { xml_output.append("<code>"); |