quicktype-core 7.0.14 → 7.0.15

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.
@@ -731,7 +731,9 @@ class MinMaxValueTransformer extends ProducerTransformer {
731
731
  equals(other) {
732
732
  if (!super.equals(other))
733
733
  return false;
734
- return (other instanceof MinMaxValueTransformer && this.minimum === other.minimum && this.maximum === other.maximum);
734
+ return (other instanceof MinMaxValueTransformer &&
735
+ this.minimum === other.minimum &&
736
+ this.maximum === other.maximum);
735
737
  }
736
738
  }
737
739
  exports.MinMaxValueTransformer = MinMaxValueTransformer;
@@ -80,7 +80,10 @@ function normalizeURI(uri) {
80
80
  if (typeof uri === "string") {
81
81
  uri = new URI(uri);
82
82
  }
83
- return new URI(URI.decode(uri.clone().normalize().toString()));
83
+ return new URI(URI.decode(uri
84
+ .clone()
85
+ .normalize()
86
+ .toString()));
84
87
  }
85
88
  class Ref {
86
89
  constructor(addressURI, path) {
@@ -1017,7 +1020,10 @@ class JSONSchemaInput {
1017
1020
  else {
1018
1021
  normalizedURIs = uris.map(uri => {
1019
1022
  const normalizedURI = normalizeURI(uri);
1020
- if (normalizedURI.clone().hash("").toString() === "") {
1023
+ if (normalizedURI
1024
+ .clone()
1025
+ .hash("")
1026
+ .toString() === "") {
1021
1027
  normalizedURI.path(name);
1022
1028
  }
1023
1029
  return normalizedURI;
@@ -40,7 +40,7 @@ exports.all = [
40
40
  new Dart_1.DartTargetLanguage(),
41
41
  new Python_1.PythonTargetLanguage("Python", ["python", "py"], "py"),
42
42
  new Pike_1.PikeTargetLanguage(),
43
- new Haskell_1.HaskellTargetLanguage()
43
+ new Haskell_1.HaskellTargetLanguage(),
44
44
  ];
45
45
  function languageNamed(name, targetLanguages) {
46
46
  if (targetLanguages === undefined) {
@@ -22,30 +22,12 @@ const upperUnderscoreValue = ["upper-underscore-case", "upper-underscore"];
22
22
  const pascalUpperAcronymsValue = ["pascal-case-upper-acronyms", "pascal-upper-acronyms"];
23
23
  const camelUpperAcronymsValue = ["camel-case-upper-acronyms", "camel-upper-acronyms"];
24
24
  exports.cPlusPlusOptions = {
25
- typeSourceStyle: new RendererOptions_1.EnumOption("source-style", "Source code generation type, whether to generate single or multiple source files", [
26
- ["single-source", true],
27
- ["multi-source", false]
28
- ], "single-source", "secondary"),
29
- includeLocation: new RendererOptions_1.EnumOption("include-location", "Whether json.hpp is to be located globally or locally", [
30
- ["local-include", true],
31
- ["global-include", false]
32
- ], "local-include", "secondary"),
33
- codeFormat: new RendererOptions_1.EnumOption("code-format", "Generate classes with getters/setters, instead of structs", [
34
- ["with-struct", false],
35
- ["with-getter-setter", true]
36
- ], "with-getter-setter"),
37
- wstring: new RendererOptions_1.EnumOption("wstring", "Store strings using Utf-16 std::wstring, rather than Utf-8 std::string", [
38
- ["use-string", false],
39
- ["use-wstring", true]
40
- ], "use-string"),
41
- msbuildPermissive: new RendererOptions_1.EnumOption("msbuildPermissive", "Moves to_json and from_json types into the nlohmann::details namespace, so that msbuild can build it with conformance mode disabled", [
42
- ["not-permissive", false],
43
- ["use-permissive", true]
44
- ], "not-permissive", "secondary"),
45
- westConst: new RendererOptions_1.EnumOption("const-style", "Put const to the left/west (const T) or right/east (T const)", [
46
- ["west-const", true],
47
- ["east-const", false]
48
- ], "west-const"),
25
+ typeSourceStyle: new RendererOptions_1.EnumOption("source-style", "Source code generation type, whether to generate single or multiple source files", [["single-source", true], ["multi-source", false]], "single-source", "secondary"),
26
+ includeLocation: new RendererOptions_1.EnumOption("include-location", "Whether json.hpp is to be located globally or locally", [["local-include", true], ["global-include", false]], "local-include", "secondary"),
27
+ codeFormat: new RendererOptions_1.EnumOption("code-format", "Generate classes with getters/setters, instead of structs", [["with-struct", false], ["with-getter-setter", true]], "with-getter-setter"),
28
+ wstring: new RendererOptions_1.EnumOption("wstring", "Store strings using Utf-16 std::wstring, rather than Utf-8 std::string", [["use-string", false], ["use-wstring", true]], "use-string"),
29
+ msbuildPermissive: new RendererOptions_1.EnumOption("msbuildPermissive", "Moves to_json and from_json types into the nlohmann::details namespace, so that msbuild can build it with conformance mode disabled", [["not-permissive", false], ["use-permissive", true]], "not-permissive", "secondary"),
30
+ westConst: new RendererOptions_1.EnumOption("const-style", "Put const to the left/west (const T) or right/east (T const)", [["west-const", true], ["east-const", false]], "west-const"),
49
31
  justTypes: new RendererOptions_1.BooleanOption("just-types", "Plain types only", false),
50
32
  namespace: new RendererOptions_1.StringOption("namespace", "Name of the generated namespace(s)", "NAME", "quicktype"),
51
33
  enumType: new RendererOptions_1.StringOption("enum-type", "Type of enum class", "NAME", "int", "secondary"),
@@ -74,7 +56,7 @@ exports.cPlusPlusOptions = {
74
56
  camelUpperAcronymsValue
75
57
  ]),
76
58
  boost: new RendererOptions_1.BooleanOption("boost", "Require a dependency on boost. Without boost, C++17 is required", true),
77
- hideNullOptional: new RendererOptions_1.BooleanOption("hide-null-optional", "Hide null value for optional field", false)
59
+ hideNullOptional: new RendererOptions_1.BooleanOption("hide-null-optional", "Hide null value for optional field", false),
78
60
  };
79
61
  class CPlusPlusTargetLanguage extends TargetLanguage_1.TargetLanguage {
80
62
  constructor(displayName = "C++", names = ["c++", "cpp", "cplusplus"], extension = "cpp") {
@@ -95,7 +77,7 @@ class CPlusPlusTargetLanguage extends TargetLanguage_1.TargetLanguage {
95
77
  exports.cPlusPlusOptions.enumeratorNamingStyle,
96
78
  exports.cPlusPlusOptions.enumType,
97
79
  exports.cPlusPlusOptions.boost,
98
- exports.cPlusPlusOptions.hideNullOptional
80
+ exports.cPlusPlusOptions.hideNullOptional,
99
81
  ];
100
82
  }
101
83
  get supportsUnionsWithBothNumberTypes() {
@@ -322,7 +304,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
322
304
  super(targetLanguage, renderContext);
323
305
  this._options = _options;
324
306
  this._gettersAndSettersForPropertyName = new Map();
325
- this.NarrowString = new (class extends BaseString {
307
+ this.NarrowString = new class extends BaseString {
326
308
  constructor() {
327
309
  super("std::string", "const std::string & ", "std::smatch", "std::regex", "", new WrappingCode(["std::to_string("], [")"]), "", "");
328
310
  }
@@ -332,8 +314,8 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
332
314
  emitHelperFunctions() {
333
315
  return;
334
316
  }
335
- })();
336
- this.WideString = new (class extends BaseString {
317
+ }();
318
+ this.WideString = new class extends BaseString {
337
319
  constructor(superThis) {
338
320
  super("std::wstring", "const std::wstring & ", "std::wsmatch", "std::wregex", "L", new WrappingCode(["std::to_wstring("], [")"]), "Utf16_Utf8", "convert");
339
321
  this.superThis = superThis;
@@ -416,7 +398,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
416
398
  });
417
399
  this.superThis.ensureBlankLine();
418
400
  }
419
- })(this);
401
+ }(this);
420
402
  this._enumType = _options.enumType;
421
403
  this._namespaceNames = _options.namespace.split("::");
422
404
  this.typeNamingStyle = _options.typeNamingStyle;
@@ -559,7 +541,10 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
559
541
  this.emitCommentLines(this.leadingComments);
560
542
  }
561
543
  else if (!this._options.justTypes) {
562
- this.emitCommentLines([" To parse this JSON data, first install", ""]);
544
+ this.emitCommentLines([
545
+ " To parse this JSON data, first install",
546
+ "",
547
+ ]);
563
548
  if (this._options.boost) {
564
549
  this.emitCommentLines([" Boost http://www.boost.org"]);
565
550
  }
@@ -679,12 +664,10 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
679
664
  return [optionalType, "<", variant, ">"];
680
665
  }
681
666
  ourQualifier(inJsonNamespace) {
682
- return inJsonNamespace || this._options.msbuildPermissive
683
- ? [collection_utils_1.arrayIntercalate("::", this._namespaceNames), "::"]
684
- : [];
667
+ return (inJsonNamespace || this._options.msbuildPermissive) ? [collection_utils_1.arrayIntercalate("::", this._namespaceNames), "::"] : [];
685
668
  }
686
669
  jsonQualifier(inJsonNamespace) {
687
- return inJsonNamespace || this._options.msbuildPermissive ? [] : "nlohmann::";
670
+ return (inJsonNamespace || this._options.msbuildPermissive) ? [] : "nlohmann::";
688
671
  }
689
672
  variantIndirection(needIndirection, typeSrc) {
690
673
  if (!needIndirection)
@@ -693,8 +676,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
693
676
  }
694
677
  cppType(t, ctx, withIssues, forceNarrowString, isOptional) {
695
678
  const inJsonNamespace = ctx.inJsonNamespace;
696
- if (isOptional && t instanceof Type_1.UnionType) {
697
- // avoid have optionalType<optionalType<Type>>
679
+ if (isOptional && t instanceof Type_1.UnionType) { // avoid have optionalType<optionalType<Type>>
698
680
  for (const tChild of t.getChildren()) {
699
681
  if (tChild.isNullable) {
700
682
  isOptional = false;
@@ -704,16 +686,10 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
704
686
  }
705
687
  let typeSource = TypeUtils_1.matchType(t, _anyType => {
706
688
  isOptional = false;
707
- return Source_1.maybeAnnotated(withIssues, Annotation_1.anyTypeIssueAnnotation, [
708
- this.jsonQualifier(inJsonNamespace),
709
- "json"
710
- ]);
689
+ return Source_1.maybeAnnotated(withIssues, Annotation_1.anyTypeIssueAnnotation, [this.jsonQualifier(inJsonNamespace), "json"]);
711
690
  }, _nullType => {
712
691
  isOptional = false;
713
- return Source_1.maybeAnnotated(withIssues, Annotation_1.nullTypeIssueAnnotation, [
714
- this.jsonQualifier(inJsonNamespace),
715
- "json"
716
- ]);
692
+ return Source_1.maybeAnnotated(withIssues, Annotation_1.nullTypeIssueAnnotation, [this.jsonQualifier(inJsonNamespace), "json"]);
717
693
  }, _boolType => "bool", _integerType => "int64_t", _doubleType => "double", _stringType => {
718
694
  if (forceNarrowString) {
719
695
  return "std::string";
@@ -725,7 +701,10 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
725
701
  "std::vector<",
726
702
  this.cppType(arrayType.items, { needsForwardIndirection: false, needsOptionalIndirection: true, inJsonNamespace }, withIssues, forceNarrowString, false),
727
703
  ">"
728
- ], classType => this.variantIndirection(ctx.needsForwardIndirection && this.isForwardDeclaredType(classType) && !isOptional, [this.ourQualifier(inJsonNamespace), this.nameForNamedType(classType)]), mapType => {
704
+ ], classType => this.variantIndirection(ctx.needsForwardIndirection && this.isForwardDeclaredType(classType) && !isOptional, [
705
+ this.ourQualifier(inJsonNamespace),
706
+ this.nameForNamedType(classType)
707
+ ]), mapType => {
729
708
  let keyType = this._stringType.getType();
730
709
  if (forceNarrowString) {
731
710
  keyType = "std::string";
@@ -746,7 +725,12 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
746
725
  });
747
726
  if (!isOptional)
748
727
  return typeSource;
749
- return [optionalType, "<", typeSource, ">"];
728
+ return [
729
+ optionalType,
730
+ "<",
731
+ typeSource,
732
+ ">"
733
+ ];
750
734
  }
751
735
  /**
752
736
  * similar to cppType, it practically gathers all the generated types within
@@ -850,8 +834,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
850
834
  * a member called 'value' value = value will screw up the compiler
851
835
  */
852
836
  const checkConst = this.lookupGlobalName(GlobalNames.CheckConstraint);
853
- if ((property.type instanceof Type_1.UnionType && property.type.findMember("null") !== undefined) ||
854
- (property.isOptional && property.type.kind !== "null" && property.type.kind !== "any")) {
837
+ if ((property.type instanceof Type_1.UnionType && property.type.findMember("null") !== undefined) || (property.isOptional && property.type.kind !== "null" && property.type.kind !== "any")) {
855
838
  this.emitLine(rendered, " ", getterName, "() const { return ", name, "; }");
856
839
  if (constraints !== undefined && constraints.has(jsonName)) {
857
840
  this.emitLine("void ", setterName, "(", rendered, " value) { if (value) ", checkConst, "(", this._stringType.createStringLiteral([name]), ", ", this.constraintMember(jsonName), ", *value); this->", name, " = value; }");
@@ -884,26 +867,15 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
884
867
  res.set(jsonName, [
885
868
  this.constraintMember(jsonName),
886
869
  "(",
887
- minMax !== undefined && minMax[0] !== undefined ? String(minMax[0]) : this._nulloptType,
870
+ (minMax !== undefined && minMax[0] !== undefined) ? String(minMax[0]) : this._nulloptType,
888
871
  ", ",
889
- minMax !== undefined && minMax[1] !== undefined ? String(minMax[1]) : this._nulloptType,
872
+ (minMax !== undefined && minMax[1] !== undefined) ? String(minMax[1]) : this._nulloptType,
890
873
  ", ",
891
- minMaxLength !== undefined && minMaxLength[0] !== undefined
892
- ? String(minMaxLength[0])
893
- : this._nulloptType,
874
+ (minMaxLength !== undefined && minMaxLength[0] !== undefined) ? String(minMaxLength[0]) : this._nulloptType,
894
875
  ", ",
895
- minMaxLength !== undefined && minMaxLength[1] !== undefined
896
- ? String(minMaxLength[1])
897
- : this._nulloptType,
876
+ (minMaxLength !== undefined && minMaxLength[1] !== undefined) ? String(minMaxLength[1]) : this._nulloptType,
898
877
  ", ",
899
- pattern === undefined
900
- ? this._nulloptType
901
- : [
902
- this._stringType.getType(),
903
- "(",
904
- this._stringType.createStringLiteral([Strings_1.stringEscape(pattern)]),
905
- ")"
906
- ],
878
+ (pattern === undefined) ? this._nulloptType : [this._stringType.getType(), "(", this._stringType.createStringLiteral([Strings_1.stringEscape(pattern)]), ")"],
907
879
  ")"
908
880
  ]);
909
881
  });
@@ -964,11 +936,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
964
936
  toType = this.cppType(t, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: true }, false, false, false);
965
937
  this.emitLine([
966
938
  "x = ",
967
- this._stringType.wrapEncodingChange([ourQualifier], cppType, toType, [
968
- "j.get<",
969
- cppType,
970
- ">()"
971
- ]),
939
+ this._stringType.wrapEncodingChange([ourQualifier], cppType, toType, ["j.get<", cppType, ">()"]),
972
940
  ";"
973
941
  ]);
974
942
  });
@@ -1008,7 +976,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1008
976
  return;
1009
977
  }
1010
978
  if (p.isOptional || t instanceof Type_1.UnionType) {
1011
- const [nullOrOptional, typeSet] = (function () {
979
+ const [nullOrOptional, typeSet] = function () {
1012
980
  if (t instanceof Type_1.UnionType) {
1013
981
  const [maybeNull, nonNulls] = TypeUtils_1.removeNullFromUnion(t, true);
1014
982
  return [maybeNull !== null || p.isOptional, nonNulls];
@@ -1018,7 +986,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1018
986
  set.add(t);
1019
987
  return [true, set];
1020
988
  }
1021
- })();
989
+ }();
1022
990
  if (nullOrOptional) {
1023
991
  cppType = this.cppTypeInOptional(typeSet, {
1024
992
  needsForwardIndirection: false,
@@ -1077,11 +1045,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1077
1045
  ";"
1078
1046
  ];
1079
1047
  if (p.isOptional && this._options.hideNullOptional) {
1080
- this.emitBlock([
1081
- "if (",
1082
- this._stringType.wrapEncodingChange([ourQualifier], cppType, toType, ["x.", getter]),
1083
- ")"
1084
- ], false, () => {
1048
+ this.emitBlock(["if (", this._stringType.wrapEncodingChange([ourQualifier], cppType, toType, ["x.", getter]), ")"], false, () => {
1085
1049
  this.emitLine(assignment);
1086
1050
  });
1087
1051
  }
@@ -1195,14 +1159,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1195
1159
  const ourQualifier = this.ourQualifier(true);
1196
1160
  this.emitBlock(["inline void from_json(", this.withConst("json"), " & j, ", ourQualifier, enumName, " & x)"], false, () => {
1197
1161
  if (this.isLargeEnum(e)) {
1198
- this.emitBlock([
1199
- "static std::unordered_map<",
1200
- this._stringType.getType(),
1201
- ", ",
1202
- ourQualifier,
1203
- enumName,
1204
- "> enumValues"
1205
- ], true, () => {
1162
+ this.emitBlock(["static std::unordered_map<", this._stringType.getType(), ", ", ourQualifier, enumName, "> enumValues"], true, () => {
1206
1163
  this.forEachEnumCase(e, "none", (name, jsonName) => {
1207
1164
  this.emitLine("{", this._stringType.wrapEncodingChange([ourQualifier], this._stringType.getType(), this.NarrowString.getType(), [this._stringType.createStringLiteral([Strings_1.stringEscape(jsonName)])]), ", ", ourQualifier, enumName, "::", name, "},");
1208
1165
  });
@@ -1349,15 +1306,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1349
1306
  this.ensureBlankLine();
1350
1307
  }
1351
1308
  const checkConst = this.lookupGlobalName(GlobalNames.CheckConstraint);
1352
- this.emitBlock([
1353
- "inline void ",
1354
- checkConst,
1355
- "(",
1356
- this._stringType.getConstType(),
1357
- " name, ",
1358
- this.withConst(classConstraint),
1359
- " & c, int64_t value)"
1360
- ], false, () => {
1309
+ this.emitBlock(["inline void ", checkConst, "(", this._stringType.getConstType(), " name, ", this.withConst(classConstraint), " & c, int64_t value)"], false, () => {
1361
1310
  this.emitBlock(["if (c.", getterMinValue, "() != ", this._nulloptType, " && value < *c.", getterMinValue, "())"], false, () => {
1362
1311
  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([")"]), ");");
1363
1312
  });
@@ -1368,38 +1317,12 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1368
1317
  this.ensureBlankLine();
1369
1318
  });
1370
1319
  this.ensureBlankLine();
1371
- this.emitBlock([
1372
- "inline void ",
1373
- checkConst,
1374
- "(",
1375
- this._stringType.getConstType(),
1376
- " name, ",
1377
- this.withConst(classConstraint),
1378
- " & c, ",
1379
- this._stringType.getConstType(),
1380
- " value)"
1381
- ], false, () => {
1382
- this.emitBlock([
1383
- "if (c.",
1384
- getterMinLength,
1385
- "() != ",
1386
- this._nulloptType,
1387
- " && value.length() < *c.",
1388
- getterMinLength,
1389
- "())"
1390
- ], false, () => {
1320
+ this.emitBlock(["inline void ", checkConst, "(", this._stringType.getConstType(), " name, ", this.withConst(classConstraint), " & c, ", this._stringType.getConstType(), " value)"], false, () => {
1321
+ this.emitBlock(["if (c.", getterMinLength, "() != ", this._nulloptType, " && value.length() < *c.", getterMinLength, "())"], false, () => {
1391
1322
  this.emitLine("throw ", this.lookupGlobalName(GlobalNames.ValueTooShortException), " (", this._stringType.createStringLiteral(["Value too short for "]), " + name + ", this._stringType.createStringLiteral([" ("]), " + ", this._stringType.wrapToString(["value.length()"]), " + ", this._stringType.createStringLiteral(["<"]), " + ", this._stringType.wrapToString(["*c.", getterMinLength, "()"]), " + ", this._stringType.createStringLiteral([")"]), ");");
1392
1323
  });
1393
1324
  this.ensureBlankLine();
1394
- this.emitBlock([
1395
- "if (c.",
1396
- getterMaxLength,
1397
- "() != ",
1398
- this._nulloptType,
1399
- " && value.length() > *c.",
1400
- getterMaxLength,
1401
- "())"
1402
- ], false, () => {
1325
+ this.emitBlock(["if (c.", getterMaxLength, "() != ", this._nulloptType, " && value.length() > *c.", getterMaxLength, "())"], false, () => {
1403
1326
  this.emitLine("throw ", this.lookupGlobalName(GlobalNames.ValueTooLongException), " (", this._stringType.createStringLiteral(["Value too long for "]), " + name + ", this._stringType.createStringLiteral([" ("]), " + ", this._stringType.wrapToString(["value.length()"]), " + ", this._stringType.createStringLiteral([">"]), " + ", this._stringType.wrapToString(["*c.", getterMaxLength, "()"]), " + ", this._stringType.createStringLiteral([")"]), ");");
1404
1327
  });
1405
1328
  this.ensureBlankLine();
@@ -1420,28 +1343,24 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1420
1343
  this.emitConstraintClasses();
1421
1344
  this.ensureBlankLine();
1422
1345
  }
1423
- this.emitBlock(["inline json get_untyped(", this.withConst("json"), " & j, ", this.withConst("char"), " * property)"], false, () => {
1346
+ this.emitBlock([
1347
+ "inline json get_untyped(", this.withConst("json"), " & j, ", this.withConst("char"), " * property)"
1348
+ ], false, () => {
1424
1349
  this.emitBlock(["if (j.find(property) != j.end())"], false, () => {
1425
1350
  this.emitLine("return j.at(property).get<json>();");
1426
1351
  });
1427
1352
  this.emitLine("return json();");
1428
1353
  });
1429
1354
  this.ensureBlankLine();
1430
- this.emitBlock(["inline json get_untyped(", this.withConst("json"), " & j, std::string property)"], false, () => {
1355
+ this.emitBlock([
1356
+ "inline json get_untyped(", this.withConst("json"), " & j, std::string property)"
1357
+ ], false, () => {
1431
1358
  this.emitLine("return get_untyped(j, property.data());");
1432
1359
  });
1433
1360
  this.ensureBlankLine();
1434
1361
  if (this.haveUnions || this.haveOptionalProperties) {
1435
1362
  this.emitLine("template <typename T>");
1436
- this.emitBlock([
1437
- "inline ",
1438
- optionalType,
1439
- "<T> get_optional(",
1440
- this.withConst("json"),
1441
- " & j, ",
1442
- this.withConst("char"),
1443
- " * property)"
1444
- ], false, () => {
1363
+ this.emitBlock(["inline ", optionalType, "<T> get_optional(", this.withConst("json"), " & j, ", this.withConst("char"), " * property)"], false, () => {
1445
1364
  this.emitBlock(["if (j.find(property) != j.end())"], false, () => {
1446
1365
  this.emitLine("return j.at(property).get<", optionalType, "<T>>();");
1447
1366
  });
@@ -78,33 +78,30 @@ function csTypeForTransformedStringType(t) {
78
78
  }
79
79
  }
80
80
  exports.cSharpOptions = {
81
- framework: new RendererOptions_1.EnumOption("framework", "Serialization framework", [
82
- ["NewtonSoft", Framework.Newtonsoft],
83
- ["SystemTextJson", Framework.SystemTextJson]
84
- ], "NewtonSoft"),
81
+ framework: new RendererOptions_1.EnumOption("framework", "Serialization framework", [["NewtonSoft", Framework.Newtonsoft], ["SystemTextJson", Framework.SystemTextJson]], "NewtonSoft"),
85
82
  useList: new RendererOptions_1.EnumOption("array-type", "Use T[] or List<T>", [
86
83
  ["array", false],
87
- ["list", true]
84
+ ["list", true],
88
85
  ]),
89
86
  dense: new RendererOptions_1.EnumOption("density", "Property density", [
90
87
  ["normal", false],
91
- ["dense", true]
88
+ ["dense", true],
92
89
  ], "normal", "secondary"),
93
90
  // FIXME: Do this via a configurable named eventually.
94
91
  namespace: new RendererOptions_1.StringOption("namespace", "Generated namespace", "NAME", "QuickType"),
95
92
  version: new RendererOptions_1.EnumOption("csharp-version", "C# version", [
96
93
  ["5", 5],
97
- ["6", 6]
94
+ ["6", 6],
98
95
  ], "6", "secondary"),
99
96
  virtual: new RendererOptions_1.BooleanOption("virtual", "Generate virtual properties", false),
100
97
  typeForAny: new RendererOptions_1.EnumOption("any-type", 'Type to use for "any"', [
101
98
  ["object", "object"],
102
- ["dynamic", "dynamic"]
99
+ ["dynamic", "dynamic"],
103
100
  ], "object", "secondary"),
104
101
  useDecimal: new RendererOptions_1.EnumOption("number-type", "Type to use for numbers", [
105
102
  ["double", false],
106
- ["decimal", true]
107
- ], "double", "secondary")
103
+ ["decimal", true],
104
+ ], "double", "secondary"),
108
105
  };
109
106
  class CSharpTargetLanguage extends TargetLanguage_1.TargetLanguage {
110
107
  constructor() {
@@ -119,7 +116,7 @@ class CSharpTargetLanguage extends TargetLanguage_1.TargetLanguage {
119
116
  exports.cSharpOptions.useList,
120
117
  exports.cSharpOptions.useDecimal,
121
118
  exports.cSharpOptions.typeForAny,
122
- exports.cSharpOptions.virtual
119
+ exports.cSharpOptions.virtual,
123
120
  ];
124
121
  }
125
122
  get stringTypeMapping() {
@@ -203,9 +200,9 @@ class CSharpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
203
200
  "Equals",
204
201
  "GetType",
205
202
  "MemberwiseClone",
206
- "ReferenceEquals"
203
+ "ReferenceEquals",
207
204
  ],
208
- includeGlobalForbidden: false
205
+ includeGlobalForbidden: false,
209
206
  };
210
207
  }
211
208
  forbiddenForUnionMembers(_, unionNamed) {
@@ -242,7 +239,7 @@ class CSharpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
242
239
  }
243
240
  csType(t, follow = Transformers_1.followTargetType, withIssues = false) {
244
241
  const actualType = follow(t);
245
- return TypeUtils_1.matchType(actualType, _anyType => Source_1.maybeAnnotated(withIssues, Annotation_1.anyTypeIssueAnnotation, this._csOptions.typeForAny), _nullType => Source_1.maybeAnnotated(withIssues, Annotation_1.nullTypeIssueAnnotation, this._csOptions.typeForAny), _boolType => "bool", _integerType => "long", _doubleType => this.doubleType, _stringType => "string", arrayType => {
242
+ return TypeUtils_1.matchType(actualType, (_anyType) => Source_1.maybeAnnotated(withIssues, Annotation_1.anyTypeIssueAnnotation, this._csOptions.typeForAny), (_nullType) => Source_1.maybeAnnotated(withIssues, Annotation_1.nullTypeIssueAnnotation, this._csOptions.typeForAny), (_boolType) => "bool", (_integerType) => "long", (_doubleType) => this.doubleType, (_stringType) => "string", (arrayType) => {
246
243
  const itemsType = this.csType(arrayType.items, follow, withIssues);
247
244
  if (this._csOptions.useList) {
248
245
  return ["System.Collections.Generic.List<", itemsType, ">"];
@@ -250,16 +247,12 @@ class CSharpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
250
247
  else {
251
248
  return [itemsType, "[]"];
252
249
  }
253
- }, classType => this.nameForNamedType(classType), mapType => [
254
- "System.Collections.Generic.Dictionary<string, ",
255
- this.csType(mapType.values, follow, withIssues),
256
- ">"
257
- ], enumType => this.nameForNamedType(enumType), unionType => {
250
+ }, (classType) => this.nameForNamedType(classType), (mapType) => ["System.Collections.Generic.Dictionary<string, ", this.csType(mapType.values, follow, withIssues), ">"], (enumType) => this.nameForNamedType(enumType), (unionType) => {
258
251
  const nullable = TypeUtils_1.nullableFromUnion(unionType);
259
252
  if (nullable !== null)
260
253
  return this.nullableCSType(nullable, noFollow);
261
254
  return this.nameForNamedType(unionType);
262
- }, transformedStringType => csTypeForTransformedStringType(transformedStringType));
255
+ }, (transformedStringType) => csTypeForTransformedStringType(transformedStringType));
263
256
  }
264
257
  nullableCSType(t, follow = Transformers_1.followTargetType, withIssues = false) {
265
258
  t = Transformers_1.followTargetType(t);
@@ -369,9 +362,9 @@ class CSharpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
369
362
  this.emitLine("public ", csType, " ", fieldName, ";");
370
363
  });
371
364
  this.ensureBlankLine();
372
- const nullTests = Array.from(nonNulls).map(t => [
365
+ const nullTests = Array.from(nonNulls).map((t) => [
373
366
  this.nameForUnionMember(u, t),
374
- " == null"
367
+ " == null",
375
368
  ]);
376
369
  this.ensureBlankLine();
377
370
  this.forEachUnionMember(u, nonNulls, "none", null, (fieldName, t) => {
@@ -385,7 +378,7 @@ class CSharpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
385
378
  }
386
379
  emitEnumDefinition(e, enumName) {
387
380
  const caseNames = [];
388
- this.forEachEnumCase(e, "none", name => {
381
+ this.forEachEnumCase(e, "none", (name) => {
389
382
  if (caseNames.length > 0)
390
383
  caseNames.push(", ");
391
384
  caseNames.push(name);
@@ -482,13 +475,13 @@ exports.newtonsoftCSharpOptions = Object.assign({}, exports.cSharpOptions, {
482
475
  ["complete", { namespaces: true, helpers: true, attributes: true }],
483
476
  ["attributes-only", { namespaces: true, helpers: false, attributes: true }],
484
477
  ["just-types-and-namespace", { namespaces: true, helpers: false, attributes: false }],
485
- ["just-types", { namespaces: true, helpers: false, attributes: false }]
478
+ ["just-types", { namespaces: true, helpers: false, attributes: false }],
486
479
  ]),
487
480
  baseclass: new RendererOptions_1.EnumOption("base-class", "Base class", [
488
481
  ["EntityData", "EntityData"],
489
- ["Object", undefined]
482
+ ["Object", undefined],
490
483
  ], "Object", "secondary"),
491
- checkRequired: new RendererOptions_1.BooleanOption("check-required", "Fail if required properties are missing", false)
484
+ checkRequired: new RendererOptions_1.BooleanOption("check-required", "Fail if required properties are missing", false),
492
485
  });
493
486
  class NewtonsoftCSharpRenderer extends CSharpRenderer {
494
487
  constructor(targetLanguage, renderContext, _options) {
@@ -511,7 +504,7 @@ class NewtonsoftCSharpRenderer extends CSharpRenderer {
511
504
  "MetadataPropertyHandling",
512
505
  "DateParseHandling",
513
506
  "FromJson",
514
- "Required"
507
+ "Required",
515
508
  ];
516
509
  if (this._options.dense) {
517
510
  forbidden.push("J", "R", "N");
@@ -534,12 +527,12 @@ class NewtonsoftCSharpRenderer extends CSharpRenderer {
534
527
  }
535
528
  return new Naming_1.SimpleName([`${xfer.kind}_converter`], namingFunction, ConvenienceRenderer_1.inferredNameOrder + 30);
536
529
  }
537
- return new Naming_1.DependencyName(namingFunction, typeName.order + 30, lookup => `${lookup(typeName)}_converter`);
530
+ return new Naming_1.DependencyName(namingFunction, typeName.order + 30, (lookup) => `${lookup(typeName)}_converter`);
538
531
  }
539
532
  makeNamedTypeDependencyNames(t, name) {
540
533
  if (!(t instanceof Type_1.EnumType))
541
534
  return [];
542
- const extensionsName = new Naming_1.DependencyName(namingFunction, name.order + 30, lookup => `${lookup(name)}_extensions`);
535
+ const extensionsName = new Naming_1.DependencyName(namingFunction, name.order + 30, (lookup) => `${lookup(name)}_extensions`);
543
536
  this._enumExtensionsNames.set(name, extensionsName);
544
537
  return [extensionsName];
545
538
  }
@@ -679,7 +672,7 @@ class NewtonsoftCSharpRenderer extends CSharpRenderer {
679
672
  // Sometimes multiple top-levels will resolve to the same type, so we have to take care
680
673
  // not to emit more than one extension method for the same type.
681
674
  const seenTypes = new Set();
682
- this.forEachTopLevel("none", t => {
675
+ this.forEachTopLevel("none", (t) => {
683
676
  // FIXME: Make ToJson a Named
684
677
  if (!seenTypes.has(t)) {
685
678
  seenTypes.add(t);
@@ -772,7 +765,7 @@ class NewtonsoftCSharpRenderer extends CSharpRenderer {
772
765
  this.emitLine("var ", variableName, " = new List<", this.csType(targetType.items), ">();");
773
766
  this.emitLine("while (reader.TokenType != JsonToken.EndArray)");
774
767
  this.emitBlock(() => {
775
- this.emitDecodeTransformer(xfer.itemTransformer, xfer.itemTargetType, v => this.emitLine(variableName, ".Add(", v, ");"), "arrayItem");
768
+ this.emitDecodeTransformer(xfer.itemTransformer, xfer.itemTargetType, (v) => this.emitLine(variableName, ".Add(", v, ");"), "arrayItem");
776
769
  // FIXME: handle EOF
777
770
  this.emitLine("reader.Read();");
778
771
  });
@@ -826,7 +819,7 @@ class NewtonsoftCSharpRenderer extends CSharpRenderer {
826
819
  }
827
820
  if (xfer instanceof Transformers_1.ChoiceTransformer) {
828
821
  const caseXfers = xfer.transformers;
829
- if (caseXfers.length > 1 && caseXfers.every(caseXfer => caseXfer instanceof Transformers_1.StringMatchTransformer)) {
822
+ if (caseXfers.length > 1 && caseXfers.every((caseXfer) => caseXfer instanceof Transformers_1.StringMatchTransformer)) {
830
823
  this.emitLine("switch (", variable, ")");
831
824
  this.emitBlock(() => {
832
825
  for (const caseXfer of caseXfers) {
@@ -1044,7 +1037,7 @@ class NewtonsoftCSharpRenderer extends CSharpRenderer {
1044
1037
  if (haveNullable && !(targetType instanceof Type_1.UnionType)) {
1045
1038
  this.emitLine("if (reader.TokenType == JsonToken.Null) return null;");
1046
1039
  }
1047
- const allHandled = this.emitDecodeTransformer(xfer, targetType, v => this.emitLine("return ", v, ";"));
1040
+ const allHandled = this.emitDecodeTransformer(xfer, targetType, (v) => this.emitLine("return ", v, ";"));
1048
1041
  if (!allHandled) {
1049
1042
  this.emitThrow(['"Cannot unmarshal type ', csType, '"']);
1050
1043
  }
@@ -1091,13 +1084,13 @@ exports.systemTextJsonCSharpOptions = Object.assign({}, exports.cSharpOptions, {
1091
1084
  ["complete", { namespaces: true, helpers: true, attributes: true }],
1092
1085
  ["attributes-only", { namespaces: true, helpers: false, attributes: true }],
1093
1086
  ["just-types-and-namespace", { namespaces: true, helpers: false, attributes: false }],
1094
- ["just-types", { namespaces: true, helpers: false, attributes: false }]
1087
+ ["just-types", { namespaces: true, helpers: false, attributes: false }],
1095
1088
  ]),
1096
1089
  baseclass: new RendererOptions_1.EnumOption("base-class", "Base class", [
1097
1090
  ["EntityData", "EntityData"],
1098
- ["Object", undefined]
1091
+ ["Object", undefined],
1099
1092
  ], "Object", "secondary"),
1100
- checkRequired: new RendererOptions_1.BooleanOption("check-required", "Fail if required properties are missing", false)
1093
+ checkRequired: new RendererOptions_1.BooleanOption("check-required", "Fail if required properties are missing", false),
1101
1094
  });
1102
1095
  class SystemTextJsonCSharpRenderer extends CSharpRenderer {
1103
1096
  constructor(targetLanguage, renderContext, _options) {
@@ -1574,7 +1567,7 @@ class SystemTextJsonCSharpRenderer extends CSharpRenderer {
1574
1567
  this.emitBlock(() => {
1575
1568
  // this.emitLine("var uri = new Uri(", variable, ");");
1576
1569
  // The default value about:blank should never happen, but this way we avoid a null reference warning.
1577
- this.emitLine('var uri = new Uri("about:blank");');
1570
+ this.emitLine("var uri = new Uri(\"about:blank\");");
1578
1571
  this.emitLine("if (!string.IsNullOrEmpty(stringValue))");
1579
1572
  this.emitBlock(() => {
1580
1573
  this.emitLine("uri = new Uri(", variable, ");");
@@ -13,10 +13,7 @@ const Source_1 = require("../Source");
13
13
  const Annotation_1 = require("../Annotation");
14
14
  exports.elmOptions = {
15
15
  justTypes: new RendererOptions_1.BooleanOption("just-types", "Plain types only", false),
16
- useList: new RendererOptions_1.EnumOption("array-type", "Use Array or List", [
17
- ["array", false],
18
- ["list", true]
19
- ]),
16
+ useList: new RendererOptions_1.EnumOption("array-type", "Use Array or List", [["array", false], ["list", true]]),
20
17
  // FIXME: Do this via a configurable named eventually.
21
18
  moduleName: new RendererOptions_1.StringOption("module", "Generated module name", "NAME", "QuickType")
22
19
  };