@idlizer/core 2.1.10-arktscgen-5 → 2.1.10-arktscgen-6

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.
Files changed (104) hide show
  1. package/build/lib/src/Language.js +1 -1
  2. package/build/lib/src/LanguageWriters/ArgConvertors.d.ts +16 -6
  3. package/build/lib/src/LanguageWriters/ArgConvertors.js +80 -92
  4. package/build/lib/src/LanguageWriters/LanguageWriter.d.ts +8 -6
  5. package/build/lib/src/LanguageWriters/LanguageWriter.js +8 -2
  6. package/build/lib/src/LanguageWriters/common.d.ts +1 -0
  7. package/build/lib/src/LanguageWriters/common.js +2 -1
  8. package/build/lib/src/LanguageWriters/convertors/CppConvertors.d.ts +7 -1
  9. package/build/lib/src/LanguageWriters/convertors/CppConvertors.js +53 -15
  10. package/build/lib/src/LanguageWriters/convertors/ETSConvertors.d.ts +1 -0
  11. package/build/lib/src/LanguageWriters/convertors/ETSConvertors.js +10 -8
  12. package/build/lib/src/LanguageWriters/convertors/InteropConvertors.js +1 -1
  13. package/build/lib/src/LanguageWriters/convertors/TSConvertors.js +25 -14
  14. package/build/lib/src/LanguageWriters/index.d.ts +4 -3
  15. package/build/lib/src/LanguageWriters/index.js +9 -11
  16. package/build/lib/src/LanguageWriters/nameConvertor.d.ts +2 -0
  17. package/build/lib/src/LanguageWriters/nameConvertor.js +11 -0
  18. package/build/lib/src/LanguageWriters/writers/CppLanguageWriter.js +1 -1
  19. package/build/lib/src/LanguageWriters/writers/ETSLanguageWriter.d.ts +1 -8
  20. package/build/lib/src/LanguageWriters/writers/ETSLanguageWriter.js +52 -89
  21. package/build/lib/src/LanguageWriters/writers/TsLanguageWriter.d.ts +3 -0
  22. package/build/lib/src/LanguageWriters/writers/TsLanguageWriter.js +24 -7
  23. package/build/lib/src/config.d.ts +2 -1461
  24. package/build/lib/src/config.js +16 -32
  25. package/build/lib/src/configMerge.d.ts +3 -0
  26. package/build/lib/src/configMerge.js +63 -0
  27. package/build/lib/src/diagnostictypes.d.ts +1 -5
  28. package/build/lib/src/diagnostictypes.js +1 -27
  29. package/build/lib/src/from-idl/DtsPrinter.js +12 -5
  30. package/build/lib/src/from-idl/IDLLinter.d.ts +3 -4
  31. package/build/lib/src/from-idl/IDLLinter.js +30 -32
  32. package/build/lib/src/from-idl/deserialize.d.ts +3 -4
  33. package/build/lib/src/from-idl/deserialize.js +29 -641
  34. package/build/lib/src/from-idl/parser.d.ts +20 -2
  35. package/build/lib/src/from-idl/parser.js +97 -29
  36. package/build/lib/src/idl/builders.d.ts +43 -0
  37. package/build/lib/src/idl/builders.js +135 -0
  38. package/build/lib/src/idl/discriminators.d.ts +53 -0
  39. package/build/lib/src/idl/discriminators.js +232 -0
  40. package/build/lib/src/idl/dump.d.ts +48 -0
  41. package/build/lib/src/idl/dump.js +327 -0
  42. package/build/lib/src/idl/index.d.ts +9 -0
  43. package/build/lib/src/idl/index.js +23 -0
  44. package/build/lib/src/idl/keywords.d.ts +2 -0
  45. package/build/lib/src/{options.js → idl/keywords.js} +7 -3
  46. package/build/lib/src/idl/node.d.ts +233 -0
  47. package/build/lib/src/idl/node.js +103 -0
  48. package/build/lib/src/idl/stdlib.d.ts +34 -0
  49. package/build/lib/src/idl/stdlib.js +54 -0
  50. package/build/lib/src/idl/utils.d.ts +44 -0
  51. package/build/lib/src/idl/utils.js +215 -0
  52. package/build/lib/src/idl/visitors.d.ts +15 -0
  53. package/build/lib/src/idl/visitors.js +593 -0
  54. package/build/lib/src/index.d.ts +4 -2
  55. package/build/lib/src/index.js +5 -3
  56. package/build/lib/src/inputPaths.d.ts +11 -0
  57. package/build/lib/src/inputPaths.js +81 -0
  58. package/build/lib/src/languageSpecificKeywords.d.ts +0 -1
  59. package/build/lib/src/languageSpecificKeywords.js +0 -5
  60. package/build/lib/src/peer-generation/LayoutManager.d.ts +1 -1
  61. package/build/lib/src/peer-generation/Materialized.d.ts +8 -2
  62. package/build/lib/src/peer-generation/Materialized.js +24 -12
  63. package/build/lib/src/peer-generation/PeerLibrary.d.ts +10 -15
  64. package/build/lib/src/peer-generation/PeerLibrary.js +35 -215
  65. package/build/lib/src/peer-generation/ReferenceResolver.d.ts +6 -1
  66. package/build/lib/src/peer-generation/ReferenceResolver.js +93 -2
  67. package/build/lib/src/peer-generation/idl/common.d.ts +6 -2
  68. package/build/lib/src/peer-generation/idl/common.js +7 -7
  69. package/build/lib/src/peer-generation/isMaterialized.js +2 -3
  70. package/build/lib/src/peer-generation/modules.js +2 -0
  71. package/build/lib/src/peer-generation/toDeclaration.d.ts +4 -0
  72. package/build/lib/src/peer-generation/toDeclaration.js +53 -0
  73. package/build/lib/src/peer-generation/unions.d.ts +1 -1
  74. package/build/lib/src/peer-generation/unions.js +15 -7
  75. package/build/lib/src/resolveNamedNode.d.ts +1 -0
  76. package/build/lib/src/resolveNamedNode.js +7 -0
  77. package/build/lib/src/transformers/FqnTransformer.d.ts +1 -1
  78. package/build/lib/src/transformers/FqnTransformer.js +20 -12
  79. package/build/lib/src/transformers/GenericTransformer.d.ts +4 -3
  80. package/build/lib/src/transformers/GenericTransformer.js +252 -158
  81. package/build/lib/src/transformers/IdlTransformer.d.ts +6 -0
  82. package/build/lib/src/transformers/IdlTransformer.js +7 -0
  83. package/build/lib/src/transformers/NullTransformer.d.ts +1 -1
  84. package/build/lib/src/transformers/NullTransformer.js +27 -21
  85. package/build/lib/src/transformers/OnSerializeTransformer.d.ts +1 -1
  86. package/build/lib/src/transformers/OnSerializeTransformer.js +28 -13
  87. package/build/lib/src/util.d.ts +4 -0
  88. package/build/lib/src/util.js +22 -0
  89. package/package.json +6 -7
  90. package/build/lib/src/LanguageWriters/convertors/JavaConvertors.d.ts +0 -37
  91. package/build/lib/src/LanguageWriters/convertors/JavaConvertors.js +0 -210
  92. package/build/lib/src/LanguageWriters/writers/JavaLanguageWriter.d.ts +0 -85
  93. package/build/lib/src/LanguageWriters/writers/JavaLanguageWriter.js +0 -306
  94. package/build/lib/src/from-idl/webidl2-utils.d.ts +0 -21
  95. package/build/lib/src/from-idl/webidl2-utils.js +0 -87
  96. package/build/lib/src/idl.d.ts +0 -444
  97. package/build/lib/src/idl.js +0 -1385
  98. package/build/lib/src/idlize.d.ts +0 -25
  99. package/build/lib/src/idlize.js +0 -198
  100. package/build/lib/src/options.d.ts +0 -13
  101. package/build/lib/src/peer-generation/BuilderClass.d.ts +0 -20
  102. package/build/lib/src/peer-generation/BuilderClass.js +0 -68
  103. package/webidl2.js/dist/webidl2.js +0 -4622
  104. package/webidl2.js/package.json +0 -55
