quicktype-core 23.0.44 → 23.0.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/language/CPlusPlus.d.ts +37 -30
- package/dist/language/CPlusPlus.js +97 -65
- package/package.json +1 -1
|
@@ -51,21 +51,27 @@ export declare enum GlobalNames {
|
|
|
51
51
|
CheckConstraint = 7
|
|
52
52
|
}
|
|
53
53
|
export declare enum MemberNames {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
54
|
+
MinIntValue = 0,
|
|
55
|
+
GetMinIntValue = 1,
|
|
56
|
+
SetMinIntValue = 2,
|
|
57
|
+
MaxIntValue = 3,
|
|
58
|
+
GetMaxIntValue = 4,
|
|
59
|
+
SetMaxIntValue = 5,
|
|
60
|
+
MinDoubleValue = 6,
|
|
61
|
+
GetMinDoubleValue = 7,
|
|
62
|
+
SetMinDoubleValue = 8,
|
|
63
|
+
MaxDoubleValue = 9,
|
|
64
|
+
GetMaxDoubleValue = 10,
|
|
65
|
+
SetMaxDoubleValue = 11,
|
|
66
|
+
MinLength = 12,
|
|
67
|
+
GetMinLength = 13,
|
|
68
|
+
SetMinLength = 14,
|
|
69
|
+
MaxLength = 15,
|
|
70
|
+
GetMaxLength = 16,
|
|
71
|
+
SetMaxLength = 17,
|
|
72
|
+
Pattern = 18,
|
|
73
|
+
GetPattern = 19,
|
|
74
|
+
SetPattern = 20
|
|
69
75
|
}
|
|
70
76
|
type ConstraintMember = {
|
|
71
77
|
name: MemberNames;
|
|
@@ -96,8 +102,8 @@ export type TypeContext = {
|
|
|
96
102
|
inJsonNamespace: boolean;
|
|
97
103
|
};
|
|
98
104
|
declare class WrappingCode {
|
|
99
|
-
private _start;
|
|
100
|
-
private _end;
|
|
105
|
+
private readonly _start;
|
|
106
|
+
private readonly _end;
|
|
101
107
|
constructor(start: Sourcelike[], end: Sourcelike[]);
|
|
102
108
|
wrap(qualifier: Sourcelike, inner: Sourcelike): Sourcelike;
|
|
103
109
|
}
|
|
@@ -106,24 +112,24 @@ export declare class CPlusPlusRenderer extends ConvenienceRenderer {
|
|
|
106
112
|
/**
|
|
107
113
|
* For forward declaration practically
|
|
108
114
|
*/
|
|
109
|
-
private _enumType;
|
|
110
|
-
private _generatedFiles;
|
|
115
|
+
private readonly _enumType;
|
|
116
|
+
private readonly _generatedFiles;
|
|
111
117
|
private _currentFilename;
|
|
112
118
|
private _allTypeNames;
|
|
113
119
|
private readonly _gettersAndSettersForPropertyName;
|
|
114
120
|
private readonly _namespaceNames;
|
|
115
|
-
private _memberNameStyle;
|
|
116
|
-
private _namedTypeNameStyle;
|
|
117
|
-
private _generatedGlobalNames;
|
|
118
|
-
private _generatedMemberNames;
|
|
119
|
-
private _forbiddenGlobalNames;
|
|
121
|
+
private readonly _memberNameStyle;
|
|
122
|
+
private readonly _namedTypeNameStyle;
|
|
123
|
+
private readonly _generatedGlobalNames;
|
|
124
|
+
private readonly _generatedMemberNames;
|
|
125
|
+
private readonly _forbiddenGlobalNames;
|
|
120
126
|
private readonly _memberNamingFunction;
|
|
121
|
-
private _stringType;
|
|
122
|
-
private _optionalType;
|
|
123
|
-
private _optionalFactory;
|
|
124
|
-
private _nulloptType;
|
|
125
|
-
private _variantType;
|
|
126
|
-
private _variantIndexMethodName;
|
|
127
|
+
private readonly _stringType;
|
|
128
|
+
private readonly _optionalType;
|
|
129
|
+
private readonly _optionalFactory;
|
|
130
|
+
private readonly _nulloptType;
|
|
131
|
+
private readonly _variantType;
|
|
132
|
+
private readonly _variantIndexMethodName;
|
|
127
133
|
protected readonly typeNamingStyle: NamingStyle;
|
|
128
134
|
protected readonly enumeratorNamingStyle: NamingStyle;
|
|
129
135
|
constructor(targetLanguage: TargetLanguage, renderContext: RenderContext, _options: OptionValues<typeof cPlusPlusOptions>);
|
|
@@ -193,6 +199,7 @@ export declare class CPlusPlusRenderer extends ConvenienceRenderer {
|
|
|
193
199
|
protected emitOptionalHelpers(): void;
|
|
194
200
|
protected emitDeclaration(decl: Declaration): void;
|
|
195
201
|
protected emitGetterSetter(t: string, getterName: string, setterName: string, memberName: string): void;
|
|
202
|
+
protected emitNumericCheckConstraints(checkConst: string, classConstraint: string, getterMinValue: string, getterMaxValue: string, cppType: string): void;
|
|
196
203
|
protected emitConstraintClasses(): void;
|
|
197
204
|
protected emitHelperFunctions(): void;
|
|
198
205
|
protected emitExtraIncludes(): void;
|
|
@@ -243,21 +243,27 @@ var GlobalNames;
|
|
|
243
243
|
})(GlobalNames = exports.GlobalNames || (exports.GlobalNames = {}));
|
|
244
244
|
var MemberNames;
|
|
245
245
|
(function (MemberNames) {
|
|
246
|
-
MemberNames[MemberNames["
|
|
247
|
-
MemberNames[MemberNames["
|
|
248
|
-
MemberNames[MemberNames["
|
|
249
|
-
MemberNames[MemberNames["
|
|
250
|
-
MemberNames[MemberNames["
|
|
251
|
-
MemberNames[MemberNames["
|
|
252
|
-
MemberNames[MemberNames["
|
|
253
|
-
MemberNames[MemberNames["
|
|
254
|
-
MemberNames[MemberNames["
|
|
255
|
-
MemberNames[MemberNames["
|
|
256
|
-
MemberNames[MemberNames["
|
|
257
|
-
MemberNames[MemberNames["
|
|
258
|
-
MemberNames[MemberNames["
|
|
259
|
-
MemberNames[MemberNames["
|
|
260
|
-
MemberNames[MemberNames["
|
|
246
|
+
MemberNames[MemberNames["MinIntValue"] = 0] = "MinIntValue";
|
|
247
|
+
MemberNames[MemberNames["GetMinIntValue"] = 1] = "GetMinIntValue";
|
|
248
|
+
MemberNames[MemberNames["SetMinIntValue"] = 2] = "SetMinIntValue";
|
|
249
|
+
MemberNames[MemberNames["MaxIntValue"] = 3] = "MaxIntValue";
|
|
250
|
+
MemberNames[MemberNames["GetMaxIntValue"] = 4] = "GetMaxIntValue";
|
|
251
|
+
MemberNames[MemberNames["SetMaxIntValue"] = 5] = "SetMaxIntValue";
|
|
252
|
+
MemberNames[MemberNames["MinDoubleValue"] = 6] = "MinDoubleValue";
|
|
253
|
+
MemberNames[MemberNames["GetMinDoubleValue"] = 7] = "GetMinDoubleValue";
|
|
254
|
+
MemberNames[MemberNames["SetMinDoubleValue"] = 8] = "SetMinDoubleValue";
|
|
255
|
+
MemberNames[MemberNames["MaxDoubleValue"] = 9] = "MaxDoubleValue";
|
|
256
|
+
MemberNames[MemberNames["GetMaxDoubleValue"] = 10] = "GetMaxDoubleValue";
|
|
257
|
+
MemberNames[MemberNames["SetMaxDoubleValue"] = 11] = "SetMaxDoubleValue";
|
|
258
|
+
MemberNames[MemberNames["MinLength"] = 12] = "MinLength";
|
|
259
|
+
MemberNames[MemberNames["GetMinLength"] = 13] = "GetMinLength";
|
|
260
|
+
MemberNames[MemberNames["SetMinLength"] = 14] = "SetMinLength";
|
|
261
|
+
MemberNames[MemberNames["MaxLength"] = 15] = "MaxLength";
|
|
262
|
+
MemberNames[MemberNames["GetMaxLength"] = 16] = "GetMaxLength";
|
|
263
|
+
MemberNames[MemberNames["SetMaxLength"] = 17] = "SetMaxLength";
|
|
264
|
+
MemberNames[MemberNames["Pattern"] = 18] = "Pattern";
|
|
265
|
+
MemberNames[MemberNames["GetPattern"] = 19] = "GetPattern";
|
|
266
|
+
MemberNames[MemberNames["SetPattern"] = 20] = "SetPattern";
|
|
261
267
|
})(MemberNames = exports.MemberNames || (exports.MemberNames = {}));
|
|
262
268
|
function addQualifier(qualifier, qualified) {
|
|
263
269
|
if (qualified.length === 0) {
|
|
@@ -546,17 +552,29 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
546
552
|
getConstraintMembers() {
|
|
547
553
|
return [
|
|
548
554
|
{
|
|
549
|
-
name: MemberNames.
|
|
550
|
-
getter: MemberNames.
|
|
551
|
-
setter: MemberNames.
|
|
555
|
+
name: MemberNames.MinIntValue,
|
|
556
|
+
getter: MemberNames.GetMinIntValue,
|
|
557
|
+
setter: MemberNames.SetMinIntValue,
|
|
552
558
|
cppType: "int64_t"
|
|
553
559
|
},
|
|
554
560
|
{
|
|
555
|
-
name: MemberNames.
|
|
556
|
-
getter: MemberNames.
|
|
557
|
-
setter: MemberNames.
|
|
561
|
+
name: MemberNames.MaxIntValue,
|
|
562
|
+
getter: MemberNames.GetMaxIntValue,
|
|
563
|
+
setter: MemberNames.SetMaxIntValue,
|
|
558
564
|
cppType: "int64_t"
|
|
559
565
|
},
|
|
566
|
+
{
|
|
567
|
+
name: MemberNames.MinDoubleValue,
|
|
568
|
+
getter: MemberNames.GetMinDoubleValue,
|
|
569
|
+
setter: MemberNames.SetMinDoubleValue,
|
|
570
|
+
cppType: "double"
|
|
571
|
+
},
|
|
572
|
+
{
|
|
573
|
+
name: MemberNames.MaxDoubleValue,
|
|
574
|
+
getter: MemberNames.GetMaxDoubleValue,
|
|
575
|
+
setter: MemberNames.SetMaxDoubleValue,
|
|
576
|
+
cppType: "double"
|
|
577
|
+
},
|
|
560
578
|
{
|
|
561
579
|
name: MemberNames.MinLength,
|
|
562
580
|
getter: MemberNames.GetMinLength,
|
|
@@ -805,7 +823,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
805
823
|
}
|
|
806
824
|
}
|
|
807
825
|
}
|
|
808
|
-
|
|
826
|
+
const typeSource = (0, TypeUtils_1.matchType)(t, _anyType => {
|
|
809
827
|
isOptional = false;
|
|
810
828
|
return (0, Source_1.maybeAnnotated)(withIssues, Annotation_1.anyTypeIssueAnnotation, [
|
|
811
829
|
this.jsonQualifier(inJsonNamespace),
|
|
@@ -949,7 +967,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
949
967
|
needsOptionalIndirection: true,
|
|
950
968
|
inJsonNamespace: false
|
|
951
969
|
}, true, false, property.isOptional), name);
|
|
952
|
-
if (constraints
|
|
970
|
+
if (constraints === null || constraints === void 0 ? void 0 : constraints.has(jsonName)) {
|
|
953
971
|
/** FIXME!!! NameStyle will/can collide with other Names */
|
|
954
972
|
const cnst = this.lookupGlobalName(GlobalNames.ClassMemberConstraints);
|
|
955
973
|
this.emitMember(cnst, this.constraintMember(jsonName));
|
|
@@ -983,7 +1001,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
983
1001
|
if ((property.type instanceof Type_1.UnionType && property.type.findMember("null") !== undefined) ||
|
|
984
1002
|
(property.isOptional && property.type.kind !== "null" && property.type.kind !== "any")) {
|
|
985
1003
|
this.emitLine(rendered, " ", getterName, "() const { return ", name, "; }");
|
|
986
|
-
if (constraints
|
|
1004
|
+
if (constraints === null || constraints === void 0 ? void 0 : constraints.has(jsonName)) {
|
|
987
1005
|
this.emitLine("void ", setterName, "(", rendered, " value) { if (value) ", checkConst, "(", this._stringType.createStringLiteral([name]), ", ", this.constraintMember(jsonName), ", *value); this->", name, " = value; }");
|
|
988
1006
|
}
|
|
989
1007
|
else {
|
|
@@ -993,7 +1011,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
993
1011
|
else {
|
|
994
1012
|
this.emitLine(this.withConst(rendered), " & ", getterName, "() const { return ", name, "; }");
|
|
995
1013
|
this.emitLine(rendered, " & ", mutableGetterName, "() { return ", name, "; }");
|
|
996
|
-
if (constraints
|
|
1014
|
+
if (constraints === null || constraints === void 0 ? void 0 : constraints.has(jsonName)) {
|
|
997
1015
|
this.emitLine("void ", setterName, "(", this.withConst(rendered), " & value) { ", checkConst, "(", this._stringType.createStringLiteral([name]), ", ", this.constraintMember(jsonName), ", value); this->", name, " = value; }");
|
|
998
1016
|
}
|
|
999
1017
|
else {
|
|
@@ -1005,26 +1023,32 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
1005
1023
|
});
|
|
1006
1024
|
}
|
|
1007
1025
|
generateClassConstraints(c) {
|
|
1008
|
-
|
|
1026
|
+
const res = new Map();
|
|
1009
1027
|
this.forEachClassProperty(c, "none", (_name, jsonName, property) => {
|
|
1010
1028
|
const constraints = constraintsForType(property.type);
|
|
1011
1029
|
if (constraints === undefined)
|
|
1012
1030
|
return;
|
|
1013
1031
|
const { minMax, minMaxLength, pattern } = constraints;
|
|
1032
|
+
// TODO is there a better way to check if property.type is an interger or a number?
|
|
1033
|
+
const cppType = this.cppType(property.type, {
|
|
1034
|
+
needsForwardIndirection: true,
|
|
1035
|
+
needsOptionalIndirection: true,
|
|
1036
|
+
inJsonNamespace: false
|
|
1037
|
+
}, true, false, property.isOptional);
|
|
1014
1038
|
res.set(jsonName, [
|
|
1015
1039
|
this.constraintMember(jsonName),
|
|
1016
1040
|
"(",
|
|
1017
|
-
minMax
|
|
1041
|
+
(minMax === null || minMax === void 0 ? void 0 : minMax[0]) && cppType === "int64_t" ? String(minMax[0]) : this._nulloptType,
|
|
1018
1042
|
", ",
|
|
1019
|
-
minMax
|
|
1043
|
+
(minMax === null || minMax === void 0 ? void 0 : minMax[1]) && cppType === "int64_t" ? String(minMax[1]) : this._nulloptType,
|
|
1020
1044
|
", ",
|
|
1021
|
-
|
|
1022
|
-
? String(minMaxLength[0])
|
|
1023
|
-
: this._nulloptType,
|
|
1045
|
+
(minMax === null || minMax === void 0 ? void 0 : minMax[0]) && cppType === "double" ? String(minMax[0]) : this._nulloptType,
|
|
1024
1046
|
", ",
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1047
|
+
(minMax === null || minMax === void 0 ? void 0 : minMax[1]) && cppType === "double" ? String(minMax[1]) : this._nulloptType,
|
|
1048
|
+
", ",
|
|
1049
|
+
(minMaxLength === null || minMaxLength === void 0 ? void 0 : minMaxLength[0]) ? String(minMaxLength[0]) : this._nulloptType,
|
|
1050
|
+
", ",
|
|
1051
|
+
(minMaxLength === null || minMaxLength === void 0 ? void 0 : minMaxLength[1]) ? String(minMaxLength[1]) : this._nulloptType,
|
|
1028
1052
|
", ",
|
|
1029
1053
|
pattern === undefined
|
|
1030
1054
|
? this._nulloptType
|
|
@@ -1180,7 +1204,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
1180
1204
|
return [maybeNull !== null || p.isOptional, nonNulls];
|
|
1181
1205
|
}
|
|
1182
1206
|
else {
|
|
1183
|
-
|
|
1207
|
+
const set = new Set();
|
|
1184
1208
|
set.add(t);
|
|
1185
1209
|
return [true, set];
|
|
1186
1210
|
}
|
|
@@ -1251,7 +1275,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
1251
1275
|
else {
|
|
1252
1276
|
getter = [name];
|
|
1253
1277
|
}
|
|
1254
|
-
|
|
1278
|
+
const assignment = [
|
|
1255
1279
|
"j[",
|
|
1256
1280
|
this._stringType.wrapEncodingChange([ourQualifier], this._stringType.getType(), this.NarrowString.getType(), this._stringType.createStringLiteral([(0, Strings_1.stringEscape)(json)])),
|
|
1257
1281
|
"] = ",
|
|
@@ -1351,7 +1375,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
1351
1375
|
needsOptionalIndirection: true,
|
|
1352
1376
|
inJsonNamespace: true
|
|
1353
1377
|
}, false, true, false);
|
|
1354
|
-
|
|
1378
|
+
const toType = this.cppType(typeForKind, {
|
|
1355
1379
|
needsForwardIndirection: true,
|
|
1356
1380
|
needsOptionalIndirection: true,
|
|
1357
1381
|
inJsonNamespace: true
|
|
@@ -1522,17 +1546,42 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
1522
1546
|
this.emitLine("void ", setterName, "(", t, " ", memberName, ") { this->", memberName, " = ", memberName, "; }");
|
|
1523
1547
|
this.emitLine("auto ", getterName, "() const { return ", memberName, "; }");
|
|
1524
1548
|
}
|
|
1549
|
+
emitNumericCheckConstraints(checkConst, classConstraint, getterMinValue, getterMaxValue, cppType) {
|
|
1550
|
+
this.emitBlock([
|
|
1551
|
+
"inline void ",
|
|
1552
|
+
checkConst,
|
|
1553
|
+
"(",
|
|
1554
|
+
this._stringType.getConstType(),
|
|
1555
|
+
" name, ",
|
|
1556
|
+
this.withConst(classConstraint),
|
|
1557
|
+
" & c, ",
|
|
1558
|
+
cppType,
|
|
1559
|
+
" value)"
|
|
1560
|
+
], false, () => {
|
|
1561
|
+
this.emitBlock(["if (c.", getterMinValue, "() != ", this._nulloptType, " && value < *c.", getterMinValue, "())"], false, () => {
|
|
1562
|
+
this.emitLine("throw ", this.lookupGlobalName(GlobalNames.ValueTooLowException), " (", this._stringType.createStringLiteral(["Value too low for "]), " + name + ", this._stringType.createStringLiteral([" ("]), " + ", this._stringType.wrapToString(["value"]), " + ", this._stringType.createStringLiteral(["<"]), " + ", this._stringType.wrapToString(["*c.", getterMinValue, "()"]), " + ", this._stringType.createStringLiteral([")"]), ");");
|
|
1563
|
+
});
|
|
1564
|
+
this.ensureBlankLine();
|
|
1565
|
+
this.emitBlock(["if (c.", getterMaxValue, "() != ", this._nulloptType, " && value > *c.", getterMaxValue, "())"], false, () => {
|
|
1566
|
+
this.emitLine("throw ", this.lookupGlobalName(GlobalNames.ValueTooHighException), " (", this._stringType.createStringLiteral(["Value too high for "]), " + name + ", this._stringType.createStringLiteral([" ("]), " + ", this._stringType.wrapToString(["value"]), " + ", this._stringType.createStringLiteral([">"]), " + ", this._stringType.wrapToString(["*c.", getterMaxValue, "()"]), " + ", this._stringType.createStringLiteral([")"]), ");");
|
|
1567
|
+
});
|
|
1568
|
+
this.ensureBlankLine();
|
|
1569
|
+
});
|
|
1570
|
+
this.ensureBlankLine();
|
|
1571
|
+
}
|
|
1525
1572
|
emitConstraintClasses() {
|
|
1526
1573
|
const ourQualifier = this.ourQualifier(false);
|
|
1527
|
-
const
|
|
1528
|
-
const
|
|
1574
|
+
const getterMinIntValue = this.lookupMemberName(MemberNames.GetMinIntValue);
|
|
1575
|
+
const getterMaxIntValue = this.lookupMemberName(MemberNames.GetMaxIntValue);
|
|
1576
|
+
const getterMinDoubleValue = this.lookupMemberName(MemberNames.GetMinDoubleValue);
|
|
1577
|
+
const getterMaxDoubleValue = this.lookupMemberName(MemberNames.GetMaxDoubleValue);
|
|
1529
1578
|
const getterMinLength = this.lookupMemberName(MemberNames.GetMinLength);
|
|
1530
1579
|
const getterMaxLength = this.lookupMemberName(MemberNames.GetMaxLength);
|
|
1531
1580
|
const getterPattern = this.lookupMemberName(MemberNames.GetPattern);
|
|
1532
1581
|
const classConstraint = this.lookupGlobalName(GlobalNames.ClassMemberConstraints);
|
|
1533
1582
|
this.emitBlock(["class ", classConstraint], true, () => {
|
|
1534
1583
|
this.emitLine("private:");
|
|
1535
|
-
|
|
1584
|
+
const constraintMembers = this.getConstraintMembers();
|
|
1536
1585
|
for (const member of constraintMembers) {
|
|
1537
1586
|
this.emitMember([this._optionalType, "<", member.cppType, ">"], this.lookupMemberName(member.name));
|
|
1538
1587
|
}
|
|
@@ -1580,25 +1629,8 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
1580
1629
|
this.ensureBlankLine();
|
|
1581
1630
|
}
|
|
1582
1631
|
const checkConst = this.lookupGlobalName(GlobalNames.CheckConstraint);
|
|
1583
|
-
this.
|
|
1584
|
-
|
|
1585
|
-
checkConst,
|
|
1586
|
-
"(",
|
|
1587
|
-
this._stringType.getConstType(),
|
|
1588
|
-
" name, ",
|
|
1589
|
-
this.withConst(classConstraint),
|
|
1590
|
-
" & c, int64_t value)"
|
|
1591
|
-
], false, () => {
|
|
1592
|
-
this.emitBlock(["if (c.", getterMinValue, "() != ", this._nulloptType, " && value < *c.", getterMinValue, "())"], false, () => {
|
|
1593
|
-
this.emitLine("throw ", this.lookupGlobalName(GlobalNames.ValueTooLowException), " (", this._stringType.createStringLiteral(["Value too low for "]), " + name + ", this._stringType.createStringLiteral([" ("]), " + ", this._stringType.wrapToString(["value"]), " + ", this._stringType.createStringLiteral(["<"]), " + ", this._stringType.wrapToString(["*c.", getterMinValue, "()"]), " + ", this._stringType.createStringLiteral([")"]), ");");
|
|
1594
|
-
});
|
|
1595
|
-
this.ensureBlankLine();
|
|
1596
|
-
this.emitBlock(["if (c.", getterMaxValue, "() != ", this._nulloptType, " && value > *c.", getterMaxValue, "())"], false, () => {
|
|
1597
|
-
this.emitLine("throw ", this.lookupGlobalName(GlobalNames.ValueTooHighException), " (", this._stringType.createStringLiteral(["Value too high for "]), " + name + ", this._stringType.createStringLiteral([" ("]), " + ", this._stringType.wrapToString(["value"]), " + ", this._stringType.createStringLiteral([">"]), " + ", this._stringType.wrapToString(["*c.", getterMaxValue, "()"]), " + ", this._stringType.createStringLiteral([")"]), ");");
|
|
1598
|
-
});
|
|
1599
|
-
this.ensureBlankLine();
|
|
1600
|
-
});
|
|
1601
|
-
this.ensureBlankLine();
|
|
1632
|
+
this.emitNumericCheckConstraints(checkConst, classConstraint, getterMinIntValue, getterMaxIntValue, "int64_t");
|
|
1633
|
+
this.emitNumericCheckConstraints(checkConst, classConstraint, getterMinDoubleValue, getterMaxDoubleValue, "double");
|
|
1602
1634
|
this.emitBlock([
|
|
1603
1635
|
"inline void ",
|
|
1604
1636
|
checkConst,
|
|
@@ -1799,8 +1831,8 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
1799
1831
|
}
|
|
1800
1832
|
}
|
|
1801
1833
|
else {
|
|
1802
|
-
|
|
1803
|
-
|
|
1834
|
+
const userNamespaceForwardDecls = this.gatherUserNamespaceForwardDecls();
|
|
1835
|
+
const nlohmannNamespaceForwardDecls = this.gatherNlohmannNamespaceForwardDecls();
|
|
1804
1836
|
if (userNamespaceForwardDecls.length == 0 && nlohmannNamespaceForwardDecls.length > 0) {
|
|
1805
1837
|
this.emitNamespaces(["nlohmann"], () => {
|
|
1806
1838
|
this.emitGatheredSource(nlohmannNamespaceForwardDecls);
|
|
@@ -1851,7 +1883,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
1851
1883
|
const propTypes = this.generatedTypes(isClassMember, propertyType);
|
|
1852
1884
|
for (const t of propTypes) {
|
|
1853
1885
|
const typeName = this.sourcelikeToString(t.name);
|
|
1854
|
-
|
|
1886
|
+
const propRecord = { kind: undefined, typeKind: undefined };
|
|
1855
1887
|
if (t.type instanceof Type_1.ClassType) {
|
|
1856
1888
|
/**
|
|
1857
1889
|
* Ok. We can NOT forward declare direct class members, e.g. a class type is included
|
|
@@ -1905,7 +1937,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
1905
1937
|
* Need to generate "includes", in terms 'c' has members, which
|
|
1906
1938
|
* are defined by others
|
|
1907
1939
|
*/
|
|
1908
|
-
|
|
1940
|
+
const includes = new Map();
|
|
1909
1941
|
if (c instanceof Type_1.UnionType) {
|
|
1910
1942
|
this.updateIncludes(false, includes, c, defName);
|
|
1911
1943
|
}
|
|
@@ -2048,12 +2080,12 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
2048
2080
|
}
|
|
2049
2081
|
}
|
|
2050
2082
|
isConversionRequired(t) {
|
|
2051
|
-
|
|
2083
|
+
const originalType = this.cppType(t, {
|
|
2052
2084
|
needsForwardIndirection: true,
|
|
2053
2085
|
needsOptionalIndirection: true,
|
|
2054
2086
|
inJsonNamespace: true
|
|
2055
2087
|
}, false, false, false);
|
|
2056
|
-
|
|
2088
|
+
const newType = this.cppType(t, {
|
|
2057
2089
|
needsForwardIndirection: true,
|
|
2058
2090
|
needsOptionalIndirection: true,
|
|
2059
2091
|
inJsonNamespace: true
|