quicktype 17.0.6 → 18.0.1
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/cli/CompressedJSONFromStream.js +26 -38
- package/dist/cli/GraphQLIntrospection.js +33 -41
- package/dist/cli/TypeSource.d.ts +1 -1
- package/dist/cli/URLGrammar.js +4 -3
- package/dist/cli/index.js +363 -364
- package/dist/quicktype-core/Annotation.js +2 -0
- package/dist/quicktype-core/ConvenienceRenderer.d.ts +17 -17
- package/dist/quicktype-core/ConvenienceRenderer.js +104 -81
- package/dist/quicktype-core/DateTime.js +1 -0
- package/dist/quicktype-core/DeclarationIR.d.ts +1 -1
- package/dist/quicktype-core/DeclarationIR.js +13 -10
- package/dist/quicktype-core/EncodedMarkovChain.js +1 -0
- package/dist/quicktype-core/GatherNames.js +47 -25
- package/dist/quicktype-core/Graph.d.ts +2 -2
- package/dist/quicktype-core/Graph.js +23 -19
- package/dist/quicktype-core/GraphRewriting.d.ts +2 -2
- package/dist/quicktype-core/GraphRewriting.js +65 -54
- package/dist/quicktype-core/MakeTransformations.js +23 -22
- package/dist/quicktype-core/MarkovChain.d.ts +3 -3
- package/dist/quicktype-core/MarkovChain.js +9 -8
- package/dist/quicktype-core/Messages.d.ts +3 -3
- package/dist/quicktype-core/Messages.js +8 -3
- package/dist/quicktype-core/Naming.d.ts +11 -11
- package/dist/quicktype-core/Naming.js +76 -61
- package/dist/quicktype-core/Renderer.d.ts +6 -6
- package/dist/quicktype-core/Renderer.js +34 -17
- package/dist/quicktype-core/RendererOptions.d.ts +5 -5
- package/dist/quicktype-core/RendererOptions.js +6 -3
- package/dist/quicktype-core/Run.d.ts +9 -9
- package/dist/quicktype-core/Run.js +72 -67
- package/dist/quicktype-core/Source.d.ts +3 -3
- package/dist/quicktype-core/Source.js +19 -18
- package/dist/quicktype-core/TargetLanguage.d.ts +10 -10
- package/dist/quicktype-core/TargetLanguage.js +6 -2
- package/dist/quicktype-core/Transformers.d.ts +25 -25
- package/dist/quicktype-core/Transformers.js +94 -66
- package/dist/quicktype-core/Type.d.ts +41 -43
- package/dist/quicktype-core/Type.js +96 -71
- package/dist/quicktype-core/TypeBuilder.d.ts +2 -2
- package/dist/quicktype-core/TypeBuilder.js +53 -47
- package/dist/quicktype-core/TypeGraph.d.ts +4 -4
- package/dist/quicktype-core/TypeGraph.js +49 -40
- package/dist/quicktype-core/TypeUtils.d.ts +2 -2
- package/dist/quicktype-core/TypeUtils.js +23 -22
- package/dist/quicktype-core/UnifyClasses.js +16 -12
- package/dist/quicktype-core/UnionBuilder.d.ts +3 -3
- package/dist/quicktype-core/UnionBuilder.js +33 -30
- package/dist/quicktype-core/attributes/AccessorNames.d.ts +2 -2
- package/dist/quicktype-core/attributes/AccessorNames.js +18 -17
- package/dist/quicktype-core/attributes/Constraints.d.ts +3 -3
- package/dist/quicktype-core/attributes/Constraints.js +8 -4
- package/dist/quicktype-core/attributes/Description.js +6 -5
- package/dist/quicktype-core/attributes/EnumValues.js +4 -3
- package/dist/quicktype-core/attributes/StringTypes.d.ts +1 -1
- package/dist/quicktype-core/attributes/StringTypes.js +24 -21
- package/dist/quicktype-core/attributes/TypeAttributes.d.ts +3 -3
- package/dist/quicktype-core/attributes/TypeAttributes.js +12 -10
- package/dist/quicktype-core/attributes/TypeNames.d.ts +9 -9
- package/dist/quicktype-core/attributes/TypeNames.js +49 -21
- package/dist/quicktype-core/attributes/URIAttributes.d.ts +1 -1
- package/dist/quicktype-core/attributes/URIAttributes.js +10 -6
- package/dist/quicktype-core/index.js +128 -125
- package/dist/quicktype-core/input/CompressedJSON.d.ts +7 -7
- package/dist/quicktype-core/input/CompressedJSON.js +49 -54
- package/dist/quicktype-core/input/FetchingJSONSchemaStore.js +5 -13
- package/dist/quicktype-core/input/Inference.d.ts +2 -2
- package/dist/quicktype-core/input/Inference.js +25 -17
- package/dist/quicktype-core/input/Inputs.d.ts +2 -2
- package/dist/quicktype-core/input/Inputs.js +38 -54
- package/dist/quicktype-core/input/JSONSchemaInput.d.ts +11 -11
- package/dist/quicktype-core/input/JSONSchemaInput.js +503 -523
- package/dist/quicktype-core/input/JSONSchemaStore.d.ts +1 -1
- package/dist/quicktype-core/input/JSONSchemaStore.js +24 -35
- package/dist/quicktype-core/input/PostmanCollection.js +2 -1
- package/dist/quicktype-core/input/io/NodeIO.js +55 -44
- package/dist/quicktype-core/input/io/get-stream/index.js +6 -2
- package/dist/quicktype-core/language/All.js +3 -2
- package/dist/quicktype-core/language/CPlusPlus.d.ts +8 -8
- package/dist/quicktype-core/language/CPlusPlus.js +185 -151
- package/dist/quicktype-core/language/CSharp.d.ts +7 -7
- package/dist/quicktype-core/language/CSharp.js +82 -72
- package/dist/quicktype-core/language/Crystal.d.ts +2 -2
- package/dist/quicktype-core/language/Crystal.js +18 -17
- package/dist/quicktype-core/language/Dart.d.ts +4 -4
- package/dist/quicktype-core/language/Dart.js +36 -34
- package/dist/quicktype-core/language/Elm.d.ts +6 -6
- package/dist/quicktype-core/language/Elm.js +47 -45
- package/dist/quicktype-core/language/Golang.d.ts +4 -4
- package/dist/quicktype-core/language/Golang.js +23 -20
- package/dist/quicktype-core/language/Haskell.d.ts +5 -5
- package/dist/quicktype-core/language/Haskell.js +25 -23
- package/dist/quicktype-core/language/JSONSchema.d.ts +3 -3
- package/dist/quicktype-core/language/JSONSchema.js +17 -16
- package/dist/quicktype-core/language/Java.d.ts +2 -2
- package/dist/quicktype-core/language/Java.js +97 -97
- package/dist/quicktype-core/language/JavaScript.d.ts +7 -7
- package/dist/quicktype-core/language/JavaScript.js +20 -18
- package/dist/quicktype-core/language/JavaScriptPropTypes.js +15 -13
- package/dist/quicktype-core/language/JavaScriptUnicodeMaps.js +12 -11
- package/dist/quicktype-core/language/Kotlin.d.ts +2 -2
- package/dist/quicktype-core/language/Kotlin.js +39 -37
- package/dist/quicktype-core/language/Objective-C.d.ts +3 -3
- package/dist/quicktype-core/language/Objective-C.js +45 -41
- package/dist/quicktype-core/language/Php.d.ts +2 -2
- package/dist/quicktype-core/language/Php.js +66 -41
- package/dist/quicktype-core/language/Pike.d.ts +1 -1
- package/dist/quicktype-core/language/Pike.js +18 -17
- package/dist/quicktype-core/language/Python.d.ts +8 -8
- package/dist/quicktype-core/language/Python.js +63 -64
- package/dist/quicktype-core/language/Rust.d.ts +2 -2
- package/dist/quicktype-core/language/Rust.js +21 -19
- package/dist/quicktype-core/language/Swift.d.ts +7 -7
- package/dist/quicktype-core/language/Swift.js +568 -565
- package/dist/quicktype-core/language/TypeScriptFlow.d.ts +7 -7
- package/dist/quicktype-core/language/TypeScriptFlow.js +28 -26
- package/dist/quicktype-core/language/ruby/index.d.ts +4 -4
- package/dist/quicktype-core/language/ruby/index.js +49 -24
- package/dist/quicktype-core/language/ruby/keywords.js +1 -0
- package/dist/quicktype-core/rewrites/CombineClasses.js +9 -8
- package/dist/quicktype-core/rewrites/ExpandStrings.d.ts +1 -1
- package/dist/quicktype-core/rewrites/ExpandStrings.js +18 -17
- package/dist/quicktype-core/rewrites/FlattenStrings.js +7 -6
- package/dist/quicktype-core/rewrites/FlattenUnions.js +9 -8
- package/dist/quicktype-core/rewrites/InferMaps.js +11 -10
- package/dist/quicktype-core/rewrites/ReplaceObjectType.js +8 -7
- package/dist/quicktype-core/rewrites/ResolveIntersections.js +68 -67
- package/dist/quicktype-core/support/Acronyms.js +3 -1
- package/dist/quicktype-core/support/Chance.js +10 -0
- package/dist/quicktype-core/support/Converters.js +1 -0
- package/dist/quicktype-core/support/Strings.d.ts +4 -4
- package/dist/quicktype-core/support/Strings.js +17 -16
- package/dist/quicktype-core/support/Support.d.ts +1 -1
- package/dist/quicktype-core/support/Support.js +30 -6
- package/dist/quicktype-graphql-input/GraphQLSchema.d.ts +4 -4
- package/dist/quicktype-graphql-input/GraphQLSchema.js +1 -0
- package/dist/quicktype-graphql-input/index.d.ts +1 -1
- package/dist/quicktype-graphql-input/index.js +229 -212
- package/dist/quicktype-typescript-input/index.js +28 -4
- package/package.json +24 -20
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.PhpRenderer = exports.phpNameStyle = exports.stringEscape = exports.PhpTargetLanguage = exports.phpOptions = void 0;
|
|
3
27
|
const Annotation_1 = require("../Annotation");
|
|
4
28
|
const ConvenienceRenderer_1 = require("../ConvenienceRenderer");
|
|
5
29
|
const Naming_1 = require("../Naming");
|
|
@@ -10,13 +34,13 @@ const Strings_1 = require("../support/Strings");
|
|
|
10
34
|
const Support_1 = require("../support/Support");
|
|
11
35
|
const TargetLanguage_1 = require("../TargetLanguage");
|
|
12
36
|
const TypeUtils_1 = require("../TypeUtils");
|
|
13
|
-
const _ = require("lodash");
|
|
37
|
+
const _ = __importStar(require("lodash"));
|
|
14
38
|
exports.phpOptions = {
|
|
15
39
|
withGet: new RendererOptions_1.BooleanOption("with-get", "Create Getter", true),
|
|
16
40
|
fastGet: new RendererOptions_1.BooleanOption("fast-get", "getter without validation", false),
|
|
17
41
|
withSet: new RendererOptions_1.BooleanOption("with-set", "Create Setter", false),
|
|
18
42
|
withClosing: new RendererOptions_1.BooleanOption("with-closing", "PHP Closing Tag", false),
|
|
19
|
-
acronymStyle: Acronyms_1.acronymOption(Acronyms_1.AcronymStyleOptions.Pascal)
|
|
43
|
+
acronymStyle: (0, Acronyms_1.acronymOption)(Acronyms_1.AcronymStyleOptions.Pascal)
|
|
20
44
|
};
|
|
21
45
|
class PhpTargetLanguage extends TargetLanguage_1.TargetLanguage {
|
|
22
46
|
constructor() {
|
|
@@ -29,7 +53,7 @@ class PhpTargetLanguage extends TargetLanguage_1.TargetLanguage {
|
|
|
29
53
|
return true;
|
|
30
54
|
}
|
|
31
55
|
makeRenderer(renderContext, untypedOptionValues) {
|
|
32
|
-
const options = RendererOptions_1.getOptionValues(exports.phpOptions, untypedOptionValues);
|
|
56
|
+
const options = (0, RendererOptions_1.getOptionValues)(exports.phpOptions, untypedOptionValues);
|
|
33
57
|
return new PhpRenderer(this, renderContext, options);
|
|
34
58
|
}
|
|
35
59
|
get stringTypeMapping() {
|
|
@@ -42,29 +66,30 @@ class PhpTargetLanguage extends TargetLanguage_1.TargetLanguage {
|
|
|
42
66
|
}
|
|
43
67
|
}
|
|
44
68
|
exports.PhpTargetLanguage = PhpTargetLanguage;
|
|
45
|
-
exports.stringEscape = Strings_1.utf16ConcatMap(Strings_1.escapeNonPrintableMapper(Strings_1.isAscii, Strings_1.standardUnicodeHexEscape));
|
|
69
|
+
exports.stringEscape = (0, Strings_1.utf16ConcatMap)((0, Strings_1.escapeNonPrintableMapper)(Strings_1.isAscii, Strings_1.standardUnicodeHexEscape));
|
|
46
70
|
function isStartCharacter(codePoint) {
|
|
47
71
|
if (codePoint === 0x5f)
|
|
48
72
|
return true; // underscore
|
|
49
|
-
return Strings_1.isAscii(codePoint) && Strings_1.isLetter(codePoint);
|
|
73
|
+
return (0, Strings_1.isAscii)(codePoint) && (0, Strings_1.isLetter)(codePoint);
|
|
50
74
|
}
|
|
51
75
|
function isPartCharacter(codePoint) {
|
|
52
|
-
return isStartCharacter(codePoint) || (Strings_1.isAscii(codePoint) && Strings_1.isDigit(codePoint));
|
|
76
|
+
return isStartCharacter(codePoint) || ((0, Strings_1.isAscii)(codePoint) && (0, Strings_1.isDigit)(codePoint));
|
|
53
77
|
}
|
|
54
|
-
const legalizeName = Strings_1.utf16LegalizeCharacters(isPartCharacter);
|
|
78
|
+
const legalizeName = (0, Strings_1.utf16LegalizeCharacters)(isPartCharacter);
|
|
55
79
|
function phpNameStyle(startWithUpper, upperUnderscore, original, acronymsStyle = Strings_1.allUpperWordStyle) {
|
|
56
|
-
const words = Strings_1.splitIntoWords(original);
|
|
57
|
-
return Strings_1.combineWords(words, legalizeName, upperUnderscore ? Strings_1.allUpperWordStyle : startWithUpper ? Strings_1.firstUpperWordStyle : Strings_1.allLowerWordStyle, upperUnderscore ? Strings_1.allUpperWordStyle : Strings_1.firstUpperWordStyle, upperUnderscore || startWithUpper ? Strings_1.allUpperWordStyle : Strings_1.allLowerWordStyle, acronymsStyle, upperUnderscore ? "_" : "", isStartCharacter);
|
|
80
|
+
const words = (0, Strings_1.splitIntoWords)(original);
|
|
81
|
+
return (0, Strings_1.combineWords)(words, legalizeName, upperUnderscore ? Strings_1.allUpperWordStyle : startWithUpper ? Strings_1.firstUpperWordStyle : Strings_1.allLowerWordStyle, upperUnderscore ? Strings_1.allUpperWordStyle : Strings_1.firstUpperWordStyle, upperUnderscore || startWithUpper ? Strings_1.allUpperWordStyle : Strings_1.allLowerWordStyle, acronymsStyle, upperUnderscore ? "_" : "", isStartCharacter);
|
|
58
82
|
}
|
|
59
83
|
exports.phpNameStyle = phpNameStyle;
|
|
60
84
|
class PhpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
85
|
+
_options;
|
|
86
|
+
_gettersAndSettersForPropertyName = new Map();
|
|
87
|
+
_haveEmittedLeadingComments = false;
|
|
88
|
+
_converterClassname = "Converter";
|
|
89
|
+
_converterKeywords = [];
|
|
61
90
|
constructor(targetLanguage, renderContext, _options) {
|
|
62
91
|
super(targetLanguage, renderContext);
|
|
63
92
|
this._options = _options;
|
|
64
|
-
this._gettersAndSettersForPropertyName = new Map();
|
|
65
|
-
this._haveEmittedLeadingComments = false;
|
|
66
|
-
this._converterClassname = "Converter";
|
|
67
|
-
this._converterKeywords = [];
|
|
68
93
|
}
|
|
69
94
|
forbiddenForObjectProperties(_c, _className) {
|
|
70
95
|
return { names: [], includeGlobalForbidden: true };
|
|
@@ -82,10 +107,10 @@ class PhpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
82
107
|
return this.getNameStyling("enumCaseNamingFunction");
|
|
83
108
|
}
|
|
84
109
|
unionNeedsName(u) {
|
|
85
|
-
return TypeUtils_1.nullableFromUnion(u) === null;
|
|
110
|
+
return (0, TypeUtils_1.nullableFromUnion)(u) === null;
|
|
86
111
|
}
|
|
87
112
|
namedTypeToNameForTopLevel(type) {
|
|
88
|
-
return TypeUtils_1.directlyReachableSingleNamedType(type);
|
|
113
|
+
return (0, TypeUtils_1.directlyReachableSingleNamedType)(type);
|
|
89
114
|
}
|
|
90
115
|
makeNamesForPropertyGetterAndSetter(_c, _className, _p, _jsonName, name) {
|
|
91
116
|
const getterName = new Naming_1.DependencyName(this.getNameStyling("propertyNamingFunction"), name.order, lookup => `get_${lookup(name)}`);
|
|
@@ -117,9 +142,9 @@ class PhpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
117
142
|
}
|
|
118
143
|
getNameStyling(convention) {
|
|
119
144
|
const styling = {
|
|
120
|
-
typeNamingFunction: Naming_1.funPrefixNamer("types", n => phpNameStyle(true, false, n, Acronyms_1.acronymStyle(this._options.acronymStyle))),
|
|
121
|
-
propertyNamingFunction: Naming_1.funPrefixNamer("properties", n => phpNameStyle(false, false, n, Acronyms_1.acronymStyle(this._options.acronymStyle))),
|
|
122
|
-
enumCaseNamingFunction: Naming_1.funPrefixNamer("enum-cases", n => phpNameStyle(true, true, n, Acronyms_1.acronymStyle(this._options.acronymStyle)))
|
|
145
|
+
typeNamingFunction: (0, Naming_1.funPrefixNamer)("types", n => phpNameStyle(true, false, n, (0, Acronyms_1.acronymStyle)(this._options.acronymStyle))),
|
|
146
|
+
propertyNamingFunction: (0, Naming_1.funPrefixNamer)("properties", n => phpNameStyle(false, false, n, (0, Acronyms_1.acronymStyle)(this._options.acronymStyle))),
|
|
147
|
+
enumCaseNamingFunction: (0, Naming_1.funPrefixNamer)("enum-cases", n => phpNameStyle(true, true, n, (0, Acronyms_1.acronymStyle)(this._options.acronymStyle)))
|
|
123
148
|
};
|
|
124
149
|
return styling[convention];
|
|
125
150
|
}
|
|
@@ -151,8 +176,8 @@ class PhpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
151
176
|
function optionalize(s) {
|
|
152
177
|
return [isOptional ? prefix : "", s, isOptional ? suffix : ""];
|
|
153
178
|
}
|
|
154
|
-
return TypeUtils_1.matchType(t, _anyType => Source_1.maybeAnnotated(isOptional, Annotation_1.anyTypeIssueAnnotation, "Object"), _nullType => Source_1.maybeAnnotated(isOptional, Annotation_1.nullTypeIssueAnnotation, "Object"), _boolType => optionalize("bool"), _integerType => optionalize("int"), _doubleType => optionalize("float"), _stringType => optionalize("string"), _arrayType => optionalize("array"), classType => optionalize(this.nameForNamedType(classType)), _mapType => optionalize("stdClass"), enumType => optionalize(this.nameForNamedType(enumType)), unionType => {
|
|
155
|
-
const nullable = TypeUtils_1.nullableFromUnion(unionType);
|
|
179
|
+
return (0, TypeUtils_1.matchType)(t, _anyType => (0, Source_1.maybeAnnotated)(isOptional, Annotation_1.anyTypeIssueAnnotation, "Object"), _nullType => (0, Source_1.maybeAnnotated)(isOptional, Annotation_1.nullTypeIssueAnnotation, "Object"), _boolType => optionalize("bool"), _integerType => optionalize("int"), _doubleType => optionalize("float"), _stringType => optionalize("string"), _arrayType => optionalize("array"), classType => optionalize(this.nameForNamedType(classType)), _mapType => optionalize("stdClass"), enumType => optionalize(this.nameForNamedType(enumType)), unionType => {
|
|
180
|
+
const nullable = (0, TypeUtils_1.nullableFromUnion)(unionType);
|
|
156
181
|
if (nullable !== null)
|
|
157
182
|
return this.phpType(true, nullable, true, prefix, suffix);
|
|
158
183
|
return this.nameForNamedType(unionType);
|
|
@@ -173,8 +198,8 @@ class PhpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
173
198
|
});
|
|
174
199
|
}
|
|
175
200
|
phpDocConvertType(className, t) {
|
|
176
|
-
return TypeUtils_1.matchType(t, _anyType => "any", _nullType => "null", _boolType => "bool", _integerType => "int", _doubleType => "float", _stringType => "string", arrayType => [this.phpDocConvertType(className, arrayType.items), "[]"], _classType => _classType.getCombinedName(), _mapType => "stdClass", enumType => this.nameForNamedType(enumType), unionType => {
|
|
177
|
-
const nullable = TypeUtils_1.nullableFromUnion(unionType);
|
|
201
|
+
return (0, TypeUtils_1.matchType)(t, _anyType => "any", _nullType => "null", _boolType => "bool", _integerType => "int", _doubleType => "float", _stringType => "string", arrayType => [this.phpDocConvertType(className, arrayType.items), "[]"], _classType => _classType.getCombinedName(), _mapType => "stdClass", enumType => this.nameForNamedType(enumType), unionType => {
|
|
202
|
+
const nullable = (0, TypeUtils_1.nullableFromUnion)(unionType);
|
|
178
203
|
if (nullable !== null) {
|
|
179
204
|
return [this.phpDocConvertType(className, nullable), "|null"];
|
|
180
205
|
}
|
|
@@ -187,10 +212,10 @@ class PhpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
187
212
|
});
|
|
188
213
|
}
|
|
189
214
|
phpConvertType(className, t) {
|
|
190
|
-
return TypeUtils_1.matchType(t, _anyType => "any", _nullType => "null", _boolType => "bool", _integerType => "int", _doubleType => "float", _stringType => "string", _arrayType => "array", _classType => "stdClass", _mapType => "stdClass", _enumType => "string", // TODO number this.nameForNamedType(enumType),
|
|
215
|
+
return (0, TypeUtils_1.matchType)(t, _anyType => "any", _nullType => "null", _boolType => "bool", _integerType => "int", _doubleType => "float", _stringType => "string", _arrayType => "array", _classType => "stdClass", _mapType => "stdClass", _enumType => "string", // TODO number this.nameForNamedType(enumType),
|
|
191
216
|
// TODO number this.nameForNamedType(enumType),
|
|
192
217
|
unionType => {
|
|
193
|
-
const nullable = TypeUtils_1.nullableFromUnion(unionType);
|
|
218
|
+
const nullable = (0, TypeUtils_1.nullableFromUnion)(unionType);
|
|
194
219
|
if (nullable !== null) {
|
|
195
220
|
return ["?", this.phpConvertType(className, nullable)];
|
|
196
221
|
}
|
|
@@ -203,7 +228,7 @@ class PhpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
203
228
|
});
|
|
204
229
|
}
|
|
205
230
|
phpToObjConvert(className, t, lhs, args) {
|
|
206
|
-
return TypeUtils_1.matchType(t, _anyType => this.emitLine(...lhs, ...args, "; /*any*/"), _nullType => this.emitLine(...lhs, ...args, "; /*null*/"), _boolType => this.emitLine(...lhs, ...args, "; /*bool*/"), _integerType => this.emitLine(...lhs, ...args, "; /*int*/"), _doubleType => this.emitLine(...lhs, ...args, "; /*float*/"), _stringType => this.emitLine(...lhs, ...args, "; /*string*/"), arrayType => {
|
|
231
|
+
return (0, TypeUtils_1.matchType)(t, _anyType => this.emitLine(...lhs, ...args, "; /*any*/"), _nullType => this.emitLine(...lhs, ...args, "; /*null*/"), _boolType => this.emitLine(...lhs, ...args, "; /*bool*/"), _integerType => this.emitLine(...lhs, ...args, "; /*int*/"), _doubleType => this.emitLine(...lhs, ...args, "; /*float*/"), _stringType => this.emitLine(...lhs, ...args, "; /*string*/"), arrayType => {
|
|
207
232
|
this.emitLine(...lhs, "array_map(function ($value) {");
|
|
208
233
|
this.indent(() => {
|
|
209
234
|
this.phpToObjConvert(className, arrayType.items, ["return "], ["$value"]);
|
|
@@ -220,7 +245,7 @@ class PhpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
220
245
|
});
|
|
221
246
|
this.emitLine("return to(", ...args, ");");
|
|
222
247
|
}, enumType => this.emitLine(...lhs, this.nameForNamedType(enumType), "::to(", ...args, "); ", "/*enum*/"), unionType => {
|
|
223
|
-
const nullable = TypeUtils_1.nullableFromUnion(unionType);
|
|
248
|
+
const nullable = (0, TypeUtils_1.nullableFromUnion)(unionType);
|
|
224
249
|
if (nullable !== null) {
|
|
225
250
|
this.emitLine("if (!is_null(", ...args, ")) {");
|
|
226
251
|
this.indent(() => this.phpToObjConvert(className, nullable, lhs, args));
|
|
@@ -245,7 +270,7 @@ class PhpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
245
270
|
// }
|
|
246
271
|
}
|
|
247
272
|
phpFromObjConvert(className, t, lhs, args) {
|
|
248
|
-
return TypeUtils_1.matchType(t, _anyType => this.emitLine(...lhs, ...args, "; /*any*/"), _nullType => this.emitLine(...lhs, ...args, "; /*null*/"), _boolType => this.emitLine(...lhs, ...args, "; /*bool*/"), _integerType => this.emitLine(...lhs, ...args, "; /*int*/"), _doubleType => this.emitLine(...lhs, ...args, "; /*float*/"), _stringType => this.emitLine(...lhs, ...args, "; /*string*/"), arrayType => {
|
|
273
|
+
return (0, TypeUtils_1.matchType)(t, _anyType => this.emitLine(...lhs, ...args, "; /*any*/"), _nullType => this.emitLine(...lhs, ...args, "; /*null*/"), _boolType => this.emitLine(...lhs, ...args, "; /*bool*/"), _integerType => this.emitLine(...lhs, ...args, "; /*int*/"), _doubleType => this.emitLine(...lhs, ...args, "; /*float*/"), _stringType => this.emitLine(...lhs, ...args, "; /*string*/"), arrayType => {
|
|
249
274
|
this.emitLine(...lhs, " array_map(function ($value) {");
|
|
250
275
|
this.indent(() => {
|
|
251
276
|
this.phpFromObjConvert(className, arrayType.items, ["return "], ["$value"]);
|
|
@@ -262,7 +287,7 @@ class PhpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
262
287
|
});
|
|
263
288
|
this.emitLine("return from(", ...args, ");");
|
|
264
289
|
}, enumType => this.emitLine(...lhs, this.nameForNamedType(enumType), "::from(", ...args, "); ", "/*enum*/"), unionType => {
|
|
265
|
-
const nullable = TypeUtils_1.nullableFromUnion(unionType);
|
|
290
|
+
const nullable = (0, TypeUtils_1.nullableFromUnion)(unionType);
|
|
266
291
|
if (nullable !== null) {
|
|
267
292
|
this.emitLine("if (!is_null(", ...args, ")) {");
|
|
268
293
|
this.indent(() => this.phpFromObjConvert(className, nullable, lhs, args));
|
|
@@ -283,7 +308,7 @@ class PhpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
283
308
|
});
|
|
284
309
|
}
|
|
285
310
|
phpSampleConvert(className, t, lhs, args, idx, suffix) {
|
|
286
|
-
return TypeUtils_1.matchType(t, _anyType => this.emitLine(...lhs, "'AnyType::", className, "::", args, "::" + idx, "'", suffix, "/*", "" + idx, ":", args, "*/"), _nullType => this.emitLine(...lhs, "null", suffix, " /*", "" + idx, ":", args, "*/"), _boolType => this.emitLine(...lhs, "true", suffix, " /*", "" + idx, ":", args, "*/"), _integerType => this.emitLine(...lhs, "" + idx, suffix, " /*", "" + idx, ":", args, "*/"), _doubleType => this.emitLine(...lhs, "" + (idx + idx / 1000), suffix, " /*", "" + idx, ":", args, "*/"), _stringType => this.emitLine(...lhs, "'", className, "::", args, "::" + idx, "'", suffix, " /*", "" + idx, ":", args, "*/"), arrayType => {
|
|
311
|
+
return (0, TypeUtils_1.matchType)(t, _anyType => this.emitLine(...lhs, "'AnyType::", className, "::", args, "::" + idx, "'", suffix, "/*", "" + idx, ":", args, "*/"), _nullType => this.emitLine(...lhs, "null", suffix, " /*", "" + idx, ":", args, "*/"), _boolType => this.emitLine(...lhs, "true", suffix, " /*", "" + idx, ":", args, "*/"), _integerType => this.emitLine(...lhs, "" + idx, suffix, " /*", "" + idx, ":", args, "*/"), _doubleType => this.emitLine(...lhs, "" + (idx + idx / 1000), suffix, " /*", "" + idx, ":", args, "*/"), _stringType => this.emitLine(...lhs, "'", className, "::", args, "::" + idx, "'", suffix, " /*", "" + idx, ":", args, "*/"), arrayType => {
|
|
287
312
|
this.emitLine(...lhs, " array(");
|
|
288
313
|
this.indent(() => {
|
|
289
314
|
this.phpSampleConvert(className, arrayType.items, [], [], idx, "");
|
|
@@ -297,7 +322,7 @@ class PhpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
297
322
|
});
|
|
298
323
|
this.emitLine("return sample();");
|
|
299
324
|
}, enumType => this.emitLine(...lhs, this.nameForNamedType(enumType), "::sample()", suffix, " /*enum*/"), unionType => {
|
|
300
|
-
const nullable = TypeUtils_1.nullableFromUnion(unionType);
|
|
325
|
+
const nullable = (0, TypeUtils_1.nullableFromUnion)(unionType);
|
|
301
326
|
if (nullable !== null) {
|
|
302
327
|
this.phpSampleConvert(className, nullable, lhs, args, idx, suffix);
|
|
303
328
|
return;
|
|
@@ -317,7 +342,7 @@ class PhpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
317
342
|
const is = (isfn, myT = className) => {
|
|
318
343
|
this.emitBlock(["if (!", isfn, "(", scopeAttrName, "))"], () => this.emitLine('throw new Exception("Attribute Error:', myT, "::", attrName, '");'));
|
|
319
344
|
};
|
|
320
|
-
return TypeUtils_1.matchType(t, _anyType => is("defined"), _nullType => is("is_null"), _boolType => is("is_bool"), _integerType => is("is_integer"), _doubleType => is("is_float"), _stringType => is("is_string"), arrayType => {
|
|
345
|
+
return (0, TypeUtils_1.matchType)(t, _anyType => is("defined"), _nullType => is("is_null"), _boolType => is("is_bool"), _integerType => is("is_integer"), _doubleType => is("is_float"), _stringType => is("is_string"), arrayType => {
|
|
321
346
|
is("is_array");
|
|
322
347
|
this.emitLine("array_walk(", scopeAttrName, ", function(", scopeAttrName, "_v) {");
|
|
323
348
|
this.indent(() => {
|
|
@@ -335,7 +360,7 @@ class PhpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
335
360
|
}, enumType => {
|
|
336
361
|
this.emitLine(this.phpType(false, enumType), "::to(", scopeAttrName, ");");
|
|
337
362
|
}, unionType => {
|
|
338
|
-
const nullable = TypeUtils_1.nullableFromUnion(unionType);
|
|
363
|
+
const nullable = (0, TypeUtils_1.nullableFromUnion)(unionType);
|
|
339
364
|
if (nullable !== null) {
|
|
340
365
|
this.emitBlock(["if (!is_null(", scopeAttrName, "))"], () => {
|
|
341
366
|
this.phpValidate(className, nullable, attrName, scopeAttrName);
|
|
@@ -486,7 +511,7 @@ class PhpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
486
511
|
let idx = 31;
|
|
487
512
|
this.forEachClassProperty(c, "leading-and-interposing", (name, jsonName, p) => {
|
|
488
513
|
const desc = this.descriptionForClassProperty(c, jsonName);
|
|
489
|
-
const names = Support_1.defined(this._gettersAndSettersForPropertyName.get(name));
|
|
514
|
+
const names = (0, Support_1.defined)(this._gettersAndSettersForPropertyName.get(name));
|
|
490
515
|
this.ensureBlankLine();
|
|
491
516
|
this.emitFromMethod(names, p, className, name, desc);
|
|
492
517
|
this.ensureBlankLine();
|
|
@@ -505,7 +530,7 @@ class PhpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
505
530
|
let lines = [];
|
|
506
531
|
let p = "return ";
|
|
507
532
|
this.forEachClassProperty(c, "none", (name, _jsonName, _p) => {
|
|
508
|
-
const names = Support_1.defined(this._gettersAndSettersForPropertyName.get(name));
|
|
533
|
+
const names = (0, Support_1.defined)(this._gettersAndSettersForPropertyName.get(name));
|
|
509
534
|
lines.push([p, className, "::", names.validate, "($this->", name, ")"]);
|
|
510
535
|
p = "|| ";
|
|
511
536
|
});
|
|
@@ -523,7 +548,7 @@ class PhpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
523
548
|
], () => {
|
|
524
549
|
this.emitLine("$out = new stdClass();");
|
|
525
550
|
this.forEachClassProperty(c, "none", (name, jsonName) => {
|
|
526
|
-
const names = Support_1.defined(this._gettersAndSettersForPropertyName.get(name));
|
|
551
|
+
const names = (0, Support_1.defined)(this._gettersAndSettersForPropertyName.get(name));
|
|
527
552
|
this.emitLine("$out->{'", jsonName, "'} = $this->", names.to, "();");
|
|
528
553
|
});
|
|
529
554
|
this.emitLine("return $out;");
|
|
@@ -542,14 +567,14 @@ class PhpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
542
567
|
], () => {
|
|
543
568
|
if (this._options.fastGet) {
|
|
544
569
|
this.forEachClassProperty(c, "none", name => {
|
|
545
|
-
const names = Support_1.defined(this._gettersAndSettersForPropertyName.get(name));
|
|
570
|
+
const names = (0, Support_1.defined)(this._gettersAndSettersForPropertyName.get(name));
|
|
546
571
|
this.emitLine(className, "::", names.validate, "($this->", name, ", true);");
|
|
547
572
|
});
|
|
548
573
|
}
|
|
549
574
|
this.emitLine("return new ", className, "(");
|
|
550
575
|
let comma = " ";
|
|
551
576
|
this.forEachClassProperty(c, "none", (name, jsonName) => {
|
|
552
|
-
const names = Support_1.defined(this._gettersAndSettersForPropertyName.get(name));
|
|
577
|
+
const names = (0, Support_1.defined)(this._gettersAndSettersForPropertyName.get(name));
|
|
553
578
|
this.emitLine(comma, className, "::", names.from, "($obj->{'", jsonName, "'})");
|
|
554
579
|
comma = ",";
|
|
555
580
|
});
|
|
@@ -560,7 +585,7 @@ class PhpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
560
585
|
this.emitLine("return new ", className, "(");
|
|
561
586
|
let comma = " ";
|
|
562
587
|
this.forEachClassProperty(c, "none", name => {
|
|
563
|
-
const names = Support_1.defined(this._gettersAndSettersForPropertyName.get(name));
|
|
588
|
+
const names = (0, Support_1.defined)(this._gettersAndSettersForPropertyName.get(name));
|
|
564
589
|
this.emitLine(comma, className, "::", names.sample, "()");
|
|
565
590
|
comma = ",";
|
|
566
591
|
});
|
|
@@ -624,7 +649,7 @@ class PhpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
624
649
|
this.indent(() => {
|
|
625
650
|
this.forEachEnumCase(e, "none", (name, jsonName) => {
|
|
626
651
|
// Todo String or Number
|
|
627
|
-
this.emitLine("case ", enumName, "::$", name, "->enum: return '", exports.stringEscape(jsonName), "';");
|
|
652
|
+
this.emitLine("case ", enumName, "::$", name, "->enum: return '", (0, exports.stringEscape)(jsonName), "';");
|
|
628
653
|
});
|
|
629
654
|
});
|
|
630
655
|
this.emitLine("}");
|
|
@@ -647,7 +672,7 @@ class PhpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
647
672
|
this.indent(() => {
|
|
648
673
|
this.forEachEnumCase(e, "none", (name, jsonName) => {
|
|
649
674
|
// Todo String or Enum
|
|
650
|
-
this.emitLine("case '", exports.stringEscape(jsonName), "': return ", enumName, "::$", name, ";");
|
|
675
|
+
this.emitLine("case '", (0, exports.stringEscape)(jsonName), "': return ", enumName, "::$", name, ";");
|
|
651
676
|
});
|
|
652
677
|
});
|
|
653
678
|
this.emitLine("}");
|
|
@@ -671,7 +696,7 @@ class PhpRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
671
696
|
if (this._options.withClosing) {
|
|
672
697
|
this.emitLine("?>");
|
|
673
698
|
}
|
|
674
|
-
super.finishFile(Support_1.defined(givenFilename));
|
|
699
|
+
super.finishFile((0, Support_1.defined)(givenFilename));
|
|
675
700
|
}
|
|
676
701
|
}
|
|
677
702
|
exports.PhpRenderer = PhpRenderer;
|
|
@@ -13,7 +13,7 @@ export declare class PikeTargetLanguage extends TargetLanguage {
|
|
|
13
13
|
}
|
|
14
14
|
export declare class PikeRenderer extends ConvenienceRenderer {
|
|
15
15
|
protected emitSourceStructure(): void;
|
|
16
|
-
protected
|
|
16
|
+
protected get enumCasesInGlobalNamespace(): boolean;
|
|
17
17
|
protected makeEnumCaseNamer(): Namer;
|
|
18
18
|
protected makeNamedTypeNamer(): Namer;
|
|
19
19
|
protected makeUnionMemberNamer(): Namer;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PikeRenderer = exports.PikeTargetLanguage = exports.pikeOptions = void 0;
|
|
3
4
|
const ConvenienceRenderer_1 = require("../ConvenienceRenderer");
|
|
4
5
|
const Naming_1 = require("../Naming");
|
|
5
6
|
const Source_1 = require("../Source");
|
|
@@ -62,10 +63,10 @@ const keywords = [
|
|
|
62
63
|
"typeof",
|
|
63
64
|
"global"
|
|
64
65
|
];
|
|
65
|
-
const legalizeName = Strings_1.legalizeCharacters(Strings_1.isLetterOrUnderscoreOrDigit);
|
|
66
|
-
const enumNamingFunction = Naming_1.funPrefixNamer("enumNamer", Strings_1.makeNameStyle("upper-underscore", legalizeName));
|
|
67
|
-
const namingFunction = Naming_1.funPrefixNamer("genericNamer", Strings_1.makeNameStyle("underscore", legalizeName));
|
|
68
|
-
const namedTypeNamingFunction = Naming_1.funPrefixNamer("typeNamer", Strings_1.makeNameStyle("pascal", legalizeName));
|
|
66
|
+
const legalizeName = (0, Strings_1.legalizeCharacters)(Strings_1.isLetterOrUnderscoreOrDigit);
|
|
67
|
+
const enumNamingFunction = (0, Naming_1.funPrefixNamer)("enumNamer", (0, Strings_1.makeNameStyle)("upper-underscore", legalizeName));
|
|
68
|
+
const namingFunction = (0, Naming_1.funPrefixNamer)("genericNamer", (0, Strings_1.makeNameStyle)("underscore", legalizeName));
|
|
69
|
+
const namedTypeNamingFunction = (0, Naming_1.funPrefixNamer)("typeNamer", (0, Strings_1.makeNameStyle)("pascal", legalizeName));
|
|
69
70
|
class PikeTargetLanguage extends TargetLanguage_1.TargetLanguage {
|
|
70
71
|
constructor() {
|
|
71
72
|
super("Pike", ["pike", "pikelang"], "pmod");
|
|
@@ -120,20 +121,20 @@ class PikeRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
120
121
|
}
|
|
121
122
|
sourceFor(t) {
|
|
122
123
|
if (["class", "object", "enum"].indexOf(t.kind) >= 0) {
|
|
123
|
-
return Source_1.singleWord(this.nameForNamedType(t));
|
|
124
|
+
return (0, Source_1.singleWord)(this.nameForNamedType(t));
|
|
124
125
|
}
|
|
125
|
-
return TypeUtils_1.matchType(t, _anyType => Source_1.singleWord("mixed"), _nullType => Source_1.singleWord("mixed"), _boolType => Source_1.singleWord("bool"), _integerType => Source_1.singleWord("int"), _doubleType => Source_1.singleWord("float"), _stringType => Source_1.singleWord("string"), arrayType => Source_1.singleWord(["array(", this.sourceFor(arrayType.items).source, ")"]), _classType => Source_1.singleWord(this.nameForNamedType(_classType)), mapType => {
|
|
126
|
+
return (0, TypeUtils_1.matchType)(t, _anyType => (0, Source_1.singleWord)("mixed"), _nullType => (0, Source_1.singleWord)("mixed"), _boolType => (0, Source_1.singleWord)("bool"), _integerType => (0, Source_1.singleWord)("int"), _doubleType => (0, Source_1.singleWord)("float"), _stringType => (0, Source_1.singleWord)("string"), arrayType => (0, Source_1.singleWord)(["array(", this.sourceFor(arrayType.items).source, ")"]), _classType => (0, Source_1.singleWord)(this.nameForNamedType(_classType)), mapType => {
|
|
126
127
|
let valueSource;
|
|
127
128
|
const v = mapType.values;
|
|
128
129
|
valueSource = this.sourceFor(v).source;
|
|
129
|
-
return Source_1.singleWord(["mapping(string:", valueSource, ")"]);
|
|
130
|
-
}, _enumType => Source_1.singleWord("enum"), unionType => {
|
|
131
|
-
if (TypeUtils_1.nullableFromUnion(unionType) !== null) {
|
|
132
|
-
const children = Array.from(unionType.getChildren()).map(c => Source_1.parenIfNeeded(this.sourceFor(c)));
|
|
133
|
-
return Source_1.multiWord("|", ...children);
|
|
130
|
+
return (0, Source_1.singleWord)(["mapping(string:", valueSource, ")"]);
|
|
131
|
+
}, _enumType => (0, Source_1.singleWord)("enum"), unionType => {
|
|
132
|
+
if ((0, TypeUtils_1.nullableFromUnion)(unionType) !== null) {
|
|
133
|
+
const children = Array.from(unionType.getChildren()).map(c => (0, Source_1.parenIfNeeded)(this.sourceFor(c)));
|
|
134
|
+
return (0, Source_1.multiWord)("|", ...children);
|
|
134
135
|
}
|
|
135
136
|
else {
|
|
136
|
-
return Source_1.singleWord(this.nameForNamedType(unionType));
|
|
137
|
+
return (0, Source_1.singleWord)(this.nameForNamedType(unionType));
|
|
137
138
|
}
|
|
138
139
|
});
|
|
139
140
|
}
|
|
@@ -152,7 +153,7 @@ class PikeRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
152
153
|
let table = [];
|
|
153
154
|
this.forEachEnumCase(e, "none", (name, jsonName) => {
|
|
154
155
|
table.push([
|
|
155
|
-
[name, ' = "', Strings_1.stringEscape(jsonName), '", '],
|
|
156
|
+
[name, ' = "', (0, Strings_1.stringEscape)(jsonName), '", '],
|
|
156
157
|
['// json: "', jsonName, '"']
|
|
157
158
|
]);
|
|
158
159
|
});
|
|
@@ -160,12 +161,12 @@ class PikeRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
160
161
|
});
|
|
161
162
|
}
|
|
162
163
|
emitUnion(u, unionName) {
|
|
163
|
-
const isMaybeWithSingleType = TypeUtils_1.nullableFromUnion(u);
|
|
164
|
+
const isMaybeWithSingleType = (0, TypeUtils_1.nullableFromUnion)(u);
|
|
164
165
|
if (isMaybeWithSingleType !== null) {
|
|
165
166
|
return;
|
|
166
167
|
}
|
|
167
168
|
this.emitDescription(this.descriptionForType(u));
|
|
168
|
-
const [, nonNulls] = TypeUtils_1.removeNullFromUnion(u);
|
|
169
|
+
const [, nonNulls] = (0, TypeUtils_1.removeNullFromUnion)(u);
|
|
169
170
|
let types = [];
|
|
170
171
|
this.forEachUnionMember(u, nonNulls, "none", null, (_name, t) => {
|
|
171
172
|
const pikeType = this.sourceFor(t).source;
|
|
@@ -253,7 +254,7 @@ class PikeRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
253
254
|
this.emitBlock(["string encode_json()"], () => {
|
|
254
255
|
this.emitMappingBlock(["mapping(string:mixed) json = "], () => {
|
|
255
256
|
this.forEachClassProperty(c, "none", (name, jsonName) => {
|
|
256
|
-
this.emitLine(['"', Strings_1.stringEscape(jsonName), '" : ', name, ","]);
|
|
257
|
+
this.emitLine(['"', (0, Strings_1.stringEscape)(jsonName), '" : ', name, ","]);
|
|
257
258
|
});
|
|
258
259
|
});
|
|
259
260
|
this.ensureBlankLine();
|
|
@@ -265,7 +266,7 @@ class PikeRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
265
266
|
this.emitLine([className, " retval = ", className, "();"]);
|
|
266
267
|
this.ensureBlankLine();
|
|
267
268
|
this.forEachClassProperty(c, "none", (name, jsonName) => {
|
|
268
|
-
this.emitLine(["retval.", name, ' = json["', Strings_1.stringEscape(jsonName), '"];']);
|
|
269
|
+
this.emitLine(["retval.", name, ' = json["', (0, Strings_1.stringEscape)(jsonName), '"];']);
|
|
269
270
|
});
|
|
270
271
|
this.ensureBlankLine();
|
|
271
272
|
this.emitLine(["return retval;"]);
|
|
@@ -7,7 +7,7 @@ import { ConvenienceRenderer, ForbiddenWordsInfo } from "../ConvenienceRenderer"
|
|
|
7
7
|
import { Namer, Name, DependencyName } from "../Naming";
|
|
8
8
|
import { Sourcelike, MultiWord } from "../Source";
|
|
9
9
|
import { Transformer } from "../Transformers";
|
|
10
|
-
export
|
|
10
|
+
export type PythonFeatures = {
|
|
11
11
|
typeHints: boolean;
|
|
12
12
|
dataClasses: boolean;
|
|
13
13
|
};
|
|
@@ -18,9 +18,9 @@ export declare const pythonOptions: {
|
|
|
18
18
|
};
|
|
19
19
|
export declare class PythonTargetLanguage extends TargetLanguage {
|
|
20
20
|
protected getOptions(): Option<any>[];
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
get stringTypeMapping(): StringTypeMapping;
|
|
22
|
+
get supportsUnionsWithBothNumberTypes(): boolean;
|
|
23
|
+
get supportsOptionalClassProperties(): boolean;
|
|
24
24
|
needsTransformerForType(t: Type): boolean;
|
|
25
25
|
protected makeRenderer(renderContext: RenderContext, untypedOptionValues: {
|
|
26
26
|
[name: string]: any;
|
|
@@ -37,9 +37,9 @@ export declare class PythonRenderer extends ConvenienceRenderer {
|
|
|
37
37
|
protected namerForObjectProperty(): Namer;
|
|
38
38
|
protected makeUnionMemberNamer(): null;
|
|
39
39
|
protected makeEnumCaseNamer(): Namer;
|
|
40
|
-
protected
|
|
40
|
+
protected get commentLineStart(): string;
|
|
41
41
|
protected emitDescriptionBlock(lines: Sourcelike[]): void;
|
|
42
|
-
protected
|
|
42
|
+
protected get needsTypeDeclarationBeforeUse(): boolean;
|
|
43
43
|
protected canBeForwardDeclared(t: Type): boolean;
|
|
44
44
|
protected emitBlock(line: Sourcelike, f: () => void): void;
|
|
45
45
|
protected string(s: string): Sourcelike;
|
|
@@ -61,8 +61,8 @@ export declare class PythonRenderer extends ConvenienceRenderer {
|
|
|
61
61
|
protected emitClosingCode(): void;
|
|
62
62
|
protected emitSourceStructure(_givenOutputFilename: string): void;
|
|
63
63
|
}
|
|
64
|
-
export
|
|
65
|
-
export
|
|
64
|
+
export type ConverterFunction = "none" | "bool" | "int" | "from-float" | "to-float" | "str" | "to-enum" | "list" | "to-class" | "dict" | "union" | "from-datetime" | "from-stringified-bool" | "is-type";
|
|
65
|
+
export type ValueOrLambda = {
|
|
66
66
|
value: Sourcelike | undefined;
|
|
67
67
|
lambda?: MultiWord;
|
|
68
68
|
};
|