@@ -1,306 +0,0 @@
1
- /*
2
- * Copyright (c) 2024 Huawei Device Co., Ltd.
3
- * Licensed under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License.
5
- * You may obtain a copy of the License at
6
- *
7
- * http://www.apache.org/licenses/LICENSE-2.0
8
- *
9
- * Unless required by applicable law or agreed to in writing, software
10
- * distributed under the License is distributed on an "AS IS" BASIS,
11
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- * See the License for the specific language governing permissions and
13
- * limitations under the License.
14
- */
15
- import { Language } from '../../Language';
16
- import { IndentedPrinter } from "../../IndentedPrinter";
17
- import { AssignStatement, BlockStatement, FieldModifier, LambdaExpression, Method, MethodModifier, MethodSignature, NamedMethodSignature, } from "../LanguageWriter";
18
- import { CLikeExpressionStatement, CLikeLanguageWriter, CLikeLoopStatement, CLikeReturnStatement } from "./CLikeLanguageWriter";
19
- import * as idl from '../../idl';
20
- import { RuntimeType } from "../common";
21
- ////////////////////////////////////////////////////////////////
22
- // EXPRESSIONS //
23
- ////////////////////////////////////////////////////////////////
24
- class JavaLambdaExpression extends LambdaExpression {
25
- constructor(writer, signature, resolver, body) {
26
- super(writer, signature, resolver, body);
27
- }
28
- get statementHasSemicolon() {
29
- return true;
30
- }
31
- asString() {
32
- const params = this.signature.args.map((it, i) => `${idl.forceAsNamedNode(it).name} ${this.signature.argName(i)}`);
33
- return `(${params.join(", ")}) ->${this.bodyAsString(true)}`;
34
- }
35
- }
36
- export class JavaCastExpression {
37
- constructor(value, type, unsafe = false) {
38
- this.value = value;
39
- this.type = type;
40
- this.unsafe = unsafe;
41
- }
42
- asString() {
43
- return `(${this.type})(${this.value.asString()})`;
44
- }
45
- }
46
- ////////////////////////////////////////////////////////////////
47
- // STATEMENTS //
48
- ////////////////////////////////////////////////////////////////
49
- export class JavaAssignStatement extends AssignStatement {
50
- constructor(variableName, type, expression, isDeclared = true, isConst = true) {
51
- super(variableName, type, expression, isDeclared, isConst);
52
- this.variableName = variableName;
53
- this.type = type;
54
- this.expression = expression;
55
- this.isDeclared = isDeclared;
56
- this.isConst = isConst;
57
- }
58
- write(writer) {
59
- if (this.isDeclared) {
60
- const typeSpec = this.type ? writer.getNodeName(this.type) : "var";
61
- writer.print(`${typeSpec} ${this.variableName} = ${this.expression.asString()};`);
62
- }
63
- else {
64
- writer.print(`${this.variableName} = ${this.expression.asString()};`);
65
- }
66
- }
67
- }
68
- class JavaMapForEachStatement {
69
- constructor(map, key, value, body) {
70
- this.map = map;
71
- this.key = key;
72
- this.value = value;
73
- this.body = body;
74
- }
75
- write(writer) {
76
- const entryVar = `${this.map}Entry`;
77
- writer.print(`for (var ${entryVar}: ${this.map}.entrySet()) {`);
78
- writer.pushIndent();
79
- writer.print(`var ${this.key} = ${entryVar}.getKey();`);
80
- writer.print(`var ${this.value} = ${entryVar}.getValue();`);
81
- writer.writeStatement(new BlockStatement(this.body, false));
82
- writer.popIndent();
83
- writer.print(`}`);
84
- }
85
- }
86
- ////////////////////////////////////////////////////////////////
87
- // WRITER //
88
- ////////////////////////////////////////////////////////////////
89
- export class JavaLanguageWriter extends CLikeLanguageWriter {
90
- constructor(printer, resolver, typeConvertor) {
91
- super(printer, resolver, Language.JAVA);
92
- this.typeConvertor = typeConvertor;
93
- }
94
- getNodeName(type) {
95
- // another stub. Bad one.
96
- // I hope that I will rewrite LWs soon
97
- if (idl.isType(type) && idl.isReferenceType(type)) {
98
- if (type.name.startsWith('%TEXT%:')) {
99
- return type.name.substring(7);
100
- }
101
- }
102
- return this.typeConvertor.convert(type);
103
- }
104
- fork(options) {
105
- var _a;
106
- return new JavaLanguageWriter(new IndentedPrinter([], this.indentDepth()), (_a = options === null || options === void 0 ? void 0 : options.resolver) !== null && _a !== void 0 ? _a : this.resolver, this.typeConvertor);
107
- }
108
- get interopModule() {
109
- return "org.koalaui.interop";
110
- }
111
- writeClass(name, op, superClass, interfaces, generics, isDeclared, isExport = true) {
112
- let genericsClause = (generics === null || generics === void 0 ? void 0 : generics.length) ? `<${generics.join(', ')}> ` : ``;
113
- let extendsClause = superClass ? ` extends ${superClass}` : '';
114
- let implementsClause = interfaces ? ` implements ${interfaces.join(",")}` : '';
115
- this.printer.print(`${isExport ? 'public ' : ''}class ${name}${genericsClause}${extendsClause}${implementsClause} {`); // TODO check for multiple classes in file
116
- this.pushIndent();
117
- op(this);
118
- this.popIndent();
119
- this.printer.print(`}`);
120
- }
121
- writeInterface(name, op, superInterfaces, generics) {
122
- let extendsClause = superInterfaces ? ` extends ${superInterfaces.join(",")}` : '';
123
- this.printer.print(`interface ${name}${extendsClause} {`);
124
- this.pushIndent();
125
- op(this);
126
- this.popIndent();
127
- this.printer.print(`}`);
128
- }
129
- writeMethodCall(receiver, method, params, nullable = false) {
130
- if (nullable) {
131
- this.printer.print(`if (${receiver} != null) ${receiver}.${method}(${params.join(", ")});`);
132
- }
133
- else {
134
- super.writeMethodCall(receiver, method, params, nullable);
135
- }
136
- }
137
- writeFieldDeclaration(name, type, modifiers, optional, initExpr) {
138
- let prefix = this.makeFieldModifiersList(modifiers);
139
- this.printer.print(`${prefix} ${(this.getNodeName(type))} ${name}${initExpr ? ` = ${initExpr.asString()}` : ""};`);
140
- }
141
- writeNativeMethodDeclaration(method) {
142
- this.writeMethodDeclaration(method.name, method.signature, [MethodModifier.STATIC, MethodModifier.NATIVE]);
143
- }
144
- writeConstructorImplementation(className, signature, op, delegationCall, modifiers) {
145
- this.printer.print(`${modifiers ? modifiers.map((it) => MethodModifier[it].toLowerCase()).join(' ') : ''} ${className}(${signature.args.map((it, index) => `${this.getNodeName(it)} ${signature.argName(index)}`).join(", ")}) {`);
146
- this.pushIndent();
147
- if (delegationCall) {
148
- this.print(`super(${delegationCall.delegationArgs.map(it => it.asString()).join(", ")});`);
149
- }
150
- op(this);
151
- this.popIndent();
152
- this.printer.print(`}`);
153
- }
154
- writeProperty(propName, propType, modifiers, getter, setter, initExpr) {
155
- let isStatic = modifiers.includes(FieldModifier.STATIC);
156
- let isMutable = !modifiers.includes(FieldModifier.READONLY);
157
- let containerName = propName.concat("_container");
158
- if (getter) {
159
- if (!getter.op) {
160
- this.print(`private var ${this.getNodeName(propType)} ${containerName};`);
161
- }
162
- this.writeGetterImplementation(new Method(propName, new MethodSignature(propType, []), isStatic ? [MethodModifier.STATIC, MethodModifier.PUBLIC] : [MethodModifier.PUBLIC]), getter ? getter.op :
163
- (writer) => {
164
- writer.print(`return ${containerName}`);
165
- });
166
- if (isMutable) {
167
- const setSignature = new NamedMethodSignature(idl.IDLVoidType, [propType], [propName]);
168
- this.writeSetterImplementation(new Method(propName, setSignature, isStatic ? [MethodModifier.STATIC, MethodModifier.PUBLIC] : [MethodModifier.PUBLIC]), setter ? setter.op :
169
- (writer) => {
170
- writer.print(`${containerName} = ${propName};`);
171
- });
172
- }
173
- }
174
- else {
175
- // TBD: use initExpr
176
- this.writeMethodDeclaration(propName, new MethodSignature(propType, []));
177
- }
178
- }
179
- writeTypeDeclaration(decl) {
180
- throw new Error(`Type declarations do not exist in Java, use something else`);
181
- }
182
- writeConstant(constName, constType, constVal) {
183
- throw new Error("writeConstant for Java is not implemented yet.");
184
- }
185
- writeImports(moduleName, importedFeatures, aliases) {
186
- if (importedFeatures.length !== aliases.length) {
187
- throw new Error(`Inconsistent imports from ${moduleName}`);
188
- }
189
- for (let i = 0; i < importedFeatures.length; i++) {
190
- this.writeExpressionStatement(this.makeString(`import ${moduleName}.${importedFeatures[i]}`));
191
- }
192
- }
193
- makeAssign(variableName, type, expr, isDeclared = true, isConst = true) {
194
- return new JavaAssignStatement(variableName, type, expr, isDeclared, isConst);
195
- }
196
- makeLambda(signature, body) {
197
- return new JavaLambdaExpression(this, signature, this.resolver, body);
198
- }
199
- makeReturn(expr) {
200
- return new CLikeReturnStatement(expr);
201
- }
202
- makeDefinedCheck(value) {
203
- return this.makeString(`${value} != null`);
204
- }
205
- makeLoop(counter, limit, statement) {
206
- return new CLikeLoopStatement(counter, limit, statement);
207
- }
208
- makeMapForEach(map, key, value, body) {
209
- return new JavaMapForEachStatement(map, key, value, body);
210
- }
211
- makeMapSize(map) {
212
- return this.makeString(`${map}.size()`);
213
- }
214
- makeCast(value, node, options) {
215
- var _a;
216
- return new JavaCastExpression(value, this.getNodeName(node), (_a = options === null || options === void 0 ? void 0 : options.unsafe) !== null && _a !== void 0 ? _a : false);
217
- }
218
- makeStatement(expr) {
219
- return new CLikeExpressionStatement(expr);
220
- }
221
- makeUnionSelector(value, valueType) {
222
- return this.makeAssign(valueType, undefined, this.makeMethodCall(value, "getSelector", []), false);
223
- }
224
- makeUnionVariantCondition(_convertor, _valueName, valueType, _type, convertorIndex) {
225
- return this.makeString(`${valueType} == ${convertorIndex}`);
226
- }
227
- makeUnionVariantCast(value, type, convertor, index) {
228
- return this.makeMethodCall(value, `getValue${index}`, []);
229
- }
230
- makeUnionTypeDefaultInitializer() {
231
- return this.makeString("-1");
232
- }
233
- writePrintLog(message) {
234
- this.print(`System.out.println("${message}")`);
235
- }
236
- mapIDLContainerType(type) {
237
- switch (type.containerKind) {
238
- case "sequence": return `${this.getNodeName(type.elementType[0])}[]`;
239
- }
240
- throw new Error(`Unmapped container type ${idl.DebugUtils.debugPrintType(type)}`);
241
- }
242
- applyToObject(p, param, value, args) {
243
- throw new Error("Method not implemented.");
244
- }
245
- getObjectAccessor(convertor, value, args) {
246
- return value;
247
- }
248
- makeUndefined() {
249
- return this.makeString("null");
250
- }
251
- makeRuntimeType(rt) {
252
- return this.makeString(`RuntimeType.${RuntimeType[rt]}`);
253
- }
254
- makeRuntimeTypeGetterCall(value) {
255
- return this.makeMethodCall("Ark_Object", "getRuntimeType", [this.makeString(value)]);
256
- }
257
- makeMapInsert(keyAccessor, key, valueAccessor, value) {
258
- throw new Error("Method not implemented.");
259
- }
260
- getTagType() {
261
- throw new Error("Method not implemented.");
262
- }
263
- getRuntimeType() {
264
- throw new Error("Method not implemented.");
265
- }
266
- makeTupleAssign(receiver, tupleFields) {
267
- throw new Error("Method not implemented.");
268
- }
269
- get supportedModifiers() {
270
- return [MethodModifier.PUBLIC, MethodModifier.PRIVATE, MethodModifier.STATIC, MethodModifier.NATIVE];
271
- }
272
- get supportedFieldModifiers() {
273
- return [FieldModifier.PUBLIC, FieldModifier.PRIVATE, FieldModifier.PROTECTED, FieldModifier.STATIC, FieldModifier.FINAL];
274
- }
275
- makeArrayInit(type, size) {
276
- return this.makeString(`new ${this.getNodeName(type.elementType[0])}[${size !== null && size !== void 0 ? size : 0}]`);
277
- }
278
- makeClassInit(type, paramenters) {
279
- throw new Error("Method not implemented.");
280
- }
281
- makeMapInit(type) {
282
- throw new Error("Method not implemented.");
283
- }
284
- makeTupleAccess(value, index) {
285
- return this.makeString(`${value}.value${index}`);
286
- }
287
- enumFromI32(value, enumEntry) {
288
- const enumName = idl.forceAsNamedNode(enumEntry).name;
289
- const ordinal = value.asString();
290
- return this.makeString(`${enumName}.values()[${ordinal}]`);
291
- }
292
- makeValueFromOption(value) {
293
- return this.makeString(`${value}`);
294
- }
295
- runtimeType(param, valueType, value) {
296
- this.writeStatement(this.makeAssign(valueType, undefined, this.makeRuntimeTypeGetterCall(value), false));
297
- }
298
- i32FromEnum(value, enumEntry) {
299
- const i32Value = idl.isStringEnum(enumEntry)
300
- ? `${value.asString()}.ordinal`
301
- : `${value.asString()}.value`;
302
- return this.makeString(i32Value);
303
- }
304
- castToBoolean(value) { return value; }
305
- }
306
- //# sourceMappingURL=JavaLanguageWriter.js.map
@@ -1,21 +0,0 @@
1
- import * as webidl2 from "webidl2";
2
- export declare function isEnum(node: webidl2.IDLRootType): node is webidl2.EnumType;
3
- export declare function isInterface(node: webidl2.IDLRootType): node is webidl2.InterfaceType;
4
- export declare function isImport(node: webidl2.IDLRootType): node is webidl2.ImportType;
5
- export declare function isPackage(node: webidl2.IDLRootType): node is webidl2.PackageType;
6
- export declare function isClass(node: webidl2.IDLRootType): node is webidl2.InterfaceType;
7
- export declare function isCallback(node: webidl2.IDLRootType): node is webidl2.CallbackType;
8
- export declare function isTypedef(node: webidl2.IDLRootType): node is webidl2.TypedefType;
9
- export declare function isDictionary(node: webidl2.IDLRootType): node is webidl2.DictionaryType;
10
- export declare function isAttribute(node: webidl2.IDLInterfaceMemberType | webidl2.IDLNamespaceMemberType): node is webidl2.AttributeMemberType;
11
- export declare function isOperation(node: webidl2.IDLInterfaceMemberType | webidl2.IDLNamespaceMemberType): node is webidl2.OperationMemberType;
12
- export declare function isConstructor(node: webidl2.IDLInterfaceMemberType): node is webidl2.ConstructorMemberType;
13
- export declare function isUnionTypeDescription(node: webidl2.IDLTypeDescription): node is webidl2.UnionTypeDescription;
14
- export declare function isSingleTypeDescription(node: webidl2.IDLTypeDescription): node is webidl2.SingleTypeDescription;
15
- export declare function isSequenceTypeDescription(node: webidl2.IDLTypeDescription): node is webidl2.SequenceTypeDescription;
16
- export declare function isPromiseTypeDescription(node: webidl2.IDLTypeDescription): node is webidl2.PromiseTypeDescription;
17
- export declare function isRecordTypeDescription(node: webidl2.IDLTypeDescription): node is webidl2.RecordTypeDescription;
18
- export declare function isConstant(node: webidl2.IDLRootType): node is webidl2.ConstantMemberType;
19
- export declare function isUnspecifiedGenericTypeDescription(node: webidl2.IDLTypeDescription): node is webidl2.UnspecifiedGenericTypeDescription;
20
- export declare function isOptional(node: webidl2.AttributeMemberType | webidl2.OperationMemberType): boolean;
21
- //# sourceMappingURL=webidl2-utils.d.ts.map
@@ -1,87 +0,0 @@
1
- /*
2
- * Copyright (c) 2024 Huawei Device Co., Ltd.
3
- * Licensed under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License.
5
- * You may obtain a copy of the License at
6
- *
7
- * http://www.apache.org/licenses/LICENSE-2.0
8
- *
9
- * Unless required by applicable law or agreed to in writing, software
10
- * distributed under the License is distributed on an "AS IS" BASIS,
11
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- * See the License for the specific language governing permissions and
13
- * limitations under the License.
14
- */
15
- import { IDLEntity } from "../idl";
16
- export function isEnum(node) {
17
- return node.type === "enum";
18
- }
19
- export function isInterface(node) {
20
- return node.type === "interface";
21
- }
22
- export function isImport(node) {
23
- return node.type === "import";
24
- }
25
- export function isPackage(node) {
26
- return node.type === "package";
27
- }
28
- export function isClass(node) {
29
- var _a, _b;
30
- return isInterface(node)
31
- && ((_b = (_a = node.extAttrs.find(it => it.name === "Entity")) === null || _a === void 0 ? void 0 : _a.rhs) === null || _b === void 0 ? void 0 : _b.value) === IDLEntity.Class;
32
- }
33
- export function isCallback(node) {
34
- return node.type === "callback";
35
- }
36
- export function isTypedef(node) {
37
- return node.type === "typedef";
38
- }
39
- export function isDictionary(node) {
40
- return node.type === "dictionary";
41
- }
42
- export function isAttribute(node) {
43
- return node.type === "attribute";
44
- }
45
- export function isOperation(node) {
46
- return node.type === "operation";
47
- }
48
- export function isConstructor(node) {
49
- return node.type === "constructor";
50
- }
51
- export function isUnionTypeDescription(node) {
52
- return node.union;
53
- }
54
- export function isSingleTypeDescription(node) {
55
- return (typeof node.idlType === "string");
56
- }
57
- export function isSequenceTypeDescription(node) {
58
- return node.generic === "sequence";
59
- }
60
- export function isPromiseTypeDescription(node) {
61
- return node.generic === "Promise";
62
- }
63
- export function isRecordTypeDescription(node) {
64
- return node.generic === "record";
65
- }
66
- export function isConstant(node) {
67
- return node.type === "const";
68
- }
69
- export function isUnspecifiedGenericTypeDescription(node) {
70
- switch (node.generic) {
71
- case "FrozenArray":
72
- case "ObservableArray":
73
- case "Promise":
74
- case "record":
75
- case "sequence":
76
- case "":
77
- return false;
78
- }
79
- return true;
80
- }
81
- export function isOptional(node) {
82
- return node.extAttrs
83
- .map((it) => it.name)
84
- .map((it) => it.toLowerCase())
85
- .includes("optional");
86
- }
87
- //# sourceMappingURL=webidl2-utils.js.map