quicktype-core 23.0.14 → 23.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.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +6 -2
- package/dist/language/All.js +2 -0
- package/dist/language/CJSON.d.ts +351 -0
- package/dist/language/CJSON.js +2220 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ export { StringTypes } from "./attributes/StringTypes";
|
|
|
28
28
|
export { removeNullFromUnion, matchType, nullableFromUnion } from "./TypeUtils";
|
|
29
29
|
export { ConvenienceRenderer } from "./ConvenienceRenderer";
|
|
30
30
|
export { uriTypeAttributeKind } from "./attributes/URIAttributes";
|
|
31
|
+
export { CJSONTargetLanguage, CJSONRenderer, cJSONOptions } from "./language/CJSON";
|
|
31
32
|
export { CPlusPlusTargetLanguage, CPlusPlusRenderer, cPlusPlusOptions } from "./language/CPlusPlus";
|
|
32
33
|
export { CSharpTargetLanguage, cSharpOptions, CSharpRenderer } from "./language/CSharp";
|
|
33
34
|
export { PythonTargetLanguage, PythonRenderer, pythonOptions } from "./language/Python";
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ClassType = exports.ArrayType = exports.PrimitiveType = exports.Type = exports.messageAssert = exports.messageError = exports.QuickTypeError = exports.trainMarkovChain = exports.isLetterOrDigit = exports.legalizeCharacters = exports.allUpperWordStyle = exports.firstUpperWordStyle = exports.combineWords = exports.capitalize = exports.splitIntoWords = exports.inflateBase64 = exports.checkArray = exports.checkStringMap = exports.parseJSON = exports.assertNever = exports.defined = exports.assert = exports.panic = exports.IssueAnnotationData = exports.Namer = exports.funPrefixNamer = exports.Name = exports.parenIfNeeded = exports.singleWord = exports.modifySource = exports.languageNamed = exports.defaultTargetLanguages = exports.TargetLanguage = exports.getOptionValues = exports.Option = exports.Ref = exports.JSONSchemaInput = exports.jsonInputForTargetLanguage = exports.JSONInput = exports.InputData = exports.CompressedJSON = exports.inferenceFlagsObject = exports.defaultInferenceFlags = exports.inferenceFlagNames = exports.inferenceFlags = exports.combineRenderResults = exports.quicktype = exports.quicktypeMultiFileSync = exports.quicktypeMultiFile = exports.getTargetLanguage = void 0;
|
|
4
|
-
exports.
|
|
5
|
-
exports.dartOptions = exports.DartRenderer = exports.DartTargetLanguage = exports.haskellOptions = exports.HaskellRenderer = exports.HaskellTargetLanguage = exports.CrystalRenderer = exports.CrystalTargetLanguage = exports.rubyOptions = exports.RubyRenderer = exports.RubyTargetLanguage = exports.rustOptions = exports.RustRenderer = exports.RustTargetLanguage = exports.JSONSchemaRenderer = exports.JSONSchemaTargetLanguage = exports.elmOptions = exports.ElmRenderer = exports.ElmTargetLanguage = exports.SmithyOptions = exports.Smithy4sRenderer = exports.SmithyTargetLanguage = exports.scala3Options = exports.Scala3Renderer = exports.Scala3TargetLanguage = exports.kotlinOptions = exports.KotlinRenderer = exports.KotlinTargetLanguage = exports.swiftOptions = exports.SwiftRenderer = exports.SwiftTargetLanguage = exports.tsFlowOptions = exports.FlowRenderer = exports.FlowTargetLanguage = void 0;
|
|
4
|
+
exports.JavaScriptPropTypesRenderer = exports.JavaScriptPropTypesTargetLanguage = exports.javaScriptOptions = exports.JavaScriptRenderer = exports.JavaScriptTargetLanguage = exports.javaOptions = exports.JavaRenderer = exports.JavaTargetLanguage = exports.objcOptions = exports.ObjectiveCRenderer = exports.ObjectiveCTargetLanguage = exports.goOptions = exports.GoRenderer = exports.GoTargetLanguage = exports.pythonOptions = exports.PythonRenderer = exports.PythonTargetLanguage = exports.CSharpRenderer = exports.cSharpOptions = exports.CSharpTargetLanguage = exports.cPlusPlusOptions = exports.CPlusPlusRenderer = exports.CPlusPlusTargetLanguage = exports.cJSONOptions = exports.CJSONRenderer = exports.CJSONTargetLanguage = exports.uriTypeAttributeKind = exports.ConvenienceRenderer = exports.nullableFromUnion = exports.matchType = exports.removeNullFromUnion = exports.StringTypes = exports.namesTypeAttributeKind = exports.makeNamesTypeAttributes = exports.TypeNames = exports.emptyTypeAttributes = exports.TypeAttributeKind = exports.derefTypeRef = exports.TypeBuilder = exports.sourcesFromPostmanCollection = exports.JSONSchemaStore = exports.FetchingJSONSchemaStore = exports.readFromFileOrURL = exports.readableFromFileOrURL = exports.getStream = exports.ObjectType = exports.UnionType = exports.MapType = exports.EnumType = exports.ClassProperty = void 0;
|
|
5
|
+
exports.dartOptions = exports.DartRenderer = exports.DartTargetLanguage = exports.haskellOptions = exports.HaskellRenderer = exports.HaskellTargetLanguage = exports.CrystalRenderer = exports.CrystalTargetLanguage = exports.rubyOptions = exports.RubyRenderer = exports.RubyTargetLanguage = exports.rustOptions = exports.RustRenderer = exports.RustTargetLanguage = exports.JSONSchemaRenderer = exports.JSONSchemaTargetLanguage = exports.elmOptions = exports.ElmRenderer = exports.ElmTargetLanguage = exports.SmithyOptions = exports.Smithy4sRenderer = exports.SmithyTargetLanguage = exports.scala3Options = exports.Scala3Renderer = exports.Scala3TargetLanguage = exports.kotlinOptions = exports.KotlinRenderer = exports.KotlinTargetLanguage = exports.swiftOptions = exports.SwiftRenderer = exports.SwiftTargetLanguage = exports.tsFlowOptions = exports.FlowRenderer = exports.FlowTargetLanguage = exports.TypeScriptRenderer = exports.TypeScriptTargetLanguage = exports.javaScriptPropTypesOptions = void 0;
|
|
6
6
|
var Run_1 = require("./Run");
|
|
7
7
|
Object.defineProperty(exports, "getTargetLanguage", { enumerable: true, get: function () { return Run_1.getTargetLanguage; } });
|
|
8
8
|
Object.defineProperty(exports, "quicktypeMultiFile", { enumerable: true, get: function () { return Run_1.quicktypeMultiFile; } });
|
|
@@ -106,6 +106,10 @@ var ConvenienceRenderer_1 = require("./ConvenienceRenderer");
|
|
|
106
106
|
Object.defineProperty(exports, "ConvenienceRenderer", { enumerable: true, get: function () { return ConvenienceRenderer_1.ConvenienceRenderer; } });
|
|
107
107
|
var URIAttributes_1 = require("./attributes/URIAttributes");
|
|
108
108
|
Object.defineProperty(exports, "uriTypeAttributeKind", { enumerable: true, get: function () { return URIAttributes_1.uriTypeAttributeKind; } });
|
|
109
|
+
var CJSON_1 = require("./language/CJSON");
|
|
110
|
+
Object.defineProperty(exports, "CJSONTargetLanguage", { enumerable: true, get: function () { return CJSON_1.CJSONTargetLanguage; } });
|
|
111
|
+
Object.defineProperty(exports, "CJSONRenderer", { enumerable: true, get: function () { return CJSON_1.CJSONRenderer; } });
|
|
112
|
+
Object.defineProperty(exports, "cJSONOptions", { enumerable: true, get: function () { return CJSON_1.cJSONOptions; } });
|
|
109
113
|
var CPlusPlus_1 = require("./language/CPlusPlus");
|
|
110
114
|
Object.defineProperty(exports, "CPlusPlusTargetLanguage", { enumerable: true, get: function () { return CPlusPlus_1.CPlusPlusTargetLanguage; } });
|
|
111
115
|
Object.defineProperty(exports, "CPlusPlusRenderer", { enumerable: true, get: function () { return CPlusPlus_1.CPlusPlusRenderer; } });
|
package/dist/language/All.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.languageNamed = exports.all = void 0;
|
|
|
4
4
|
const collection_utils_1 = require("collection-utils");
|
|
5
5
|
const CSharp_1 = require("./CSharp");
|
|
6
6
|
const Golang_1 = require("./Golang");
|
|
7
|
+
const CJSON_1 = require("./CJSON");
|
|
7
8
|
const CPlusPlus_1 = require("./CPlusPlus");
|
|
8
9
|
const Objective_C_1 = require("./Objective-C");
|
|
9
10
|
const Java_1 = require("./Java");
|
|
@@ -29,6 +30,7 @@ exports.all = [
|
|
|
29
30
|
new Golang_1.GoTargetLanguage(),
|
|
30
31
|
new Rust_1.RustTargetLanguage(),
|
|
31
32
|
new Crystal_1.CrystalTargetLanguage(),
|
|
33
|
+
new CJSON_1.CJSONTargetLanguage(),
|
|
32
34
|
new CPlusPlus_1.CPlusPlusTargetLanguage(),
|
|
33
35
|
new Objective_C_1.ObjectiveCTargetLanguage(),
|
|
34
36
|
new Java_1.JavaTargetLanguage(),
|
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CJSON.ts
|
|
3
|
+
* This file is used to generate cJSON code with quicktype
|
|
4
|
+
* The generated code depends of https://github.com/DaveGamble/cJSON, https://github.com/joelguittet/c-list and https://github.com/joelguittet/c-hashtable
|
|
5
|
+
*
|
|
6
|
+
* Similarly to C++ generator, it is possible to generate a single header file or multiple header files.
|
|
7
|
+
* To generate multiple header files, use the following option: --source-style multi-source
|
|
8
|
+
*
|
|
9
|
+
* JSON data are represented using structures, and functions in the cJSON style are created to use them.
|
|
10
|
+
* To parse json data from json string use the following: struct <type> * data = cJSON_Parse<type>(<string>);
|
|
11
|
+
* To get json data from cJSON object use the following: struct <type> * data = cJSON_Get<type>Value(<cjson>);
|
|
12
|
+
* To get cJSON object from json data use the following: cJSON * cjson = cJSON_Create<type>(<data>);
|
|
13
|
+
* To print json string from json data use the following: char * string = cJSON_Print<type>(<data>);
|
|
14
|
+
* To delete json data use the following: cJSON_Delete<type>(<data>);
|
|
15
|
+
*
|
|
16
|
+
* TODO list for futur enhancements:
|
|
17
|
+
* - Management of Class, Union and TopLevel should be mutualized to reduce code size and to permit Union and TopLevel having recursive Array/Map
|
|
18
|
+
* - Types check should be added to verify unwanted inputs (for example a Number passed while a String is expected, etc)
|
|
19
|
+
* - Constraints should be implemented (verification of Enum values, min/max values for Numbers and min/max length for Strings, regex)
|
|
20
|
+
* - Support of pure Any type for example providing a callback from the application to handle these cases dynamically
|
|
21
|
+
* See test/languages.ts for the test cases which are not implmented/checked.
|
|
22
|
+
*/
|
|
23
|
+
import { TargetLanguage } from "../TargetLanguage";
|
|
24
|
+
import { Type, TypeKind, ClassType, EnumType, UnionType } from "../Type";
|
|
25
|
+
import { Name, Namer } from "../Naming";
|
|
26
|
+
import { Sourcelike } from "../Source";
|
|
27
|
+
import { NamingStyle } from "../support/Strings";
|
|
28
|
+
import { ConvenienceRenderer, ForbiddenWordsInfo } from "../ConvenienceRenderer";
|
|
29
|
+
import { EnumOption, StringOption, Option, OptionValues } from "../RendererOptions";
|
|
30
|
+
import { RenderContext } from "../Renderer";
|
|
31
|
+
export declare const cJSONOptions: {
|
|
32
|
+
typeSourceStyle: EnumOption<boolean>;
|
|
33
|
+
typeIntegerSize: EnumOption<string>;
|
|
34
|
+
hashtableSize: StringOption;
|
|
35
|
+
typeNamingStyle: EnumOption<NamingStyle>;
|
|
36
|
+
memberNamingStyle: EnumOption<NamingStyle>;
|
|
37
|
+
enumeratorNamingStyle: EnumOption<NamingStyle>;
|
|
38
|
+
};
|
|
39
|
+
export declare class CJSONTargetLanguage extends TargetLanguage {
|
|
40
|
+
/**
|
|
41
|
+
* Constructor
|
|
42
|
+
* @param displayName: display name
|
|
43
|
+
* @params names: names
|
|
44
|
+
* @param extension: extension of files
|
|
45
|
+
*/
|
|
46
|
+
constructor(displayName?: string, names?: string[], extension?: string);
|
|
47
|
+
/**
|
|
48
|
+
* Return cJSON generator options
|
|
49
|
+
* @return cJSON generator options array
|
|
50
|
+
*/
|
|
51
|
+
protected getOptions(): Option<any>[];
|
|
52
|
+
/**
|
|
53
|
+
* Indicate if language support union with both number types
|
|
54
|
+
* @return true
|
|
55
|
+
*/
|
|
56
|
+
get supportsUnionsWithBothNumberTypes(): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Indicate if language support optional class properties
|
|
59
|
+
* @return true
|
|
60
|
+
*/
|
|
61
|
+
get supportsOptionalClassProperties(): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Create renderer
|
|
64
|
+
* @param renderContext: render context
|
|
65
|
+
* @param untypedOptionValues
|
|
66
|
+
* @return cJSON renderer
|
|
67
|
+
*/
|
|
68
|
+
protected makeRenderer(renderContext: RenderContext, untypedOptionValues: {
|
|
69
|
+
[name: string]: any;
|
|
70
|
+
}): CJSONRenderer;
|
|
71
|
+
}
|
|
72
|
+
export declare enum GlobalNames {
|
|
73
|
+
ClassMemberConstraints = 0,
|
|
74
|
+
ClassMemberConstraintException = 1,
|
|
75
|
+
ValueTooLowException = 2,
|
|
76
|
+
ValueTooHighException = 3,
|
|
77
|
+
ValueTooShortException = 4,
|
|
78
|
+
ValueTooLongException = 5,
|
|
79
|
+
InvalidPatternException = 6,
|
|
80
|
+
CheckConstraint = 7
|
|
81
|
+
}
|
|
82
|
+
export declare enum IncludeKind {
|
|
83
|
+
ForwardDeclare = 0,
|
|
84
|
+
Include = 1
|
|
85
|
+
}
|
|
86
|
+
export type IncludeRecord = {
|
|
87
|
+
kind: IncludeKind | undefined;
|
|
88
|
+
typeKind: TypeKind | undefined;
|
|
89
|
+
};
|
|
90
|
+
export type TypeRecord = {
|
|
91
|
+
name: Name;
|
|
92
|
+
type: Type;
|
|
93
|
+
level: number;
|
|
94
|
+
variant: boolean;
|
|
95
|
+
forceInclude: boolean;
|
|
96
|
+
};
|
|
97
|
+
export type IncludeMap = Map<string, IncludeRecord>;
|
|
98
|
+
export type TypeCJSON = {
|
|
99
|
+
cType: Sourcelike;
|
|
100
|
+
optionalQualifier: string;
|
|
101
|
+
cjsonType: string;
|
|
102
|
+
isType: Sourcelike;
|
|
103
|
+
getValue: Sourcelike;
|
|
104
|
+
addToObject: Sourcelike;
|
|
105
|
+
createObject: Sourcelike;
|
|
106
|
+
deleteType: Sourcelike;
|
|
107
|
+
items: TypeCJSON | undefined;
|
|
108
|
+
isNullable: boolean;
|
|
109
|
+
};
|
|
110
|
+
export declare class CJSONRenderer extends ConvenienceRenderer {
|
|
111
|
+
private readonly _options;
|
|
112
|
+
private currentFilename;
|
|
113
|
+
private memberNameStyle;
|
|
114
|
+
private namedTypeNameStyle;
|
|
115
|
+
private forbiddenGlobalNames;
|
|
116
|
+
protected readonly typeIntegerSize: string;
|
|
117
|
+
protected readonly hashtableSize: string;
|
|
118
|
+
protected readonly typeNamingStyle: NamingStyle;
|
|
119
|
+
protected readonly enumeratorNamingStyle: NamingStyle;
|
|
120
|
+
/**
|
|
121
|
+
* Constructor
|
|
122
|
+
* @param targetLanguage: target language
|
|
123
|
+
* @param renderContext: render context
|
|
124
|
+
* @param _options: renderer options
|
|
125
|
+
*/
|
|
126
|
+
constructor(targetLanguage: TargetLanguage, renderContext: RenderContext, _options: OptionValues<typeof cJSONOptions>);
|
|
127
|
+
/**
|
|
128
|
+
* Build forbidden names for namespace
|
|
129
|
+
* @return Forbidden names for namespace
|
|
130
|
+
*/
|
|
131
|
+
protected forbiddenNamesForGlobalNamespace(): string[];
|
|
132
|
+
/**
|
|
133
|
+
* Build forbidden names for enums
|
|
134
|
+
* @return Forbidden names for enums
|
|
135
|
+
*/
|
|
136
|
+
protected forbiddenForEnumCases(_enumType: EnumType, _enumName: Name): ForbiddenWordsInfo;
|
|
137
|
+
/**
|
|
138
|
+
* Build forbidden names for unions members
|
|
139
|
+
* @return Forbidden names for unions members
|
|
140
|
+
*/
|
|
141
|
+
protected forbiddenForUnionMembers(_u: UnionType, _unionName: Name): ForbiddenWordsInfo;
|
|
142
|
+
/**
|
|
143
|
+
* Build forbidden names for objects
|
|
144
|
+
* @return Forbidden names for objects
|
|
145
|
+
*/
|
|
146
|
+
protected forbiddenForObjectProperties(_c: ClassType, _className: Name): ForbiddenWordsInfo;
|
|
147
|
+
/**
|
|
148
|
+
* Build types member names
|
|
149
|
+
* @return types member namer
|
|
150
|
+
*/
|
|
151
|
+
protected makeNamedTypeNamer(): Namer;
|
|
152
|
+
/**
|
|
153
|
+
* Build object properties member names
|
|
154
|
+
* @return object properties member namer
|
|
155
|
+
*/
|
|
156
|
+
protected namerForObjectProperty(): Namer;
|
|
157
|
+
/**
|
|
158
|
+
* Build union member names
|
|
159
|
+
* @return union member namer
|
|
160
|
+
*/
|
|
161
|
+
protected makeUnionMemberNamer(): Namer;
|
|
162
|
+
/**
|
|
163
|
+
* Build enum member names
|
|
164
|
+
* @return enum member namer
|
|
165
|
+
*/
|
|
166
|
+
protected makeEnumCaseNamer(): Namer;
|
|
167
|
+
/**
|
|
168
|
+
* Override of super proposeUnionMemberName function
|
|
169
|
+
* @param unionType: union type
|
|
170
|
+
* @param unionName: union name
|
|
171
|
+
* @param fieldType: field type
|
|
172
|
+
* @param lookup: Lookup function
|
|
173
|
+
* @return Proposed union member name
|
|
174
|
+
*/
|
|
175
|
+
protected proposeUnionMemberName(unionType: UnionType, unionName: Name, fieldType: Type, lookup: (n: Name) => string): string;
|
|
176
|
+
/**
|
|
177
|
+
* Function called to create header file(s)
|
|
178
|
+
* @param proposedFilename: source filename provided from stdin
|
|
179
|
+
*/
|
|
180
|
+
protected emitSourceStructure(proposedFilename: string): void;
|
|
181
|
+
/**
|
|
182
|
+
* Function called to create a single header file with types and generators
|
|
183
|
+
* @param proposedFilename: source filename provided from stdin
|
|
184
|
+
*/
|
|
185
|
+
protected emitSingleSourceStructure(proposedFilename: string): void;
|
|
186
|
+
/**
|
|
187
|
+
* Function called to create a multiple header files with types and generators
|
|
188
|
+
*/
|
|
189
|
+
protected emitMultiSourceStructure(): void;
|
|
190
|
+
/**
|
|
191
|
+
* Function called to create an enum header files with types and generators
|
|
192
|
+
* @param enumType: enum type
|
|
193
|
+
* @param includes: Array of includes
|
|
194
|
+
*/
|
|
195
|
+
protected emitEnum(enumType: EnumType, includes: string[]): void;
|
|
196
|
+
/**
|
|
197
|
+
* Function called to create enum typedef
|
|
198
|
+
* @param enumType: enum type
|
|
199
|
+
*/
|
|
200
|
+
protected emitEnumTypedef(enumType: EnumType): void;
|
|
201
|
+
/**
|
|
202
|
+
* Function called to create enum prototypes
|
|
203
|
+
* @param enumType: enum type
|
|
204
|
+
*/
|
|
205
|
+
protected emitEnumPrototypes(enumType: EnumType): void;
|
|
206
|
+
/**
|
|
207
|
+
* Function called to create enum functions
|
|
208
|
+
* @param enumType: enum type
|
|
209
|
+
*/
|
|
210
|
+
protected emitEnumFunctions(enumType: EnumType): void;
|
|
211
|
+
/**
|
|
212
|
+
* Function called to create a union header files with types and generators
|
|
213
|
+
* @param unionType: union type
|
|
214
|
+
* @param includes: Array of includes
|
|
215
|
+
*/
|
|
216
|
+
protected emitUnion(unionType: UnionType, includes: string[]): void;
|
|
217
|
+
/**
|
|
218
|
+
* Function called to create union typedef
|
|
219
|
+
* @param unionType: union type
|
|
220
|
+
*/
|
|
221
|
+
protected emitUnionTypedef(unionType: UnionType): void;
|
|
222
|
+
/**
|
|
223
|
+
* Function called to create union prototypes
|
|
224
|
+
* @param unionType: union type
|
|
225
|
+
*/
|
|
226
|
+
protected emitUnionPrototypes(unionType: UnionType): void;
|
|
227
|
+
/**
|
|
228
|
+
* Function called to create union functions
|
|
229
|
+
* @param unionType: union type
|
|
230
|
+
*/
|
|
231
|
+
protected emitUnionFunctions(unionType: UnionType): void;
|
|
232
|
+
/**
|
|
233
|
+
* Function called to create a class header files with types and generators
|
|
234
|
+
* @param classType: class type
|
|
235
|
+
* @param includes: Array of includes
|
|
236
|
+
*/
|
|
237
|
+
protected emitClass(classType: ClassType, includes: string[]): void;
|
|
238
|
+
/**
|
|
239
|
+
* Function called to create class typedef
|
|
240
|
+
* @param classType: class type
|
|
241
|
+
*/
|
|
242
|
+
protected emitClassTypedef(classType: ClassType): void;
|
|
243
|
+
/**
|
|
244
|
+
* Function called to create class prototypes
|
|
245
|
+
* @param classType: class type
|
|
246
|
+
*/
|
|
247
|
+
protected emitClassPrototypes(classType: ClassType): void;
|
|
248
|
+
/**
|
|
249
|
+
* Function called to create class functions
|
|
250
|
+
* @param classType: class type
|
|
251
|
+
*/
|
|
252
|
+
protected emitClassFunctions(classType: ClassType): void;
|
|
253
|
+
/**
|
|
254
|
+
* Function called to create a top level header files with types and generators
|
|
255
|
+
* @param type: type of the top level element
|
|
256
|
+
* @param className: top level class name
|
|
257
|
+
* @param includes: Array of includes
|
|
258
|
+
*/
|
|
259
|
+
protected emitTopLevel(type: Type, className: Name, includes: string[]): void;
|
|
260
|
+
/**
|
|
261
|
+
* Function called to create top level typedef
|
|
262
|
+
* @param type: type of the top level element
|
|
263
|
+
* @param className: top level class name
|
|
264
|
+
*/
|
|
265
|
+
protected emitTopLevelTypedef(type: Type, className: Name): void;
|
|
266
|
+
/**
|
|
267
|
+
* Function called to create top level prototypes
|
|
268
|
+
* @param type: type of the top level element
|
|
269
|
+
* @param className: top level class name
|
|
270
|
+
*/
|
|
271
|
+
protected emitTopLevelPrototypes(_type: Type, className: Name): void;
|
|
272
|
+
/**
|
|
273
|
+
* Function called to create top level functions
|
|
274
|
+
* @param type: type of the top level element
|
|
275
|
+
* @param className: top level class name
|
|
276
|
+
*/
|
|
277
|
+
protected emitTopLevelFunctions(type: Type, className: Name): void;
|
|
278
|
+
/**
|
|
279
|
+
* Convert quicktype type to cJSON type
|
|
280
|
+
* @param t: quicktype type
|
|
281
|
+
* @param isOptional: true if the field is optional
|
|
282
|
+
* @param isNullable: true if the field is nullable
|
|
283
|
+
* @return cJSON type
|
|
284
|
+
*/
|
|
285
|
+
protected quicktypeTypeToCJSON(t: Type, isOptional: boolean, isNullable?: boolean): TypeCJSON;
|
|
286
|
+
/**
|
|
287
|
+
* Function called to create a file
|
|
288
|
+
* @param proposedFilename: source filename provided from stdin
|
|
289
|
+
*/
|
|
290
|
+
protected startFile(proposedFilename: Sourcelike): void;
|
|
291
|
+
/**
|
|
292
|
+
* Function called to close current file
|
|
293
|
+
*/
|
|
294
|
+
protected finishFile(): void;
|
|
295
|
+
/**
|
|
296
|
+
* Check if type need declaration before use
|
|
297
|
+
* @note If returning true, canBeForwardDeclared must be declared
|
|
298
|
+
* @return Always returns true
|
|
299
|
+
*/
|
|
300
|
+
protected get needsTypeDeclarationBeforeUse(): boolean;
|
|
301
|
+
/**
|
|
302
|
+
* Check if type can be forward declared
|
|
303
|
+
* @return true for classes, false otherwise
|
|
304
|
+
*/
|
|
305
|
+
protected canBeForwardDeclared(type: Type): boolean;
|
|
306
|
+
/**
|
|
307
|
+
* Add const to wanted Sourcelike
|
|
308
|
+
* @return Const Sourcelike
|
|
309
|
+
*/
|
|
310
|
+
protected withConst(s: Sourcelike): Sourcelike;
|
|
311
|
+
/**
|
|
312
|
+
* Emit include line
|
|
313
|
+
* @param name: filename to include
|
|
314
|
+
* @pram global: true if global include, false otherwise (default)
|
|
315
|
+
*/
|
|
316
|
+
protected emitIncludeLine(name: Sourcelike, global?: boolean): void;
|
|
317
|
+
/**
|
|
318
|
+
* Emit description block
|
|
319
|
+
* @param lines: description block lines
|
|
320
|
+
*/
|
|
321
|
+
protected emitDescriptionBlock(lines: Sourcelike[]): void;
|
|
322
|
+
/**
|
|
323
|
+
* Emit code block
|
|
324
|
+
* @param line: code block line
|
|
325
|
+
* @param f: callback function
|
|
326
|
+
* @param withName: name of the block as string
|
|
327
|
+
* @param withSemicolon: true to add semicolon at the end of the block, false otherwise
|
|
328
|
+
* @param withIndent: true to indent the block (default), false otherwise
|
|
329
|
+
*/
|
|
330
|
+
protected emitBlock(line: Sourcelike, f: () => void, withName?: string, withSemicolon?: boolean, withIndent?: boolean): void;
|
|
331
|
+
/**
|
|
332
|
+
* Emit includes
|
|
333
|
+
* @param type: class, union or enum type
|
|
334
|
+
* @param filename: current file name
|
|
335
|
+
*/
|
|
336
|
+
protected emitIncludes(type: ClassType | UnionType | EnumType, filename: string): void;
|
|
337
|
+
/**
|
|
338
|
+
* Compute includes
|
|
339
|
+
* @param isClassMender: true if class, false otherwise
|
|
340
|
+
* @param includes: include map
|
|
341
|
+
* @param propertyType: property type
|
|
342
|
+
*/
|
|
343
|
+
protected updateIncludes(isClassMember: boolean, includes: IncludeMap, propertyType: Type): void;
|
|
344
|
+
/**
|
|
345
|
+
* Compute generated types
|
|
346
|
+
* @param isClassMender: true if class, false otherwise
|
|
347
|
+
* @param type: type
|
|
348
|
+
* @return Type record array
|
|
349
|
+
*/
|
|
350
|
+
protected generatedTypes(isClassMember: boolean, type: Type): TypeRecord[];
|
|
351
|
+
}
|