Skip to content

Commit

Permalink
Fix C++ to pass jsonization of concrete classes (#444)
Browse files Browse the repository at this point in the history
We fix the C++ generator so that the generator code passes all the tests
related to jsonization of concrete classes.
  • Loading branch information
mristin authored Feb 10, 2024
1 parent 3e36069 commit 7e2bad3
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
4 changes: 4 additions & 0 deletions aas_core_codegen/cpp/aas_common/_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,10 @@ def generate_implementation(library_namespace: Stripped) -> str:
{I}const char* utf8_text,
{I}size_t utf8_text_size
) {{
{I}if (utf8_text_size == 0) {{
{II}return std::wstring();
{I}}}
{I}#ifdef _WIN32
{I}// NOTE (mristin):
{I}// We have to use MultiByteToWideChar from <windows.h> on Windows
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<html>
<head>
<title>Replace curly brackets, backslashes and indent</title>
<script>
function processInput() {
var input = document.getElementById("input");
var output = document.getElementById("output");

var text = input.value
.replaceAll("{", "{{")
.replaceAll("}", "}}")
.replaceAll(/^ /gm, "{IIIII}")
.replaceAll(/^ /gm, "{IIII}")
.replaceAll(/^ /gm, "{III}")
.replaceAll(/^ /gm, "{II}")
.replaceAll(/^ /gm, "{I}")
.replaceAll("\\", "\\\\");

output.value = text;
}

function copyOutput() {
var output = document.getElementById("output");
output.select();
document.execCommand("copy");
}

window.onload = function() {
processInput();
}
</script>
</head>
<body>
<textarea id="input" cols="120" rows="10" oninput="processInput()"></textarea>
<br/><br/><br/>
<textarea id="output" cols="120" rows="10" readonly></textarea>
<br/><br/><br/>
<button onclick="copyOutput()">Copy</button>
</body>
Original file line number Diff line number Diff line change
Expand Up @@ -13976,6 +13976,10 @@ std::wstring Utf8ToWstring(
const char* utf8_text,
size_t utf8_text_size
) {
if (utf8_text_size == 0) {
return std::wstring();
}

#ifdef _WIN32
// NOTE (mristin):
// We have to use MultiByteToWideChar from <windows.h> on Windows
Expand Down

0 comments on commit 7e2bad3

Please sign in to comment.