quicktype-core 23.0.43 → 23.0.45
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 -63
- 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,34 @@ 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
|
-
|
|
1045
|
+
(minMax === null || minMax === void 0 ? void 0 : minMax[0]) && cppType === "double" ? String(minMax[0]) : this._nulloptType,
|
|
1046
|
+
", ",
|
|
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])
|
|
1022
1050
|
? String(minMaxLength[0])
|
|
1023
1051
|
: this._nulloptType,
|
|
1024
1052
|
", ",
|
|
1025
|
-
minMaxLength
|
|
1026
|
-
? String(minMaxLength[1])
|
|
1027
|
-
: this._nulloptType,
|
|
1053
|
+
(minMaxLength === null || minMaxLength === void 0 ? void 0 : minMaxLength[1]) ? String(minMaxLength[1]) : this._nulloptType,
|
|
1028
1054
|
", ",
|
|
1029
1055
|
pattern === undefined
|
|
1030
1056
|
? this._nulloptType
|
|
@@ -1180,7 +1206,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
1180
1206
|
return [maybeNull !== null || p.isOptional, nonNulls];
|
|
1181
1207
|
}
|
|
1182
1208
|
else {
|
|
1183
|
-
|
|
1209
|
+
const set = new Set();
|
|
1184
1210
|
set.add(t);
|
|
1185
1211
|
return [true, set];
|
|
1186
1212
|
}
|
|
@@ -1251,7 +1277,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
1251
1277
|
else {
|
|
1252
1278
|
getter = [name];
|
|
1253
1279
|
}
|
|
1254
|
-
|
|
1280
|
+
const assignment = [
|
|
1255
1281
|
"j[",
|
|
1256
1282
|
this._stringType.wrapEncodingChange([ourQualifier], this._stringType.getType(), this.NarrowString.getType(), this._stringType.createStringLiteral([(0, Strings_1.stringEscape)(json)])),
|
|
1257
1283
|
"] = ",
|
|
@@ -1351,7 +1377,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
1351
1377
|
needsOptionalIndirection: true,
|
|
1352
1378
|
inJsonNamespace: true
|
|
1353
1379
|
}, false, true, false);
|
|
1354
|
-
|
|
1380
|
+
const toType = this.cppType(typeForKind, {
|
|
1355
1381
|
needsForwardIndirection: true,
|
|
1356
1382
|
needsOptionalIndirection: true,
|
|
1357
1383
|
inJsonNamespace: true
|
|
@@ -1522,17 +1548,42 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
1522
1548
|
this.emitLine("void ", setterName, "(", t, " ", memberName, ") { this->", memberName, " = ", memberName, "; }");
|
|
1523
1549
|
this.emitLine("auto ", getterName, "() const { return ", memberName, "; }");
|
|
1524
1550
|
}
|
|
1551
|
+
emitNumericCheckConstraints(checkConst, classConstraint, getterMinValue, getterMaxValue, cppType) {
|
|
1552
|
+
this.emitBlock([
|
|
1553
|
+
"inline void ",
|
|
1554
|
+
checkConst,
|
|
1555
|
+
"(",
|
|
1556
|
+
this._stringType.getConstType(),
|
|
1557
|
+
" name, ",
|
|
1558
|
+
this.withConst(classConstraint),
|
|
1559
|
+
" & c, ",
|
|
1560
|
+
cppType,
|
|
1561
|
+
" value)"
|
|
1562
|
+
], false, () => {
|
|
1563
|
+
this.emitBlock(["if (c.", getterMinValue, "() != ", this._nulloptType, " && value < *c.", getterMinValue, "())"], false, () => {
|
|
1564
|
+
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([")"]), ");");
|
|
1565
|
+
});
|
|
1566
|
+
this.ensureBlankLine();
|
|
1567
|
+
this.emitBlock(["if (c.", getterMaxValue, "() != ", this._nulloptType, " && value > *c.", getterMaxValue, "())"], false, () => {
|
|
1568
|
+
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([")"]), ");");
|
|
1569
|
+
});
|
|
1570
|
+
this.ensureBlankLine();
|
|
1571
|
+
});
|
|
1572
|
+
this.ensureBlankLine();
|
|
1573
|
+
}
|
|
1525
1574
|
emitConstraintClasses() {
|
|
1526
1575
|
const ourQualifier = this.ourQualifier(false);
|
|
1527
|
-
const
|
|
1528
|
-
const
|
|
1576
|
+
const getterMinIntValue = this.lookupMemberName(MemberNames.GetMinIntValue);
|
|
1577
|
+
const getterMaxIntValue = this.lookupMemberName(MemberNames.GetMaxIntValue);
|
|
1578
|
+
const getterMinDoubleValue = this.lookupMemberName(MemberNames.GetMinDoubleValue);
|
|
1579
|
+
const getterMaxDoubleValue = this.lookupMemberName(MemberNames.GetMaxDoubleValue);
|
|
1529
1580
|
const getterMinLength = this.lookupMemberName(MemberNames.GetMinLength);
|
|
1530
1581
|
const getterMaxLength = this.lookupMemberName(MemberNames.GetMaxLength);
|
|
1531
1582
|
const getterPattern = this.lookupMemberName(MemberNames.GetPattern);
|
|
1532
1583
|
const classConstraint = this.lookupGlobalName(GlobalNames.ClassMemberConstraints);
|
|
1533
1584
|
this.emitBlock(["class ", classConstraint], true, () => {
|
|
1534
1585
|
this.emitLine("private:");
|
|
1535
|
-
|
|
1586
|
+
const constraintMembers = this.getConstraintMembers();
|
|
1536
1587
|
for (const member of constraintMembers) {
|
|
1537
1588
|
this.emitMember([this._optionalType, "<", member.cppType, ">"], this.lookupMemberName(member.name));
|
|
1538
1589
|
}
|
|
@@ -1580,25 +1631,8 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
1580
1631
|
this.ensureBlankLine();
|
|
1581
1632
|
}
|
|
1582
1633
|
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();
|
|
1634
|
+
this.emitNumericCheckConstraints(checkConst, classConstraint, getterMinIntValue, getterMaxIntValue, "int64_t");
|
|
1635
|
+
this.emitNumericCheckConstraints(checkConst, classConstraint, getterMinDoubleValue, getterMaxDoubleValue, "double");
|
|
1602
1636
|
this.emitBlock([
|
|
1603
1637
|
"inline void ",
|
|
1604
1638
|
checkConst,
|
|
@@ -1799,8 +1833,8 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
1799
1833
|
}
|
|
1800
1834
|
}
|
|
1801
1835
|
else {
|
|
1802
|
-
|
|
1803
|
-
|
|
1836
|
+
const userNamespaceForwardDecls = this.gatherUserNamespaceForwardDecls();
|
|
1837
|
+
const nlohmannNamespaceForwardDecls = this.gatherNlohmannNamespaceForwardDecls();
|
|
1804
1838
|
if (userNamespaceForwardDecls.length == 0 && nlohmannNamespaceForwardDecls.length > 0) {
|
|
1805
1839
|
this.emitNamespaces(["nlohmann"], () => {
|
|
1806
1840
|
this.emitGatheredSource(nlohmannNamespaceForwardDecls);
|
|
@@ -1851,7 +1885,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
1851
1885
|
const propTypes = this.generatedTypes(isClassMember, propertyType);
|
|
1852
1886
|
for (const t of propTypes) {
|
|
1853
1887
|
const typeName = this.sourcelikeToString(t.name);
|
|
1854
|
-
|
|
1888
|
+
const propRecord = { kind: undefined, typeKind: undefined };
|
|
1855
1889
|
if (t.type instanceof Type_1.ClassType) {
|
|
1856
1890
|
/**
|
|
1857
1891
|
* Ok. We can NOT forward declare direct class members, e.g. a class type is included
|
|
@@ -1905,7 +1939,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
1905
1939
|
* Need to generate "includes", in terms 'c' has members, which
|
|
1906
1940
|
* are defined by others
|
|
1907
1941
|
*/
|
|
1908
|
-
|
|
1942
|
+
const includes = new Map();
|
|
1909
1943
|
if (c instanceof Type_1.UnionType) {
|
|
1910
1944
|
this.updateIncludes(false, includes, c, defName);
|
|
1911
1945
|
}
|
|
@@ -2048,12 +2082,12 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
2048
2082
|
}
|
|
2049
2083
|
}
|
|
2050
2084
|
isConversionRequired(t) {
|
|
2051
|
-
|
|
2085
|
+
const originalType = this.cppType(t, {
|
|
2052
2086
|
needsForwardIndirection: true,
|
|
2053
2087
|
needsOptionalIndirection: true,
|
|
2054
2088
|
inJsonNamespace: true
|
|
2055
2089
|
}, false, false, false);
|
|
2056
|
-
|
|
2090
|
+
const newType = this.cppType(t, {
|
|
2057
2091
|
needsForwardIndirection: true,
|
|
2058
2092
|
needsOptionalIndirection: true,
|
|
2059
2093
|
inJsonNamespace: true
|