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,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ObjectiveCRenderer = exports.ObjectiveCTargetLanguage = exports.objcOptions = void 0;
|
|
3
4
|
const collection_utils_1 = require("collection-utils");
|
|
4
5
|
const TargetLanguage_1 = require("../TargetLanguage");
|
|
5
6
|
const Type_1 = require("../Type");
|
|
@@ -38,14 +39,14 @@ class ObjectiveCTargetLanguage extends TargetLanguage_1.TargetLanguage {
|
|
|
38
39
|
];
|
|
39
40
|
}
|
|
40
41
|
makeRenderer(renderContext, untypedOptionValues) {
|
|
41
|
-
return new ObjectiveCRenderer(this, renderContext, RendererOptions_1.getOptionValues(exports.objcOptions, untypedOptionValues));
|
|
42
|
+
return new ObjectiveCRenderer(this, renderContext, (0, RendererOptions_1.getOptionValues)(exports.objcOptions, untypedOptionValues));
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
45
|
exports.ObjectiveCTargetLanguage = ObjectiveCTargetLanguage;
|
|
45
46
|
function typeNameStyle(prefix, original) {
|
|
46
|
-
const words = Strings_1.splitIntoWords(original);
|
|
47
|
-
const result = Strings_1.combineWords(words, legalizeName, Strings_1.firstUpperWordStyle, Strings_1.firstUpperWordStyle, Strings_1.allUpperWordStyle, Strings_1.allUpperWordStyle, "", isStartCharacter);
|
|
48
|
-
return Strings_1.addPrefixIfNecessary(prefix, result);
|
|
47
|
+
const words = (0, Strings_1.splitIntoWords)(original);
|
|
48
|
+
const result = (0, Strings_1.combineWords)(words, legalizeName, Strings_1.firstUpperWordStyle, Strings_1.firstUpperWordStyle, Strings_1.allUpperWordStyle, Strings_1.allUpperWordStyle, "", isStartCharacter);
|
|
49
|
+
return (0, Strings_1.addPrefixIfNecessary)(prefix, result);
|
|
49
50
|
}
|
|
50
51
|
function propertyNameStyle(original, isBool = false) {
|
|
51
52
|
// Objective-C developers are uncomfortable with property "id"
|
|
@@ -53,7 +54,7 @@ function propertyNameStyle(original, isBool = false) {
|
|
|
53
54
|
if (original === "id") {
|
|
54
55
|
original = "identifier";
|
|
55
56
|
}
|
|
56
|
-
let words = Strings_1.splitIntoWords(original);
|
|
57
|
+
let words = (0, Strings_1.splitIntoWords)(original);
|
|
57
58
|
if (isBool) {
|
|
58
59
|
if (words.length === 0) {
|
|
59
60
|
words = [{ word: "flag", isAcronym: false }];
|
|
@@ -67,7 +68,7 @@ function propertyNameStyle(original, isBool = false) {
|
|
|
67
68
|
if (words.length > 0 && forbiddenPropertyNames.indexOf(words[0].word) >= 0) {
|
|
68
69
|
words = [{ word: "the", isAcronym: false }, ...words];
|
|
69
70
|
}
|
|
70
|
-
return Strings_1.combineWords(words, legalizeName, Strings_1.allLowerWordStyle, Strings_1.firstUpperWordStyle, Strings_1.allLowerWordStyle, Strings_1.allUpperWordStyle, "", isStartCharacter);
|
|
71
|
+
return (0, Strings_1.combineWords)(words, legalizeName, Strings_1.allLowerWordStyle, Strings_1.firstUpperWordStyle, Strings_1.allLowerWordStyle, Strings_1.allUpperWordStyle, "", isStartCharacter);
|
|
71
72
|
}
|
|
72
73
|
const keywords = [
|
|
73
74
|
/*
|
|
@@ -156,7 +157,7 @@ function isPartCharacter(utf16Unit) {
|
|
|
156
157
|
const category = unicode.getCategory(utf16Unit);
|
|
157
158
|
return ["Nd", "Pc", "Mn", "Mc"].indexOf(category) >= 0 || isStartCharacter(utf16Unit);
|
|
158
159
|
}
|
|
159
|
-
const legalizeName = Strings_1.utf16LegalizeCharacters(isPartCharacter);
|
|
160
|
+
const legalizeName = (0, Strings_1.utf16LegalizeCharacters)(isPartCharacter);
|
|
160
161
|
const staticEnumValuesIdentifier = "values";
|
|
161
162
|
const forbiddenForEnumCases = ["new", staticEnumValuesIdentifier];
|
|
162
163
|
function splitExtension(filename) {
|
|
@@ -166,12 +167,15 @@ function splitExtension(filename) {
|
|
|
166
167
|
return [filename, extension === undefined ? "m" : extension];
|
|
167
168
|
}
|
|
168
169
|
class ObjectiveCRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
170
|
+
_options;
|
|
171
|
+
_currentFilename;
|
|
172
|
+
_classPrefix;
|
|
169
173
|
constructor(targetLanguage, renderContext, _options) {
|
|
170
174
|
super(targetLanguage, renderContext);
|
|
171
175
|
this._options = _options;
|
|
172
176
|
// Infer the class prefix from a top-level name if it's not given
|
|
173
177
|
if (_options.classPrefix === DEFAULT_CLASS_PREFIX) {
|
|
174
|
-
const aTopLevel = Support_1.defined(collection_utils_1.iterableFirst(this.topLevels.keys()));
|
|
178
|
+
const aTopLevel = (0, Support_1.defined)((0, collection_utils_1.iterableFirst)(this.topLevels.keys()));
|
|
175
179
|
this._classPrefix = this.inferClassPrefix(aTopLevel);
|
|
176
180
|
}
|
|
177
181
|
else {
|
|
@@ -181,7 +185,7 @@ class ObjectiveCRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
181
185
|
inferClassPrefix(name) {
|
|
182
186
|
const l = name.length;
|
|
183
187
|
let firstNonUpper = 0;
|
|
184
|
-
while (firstNonUpper < l && Strings_1.fastIsUpperCase(name.charCodeAt(firstNonUpper))) {
|
|
188
|
+
while (firstNonUpper < l && (0, Strings_1.fastIsUpperCase)(name.charCodeAt(firstNonUpper))) {
|
|
185
189
|
firstNonUpper += 1;
|
|
186
190
|
}
|
|
187
191
|
if (firstNonUpper < 2)
|
|
@@ -198,7 +202,7 @@ class ObjectiveCRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
198
202
|
return { names: forbiddenForEnumCases, includeGlobalForbidden: true };
|
|
199
203
|
}
|
|
200
204
|
makeNamedTypeNamer() {
|
|
201
|
-
return Naming_1.funPrefixNamer("types", rawName => typeNameStyle(this._classPrefix, rawName));
|
|
205
|
+
return (0, Naming_1.funPrefixNamer)("types", rawName => typeNameStyle(this._classPrefix, rawName));
|
|
202
206
|
}
|
|
203
207
|
namerForObjectProperty(_, p) {
|
|
204
208
|
// TODO why is underscore being removed?
|
|
@@ -241,52 +245,52 @@ class ObjectiveCRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
241
245
|
}
|
|
242
246
|
}
|
|
243
247
|
startFile(basename, extension) {
|
|
244
|
-
Support_1.assert(this._currentFilename === undefined, "Previous file wasn't finished");
|
|
248
|
+
(0, Support_1.assert)(this._currentFilename === undefined, "Previous file wasn't finished");
|
|
245
249
|
// FIXME: The filenames should actually be Sourcelikes, too
|
|
246
250
|
this._currentFilename = `${this.sourcelikeToString(basename)}.${extension}`;
|
|
247
251
|
}
|
|
248
252
|
finishFile() {
|
|
249
|
-
super.finishFile(Support_1.defined(this._currentFilename));
|
|
253
|
+
super.finishFile((0, Support_1.defined)(this._currentFilename));
|
|
250
254
|
this._currentFilename = undefined;
|
|
251
255
|
}
|
|
252
256
|
memoryAttribute(t, isNullable) {
|
|
253
|
-
return TypeUtils_1.matchType(t, _anyType => "copy", _nullType => "copy", _boolType => (isNullable ? "strong" : "assign"), _integerType => (isNullable ? "strong" : "assign"), _doubleType => (isNullable ? "strong" : "assign"), _stringType => "copy", _arrayType => "copy", _classType => "strong", _mapType => "copy", _enumType => "assign", unionType => {
|
|
254
|
-
const nullable = TypeUtils_1.nullableFromUnion(unionType);
|
|
257
|
+
return (0, TypeUtils_1.matchType)(t, _anyType => "copy", _nullType => "copy", _boolType => (isNullable ? "strong" : "assign"), _integerType => (isNullable ? "strong" : "assign"), _doubleType => (isNullable ? "strong" : "assign"), _stringType => "copy", _arrayType => "copy", _classType => "strong", _mapType => "copy", _enumType => "assign", unionType => {
|
|
258
|
+
const nullable = (0, TypeUtils_1.nullableFromUnion)(unionType);
|
|
255
259
|
return nullable !== null ? this.memoryAttribute(nullable, true) : "copy";
|
|
256
260
|
});
|
|
257
261
|
}
|
|
258
262
|
objcType(t, nullableOrBoxed = false) {
|
|
259
|
-
return TypeUtils_1.matchType(t, _anyType => ["id", ""],
|
|
263
|
+
return (0, TypeUtils_1.matchType)(t, _anyType => ["id", ""],
|
|
260
264
|
// For now, we're treating nulls just like any
|
|
261
265
|
_nullType => ["id", ""], _boolType => (nullableOrBoxed ? ["NSNumber", " *"] : ["BOOL", ""]), _integerType => (nullableOrBoxed ? ["NSNumber", " *"] : ["NSInteger", ""]), _doubleType => (nullableOrBoxed ? ["NSNumber", " *"] : ["double", ""]), _stringType => ["NSString", " *"], arrayType => {
|
|
262
266
|
const itemType = arrayType.items;
|
|
263
267
|
const itemTypeName = this.objcType(itemType, true);
|
|
264
268
|
// NSArray<id>* === NSArray*
|
|
265
|
-
if (TypeUtils_1.isAnyOrNull(itemType)) {
|
|
269
|
+
if ((0, TypeUtils_1.isAnyOrNull)(itemType)) {
|
|
266
270
|
return ["NSArray", " *"];
|
|
267
271
|
}
|
|
268
272
|
return [["NSArray<", itemTypeName, ">"], " *"];
|
|
269
273
|
}, classType => [this.nameForNamedType(classType), " *"], mapType => [["NSDictionary<NSString *, ", this.objcType(mapType.values, true), ">"], " *"], enumType => [this.nameForNamedType(enumType), " *"], unionType => {
|
|
270
|
-
const nullable = TypeUtils_1.nullableFromUnion(unionType);
|
|
274
|
+
const nullable = (0, TypeUtils_1.nullableFromUnion)(unionType);
|
|
271
275
|
return nullable !== null ? this.objcType(nullable, true) : ["id", ""];
|
|
272
276
|
});
|
|
273
277
|
}
|
|
274
278
|
jsonType(t) {
|
|
275
|
-
return TypeUtils_1.matchType(t, _anyType => ["id", ""],
|
|
279
|
+
return (0, TypeUtils_1.matchType)(t, _anyType => ["id", ""],
|
|
276
280
|
// For now, we're treating nulls just like any
|
|
277
281
|
_nullType => ["id", ""], _boolType => ["NSNumber", " *"], _integerType => ["NSNumber", " *"], _doubleType => ["NSNumber", " *"], _stringType => ["NSString", " *"], _arrayType => ["NSArray", " *"], _classType => ["NSDictionary<NSString *, id>", " *"], mapType => [["NSDictionary<NSString *, ", this.jsonType(mapType.values), ">"], " *"], _enumType => ["NSString", " *"], unionType => {
|
|
278
|
-
const nullable = TypeUtils_1.nullableFromUnion(unionType);
|
|
282
|
+
const nullable = (0, TypeUtils_1.nullableFromUnion)(unionType);
|
|
279
283
|
return nullable !== null ? this.jsonType(nullable) : ["id", ""];
|
|
280
284
|
});
|
|
281
285
|
}
|
|
282
286
|
fromDynamicExpression(t, ...dynamic) {
|
|
283
|
-
return TypeUtils_1.matchType(t, _anyType => dynamic, _nullType => dynamic, _boolType => dynamic, _integerType => dynamic, _doubleType => dynamic, _stringType => dynamic, arrayType => ["map(", dynamic, ", λ(id x, ", this.fromDynamicExpression(arrayType.items, "x"), "))"], classType => ["[", this.nameForNamedType(classType), " fromJSONDictionary:", dynamic, "]"], mapType => ["map(", dynamic, ", λ(id x, ", this.fromDynamicExpression(mapType.values, "x"), "))"], enumType => ["[", this.nameForNamedType(enumType), " withValue:", dynamic, "]"], unionType => {
|
|
284
|
-
const nullable = TypeUtils_1.nullableFromUnion(unionType);
|
|
287
|
+
return (0, TypeUtils_1.matchType)(t, _anyType => dynamic, _nullType => dynamic, _boolType => dynamic, _integerType => dynamic, _doubleType => dynamic, _stringType => dynamic, arrayType => ["map(", dynamic, ", λ(id x, ", this.fromDynamicExpression(arrayType.items, "x"), "))"], classType => ["[", this.nameForNamedType(classType), " fromJSONDictionary:", dynamic, "]"], mapType => ["map(", dynamic, ", λ(id x, ", this.fromDynamicExpression(mapType.values, "x"), "))"], enumType => ["[", this.nameForNamedType(enumType), " withValue:", dynamic, "]"], unionType => {
|
|
288
|
+
const nullable = (0, TypeUtils_1.nullableFromUnion)(unionType);
|
|
285
289
|
return nullable !== null ? this.fromDynamicExpression(nullable, dynamic) : dynamic;
|
|
286
290
|
});
|
|
287
291
|
}
|
|
288
292
|
toDynamicExpression(t, typed) {
|
|
289
|
-
return TypeUtils_1.matchType(t, _anyType => ["NSNullify(", typed, ")"], _nullType => ["NSNullify(", typed, ")"],
|
|
293
|
+
return (0, TypeUtils_1.matchType)(t, _anyType => ["NSNullify(", typed, ")"], _nullType => ["NSNullify(", typed, ")"],
|
|
290
294
|
// Sadly, KVC
|
|
291
295
|
_boolType => [typed, ` ? @YES : @NO`], _integerType => typed, _doubleType => typed, _stringType => typed, arrayType => {
|
|
292
296
|
if (this.implicitlyConvertsFromJSON(arrayType)) {
|
|
@@ -301,7 +305,7 @@ class ObjectiveCRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
301
305
|
}
|
|
302
306
|
return ["map(", typed, ", λ(id x, ", this.toDynamicExpression(mapType.values, "x"), "))"];
|
|
303
307
|
}, _enumType => ["[", typed, " value]"], unionType => {
|
|
304
|
-
const nullable = TypeUtils_1.nullableFromUnion(unionType);
|
|
308
|
+
const nullable = (0, TypeUtils_1.nullableFromUnion)(unionType);
|
|
305
309
|
if (nullable !== null) {
|
|
306
310
|
if (this.implicitlyConvertsFromJSON(nullable)) {
|
|
307
311
|
return ["NSNullify(", typed, ")"];
|
|
@@ -333,7 +337,7 @@ class ObjectiveCRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
333
337
|
return true;
|
|
334
338
|
}
|
|
335
339
|
else if (t instanceof Type_1.UnionType) {
|
|
336
|
-
const nullable = TypeUtils_1.nullableFromUnion(t);
|
|
340
|
+
const nullable = (0, TypeUtils_1.nullableFromUnion)(t);
|
|
337
341
|
if (nullable !== null) {
|
|
338
342
|
return this.implicitlyConvertsFromJSON(nullable);
|
|
339
343
|
}
|
|
@@ -351,11 +355,11 @@ class ObjectiveCRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
351
355
|
}
|
|
352
356
|
emitPropertyAssignment(propertyName, jsonName, propertyType) {
|
|
353
357
|
const name = ["_", propertyName];
|
|
354
|
-
TypeUtils_1.matchType(propertyType, anyType => this.emitLine(name, " = ", this.fromDynamicExpression(anyType, name), ";"), nullType => this.emitLine(name, " = ", this.fromDynamicExpression(nullType, name), ";"), boolType => this.emitLine(name, " = ", this.fromDynamicExpression(boolType, name), ";"), integerType => this.emitLine(name, " = ", this.fromDynamicExpression(integerType, name), ";"), doubleType => this.emitLine(name, " = ", this.fromDynamicExpression(doubleType, name), ";"), stringType => this.emitLine(name, " = ", this.fromDynamicExpression(stringType, name), ";"), arrayType => this.emitLine(name, " = ", this.fromDynamicExpression(arrayType, name), ";"), classType => this.emitLine(name, " = ", this.fromDynamicExpression(classType, ["(id)", name]), ";"), mapType => {
|
|
358
|
+
(0, TypeUtils_1.matchType)(propertyType, anyType => this.emitLine(name, " = ", this.fromDynamicExpression(anyType, name), ";"), nullType => this.emitLine(name, " = ", this.fromDynamicExpression(nullType, name), ";"), boolType => this.emitLine(name, " = ", this.fromDynamicExpression(boolType, name), ";"), integerType => this.emitLine(name, " = ", this.fromDynamicExpression(integerType, name), ";"), doubleType => this.emitLine(name, " = ", this.fromDynamicExpression(doubleType, name), ";"), stringType => this.emitLine(name, " = ", this.fromDynamicExpression(stringType, name), ";"), arrayType => this.emitLine(name, " = ", this.fromDynamicExpression(arrayType, name), ";"), classType => this.emitLine(name, " = ", this.fromDynamicExpression(classType, ["(id)", name]), ";"), mapType => {
|
|
355
359
|
const itemType = mapType.values;
|
|
356
360
|
this.emitLine(name, " = map(", name, ", ", ["λ(id x, ", this.fromDynamicExpression(itemType, "x"), ")"], ");");
|
|
357
361
|
}, enumType => this.emitLine(name, " = ", this.fromDynamicExpression(enumType, ["(id)", name]), ";"), unionType => {
|
|
358
|
-
const nullable = TypeUtils_1.nullableFromUnion(unionType);
|
|
362
|
+
const nullable = (0, TypeUtils_1.nullableFromUnion)(unionType);
|
|
359
363
|
if (nullable !== null) {
|
|
360
364
|
this.emitPropertyAssignment(propertyName, jsonName, nullable);
|
|
361
365
|
}
|
|
@@ -388,12 +392,12 @@ class ObjectiveCRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
388
392
|
}
|
|
389
393
|
topLevelToDataPrototype(name, pad = false) {
|
|
390
394
|
const parameter = this.variableNameForTopLevel(name);
|
|
391
|
-
const padding = pad ? Strings_1.repeatString(" ", this.sourcelikeToString(name).length - "NSData".length) : "";
|
|
395
|
+
const padding = pad ? (0, Strings_1.repeatString)(" ", this.sourcelikeToString(name).length - "NSData".length) : "";
|
|
392
396
|
return ["NSData", padding, " *_Nullable ", name, "ToData(", name, " *", parameter, ", NSError **error)"];
|
|
393
397
|
}
|
|
394
398
|
topLevelToJSONPrototype(name, pad = false) {
|
|
395
399
|
const parameter = this.variableNameForTopLevel(name);
|
|
396
|
-
const padding = pad ? Strings_1.repeatString(" ", this.sourcelikeToString(name).length - "NSString".length) : "";
|
|
400
|
+
const padding = pad ? (0, Strings_1.repeatString)(" ", this.sourcelikeToString(name).length - "NSString".length) : "";
|
|
397
401
|
return [
|
|
398
402
|
"NSString",
|
|
399
403
|
padding,
|
|
@@ -450,7 +454,7 @@ class ObjectiveCRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
450
454
|
});
|
|
451
455
|
}
|
|
452
456
|
emitClassInterface(t, className) {
|
|
453
|
-
const isTopLevel = collection_utils_1.mapContains(this.topLevels, t);
|
|
457
|
+
const isTopLevel = (0, collection_utils_1.mapContains)(this.topLevels, t);
|
|
454
458
|
this.emitDescription(this.descriptionForType(t));
|
|
455
459
|
this.emitLine("@interface ", className, " : NSObject");
|
|
456
460
|
if (DEBUG)
|
|
@@ -481,7 +485,7 @@ class ObjectiveCRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
481
485
|
hasIrregularProperties(t) {
|
|
482
486
|
let irregular = false;
|
|
483
487
|
this.forEachClassProperty(t, "none", (name, jsonName) => {
|
|
484
|
-
irregular = irregular || Strings_1.stringEscape(jsonName) !== this.sourcelikeToString(name);
|
|
488
|
+
irregular = irregular || (0, Strings_1.stringEscape)(jsonName) !== this.sourcelikeToString(name);
|
|
485
489
|
});
|
|
486
490
|
return irregular;
|
|
487
491
|
}
|
|
@@ -494,7 +498,7 @@ class ObjectiveCRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
494
498
|
}
|
|
495
499
|
// TODO Implement NSCopying
|
|
496
500
|
emitClassImplementation(t, className) {
|
|
497
|
-
const isTopLevel = collection_utils_1.mapContains(this.topLevels, t);
|
|
501
|
+
const isTopLevel = (0, collection_utils_1.mapContains)(this.topLevels, t);
|
|
498
502
|
const hasIrregularProperties = this.hasIrregularProperties(t);
|
|
499
503
|
const hasUnsafeProperties = this.hasUnsafeProperties(t);
|
|
500
504
|
this.emitLine("@implementation ", className);
|
|
@@ -503,7 +507,7 @@ class ObjectiveCRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
503
507
|
this.emitLine("static NSDictionary<NSString *, NSString *> *properties;");
|
|
504
508
|
this.emitLine("return properties = properties ? properties : @{");
|
|
505
509
|
this.indent(() => {
|
|
506
|
-
this.forEachClassProperty(t, "none", (name, jsonName) => this.emitLine(`@"${Strings_1.stringEscape(jsonName)}": @"`, name, `",`));
|
|
510
|
+
this.forEachClassProperty(t, "none", (name, jsonName) => this.emitLine(`@"${(0, Strings_1.stringEscape)(jsonName)}": @"`, name, `",`));
|
|
507
511
|
});
|
|
508
512
|
this.emitLine("};");
|
|
509
513
|
});
|
|
@@ -573,7 +577,7 @@ class ObjectiveCRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
573
577
|
this.indent(() => {
|
|
574
578
|
this.forEachClassProperty(t, "none", (propertyName, jsonKey, property) => {
|
|
575
579
|
if (!this.implicitlyConvertsToJSON(property.type)) {
|
|
576
|
-
const key = Strings_1.stringEscape(jsonKey);
|
|
580
|
+
const key = (0, Strings_1.stringEscape)(jsonKey);
|
|
577
581
|
const name = ["_", propertyName];
|
|
578
582
|
this.emitLine('@"', key, '": ', this.toDynamicExpression(property.type, name), ",");
|
|
579
583
|
}
|
|
@@ -603,11 +607,11 @@ class ObjectiveCRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
603
607
|
this.ensureBlankLine();
|
|
604
608
|
}
|
|
605
609
|
variableNameForTopLevel(name) {
|
|
606
|
-
const camelCaseName = Source_1.modifySource(serialized => {
|
|
610
|
+
const camelCaseName = (0, Source_1.modifySource)(serialized => {
|
|
607
611
|
// 1. remove class prefix
|
|
608
612
|
serialized = serialized.slice(this._classPrefix.length);
|
|
609
613
|
// 2. camel case
|
|
610
|
-
return Strings_1.camelCase(serialized);
|
|
614
|
+
return (0, Strings_1.camelCase)(serialized);
|
|
611
615
|
}, name);
|
|
612
616
|
return camelCaseName;
|
|
613
617
|
}
|
|
@@ -629,7 +633,7 @@ class ObjectiveCRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
629
633
|
this.emitLine("return ", staticEnumValuesIdentifier, " = ", staticEnumValuesIdentifier, " ? ", staticEnumValuesIdentifier, " : @{");
|
|
630
634
|
this.indent(() => {
|
|
631
635
|
this.forEachEnumCase(enumType, "none", (_, jsonValue) => {
|
|
632
|
-
const value = ['@"', Strings_1.stringEscape(jsonValue), '"'];
|
|
636
|
+
const value = ['@"', (0, Strings_1.stringEscape)(jsonValue), '"'];
|
|
633
637
|
this.emitLine(value, ": [[", enumName, " alloc] initWithValue:", value, "],");
|
|
634
638
|
});
|
|
635
639
|
});
|
|
@@ -637,7 +641,7 @@ class ObjectiveCRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
637
641
|
});
|
|
638
642
|
this.ensureBlankLine();
|
|
639
643
|
this.forEachEnumCase(enumType, "none", (name, jsonValue) => {
|
|
640
|
-
this.emitLine("+ (", enumName, " *)", name, " { return ", instances, '[@"', Strings_1.stringEscape(jsonValue), '"]; }');
|
|
644
|
+
this.emitLine("+ (", enumName, " *)", name, " { return ", instances, '[@"', (0, Strings_1.stringEscape)(jsonValue), '"]; }');
|
|
641
645
|
});
|
|
642
646
|
this.ensureBlankLine();
|
|
643
647
|
this.emitMethod("+ (instancetype _Nullable)withValue:(NSString *)value", () => this.emitLine("return ", instances, "[value];"));
|
|
@@ -654,7 +658,7 @@ class ObjectiveCRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
654
658
|
const fileMode = proposedFilename !== "stdout";
|
|
655
659
|
if (!fileMode) {
|
|
656
660
|
// We don't have a filename, so we use a top-level name
|
|
657
|
-
const firstTopLevel = Support_1.defined(collection_utils_1.mapFirst(this.topLevels));
|
|
661
|
+
const firstTopLevel = (0, Support_1.defined)((0, collection_utils_1.mapFirst)(this.topLevels));
|
|
658
662
|
proposedFilename = this.sourcelikeToString(this.nameForNamedType(firstTopLevel)) + ".m";
|
|
659
663
|
}
|
|
660
664
|
const [filename, extension] = splitExtension(proposedFilename);
|
|
@@ -688,7 +692,7 @@ class ObjectiveCRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
688
692
|
}
|
|
689
693
|
// Emit interfaces for top-level array+maps and classes
|
|
690
694
|
this.forEachTopLevel("leading-and-interposing", (t, n) => this.emitNonClassTopLevelTypedef(t, n), t => !(t instanceof Type_1.ClassType));
|
|
691
|
-
const hasTopLevelNonClassTypes = collection_utils_1.iterableSome(this.topLevels, ([_, t]) => !(t instanceof Type_1.ClassType));
|
|
695
|
+
const hasTopLevelNonClassTypes = (0, collection_utils_1.iterableSome)(this.topLevels, ([_, t]) => !(t instanceof Type_1.ClassType));
|
|
692
696
|
if (!this._options.justTypes && (hasTopLevelNonClassTypes || this._options.marshallingFunctions)) {
|
|
693
697
|
this.ensureBlankLine();
|
|
694
698
|
this.emitMark("Top-level marshaling functions");
|
|
@@ -750,9 +754,9 @@ class ObjectiveCRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
750
754
|
function needsMap(t) {
|
|
751
755
|
return (t instanceof Type_1.MapType ||
|
|
752
756
|
t instanceof Type_1.ArrayType ||
|
|
753
|
-
(t instanceof Type_1.ClassType && collection_utils_1.mapSome(t.getProperties(), p => needsMap(p.type))));
|
|
757
|
+
(t instanceof Type_1.ClassType && (0, collection_utils_1.mapSome)(t.getProperties(), p => needsMap(p.type))));
|
|
754
758
|
}
|
|
755
|
-
return collection_utils_1.iterableSome(this.typeGraph.allTypesUnordered(), needsMap);
|
|
759
|
+
return (0, collection_utils_1.iterableSome)(this.typeGraph.allTypesUnordered(), needsMap);
|
|
756
760
|
}
|
|
757
761
|
emitMapFunction() {
|
|
758
762
|
if (this.needsMap) {
|
|
@@ -17,11 +17,11 @@ export declare const phpOptions: {
|
|
|
17
17
|
export declare class PhpTargetLanguage extends TargetLanguage {
|
|
18
18
|
constructor();
|
|
19
19
|
protected getOptions(): Option<any>[];
|
|
20
|
-
|
|
20
|
+
get supportsUnionsWithBothNumberTypes(): boolean;
|
|
21
21
|
protected makeRenderer(renderContext: RenderContext, untypedOptionValues: {
|
|
22
22
|
[name: string]: any;
|
|
23
23
|
}): PhpRenderer;
|
|
24
|
-
|
|
24
|
+
get stringTypeMapping(): StringTypeMapping;
|
|
25
25
|
}
|
|
26
26
|
export declare const stringEscape: (s: string) => string;
|
|
27
27
|
export declare function phpNameStyle(startWithUpper: boolean, upperUnderscore: boolean, original: string, acronymsStyle?: (s: string) => string): string;
|