Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cpp constraints #2614

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix generating constraints on CPP output
 - Explicitly check for truthy value or zero instead of comparing to undefined, as the value could possibly be null as well
PMLavigne committed Jun 4, 2024
commit 585afe0fe54291ab9cac66f97c8917484600a62b
Original file line number Diff line number Diff line change
@@ -932,21 +932,21 @@ export class CPlusPlusRenderer extends ConvenienceRenderer {
false
);

// Explicitly comparing the minMax values to undefined here allows them to have the valid value of zero
// Check the minMax values for truthiness or if they're equal to zero, as zero is a valid value too
res.set(jsonName, [
this.constraintMember(jsonName),
"(",
minMax?.[0] !== undefined && cppType === "int64_t" ? String(minMax[0]) : this._nulloptType,
(minMax?.[0] || minMax?.[0] === 0) && cppType === "int64_t" ? String(minMax[0]) : this._nulloptType,
", ",
minMax?.[1] !== undefined && cppType === "int64_t" ? String(minMax[1]) : this._nulloptType,
(minMax?.[1] || minMax?.[1] === 0) && cppType === "int64_t" ? String(minMax[1]) : this._nulloptType,
", ",
minMax?.[0] !== undefined && cppType === "double" ? String(minMax[0]) : this._nulloptType,
(minMax?.[0] || minMax?.[0] === 0) && cppType === "double" ? String(minMax[0]) : this._nulloptType,
", ",
minMax?.[1] !== undefined && cppType === "double" ? String(minMax[1]) : this._nulloptType,
(minMax?.[1] || minMax?.[1] === 0) && cppType === "double" ? String(minMax[1]) : this._nulloptType,
", ",
minMaxLength?.[0] !== undefined ? String(minMaxLength[0]) : this._nulloptType,
minMaxLength?.[0] || minMaxLength?.[0] === 0 ? String(minMaxLength[0]) : this._nulloptType,
", ",
minMaxLength?.[1] !== undefined ? String(minMaxLength[1]) : this._nulloptType,
minMaxLength?.[1] || minMaxLength?.[1] === 0 ? String(minMaxLength[1]) : this._nulloptType,
", ",
pattern === undefined
? this._nulloptType