@glutinum/cli 1.0.0-beta.2 → 1.0.0-beta.3
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/README.md +16 -0
- package/dist/Glutinum.Converter/Abbreviations.js +9 -32
- package/dist/Glutinum.Converter/DelegateExtensions.js +378 -0
- package/dist/Glutinum.Converter/FreeTypeParameters.js +211 -0
- package/dist/Glutinum.Converter/FsharpAST.js +116 -65
- package/dist/Glutinum.Converter/Generate.js +34 -21
- package/dist/Glutinum.Converter/GlueAST.js +79 -41
- package/dist/Glutinum.Converter/Hosting.js +132 -157
- package/dist/Glutinum.Converter/Merge.js +369 -337
- package/dist/Glutinum.Converter/Packages.js +391 -92
- package/dist/Glutinum.Converter/Printer.js +396 -423
- package/dist/Glutinum.Converter/Read.js +387 -88
- package/dist/Glutinum.Converter/Reader/ClassDeclaration.js +4 -4
- package/dist/Glutinum.Converter/Reader/Declaration.js +6 -12
- package/dist/Glutinum.Converter/Reader/Documentation.js +23 -35
- package/dist/Glutinum.Converter/Reader/ExportAssignment.js +103 -36
- package/dist/Glutinum.Converter/Reader/ExportDeclaration.js +21 -36
- package/dist/Glutinum.Converter/Reader/FunctionDeclaration.js +26 -13
- package/dist/Glutinum.Converter/Reader/IndexedAccessType.js +14 -20
- package/dist/Glutinum.Converter/Reader/InterfaceDeclaration.js +45 -2
- package/dist/Glutinum.Converter/Reader/Node.js +8 -11
- package/dist/Glutinum.Converter/Reader/Parameters.js +34 -26
- package/dist/Glutinum.Converter/Reader/TypeNode.js +1988 -1342
- package/dist/Glutinum.Converter/Reader/TypeOperatorNode.js +32 -44
- package/dist/Glutinum.Converter/Reader/TypeQueryNode.js +14 -37
- package/dist/Glutinum.Converter/Reader/TypeScriptReader.js +23 -5
- package/dist/Glutinum.Converter/Reader/Types.js +290 -15
- package/dist/Glutinum.Converter/Reader/UnionTypeNode.js +14 -28
- package/dist/Glutinum.Converter/Reader/Utils.js +325 -25
- package/dist/Glutinum.Converter/Reader/VariableStatement.js +2 -3
- package/dist/Glutinum.Converter/Transform.js +3568 -8456
- package/dist/Glutinum.Converter/Transformer/AnyFunctionOverloads.js +116 -0
- package/dist/Glutinum.Converter/Transformer/CallableProperties.js +454 -0
- package/dist/Glutinum.Converter/Transformer/Comment.js +136 -0
- package/dist/Glutinum.Converter/Transformer/Conditionals.js +1149 -0
- package/dist/Glutinum.Converter/Transformer/Context.js +666 -0
- package/dist/Glutinum.Converter/Transformer/Enum.js +80 -0
- package/dist/Glutinum.Converter/Transformer/Heritage.js +406 -0
- package/dist/Glutinum.Converter/Transformer/KeyOfMaps.js +488 -0
- package/dist/Glutinum.Converter/Transformer/ParamObjectCandidate.js +596 -0
- package/dist/Glutinum.Converter/Transformer/TypeParameters.js +448 -0
- package/dist/Glutinum.Converter/Transformer/UnionOverloads.js +353 -0
- package/dist/Glutinum.Converter/Transformer/Utils.js +341 -0
- package/dist/Glutinum.Converter/TypeScript.Extensions.js +0 -10
- package/dist/Glutinum.Converter/Utils/String.js +14 -3
- package/dist/Program.js +18 -10
- package/package.json +1 -1
|
@@ -4,15 +4,15 @@ import { StringBuilder__AppendLine, StringBuilder__Append_Z721C83C5, StringBuild
|
|
|
4
4
|
import { class_type } from "../fable_modules/fable-library-js.5.17.2/Reflection.js";
|
|
5
5
|
import { max } from "../fable_modules/fable-library-js.5.17.2/Double.js";
|
|
6
6
|
import { trimStart, interpolate, substring, join, replace, concat, isNullOrWhiteSpace, replicate } from "../fable_modules/fable-library-js.5.17.2/String.js";
|
|
7
|
-
import { isDigit2 } from "../fable_modules/fable-library-js.5.17.2/Char.js";
|
|
8
7
|
import { splitLines, replace as replace_1, removeSingleQuote, removeDoubleQuote, capitalizeFirstLetter } from "./Utils/String.js";
|
|
9
|
-
import {
|
|
8
|
+
import { isDigit2 } from "../fable_modules/fable-library-js.5.17.2/Char.js";
|
|
9
|
+
import { cons, mapIndexed, empty, forAll, ofArray, concat as concat_1, partition, length, singleton, append, choose, filter, iterateIndexed, iterate, isEmpty, map, exists } from "../fable_modules/fable-library-js.5.17.2/List.js";
|
|
10
10
|
import { stringHash, disposeSafe, getEnumerator, int32ToString, Exception } from "../fable_modules/fable-library-js.5.17.2/Util.js";
|
|
11
11
|
import { sanitizeTypeParameterName } from "./Utils/Naming.js";
|
|
12
12
|
import { escape, create, isMatch, replace as replace_2 } from "../fable_modules/fable-library-js.5.17.2/RegExp.js";
|
|
13
13
|
import { removeConsecutiveEmptyLines, trimEmptyLines } from "./Utils/List.js";
|
|
14
|
+
import { FSharpInterface, FSharpAttribute } from "./FsharpAST.js";
|
|
14
15
|
import { singleton as singleton_1, append as append_1, delay, toList } from "../fable_modules/fable-library-js.5.17.2/Seq.js";
|
|
15
|
-
import { FSharpOutFile, FSharpInterface, FSharpAttribute } from "./FsharpAST.js";
|
|
16
16
|
import { List_distinct } from "../fable_modules/fable-library-js.5.17.2/Seq2.js";
|
|
17
17
|
|
|
18
18
|
export class Printer {
|
|
@@ -45,16 +45,14 @@ export function Printer__get_Unindent(__) {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
|
-
* Write the
|
|
48
|
+
* Write the text prefixed with the indentation
|
|
49
49
|
*/
|
|
50
50
|
export function Printer__Write_Z721C83C5(__, text) {
|
|
51
51
|
StringBuilder__Append_Z721C83C5(__.buffer, replicate(__.indentationLevel, __.indentationText) + text);
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
|
-
* Write the
|
|
56
|
-
*
|
|
57
|
-
* Useful when you don't want to prefix the text with indentation
|
|
55
|
+
* Write the text without indentation
|
|
58
56
|
*/
|
|
59
57
|
export function Printer__WriteInline_Z721C83C5(__, text) {
|
|
60
58
|
StringBuilder__Append_Z721C83C5(__.buffer, text);
|
|
@@ -76,21 +74,9 @@ export function Printer__set_ImportSpecifier_Z721C83C5(__, v) {
|
|
|
76
74
|
__["ImportSpecifier@"] = v;
|
|
77
75
|
}
|
|
78
76
|
|
|
79
|
-
export function Naming_$007CDigit$007C_$007C(digit) {
|
|
80
|
-
if (isNullOrWhiteSpace(digit)) {
|
|
81
|
-
return undefined;
|
|
82
|
-
}
|
|
83
|
-
else if (isDigit2(digit, 0)) {
|
|
84
|
-
return digit;
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
return undefined;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
77
|
function sanitizeEnumCaseName(name) {
|
|
92
78
|
const name_1 = capitalizeFirstLetter(removeDoubleQuote(removeSingleQuote(name)));
|
|
93
|
-
if (
|
|
79
|
+
if (!isNullOrWhiteSpace(name_1) && isDigit2(name_1, 0)) {
|
|
94
80
|
return concat("``", name_1, "``");
|
|
95
81
|
}
|
|
96
82
|
else {
|
|
@@ -126,6 +112,10 @@ function caseRulesToText(caseRules) {
|
|
|
126
112
|
}
|
|
127
113
|
}
|
|
128
114
|
|
|
115
|
+
function escapeStringLiteral(text) {
|
|
116
|
+
return replace(replace(replace(replace(replace(text, "\\", "\\\\"), "\"", "\\\""), "\r", "\\r"), "\n", "\\n"), "\t", "\\t");
|
|
117
|
+
}
|
|
118
|
+
|
|
129
119
|
function attributeToText(fsharpAttribute) {
|
|
130
120
|
switch (fsharpAttribute.tag) {
|
|
131
121
|
case 1:
|
|
@@ -143,7 +133,7 @@ function attributeToText(fsharpAttribute) {
|
|
|
143
133
|
case 8:
|
|
144
134
|
return `[<TypeScriptTaggedUnion("${fsharpAttribute.fields[0]}", ${caseRulesToText(fsharpAttribute.fields[1])})>]`;
|
|
145
135
|
case 13:
|
|
146
|
-
return concat("[<CompiledName(\"",
|
|
136
|
+
return concat("[<CompiledName(\"", escapeStringLiteral(fsharpAttribute.fields[0]), "\")>]");
|
|
147
137
|
case 14:
|
|
148
138
|
return concat("[<CompiledValue(", (fsharpAttribute.fields[0].tag === 1) ? int32ToString(fsharpAttribute.fields[0].fields[0]) : ((fsharpAttribute.fields[0].tag === 2) ? fsharpAttribute.fields[0].fields[0].toString() : ((fsharpAttribute.fields[0].tag === 0) ? concat("\"", fsharpAttribute.fields[0].fields[0], "\"") : ((fsharpAttribute.fields[0].tag === 4) ? "null" : (fsharpAttribute.fields[0].fields[0] ? "true" : "false")))), ")>]");
|
|
149
139
|
case 15:
|
|
@@ -160,8 +150,8 @@ function attributeToText(fsharpAttribute) {
|
|
|
160
150
|
return "[<EmitIndexer>]";
|
|
161
151
|
case 21:
|
|
162
152
|
if (fsharpAttribute.fields[0] != null) {
|
|
163
|
-
const
|
|
164
|
-
return concat("[<Global(\"",
|
|
153
|
+
const name_2 = fsharpAttribute.fields[0];
|
|
154
|
+
return concat("[<Global(\"", name_2, "\")>]");
|
|
165
155
|
}
|
|
166
156
|
else {
|
|
167
157
|
return "[<Global>]";
|
|
@@ -181,16 +171,7 @@ function attributeToText(fsharpAttribute) {
|
|
|
181
171
|
return "[<Obsolete>]";
|
|
182
172
|
}
|
|
183
173
|
else {
|
|
184
|
-
|
|
185
|
-
if ((message_1.indexOf("``") >= 0) ? true : (message_1.indexOf("\"\"\"") >= 0)) {
|
|
186
|
-
return concat("[<Obsolete(\"", replace(replace(replace(replace(replace(message_1, "\\", "\\\\"), "\"", "\\\""), "\r", "\\r"), "\n", "\\n"), "\t", "\\t"), "\")>]");
|
|
187
|
-
}
|
|
188
|
-
else if ((message_1.indexOf("\n") >= 0) ? true : (message_1.indexOf("\"") >= 0)) {
|
|
189
|
-
return concat("[<Obsolete(\"\"\"", message_1, "\"\"\")>]");
|
|
190
|
-
}
|
|
191
|
-
else {
|
|
192
|
-
return concat("[<Obsolete(\"", message_1, "\")>]");
|
|
193
|
-
}
|
|
174
|
+
return concat("[<Obsolete(\"", escapeStringLiteral(fsharpAttribute.fields[0]), "\")>]");
|
|
194
175
|
}
|
|
195
176
|
case 9:
|
|
196
177
|
return "[<AbstractClass>]";
|
|
@@ -203,21 +184,20 @@ function attributeToText(fsharpAttribute) {
|
|
|
203
184
|
}
|
|
204
185
|
}
|
|
205
186
|
|
|
206
|
-
function
|
|
207
|
-
|
|
208
|
-
Printer__WriteInline_Z721C83C5(printer, " ");
|
|
187
|
+
function compactAttributesText(fsharpAttributes) {
|
|
188
|
+
return replace_1(">][<", "; ", join("", map(attributeToText, fsharpAttributes)));
|
|
209
189
|
}
|
|
210
190
|
|
|
211
191
|
function printInlineAttributes(printer, fsharpAttributes) {
|
|
212
|
-
if (
|
|
213
|
-
Printer__WriteInline_Z721C83C5(printer,
|
|
192
|
+
if (!isEmpty(fsharpAttributes)) {
|
|
193
|
+
Printer__WriteInline_Z721C83C5(printer, compactAttributesText(fsharpAttributes));
|
|
214
194
|
Printer__WriteInline_Z721C83C5(printer, " ");
|
|
215
195
|
}
|
|
216
196
|
}
|
|
217
197
|
|
|
218
198
|
function printCompactAttributesAndNewLine(printer, fsharpAttributes) {
|
|
219
|
-
if (
|
|
220
|
-
Printer__Write_Z721C83C5(printer,
|
|
199
|
+
if (!isEmpty(fsharpAttributes)) {
|
|
200
|
+
Printer__Write_Z721C83C5(printer, compactAttributesText(fsharpAttributes));
|
|
221
201
|
Printer__get_NewLine(printer);
|
|
222
202
|
}
|
|
223
203
|
}
|
|
@@ -230,18 +210,18 @@ function printAttributes(printer, fsharpAttributes) {
|
|
|
230
210
|
}
|
|
231
211
|
|
|
232
212
|
export function printTypeParametersDeclaration(printer, typeParameters) {
|
|
233
|
-
const
|
|
213
|
+
const innerPrinter = Printer_$ctor();
|
|
234
214
|
if (!isEmpty(typeParameters)) {
|
|
235
|
-
Printer__WriteInline_Z721C83C5(
|
|
215
|
+
Printer__WriteInline_Z721C83C5(innerPrinter, "<");
|
|
236
216
|
iterateIndexed((index, typeParameter) => {
|
|
237
217
|
if (index !== 0) {
|
|
238
|
-
Printer__WriteInline_Z721C83C5(
|
|
218
|
+
Printer__WriteInline_Z721C83C5(innerPrinter, ", ");
|
|
239
219
|
}
|
|
240
220
|
if (typeParameter.tag === 1) {
|
|
241
|
-
Printer__WriteInline_Z721C83C5(
|
|
221
|
+
Printer__WriteInline_Z721C83C5(innerPrinter, concat("\'", sanitizeTypeParameterName(typeParameter.fields[0].Name)));
|
|
242
222
|
}
|
|
243
223
|
else {
|
|
244
|
-
Printer__WriteInline_Z721C83C5(
|
|
224
|
+
Printer__WriteInline_Z721C83C5(innerPrinter, `'T${index}`);
|
|
245
225
|
}
|
|
246
226
|
}, typeParameters);
|
|
247
227
|
iterateIndexed((index_1, typeParameter_3) => {
|
|
@@ -251,14 +231,14 @@ export function printTypeParametersDeclaration(printer, typeParameters) {
|
|
|
251
231
|
else {
|
|
252
232
|
const constraint_ = matchValue;
|
|
253
233
|
if (index_1 === 0) {
|
|
254
|
-
Printer__WriteInline_Z721C83C5(
|
|
234
|
+
Printer__WriteInline_Z721C83C5(innerPrinter, " when ");
|
|
255
235
|
}
|
|
256
236
|
else {
|
|
257
|
-
Printer__WriteInline_Z721C83C5(
|
|
237
|
+
Printer__WriteInline_Z721C83C5(innerPrinter, " and ");
|
|
258
238
|
}
|
|
259
|
-
Printer__WriteInline_Z721C83C5(
|
|
260
|
-
Printer__WriteInline_Z721C83C5(
|
|
261
|
-
Printer__WriteInline_Z721C83C5(
|
|
239
|
+
Printer__WriteInline_Z721C83C5(innerPrinter, concat("\'", typeParameter_3.Name));
|
|
240
|
+
Printer__WriteInline_Z721C83C5(innerPrinter, " :> ");
|
|
241
|
+
Printer__WriteInline_Z721C83C5(innerPrinter, printType(constraint_));
|
|
262
242
|
}
|
|
263
243
|
}, filter((_arg_1) => (_arg_1.Constraint != null), choose((_arg) => {
|
|
264
244
|
if (_arg.tag === 1) {
|
|
@@ -268,11 +248,11 @@ export function printTypeParametersDeclaration(printer, typeParameters) {
|
|
|
268
248
|
return undefined;
|
|
269
249
|
}
|
|
270
250
|
}, typeParameters)));
|
|
271
|
-
if (Printer__ToStringWithoutTrailNewLine(
|
|
272
|
-
Printer__WriteInline_Z721C83C5(
|
|
251
|
+
if (Printer__ToStringWithoutTrailNewLine(innerPrinter).endsWith(">")) {
|
|
252
|
+
Printer__WriteInline_Z721C83C5(innerPrinter, " ");
|
|
273
253
|
}
|
|
274
|
-
Printer__WriteInline_Z721C83C5(
|
|
275
|
-
Printer__WriteInline_Z721C83C5(printer, Printer__ToStringWithoutTrailNewLine(
|
|
254
|
+
Printer__WriteInline_Z721C83C5(innerPrinter, ">");
|
|
255
|
+
Printer__WriteInline_Z721C83C5(printer, Printer__ToStringWithoutTrailNewLine(innerPrinter));
|
|
276
256
|
}
|
|
277
257
|
}
|
|
278
258
|
|
|
@@ -403,34 +383,23 @@ export function printType(fsharpType) {
|
|
|
403
383
|
}
|
|
404
384
|
}
|
|
405
385
|
|
|
406
|
-
|
|
386
|
+
function FSharpAccessibility_text(accessibility) {
|
|
407
387
|
switch (accessibility.tag) {
|
|
408
|
-
case 1:
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
case 2: {
|
|
413
|
-
Printer__Write_Z721C83C5(printer, "protected ");
|
|
414
|
-
break;
|
|
415
|
-
}
|
|
388
|
+
case 1:
|
|
389
|
+
return "private ";
|
|
390
|
+
case 2:
|
|
391
|
+
return "protected ";
|
|
416
392
|
default:
|
|
417
|
-
|
|
393
|
+
return "";
|
|
418
394
|
}
|
|
419
395
|
}
|
|
420
396
|
|
|
397
|
+
export function FSharpAccessibility_print(printer, accessibility) {
|
|
398
|
+
Printer__Write_Z721C83C5(printer, FSharpAccessibility_text(accessibility));
|
|
399
|
+
}
|
|
400
|
+
|
|
421
401
|
export function FSharpAccessibility_printInline(printer, accessibility) {
|
|
422
|
-
|
|
423
|
-
case 1: {
|
|
424
|
-
Printer__WriteInline_Z721C83C5(printer, "private ");
|
|
425
|
-
break;
|
|
426
|
-
}
|
|
427
|
-
case 2: {
|
|
428
|
-
Printer__WriteInline_Z721C83C5(printer, "protected ");
|
|
429
|
-
break;
|
|
430
|
-
}
|
|
431
|
-
default:
|
|
432
|
-
Printer__WriteInline_Z721C83C5(printer, "");
|
|
433
|
-
}
|
|
402
|
+
Printer__WriteInline_Z721C83C5(printer, FSharpAccessibility_text(accessibility));
|
|
434
403
|
}
|
|
435
404
|
|
|
436
405
|
function codeInline(line) {
|
|
@@ -542,24 +511,194 @@ function printParameterType(typ) {
|
|
|
542
511
|
}
|
|
543
512
|
}
|
|
544
513
|
|
|
514
|
+
function printParameterList(printer, separator, parameters) {
|
|
515
|
+
iterateIndexed((index, p) => {
|
|
516
|
+
if (index !== 0) {
|
|
517
|
+
Printer__WriteInline_Z721C83C5(printer, separator);
|
|
518
|
+
}
|
|
519
|
+
printInlineAttributes(printer, p.Attributes);
|
|
520
|
+
if (p.IsOptional) {
|
|
521
|
+
Printer__WriteInline_Z721C83C5(printer, "?");
|
|
522
|
+
}
|
|
523
|
+
Printer__WriteInline_Z721C83C5(printer, concat(p.Name, ": ", printParameterType(p.Type)));
|
|
524
|
+
if (hasParamArrayAttribute(p.Attributes)) {
|
|
525
|
+
Printer__WriteInline_Z721C83C5(printer, " []");
|
|
526
|
+
}
|
|
527
|
+
}, parameters);
|
|
528
|
+
}
|
|
529
|
+
|
|
545
530
|
export function printParameters(printer, parameters) {
|
|
546
|
-
if (
|
|
531
|
+
if (isEmpty(parameters)) {
|
|
547
532
|
Printer__WriteInline_Z721C83C5(printer, "unit");
|
|
548
533
|
}
|
|
549
534
|
else {
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
535
|
+
printParameterList(printer, " * ", parameters);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
function accessorSuffix(accessor) {
|
|
540
|
+
switch (accessor.tag) {
|
|
541
|
+
case 1:
|
|
542
|
+
return " with set";
|
|
543
|
+
case 2:
|
|
544
|
+
return " with get, set";
|
|
545
|
+
default:
|
|
546
|
+
return " with get";
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
function printInterfaceMethod(printer, methodInfo) {
|
|
551
|
+
printXmlDoc(printer, methodInfo.XmlDoc);
|
|
552
|
+
printCompactAttributesAndNewLine(printer, methodInfo.Attributes);
|
|
553
|
+
if (methodInfo.IsStatic) {
|
|
554
|
+
Printer__Write_Z721C83C5(printer, "static ");
|
|
555
|
+
}
|
|
556
|
+
else {
|
|
557
|
+
Printer__Write_Z721C83C5(printer, "abstract ");
|
|
558
|
+
}
|
|
559
|
+
Printer__WriteInline_Z721C83C5(printer, concat("member ", methodInfo.Name));
|
|
560
|
+
printTypeParametersDeclaration(printer, methodInfo.TypeParameters);
|
|
561
|
+
if (methodInfo.IsStatic) {
|
|
562
|
+
Printer__WriteInline_Z721C83C5(printer, " ");
|
|
563
|
+
if (isEmpty(methodInfo.Parameters)) {
|
|
564
|
+
Printer__WriteInline_Z721C83C5(printer, "()");
|
|
565
|
+
}
|
|
566
|
+
else {
|
|
567
|
+
Printer__WriteInline_Z721C83C5(printer, "(");
|
|
568
|
+
printParameterList(printer, ", ", methodInfo.Parameters);
|
|
569
|
+
Printer__WriteInline_Z721C83C5(printer, ")");
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
else {
|
|
573
|
+
Printer__WriteInline_Z721C83C5(printer, ": ");
|
|
574
|
+
printParameters(printer, methodInfo.Parameters);
|
|
575
|
+
}
|
|
576
|
+
if (methodInfo.IsStatic) {
|
|
577
|
+
Printer__WriteInline_Z721C83C5(printer, " : ");
|
|
578
|
+
}
|
|
579
|
+
else {
|
|
580
|
+
Printer__WriteInline_Z721C83C5(printer, " -> ");
|
|
581
|
+
}
|
|
582
|
+
Printer__WriteInline_Z721C83C5(printer, printType(methodInfo.Type));
|
|
583
|
+
if (methodInfo.IsStatic) {
|
|
584
|
+
Printer__WriteInline_Z721C83C5(printer, " = nativeOnly");
|
|
585
|
+
}
|
|
586
|
+
Printer__get_NewLine(printer);
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
function printInterfaceProperty(printer, interfaceInfo, propertyInfo) {
|
|
590
|
+
printXmlDoc(printer, propertyInfo.XmlDoc);
|
|
591
|
+
printAttributes(printer, propertyInfo.Attributes);
|
|
592
|
+
if (propertyInfo.IsStatic) {
|
|
593
|
+
if (propertyInfo.Body.tag === 1) {
|
|
594
|
+
Printer__Write_Z721C83C5(printer, concat("[<Emit(\"\"\"", ((((((("import { " + interfaceInfo.OriginalName) + " } from \"") + Printer__get_ImportSpecifier(printer)) + "\";\n") + interfaceInfo.OriginalName) + ".") + propertyInfo.OriginalName) + "{{=$0}}", "\"\"\")>]"));
|
|
595
|
+
Printer__get_NewLine(printer);
|
|
596
|
+
}
|
|
597
|
+
Printer__Write_Z721C83C5(printer, "static member inline ");
|
|
598
|
+
FSharpAccessibility_printInline(printer, propertyInfo.Accessibility);
|
|
599
|
+
Printer__WriteInline_Z721C83C5(printer, propertyInfo.Name);
|
|
600
|
+
const printGetter = () => {
|
|
601
|
+
Printer__get_Indent(printer);
|
|
602
|
+
Printer__Write_Z721C83C5(printer, concat("with get () : ", printType(propertyInfo.Type), " ="));
|
|
603
|
+
Printer__get_NewLine(printer);
|
|
604
|
+
Printer__get_Indent(printer);
|
|
605
|
+
Printer__Write_Z721C83C5(printer, "nativeOnly");
|
|
606
|
+
Printer__get_Unindent(printer);
|
|
607
|
+
Printer__get_Unindent(printer);
|
|
608
|
+
};
|
|
609
|
+
const printerSetter = (useAndKeyword) => {
|
|
610
|
+
Printer__get_Indent(printer);
|
|
611
|
+
if (useAndKeyword) {
|
|
612
|
+
Printer__Write_Z721C83C5(printer, "and ");
|
|
553
613
|
}
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
Printer__WriteInline_Z721C83C5(printer, "?");
|
|
614
|
+
else {
|
|
615
|
+
Printer__Write_Z721C83C5(printer, "with ");
|
|
557
616
|
}
|
|
558
|
-
Printer__WriteInline_Z721C83C5(printer, concat(
|
|
559
|
-
|
|
560
|
-
|
|
617
|
+
Printer__WriteInline_Z721C83C5(printer, concat("set (value: ", printType(propertyInfo.Type), ") ="));
|
|
618
|
+
Printer__get_NewLine(printer);
|
|
619
|
+
Printer__get_Indent(printer);
|
|
620
|
+
Printer__Write_Z721C83C5(printer, "nativeOnly");
|
|
621
|
+
Printer__get_Unindent(printer);
|
|
622
|
+
Printer__get_Unindent(printer);
|
|
623
|
+
};
|
|
624
|
+
const matchValue_1 = propertyInfo.Accessor;
|
|
625
|
+
if (matchValue_1 != null) {
|
|
626
|
+
const accessor = matchValue_1;
|
|
627
|
+
Printer__get_NewLine(printer);
|
|
628
|
+
switch (accessor.tag) {
|
|
629
|
+
case 1: {
|
|
630
|
+
printerSetter(false);
|
|
631
|
+
break;
|
|
632
|
+
}
|
|
633
|
+
case 2: {
|
|
634
|
+
printGetter();
|
|
635
|
+
Printer__get_NewLine(printer);
|
|
636
|
+
printerSetter(true);
|
|
637
|
+
break;
|
|
638
|
+
}
|
|
639
|
+
default:
|
|
640
|
+
printGetter();
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
else {
|
|
644
|
+
Printer__WriteInline_Z721C83C5(printer, concat(": ", printType(propertyInfo.Type)));
|
|
645
|
+
Printer__WriteInline_Z721C83C5(printer, " = nativeOnly");
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
else {
|
|
649
|
+
Printer__Write_Z721C83C5(printer, concat("abstract member ", propertyInfo.Name));
|
|
650
|
+
iterateIndexed((index, p) => {
|
|
651
|
+
if (index === 0) {
|
|
652
|
+
Printer__WriteInline_Z721C83C5(printer, ": ");
|
|
653
|
+
}
|
|
654
|
+
else {
|
|
655
|
+
Printer__WriteInline_Z721C83C5(printer, " -> ");
|
|
561
656
|
}
|
|
562
|
-
|
|
657
|
+
const option = p.IsOptional ? " option" : "";
|
|
658
|
+
Printer__WriteInline_Z721C83C5(printer, concat(p.Name, ": ", printParameterType(p.Type), option));
|
|
659
|
+
}, propertyInfo.Parameters);
|
|
660
|
+
if (length(propertyInfo.Parameters) > 0) {
|
|
661
|
+
Printer__WriteInline_Z721C83C5(printer, " -> ");
|
|
662
|
+
}
|
|
663
|
+
else {
|
|
664
|
+
Printer__WriteInline_Z721C83C5(printer, ": ");
|
|
665
|
+
}
|
|
666
|
+
Printer__WriteInline_Z721C83C5(printer, printType(propertyInfo.Type));
|
|
667
|
+
if (propertyInfo.IsOptional) {
|
|
668
|
+
Printer__WriteInline_Z721C83C5(printer, " option");
|
|
669
|
+
}
|
|
670
|
+
let option_4;
|
|
671
|
+
const option_2 = propertyInfo.Accessor;
|
|
672
|
+
option_4 = ((option_2 != null) ? accessorSuffix(option_2) : undefined);
|
|
673
|
+
if (option_4 != null) {
|
|
674
|
+
Printer__WriteInline_Z721C83C5(printer, option_4);
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
Printer__get_NewLine(printer);
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
function printInterfaceStaticMember(printer, interfaceInfo, staticMemberInfo) {
|
|
681
|
+
printXmlDoc(printer, staticMemberInfo.XmlDoc);
|
|
682
|
+
printCompactAttributesAndNewLine(printer, staticMemberInfo.Attributes);
|
|
683
|
+
const macroArguments = join(", ", mapIndexed((index, _arg) => (`$${index}`), staticMemberInfo.Parameters));
|
|
684
|
+
Printer__Write_Z721C83C5(printer, `[<Emit("""import { ${interfaceInfo.OriginalName} } from "${Printer__get_ImportSpecifier(printer)}";
|
|
685
|
+
${interfaceInfo.OriginalName}.${staticMemberInfo.OriginalName}(${macroArguments})""")>]`);
|
|
686
|
+
Printer__get_NewLine(printer);
|
|
687
|
+
Printer__Write_Z721C83C5(printer, concat("static member inline ", staticMemberInfo.Name, " "));
|
|
688
|
+
printTypeParametersDeclaration(printer, staticMemberInfo.TypeParameters);
|
|
689
|
+
if (isEmpty(staticMemberInfo.Parameters)) {
|
|
690
|
+
Printer__WriteInline_Z721C83C5(printer, "() : ");
|
|
691
|
+
Printer__WriteInline_Z721C83C5(printer, printType(staticMemberInfo.Type));
|
|
692
|
+
Printer__WriteInline_Z721C83C5(printer, " = nativeOnly");
|
|
693
|
+
Printer__get_NewLine(printer);
|
|
694
|
+
}
|
|
695
|
+
else {
|
|
696
|
+
Printer__WriteInline_Z721C83C5(printer, "(");
|
|
697
|
+
printParameterList(printer, ", ", staticMemberInfo.Parameters);
|
|
698
|
+
Printer__WriteInline_Z721C83C5(printer, "): ");
|
|
699
|
+
Printer__WriteInline_Z721C83C5(printer, printType(staticMemberInfo.Type));
|
|
700
|
+
Printer__WriteInline_Z721C83C5(printer, " = nativeOnly");
|
|
701
|
+
Printer__get_NewLine(printer);
|
|
563
702
|
}
|
|
564
703
|
}
|
|
565
704
|
|
|
@@ -576,189 +715,17 @@ function printInterface(printer, interfaceInfo) {
|
|
|
576
715
|
Printer__get_NewLine(printer);
|
|
577
716
|
}, interfaceInfo.Inheritance);
|
|
578
717
|
iterate((_arg) => {
|
|
579
|
-
let _arg_1;
|
|
580
718
|
switch (_arg.tag) {
|
|
581
719
|
case 1: {
|
|
582
|
-
|
|
583
|
-
printXmlDoc(printer, propertyInfo.XmlDoc);
|
|
584
|
-
printAttributes(printer, propertyInfo.Attributes);
|
|
585
|
-
if (propertyInfo.IsStatic) {
|
|
586
|
-
if (propertyInfo.Body.tag === 1) {
|
|
587
|
-
Printer__Write_Z721C83C5(printer, concat("[<Emit(\"\"\"", ((((((("import { " + interfaceInfo.OriginalName) + " } from \"") + Printer__get_ImportSpecifier(printer)) + "\";\n") + interfaceInfo.OriginalName) + ".") + propertyInfo.OriginalName) + "{{=$0}}", "\"\"\")>]"));
|
|
588
|
-
Printer__get_NewLine(printer);
|
|
589
|
-
}
|
|
590
|
-
Printer__Write_Z721C83C5(printer, "static member inline ");
|
|
591
|
-
FSharpAccessibility_printInline(printer, propertyInfo.Accessibility);
|
|
592
|
-
Printer__WriteInline_Z721C83C5(printer, propertyInfo.Name);
|
|
593
|
-
const printGetter = () => {
|
|
594
|
-
Printer__get_Indent(printer);
|
|
595
|
-
Printer__Write_Z721C83C5(printer, concat("with get () : ", printType(propertyInfo.Type), " ="));
|
|
596
|
-
Printer__get_NewLine(printer);
|
|
597
|
-
Printer__get_Indent(printer);
|
|
598
|
-
Printer__Write_Z721C83C5(printer, "nativeOnly");
|
|
599
|
-
Printer__get_Unindent(printer);
|
|
600
|
-
Printer__get_Unindent(printer);
|
|
601
|
-
};
|
|
602
|
-
const printerSetter = (useAndKeyword) => {
|
|
603
|
-
Printer__get_Indent(printer);
|
|
604
|
-
if (useAndKeyword) {
|
|
605
|
-
Printer__Write_Z721C83C5(printer, "and ");
|
|
606
|
-
}
|
|
607
|
-
else {
|
|
608
|
-
Printer__Write_Z721C83C5(printer, "with ");
|
|
609
|
-
}
|
|
610
|
-
Printer__WriteInline_Z721C83C5(printer, concat("set (value: ", printType(propertyInfo.Type), ") ="));
|
|
611
|
-
Printer__get_NewLine(printer);
|
|
612
|
-
Printer__get_Indent(printer);
|
|
613
|
-
Printer__Write_Z721C83C5(printer, "nativeOnly");
|
|
614
|
-
Printer__get_Unindent(printer);
|
|
615
|
-
Printer__get_Unindent(printer);
|
|
616
|
-
};
|
|
617
|
-
const matchValue_1 = propertyInfo.Accessor;
|
|
618
|
-
if (matchValue_1 != null) {
|
|
619
|
-
const accessor = matchValue_1;
|
|
620
|
-
Printer__get_NewLine(printer);
|
|
621
|
-
switch (accessor.tag) {
|
|
622
|
-
case 1: {
|
|
623
|
-
printerSetter(false);
|
|
624
|
-
break;
|
|
625
|
-
}
|
|
626
|
-
case 2: {
|
|
627
|
-
printGetter();
|
|
628
|
-
Printer__get_NewLine(printer);
|
|
629
|
-
printerSetter(true);
|
|
630
|
-
break;
|
|
631
|
-
}
|
|
632
|
-
default:
|
|
633
|
-
printGetter();
|
|
634
|
-
}
|
|
635
|
-
}
|
|
636
|
-
else {
|
|
637
|
-
Printer__WriteInline_Z721C83C5(printer, concat(": ", printType(propertyInfo.Type)));
|
|
638
|
-
Printer__WriteInline_Z721C83C5(printer, " = nativeOnly");
|
|
639
|
-
}
|
|
640
|
-
}
|
|
641
|
-
else {
|
|
642
|
-
Printer__Write_Z721C83C5(printer, concat("abstract member ", propertyInfo.Name));
|
|
643
|
-
iterateIndexed((index_1, p_1) => {
|
|
644
|
-
if (index_1 === 0) {
|
|
645
|
-
Printer__WriteInline_Z721C83C5(printer, ": ");
|
|
646
|
-
}
|
|
647
|
-
else {
|
|
648
|
-
Printer__WriteInline_Z721C83C5(printer, " -> ");
|
|
649
|
-
}
|
|
650
|
-
const option = p_1.IsOptional ? " option" : "";
|
|
651
|
-
Printer__WriteInline_Z721C83C5(printer, concat(p_1.Name, ": ", printParameterType(p_1.Type), option));
|
|
652
|
-
}, propertyInfo.Parameters);
|
|
653
|
-
if (length(propertyInfo.Parameters) > 0) {
|
|
654
|
-
Printer__WriteInline_Z721C83C5(printer, " -> ");
|
|
655
|
-
}
|
|
656
|
-
else {
|
|
657
|
-
Printer__WriteInline_Z721C83C5(printer, ": ");
|
|
658
|
-
}
|
|
659
|
-
Printer__WriteInline_Z721C83C5(printer, printType(propertyInfo.Type));
|
|
660
|
-
if (propertyInfo.IsOptional) {
|
|
661
|
-
Printer__WriteInline_Z721C83C5(printer, " option");
|
|
662
|
-
}
|
|
663
|
-
let option_4;
|
|
664
|
-
const option_2 = propertyInfo.Accessor;
|
|
665
|
-
option_4 = ((option_2 != null) ? ((_arg_1 = option_2, (_arg_1.tag === 1) ? " with set" : ((_arg_1.tag === 2) ? " with get, set" : " with get"))) : undefined);
|
|
666
|
-
if (option_4 != null) {
|
|
667
|
-
Printer__WriteInline_Z721C83C5(printer, option_4);
|
|
668
|
-
}
|
|
669
|
-
}
|
|
670
|
-
Printer__get_NewLine(printer);
|
|
720
|
+
printInterfaceProperty(printer, interfaceInfo, _arg.fields[0]);
|
|
671
721
|
break;
|
|
672
722
|
}
|
|
673
723
|
case 2: {
|
|
674
|
-
|
|
675
|
-
printXmlDoc(printer, staticMemberInfo.XmlDoc);
|
|
676
|
-
printCompactAttributesAndNewLine(printer, staticMemberInfo.Attributes);
|
|
677
|
-
const macroArguments = join(", ", mapIndexed((index_2, _arg_2) => (`$${index_2}`), staticMemberInfo.Parameters));
|
|
678
|
-
Printer__Write_Z721C83C5(printer, `[<Emit("""import { ${interfaceInfo.OriginalName} } from "${Printer__get_ImportSpecifier(printer)}";
|
|
679
|
-
${interfaceInfo.OriginalName}.${staticMemberInfo.OriginalName}(${macroArguments})""")>]`);
|
|
680
|
-
Printer__get_NewLine(printer);
|
|
681
|
-
Printer__Write_Z721C83C5(printer, concat("static member inline ", staticMemberInfo.Name, " "));
|
|
682
|
-
printTypeParametersDeclaration(printer, staticMemberInfo.TypeParameters);
|
|
683
|
-
if (isEmpty(staticMemberInfo.Parameters)) {
|
|
684
|
-
Printer__WriteInline_Z721C83C5(printer, "() : ");
|
|
685
|
-
Printer__WriteInline_Z721C83C5(printer, printType(staticMemberInfo.Type));
|
|
686
|
-
Printer__WriteInline_Z721C83C5(printer, " = nativeOnly");
|
|
687
|
-
Printer__get_NewLine(printer);
|
|
688
|
-
}
|
|
689
|
-
else {
|
|
690
|
-
Printer__WriteInline_Z721C83C5(printer, "(");
|
|
691
|
-
iterateIndexed((index_3, p_2) => {
|
|
692
|
-
if (index_3 !== 0) {
|
|
693
|
-
Printer__WriteInline_Z721C83C5(printer, ", ");
|
|
694
|
-
}
|
|
695
|
-
printInlineAttributes(printer, p_2.Attributes);
|
|
696
|
-
if (p_2.IsOptional) {
|
|
697
|
-
Printer__WriteInline_Z721C83C5(printer, "?");
|
|
698
|
-
}
|
|
699
|
-
Printer__WriteInline_Z721C83C5(printer, concat(p_2.Name, ": ", printParameterType(p_2.Type)));
|
|
700
|
-
if (hasParamArrayAttribute(p_2.Attributes)) {
|
|
701
|
-
Printer__WriteInline_Z721C83C5(printer, " []");
|
|
702
|
-
}
|
|
703
|
-
}, staticMemberInfo.Parameters);
|
|
704
|
-
Printer__WriteInline_Z721C83C5(printer, "): ");
|
|
705
|
-
Printer__WriteInline_Z721C83C5(printer, printType(staticMemberInfo.Type));
|
|
706
|
-
Printer__WriteInline_Z721C83C5(printer, " = nativeOnly");
|
|
707
|
-
Printer__get_NewLine(printer);
|
|
708
|
-
}
|
|
724
|
+
printInterfaceStaticMember(printer, interfaceInfo, _arg.fields[0]);
|
|
709
725
|
break;
|
|
710
726
|
}
|
|
711
|
-
default:
|
|
712
|
-
|
|
713
|
-
printXmlDoc(printer, methodInfo.XmlDoc);
|
|
714
|
-
printCompactAttributesAndNewLine(printer, methodInfo.Attributes);
|
|
715
|
-
if (methodInfo.IsStatic) {
|
|
716
|
-
Printer__Write_Z721C83C5(printer, "static ");
|
|
717
|
-
}
|
|
718
|
-
else {
|
|
719
|
-
Printer__Write_Z721C83C5(printer, "abstract ");
|
|
720
|
-
}
|
|
721
|
-
Printer__WriteInline_Z721C83C5(printer, concat("member ", methodInfo.Name));
|
|
722
|
-
printTypeParametersDeclaration(printer, methodInfo.TypeParameters);
|
|
723
|
-
if (methodInfo.IsStatic) {
|
|
724
|
-
Printer__WriteInline_Z721C83C5(printer, " ");
|
|
725
|
-
if (length(methodInfo.Parameters) === 0) {
|
|
726
|
-
Printer__WriteInline_Z721C83C5(printer, "()");
|
|
727
|
-
}
|
|
728
|
-
else {
|
|
729
|
-
Printer__WriteInline_Z721C83C5(printer, "(");
|
|
730
|
-
iterateIndexed((index, p) => {
|
|
731
|
-
if (index !== 0) {
|
|
732
|
-
Printer__WriteInline_Z721C83C5(printer, ", ");
|
|
733
|
-
}
|
|
734
|
-
printInlineAttributes(printer, p.Attributes);
|
|
735
|
-
if (p.IsOptional) {
|
|
736
|
-
Printer__WriteInline_Z721C83C5(printer, "?");
|
|
737
|
-
}
|
|
738
|
-
Printer__WriteInline_Z721C83C5(printer, concat(p.Name, ": ", printParameterType(p.Type)));
|
|
739
|
-
if (hasParamArrayAttribute(p.Attributes)) {
|
|
740
|
-
Printer__WriteInline_Z721C83C5(printer, " []");
|
|
741
|
-
}
|
|
742
|
-
}, methodInfo.Parameters);
|
|
743
|
-
Printer__WriteInline_Z721C83C5(printer, ")");
|
|
744
|
-
}
|
|
745
|
-
}
|
|
746
|
-
else {
|
|
747
|
-
Printer__WriteInline_Z721C83C5(printer, ": ");
|
|
748
|
-
printParameters(printer, methodInfo.Parameters);
|
|
749
|
-
}
|
|
750
|
-
if (methodInfo.IsStatic) {
|
|
751
|
-
Printer__WriteInline_Z721C83C5(printer, " : ");
|
|
752
|
-
}
|
|
753
|
-
else {
|
|
754
|
-
Printer__WriteInline_Z721C83C5(printer, " -> ");
|
|
755
|
-
}
|
|
756
|
-
Printer__WriteInline_Z721C83C5(printer, printType(methodInfo.Type));
|
|
757
|
-
if (methodInfo.IsStatic) {
|
|
758
|
-
Printer__WriteInline_Z721C83C5(printer, " = nativeOnly");
|
|
759
|
-
}
|
|
760
|
-
Printer__get_NewLine(printer);
|
|
761
|
-
}
|
|
727
|
+
default:
|
|
728
|
+
printInterfaceMethod(printer, _arg.fields[0]);
|
|
762
729
|
}
|
|
763
730
|
}, interfaceInfo.Members);
|
|
764
731
|
if (isEmpty(interfaceInfo.Members) && isEmpty(interfaceInfo.Inheritance)) {
|
|
@@ -842,14 +809,13 @@ function printClass(printer, classInfo) {
|
|
|
842
809
|
}
|
|
843
810
|
if (!isEmpty(classInfo.ExplicitFields)) {
|
|
844
811
|
iterate((explicitField) => {
|
|
845
|
-
let _arg;
|
|
846
812
|
printXmlDoc(printer, explicitField.XmlDoc);
|
|
847
813
|
Printer__Write_Z721C83C5(printer, concat("member val ", explicitField.Name, " : "));
|
|
848
814
|
Printer__WriteInline_Z721C83C5(printer, printType(explicitField.Type));
|
|
849
815
|
Printer__WriteInline_Z721C83C5(printer, " = nativeOnly");
|
|
850
816
|
let option_3;
|
|
851
817
|
const option_1 = explicitField.Accessor;
|
|
852
|
-
option_3 = ((option_1 != null) ? (
|
|
818
|
+
option_3 = ((option_1 != null) ? accessorSuffix(option_1) : undefined);
|
|
853
819
|
if (option_3 != null) {
|
|
854
820
|
Printer__WriteInline_Z721C83C5(printer, option_3);
|
|
855
821
|
}
|
|
@@ -860,8 +826,7 @@ function printClass(printer, classInfo) {
|
|
|
860
826
|
}
|
|
861
827
|
|
|
862
828
|
function printEnum(printer, enumInfo) {
|
|
863
|
-
|
|
864
|
-
Printer__get_NewLine(printer);
|
|
829
|
+
printAttributes(printer, singleton(FSharpAttribute.RequireQualifiedAccess));
|
|
865
830
|
Printer__Write_Z721C83C5(printer, concat("type ", enumInfo.Name, " ="));
|
|
866
831
|
Printer__get_NewLine(printer);
|
|
867
832
|
Printer__get_Indent(printer);
|
|
@@ -944,14 +909,148 @@ function printDelegate(printer, delegateInfo) {
|
|
|
944
909
|
Printer__get_Unindent(printer);
|
|
945
910
|
}
|
|
946
911
|
|
|
947
|
-
function
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
912
|
+
function printUnion(printer, unionInfo) {
|
|
913
|
+
printAttributes(printer, unionInfo.Attributes);
|
|
914
|
+
Printer__Write_Z721C83C5(printer, concat("type ", printTypeNameWithTypeParameters(unionInfo.Name, unionInfo.TypeParameters), " ="));
|
|
915
|
+
Printer__get_NewLine(printer);
|
|
916
|
+
Printer__get_Indent(printer);
|
|
917
|
+
iterate((enumCaseInfo) => {
|
|
918
|
+
Printer__Write_Z721C83C5(printer, "| ");
|
|
919
|
+
switch (enumCaseInfo.tag) {
|
|
920
|
+
case 1: {
|
|
921
|
+
Printer__WriteInline_Z721C83C5(printer, printType(enumCaseInfo.fields[0]));
|
|
922
|
+
break;
|
|
923
|
+
}
|
|
924
|
+
case 2: {
|
|
925
|
+
Printer__WriteInline_Z721C83C5(printer, concat(enumCaseInfo.fields[0], " of ", printType(enumCaseInfo.fields[1])));
|
|
926
|
+
break;
|
|
927
|
+
}
|
|
928
|
+
case 3: {
|
|
929
|
+
const fields = enumCaseInfo.fields[1];
|
|
930
|
+
const caseInfo = enumCaseInfo.fields[0];
|
|
931
|
+
printInlineAttributes(printer, caseInfo.Attributes);
|
|
932
|
+
Printer__WriteInline_Z721C83C5(printer, caseInfo.Name);
|
|
933
|
+
if (!isEmpty(fields)) {
|
|
934
|
+
Printer__WriteInline_Z721C83C5(printer, concat(" of ", join(" * ", map((tupledArg) => concat(tupledArg[0], ": ", printType(tupledArg[1])), fields))));
|
|
935
|
+
}
|
|
936
|
+
break;
|
|
937
|
+
}
|
|
938
|
+
default: {
|
|
939
|
+
const enumCaseInfo_1 = enumCaseInfo.fields[0];
|
|
940
|
+
printInlineAttributes(printer, enumCaseInfo_1.Attributes);
|
|
941
|
+
Printer__WriteInline_Z721C83C5(printer, enumCaseInfo_1.Name);
|
|
942
|
+
}
|
|
952
943
|
}
|
|
953
|
-
|
|
954
|
-
|
|
944
|
+
Printer__get_NewLine(printer);
|
|
945
|
+
}, unionInfo.Cases);
|
|
946
|
+
iterate((constant) => {
|
|
947
|
+
Printer__Write_Z721C83C5(printer, `static member inline ${constant.Name}: ${unionInfo.Name} = ${unionInfo.Name}.${constant.Case} ${constant.Value}`);
|
|
948
|
+
Printer__get_NewLine(printer);
|
|
949
|
+
}, unionInfo.Constants);
|
|
950
|
+
if (exists((_arg) => {
|
|
951
|
+
switch (_arg.tag) {
|
|
952
|
+
case 6:
|
|
953
|
+
case 7:
|
|
954
|
+
return true;
|
|
955
|
+
default:
|
|
956
|
+
return false;
|
|
957
|
+
}
|
|
958
|
+
}, unionInfo.Attributes)) {
|
|
959
|
+
const returnType = printTypeNameWithTypeParameters(unionInfo.Name, unionInfo.TypeParameters);
|
|
960
|
+
iterate((caseType) => {
|
|
961
|
+
const enumerator = getEnumerator(["op_Implicit", "op_ErasedCast"]);
|
|
962
|
+
try {
|
|
963
|
+
while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
|
|
964
|
+
const name_2 = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
965
|
+
Printer__get_NewLine(printer);
|
|
966
|
+
Printer__Write_Z721C83C5(printer, "[<Emit(\"$0\")>]");
|
|
967
|
+
Printer__get_NewLine(printer);
|
|
968
|
+
Printer__Write_Z721C83C5(printer, `static member ${name_2}(value: ${caseType}) : ${returnType} = nativeOnly`);
|
|
969
|
+
Printer__get_NewLine(printer);
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
finally {
|
|
973
|
+
disposeSafe(enumerator);
|
|
974
|
+
}
|
|
975
|
+
}, List_distinct(choose((_arg_1) => {
|
|
976
|
+
if (_arg_1.tag === 2) {
|
|
977
|
+
return printType(_arg_1.fields[1]);
|
|
978
|
+
}
|
|
979
|
+
else {
|
|
980
|
+
return undefined;
|
|
981
|
+
}
|
|
982
|
+
}, unionInfo.Cases), {
|
|
983
|
+
Equals: (x, y) => (x === y),
|
|
984
|
+
GetHashCode: (x) => (stringHash(x) | 0),
|
|
985
|
+
}));
|
|
986
|
+
}
|
|
987
|
+
Printer__get_Unindent(printer);
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
function printSingleErasedCaseUnion(printer, erasedCaseUnionInfo) {
|
|
991
|
+
printXmlDoc(printer, erasedCaseUnionInfo.XmlDoc);
|
|
992
|
+
printAttributes(printer, cons(FSharpAttribute.Erase, erasedCaseUnionInfo.Attributes));
|
|
993
|
+
Printer__Write_Z721C83C5(printer, concat("type ", erasedCaseUnionInfo.Name));
|
|
994
|
+
printTypeParametersDeclaration(printer, singleton(erasedCaseUnionInfo.TypeParameter));
|
|
995
|
+
Printer__WriteInline_Z721C83C5(printer, " =");
|
|
996
|
+
Printer__get_NewLine(printer);
|
|
997
|
+
Printer__get_Indent(printer);
|
|
998
|
+
Printer__Write_Z721C83C5(printer, concat("| ", erasedCaseUnionInfo.Name, " of "));
|
|
999
|
+
const matchValue = erasedCaseUnionInfo.TypeParameter;
|
|
1000
|
+
if (matchValue.tag === 1) {
|
|
1001
|
+
Printer__WriteInline_Z721C83C5(printer, concat("\'", matchValue.fields[0].Name));
|
|
1002
|
+
}
|
|
1003
|
+
else {
|
|
1004
|
+
Printer__WriteInline_Z721C83C5(printer, printType(matchValue.fields[0]));
|
|
1005
|
+
}
|
|
1006
|
+
Printer__get_NewLine(printer);
|
|
1007
|
+
Printer__get_NewLine(printer);
|
|
1008
|
+
Printer__Write_Z721C83C5(printer, "member inline this.Value =");
|
|
1009
|
+
Printer__get_NewLine(printer);
|
|
1010
|
+
Printer__get_Indent(printer);
|
|
1011
|
+
Printer__Write_Z721C83C5(printer, concat("let (", erasedCaseUnionInfo.Name, " output) = this"));
|
|
1012
|
+
Printer__get_NewLine(printer);
|
|
1013
|
+
Printer__Write_Z721C83C5(printer, "output");
|
|
1014
|
+
Printer__get_NewLine(printer);
|
|
1015
|
+
Printer__get_Unindent(printer);
|
|
1016
|
+
Printer__get_Unindent(printer);
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
function printTypeExtension(printer, extensionInfo) {
|
|
1020
|
+
printAttributes(printer, singleton(FSharpAttribute.AutoOpen));
|
|
1021
|
+
Printer__Write_Z721C83C5(printer, concat("module ", extensionInfo.ModuleName, " ="));
|
|
1022
|
+
Printer__get_NewLine(printer);
|
|
1023
|
+
Printer__get_Indent(printer);
|
|
1024
|
+
Printer__get_NewLine(printer);
|
|
1025
|
+
Printer__Write_Z721C83C5(printer, concat("type ", printTypeNameWithTypeParameters(extensionInfo.TargetName, extensionInfo.TypeParameters), " with"));
|
|
1026
|
+
Printer__get_NewLine(printer);
|
|
1027
|
+
Printer__get_Indent(printer);
|
|
1028
|
+
const enumerator = getEnumerator(extensionInfo.Members);
|
|
1029
|
+
try {
|
|
1030
|
+
while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
|
|
1031
|
+
const extensionMember = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
1032
|
+
const parameters = join(", ", map((parameter) => concat(parameter.Name, ": ", printParameterType(parameter.Type)), extensionMember.Parameters));
|
|
1033
|
+
const arguments$ = join(", ", map((_arg) => _arg.Name, extensionMember.Parameters));
|
|
1034
|
+
Printer__Write_Z721C83C5(printer, `member inline this.${extensionMember.Name}(${parameters}) : ${printType(extensionMember.ReturnType)} =`);
|
|
1035
|
+
Printer__get_NewLine(printer);
|
|
1036
|
+
Printer__get_Indent(printer);
|
|
1037
|
+
Printer__Write_Z721C83C5(printer, `this.${extensionMember.Name}.Invoke(${arguments$})`);
|
|
1038
|
+
Printer__get_NewLine(printer);
|
|
1039
|
+
Printer__get_Unindent(printer);
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
finally {
|
|
1043
|
+
disposeSafe(enumerator);
|
|
1044
|
+
}
|
|
1045
|
+
Printer__get_Unindent(printer);
|
|
1046
|
+
Printer__get_Unindent(printer);
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
function print(printer, fsharpTypes) {
|
|
1050
|
+
const enumerator = getEnumerator(fsharpTypes);
|
|
1051
|
+
try {
|
|
1052
|
+
while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
|
|
1053
|
+
const fsharpType = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
955
1054
|
Printer__get_NewLine(printer);
|
|
956
1055
|
switch (fsharpType.tag) {
|
|
957
1056
|
case 0: {
|
|
@@ -995,33 +1094,7 @@ function print(printer_mut, fsharpTypes_mut) {
|
|
|
995
1094
|
break;
|
|
996
1095
|
}
|
|
997
1096
|
case 2: {
|
|
998
|
-
|
|
999
|
-
printXmlDoc(printer, erasedCaseUnionInfo.XmlDoc);
|
|
1000
|
-
printAttributes(printer, cons(FSharpAttribute.Erase, erasedCaseUnionInfo.Attributes));
|
|
1001
|
-
Printer__Write_Z721C83C5(printer, concat("type ", erasedCaseUnionInfo.Name));
|
|
1002
|
-
printTypeParametersDeclaration(printer, singleton(erasedCaseUnionInfo.TypeParameter));
|
|
1003
|
-
Printer__WriteInline_Z721C83C5(printer, " =");
|
|
1004
|
-
Printer__get_NewLine(printer);
|
|
1005
|
-
Printer__get_Indent(printer);
|
|
1006
|
-
Printer__Write_Z721C83C5(printer, concat("| ", erasedCaseUnionInfo.Name, " of "));
|
|
1007
|
-
const matchValue = erasedCaseUnionInfo.TypeParameter;
|
|
1008
|
-
if (matchValue.tag === 1) {
|
|
1009
|
-
Printer__WriteInline_Z721C83C5(printer, concat("\'", matchValue.fields[0].Name));
|
|
1010
|
-
}
|
|
1011
|
-
else {
|
|
1012
|
-
Printer__WriteInline_Z721C83C5(printer, printType(matchValue.fields[0]));
|
|
1013
|
-
}
|
|
1014
|
-
Printer__get_NewLine(printer);
|
|
1015
|
-
Printer__get_NewLine(printer);
|
|
1016
|
-
Printer__Write_Z721C83C5(printer, "member inline this.Value =");
|
|
1017
|
-
Printer__get_NewLine(printer);
|
|
1018
|
-
Printer__get_Indent(printer);
|
|
1019
|
-
Printer__Write_Z721C83C5(printer, concat("let (", erasedCaseUnionInfo.Name, " output) = this"));
|
|
1020
|
-
Printer__get_NewLine(printer);
|
|
1021
|
-
Printer__Write_Z721C83C5(printer, "output");
|
|
1022
|
-
Printer__get_NewLine(printer);
|
|
1023
|
-
Printer__get_Unindent(printer);
|
|
1024
|
-
Printer__get_Unindent(printer);
|
|
1097
|
+
printSingleErasedCaseUnion(printer, fsharpType.fields[0]);
|
|
1025
1098
|
break;
|
|
1026
1099
|
}
|
|
1027
1100
|
case 20: {
|
|
@@ -1029,34 +1102,7 @@ function print(printer_mut, fsharpTypes_mut) {
|
|
|
1029
1102
|
break;
|
|
1030
1103
|
}
|
|
1031
1104
|
case 21: {
|
|
1032
|
-
|
|
1033
|
-
printAttributes(printer, singleton(FSharpAttribute.AutoOpen));
|
|
1034
|
-
Printer__Write_Z721C83C5(printer, concat("module ", extensionInfo.ModuleName, " ="));
|
|
1035
|
-
Printer__get_NewLine(printer);
|
|
1036
|
-
Printer__get_Indent(printer);
|
|
1037
|
-
Printer__get_NewLine(printer);
|
|
1038
|
-
Printer__Write_Z721C83C5(printer, concat("type ", printTypeNameWithTypeParameters(extensionInfo.TargetName, extensionInfo.TypeParameters), " with"));
|
|
1039
|
-
Printer__get_NewLine(printer);
|
|
1040
|
-
Printer__get_Indent(printer);
|
|
1041
|
-
const enumerator_1 = getEnumerator(extensionInfo.Members);
|
|
1042
|
-
try {
|
|
1043
|
-
while (enumerator_1["System.Collections.IEnumerator.MoveNext"]()) {
|
|
1044
|
-
const extensionMember = enumerator_1["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
1045
|
-
const parameters = join(", ", map((parameter) => concat(parameter.Name, ": ", printParameterType(parameter.Type)), extensionMember.Parameters));
|
|
1046
|
-
const arguments$ = join(", ", map((_arg_2) => _arg_2.Name, extensionMember.Parameters));
|
|
1047
|
-
Printer__Write_Z721C83C5(printer, `member inline this.${extensionMember.Name}(${parameters}) : ${printType(extensionMember.ReturnType)} =`);
|
|
1048
|
-
Printer__get_NewLine(printer);
|
|
1049
|
-
Printer__get_Indent(printer);
|
|
1050
|
-
Printer__Write_Z721C83C5(printer, `this.${extensionMember.Name}.Invoke(${arguments$})`);
|
|
1051
|
-
Printer__get_NewLine(printer);
|
|
1052
|
-
Printer__get_Unindent(printer);
|
|
1053
|
-
}
|
|
1054
|
-
}
|
|
1055
|
-
finally {
|
|
1056
|
-
disposeSafe(enumerator_1);
|
|
1057
|
-
}
|
|
1058
|
-
Printer__get_Unindent(printer);
|
|
1059
|
-
Printer__get_Unindent(printer);
|
|
1105
|
+
printTypeExtension(printer, fsharpType.fields[0]);
|
|
1060
1106
|
break;
|
|
1061
1107
|
}
|
|
1062
1108
|
case 7:
|
|
@@ -1073,91 +1119,13 @@ function print(printer_mut, fsharpTypes_mut) {
|
|
|
1073
1119
|
case 15: {
|
|
1074
1120
|
break;
|
|
1075
1121
|
}
|
|
1076
|
-
default:
|
|
1077
|
-
|
|
1078
|
-
printAttributes(printer, unionInfo.Attributes);
|
|
1079
|
-
Printer__Write_Z721C83C5(printer, concat("type ", printTypeNameWithTypeParameters(unionInfo.Name, unionInfo.TypeParameters), " ="));
|
|
1080
|
-
Printer__get_NewLine(printer);
|
|
1081
|
-
Printer__get_Indent(printer);
|
|
1082
|
-
iterate((enumCaseInfo) => {
|
|
1083
|
-
Printer__Write_Z721C83C5(printer, "| ");
|
|
1084
|
-
switch (enumCaseInfo.tag) {
|
|
1085
|
-
case 1: {
|
|
1086
|
-
Printer__WriteInline_Z721C83C5(printer, printType(enumCaseInfo.fields[0]));
|
|
1087
|
-
Printer__get_NewLine(printer);
|
|
1088
|
-
break;
|
|
1089
|
-
}
|
|
1090
|
-
case 2: {
|
|
1091
|
-
Printer__WriteInline_Z721C83C5(printer, concat(enumCaseInfo.fields[0], " of ", printType(enumCaseInfo.fields[1])));
|
|
1092
|
-
break;
|
|
1093
|
-
}
|
|
1094
|
-
case 3: {
|
|
1095
|
-
const fields = enumCaseInfo.fields[1];
|
|
1096
|
-
const caseInfo = enumCaseInfo.fields[0];
|
|
1097
|
-
printInlineAttributes(printer, caseInfo.Attributes);
|
|
1098
|
-
Printer__WriteInline_Z721C83C5(printer, caseInfo.Name);
|
|
1099
|
-
if (!isEmpty(fields)) {
|
|
1100
|
-
Printer__WriteInline_Z721C83C5(printer, concat(" of ", join(" * ", map((tupledArg) => concat(tupledArg[0], ": ", printType(tupledArg[1])), fields))));
|
|
1101
|
-
}
|
|
1102
|
-
break;
|
|
1103
|
-
}
|
|
1104
|
-
default: {
|
|
1105
|
-
const enumCaseInfo_1 = enumCaseInfo.fields[0];
|
|
1106
|
-
printInlineAttributes(printer, enumCaseInfo_1.Attributes);
|
|
1107
|
-
Printer__WriteInline_Z721C83C5(printer, enumCaseInfo_1.Name);
|
|
1108
|
-
}
|
|
1109
|
-
}
|
|
1110
|
-
Printer__get_NewLine(printer);
|
|
1111
|
-
}, unionInfo.Cases);
|
|
1112
|
-
iterate((constant) => {
|
|
1113
|
-
Printer__Write_Z721C83C5(printer, `static member inline ${constant.Name}: ${unionInfo.Name} = ${unionInfo.Name}.${constant.Case} ${constant.Value}`);
|
|
1114
|
-
Printer__get_NewLine(printer);
|
|
1115
|
-
}, unionInfo.Constants);
|
|
1116
|
-
if (exists((_arg) => {
|
|
1117
|
-
switch (_arg.tag) {
|
|
1118
|
-
case 6:
|
|
1119
|
-
case 7:
|
|
1120
|
-
return true;
|
|
1121
|
-
default:
|
|
1122
|
-
return false;
|
|
1123
|
-
}
|
|
1124
|
-
}, unionInfo.Attributes)) {
|
|
1125
|
-
const returnType = printTypeNameWithTypeParameters(unionInfo.Name, unionInfo.TypeParameters);
|
|
1126
|
-
iterate((caseType) => {
|
|
1127
|
-
const enumerator = getEnumerator(["op_Implicit", "op_ErasedCast"]);
|
|
1128
|
-
try {
|
|
1129
|
-
while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
|
|
1130
|
-
const name_2 = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
1131
|
-
Printer__get_NewLine(printer);
|
|
1132
|
-
Printer__Write_Z721C83C5(printer, "[<Emit(\"$0\")>]");
|
|
1133
|
-
Printer__get_NewLine(printer);
|
|
1134
|
-
Printer__Write_Z721C83C5(printer, `static member ${name_2}(value: ${caseType}) : ${returnType} = nativeOnly`);
|
|
1135
|
-
Printer__get_NewLine(printer);
|
|
1136
|
-
}
|
|
1137
|
-
}
|
|
1138
|
-
finally {
|
|
1139
|
-
disposeSafe(enumerator);
|
|
1140
|
-
}
|
|
1141
|
-
}, List_distinct(choose((_arg_1) => {
|
|
1142
|
-
if (_arg_1.tag === 2) {
|
|
1143
|
-
return printType(_arg_1.fields[1]);
|
|
1144
|
-
}
|
|
1145
|
-
else {
|
|
1146
|
-
return undefined;
|
|
1147
|
-
}
|
|
1148
|
-
}, unionInfo.Cases), {
|
|
1149
|
-
Equals: (x, y) => (x === y),
|
|
1150
|
-
GetHashCode: (x) => (stringHash(x) | 0),
|
|
1151
|
-
}));
|
|
1152
|
-
}
|
|
1153
|
-
Printer__get_Unindent(printer);
|
|
1154
|
-
}
|
|
1122
|
+
default:
|
|
1123
|
+
printUnion(printer, fsharpType.fields[0]);
|
|
1155
1124
|
}
|
|
1156
|
-
printer_mut = printer;
|
|
1157
|
-
fsharpTypes_mut = tail_1(fsharpTypes);
|
|
1158
|
-
continue print;
|
|
1159
1125
|
}
|
|
1160
|
-
|
|
1126
|
+
}
|
|
1127
|
+
finally {
|
|
1128
|
+
disposeSafe(enumerator);
|
|
1161
1129
|
}
|
|
1162
1130
|
}
|
|
1163
1131
|
|
|
@@ -1172,19 +1140,24 @@ export function printFileWith(namespace_, isPackage, externalBindings, printer,
|
|
|
1172
1140
|
const bodyPrinter = Printer_$ctor();
|
|
1173
1141
|
print(bodyPrinter, transformResult.FSharpAST);
|
|
1174
1142
|
body = toString(bodyPrinter);
|
|
1175
|
-
const outFile = new FSharpOutFile(namespace_, ofArray(["Fable.Core", "Fable.Core.JsInterop", "System"]));
|
|
1176
1143
|
if (isPackage) {
|
|
1177
|
-
Printer__Write_Z721C83C5(printer, concat("namespace rec ",
|
|
1144
|
+
Printer__Write_Z721C83C5(printer, concat("namespace rec ", namespace_));
|
|
1178
1145
|
}
|
|
1179
1146
|
else {
|
|
1180
|
-
Printer__Write_Z721C83C5(printer, concat("module rec ",
|
|
1147
|
+
Printer__Write_Z721C83C5(printer, concat("module rec ", namespace_));
|
|
1181
1148
|
}
|
|
1182
1149
|
Printer__get_NewLine(printer);
|
|
1183
1150
|
Printer__get_NewLine(printer);
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1151
|
+
const enumerator = getEnumerator(["Fable.Core", "Fable.Core.JsInterop", "System"]);
|
|
1152
|
+
try {
|
|
1153
|
+
while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
|
|
1154
|
+
Printer__Write_Z721C83C5(printer, concat("open ", enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]()));
|
|
1155
|
+
Printer__get_NewLine(printer);
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
finally {
|
|
1159
|
+
disposeSafe(enumerator);
|
|
1160
|
+
}
|
|
1188
1161
|
if (transformResult.IncludeReadonlyArrayAlias && !namespace_.startsWith("Glutinum.Types")) {
|
|
1189
1162
|
Printer__get_NewLine(printer);
|
|
1190
1163
|
Printer__Write_Z721C83C5(printer, "// You need to add Glutinum.Types NuGet package to your project");
|
|
@@ -1192,10 +1165,10 @@ export function printFileWith(namespace_, isPackage, externalBindings, printer,
|
|
|
1192
1165
|
Printer__Write_Z721C83C5(printer, "open Glutinum.Types.TypeScript");
|
|
1193
1166
|
Printer__get_NewLine(printer);
|
|
1194
1167
|
}
|
|
1195
|
-
const
|
|
1168
|
+
const enumerator_1 = getEnumerator(externalBindings);
|
|
1196
1169
|
try {
|
|
1197
|
-
while (
|
|
1198
|
-
const externalBinding =
|
|
1170
|
+
while (enumerator_1["System.Collections.IEnumerator.MoveNext"]()) {
|
|
1171
|
+
const externalBinding = enumerator_1["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
1199
1172
|
if (body.indexOf(concat("Glutinum.", externalBinding, ".")) >= 0) {
|
|
1200
1173
|
Printer__get_NewLine(printer);
|
|
1201
1174
|
Printer__Write_Z721C83C5(printer, concat("// You need to add Glutinum.", externalBinding, " NuGet package to your project"));
|
|
@@ -1204,7 +1177,7 @@ export function printFileWith(namespace_, isPackage, externalBindings, printer,
|
|
|
1204
1177
|
}
|
|
1205
1178
|
}
|
|
1206
1179
|
finally {
|
|
1207
|
-
disposeSafe(
|
|
1180
|
+
disposeSafe(enumerator_1);
|
|
1208
1181
|
}
|
|
1209
1182
|
if (transformResult.IncludeRegExpAlias) {
|
|
1210
1183
|
Printer__get_NewLine(printer);
|