@idlizer/core 2.0.31 → 2.0.33

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 (34) hide show
  1. package/build/lib/src/LanguageWriters/ArgConvertors.d.ts +3 -2
  2. package/build/lib/src/LanguageWriters/ArgConvertors.js +19 -19
  3. package/build/lib/src/LanguageWriters/LanguageWriter.d.ts +9 -7
  4. package/build/lib/src/LanguageWriters/LanguageWriter.js +10 -7
  5. package/build/lib/src/LanguageWriters/convertors/CppConvertors.js +3 -5
  6. package/build/lib/src/LanguageWriters/convertors/ETSConvertors.d.ts +0 -1
  7. package/build/lib/src/LanguageWriters/convertors/ETSConvertors.js +1 -8
  8. package/build/lib/src/LanguageWriters/convertors/TSConvertors.js +2 -2
  9. package/build/lib/src/LanguageWriters/writers/CJLanguageWriter.js +1 -1
  10. package/build/lib/src/LanguageWriters/writers/CppLanguageWriter.js +1 -1
  11. package/build/lib/src/LanguageWriters/writers/ETSLanguageWriter.js +7 -3
  12. package/build/lib/src/LanguageWriters/writers/TsLanguageWriter.js +14 -3
  13. package/build/lib/src/from-idl/DtsPrinter.d.ts +1 -1
  14. package/build/lib/src/from-idl/DtsPrinter.js +28 -22
  15. package/build/lib/src/from-idl/deserialize.d.ts +1 -2
  16. package/build/lib/src/from-idl/deserialize.js +10 -12
  17. package/build/lib/src/idl.d.ts +19 -8
  18. package/build/lib/src/idl.js +82 -39
  19. package/build/lib/src/idlize.d.ts +12 -2
  20. package/build/lib/src/idlize.js +24 -9
  21. package/build/lib/src/library.d.ts +5 -10
  22. package/build/lib/src/library.js +2 -2
  23. package/build/lib/src/peer-generation/PeerFile.d.ts +4 -3
  24. package/build/lib/src/peer-generation/PeerFile.js +10 -3
  25. package/build/lib/src/peer-generation/PeerLibrary.d.ts +4 -6
  26. package/build/lib/src/peer-generation/PeerLibrary.js +18 -36
  27. package/build/lib/src/peer-generation/PeerMethod.js +5 -1
  28. package/build/lib/src/peer-generation/idl/IdlNameConvertor.js +5 -4
  29. package/build/lib/src/peer-generation/idl/common.js +3 -3
  30. package/build/lib/src/util.d.ts +2 -0
  31. package/build/lib/src/util.js +4 -0
  32. package/build/lib/src/visitor.js +1 -1
  33. package/package.json +1 -1
  34. package/webidl2.js/dist/webidl2.js +20 -19
@@ -12,6 +12,7 @@
12
12
  * See the License for the specific language governing permissions and
13
13
  * limitations under the License.
14
14
  */
15
+ import { generatorTypePrefix } from "../config";
15
16
  import { mangleMethodName, MethodModifier } from "../LanguageWriters/LanguageWriter";
16
17
  import { capitalize, isDefined } from "../util";
17
18
  import { PrimitiveTypesInstance } from "./PrimitiveType";
@@ -69,13 +70,16 @@ export class PeerMethod {
69
70
  return !((_a = this.method.modifiers) === null || _a === void 0 ? void 0 : _a.includes(MethodModifier.STATIC));
70
71
  }
71
72
  generateAPIParameters(converter) {
73
+ var _a;
72
74
  const args = this.argAndOutConvertors.map(it => {
73
75
  let isPointer = it.isPointerType();
74
76
  return `${isPointer ? "const " : ""}${converter.convert(it.nativeType())}${isPointer ? "*" : ""} ${it.param}`;
75
77
  });
76
78
  const receiver = this.generateReceiver();
77
79
  if (receiver)
78
- return [`${receiver.argType} ${receiver.argName}`, ...args];
80
+ args.unshift(`${receiver.argType} ${receiver.argName}`);
81
+ if ((_a = this.method.modifiers) === null || _a === void 0 ? void 0 : _a.includes(MethodModifier.THROWS))
82
+ args.unshift(`${generatorTypePrefix()}VMContext vmContext`);
79
83
  return args;
80
84
  }
81
85
  generateReceiver() {
@@ -53,15 +53,16 @@ export class ETSDeclarationNameConvertor extends DeclarationNameConvertor {
53
53
  return idl.getFQName(decl);
54
54
  }
55
55
  convertEnum(decl) {
56
- const namespace = idl.getNamespacesPathFor(decl).map(it => it.name).join('_');
57
- return `${namespace ? `${namespace}_` : ``}${decl.name}`;
56
+ return idl.getFQName(decl);
58
57
  }
59
58
  }
60
59
  ETSDeclarationNameConvertor.I = new ETSDeclarationNameConvertor();
61
60
  export class ETSFeatureNameConvertor extends DeclarationNameConvertor {
62
61
  convertEnum(decl) {
63
- const namespace = idl.getNamespacesPathFor(decl).map(it => it.name).join('');
64
- return `${namespace ? `${namespace}_` : ``}${decl.name}`;
62
+ const namespace = idl.getNamespacesPathFor(decl).map(it => it.name);
63
+ if (namespace.length > 0)
64
+ return namespace[0];
65
+ return decl.name;
65
66
  }
66
67
  }
67
68
  ETSFeatureNameConvertor.I = new ETSFeatureNameConvertor();
@@ -39,9 +39,9 @@ export function qualifiedName(decl, languageOrDelimiter) {
39
39
  const delimiter = typeof languageOrDelimiter === "string"
40
40
  ? languageOrDelimiter
41
41
  : (languageOrDelimiter === Language.CPP ? '_' : '.');
42
- if (idl.isEntry(decl) && decl.namespace)
43
- return qualifiedName(decl.namespace, delimiter) + delimiter + idl.forceAsNamedNode(decl).name;
44
- return idl.forceAsNamedNode(decl).name;
42
+ if (!idl.isEntry(decl))
43
+ throw new Error(`Expected to have an IDLEntry, got ${idl.IDLKind[decl.kind]}`);
44
+ return idl.getFQName(decl).split(".").join(delimiter);
45
45
  }
46
46
  export function collapseTypes(types, name) {
47
47
  const seenNames = new Set();
@@ -1,4 +1,5 @@
1
1
  import * as ts from "typescript";
2
+ import * as idl from "./idl";
2
3
  import { Language } from './Language';
3
4
  export interface NameWithType {
4
5
  name?: ts.DeclarationName;
@@ -80,4 +81,5 @@ export declare class Lazy<T> {
80
81
  get value(): T;
81
82
  }
82
83
  export declare function lazy<T>(factory: () => T): Lazy<T>;
84
+ export declare function isInNamespace(node: idl.IDLEntry): boolean;
83
85
  //# sourceMappingURL=util.d.ts.map
@@ -15,6 +15,7 @@
15
15
  import * as path from 'path';
16
16
  import * as fs from "fs";
17
17
  import * as ts from "typescript";
18
+ import * as idl from "./idl";
18
19
  import { Language } from './Language';
19
20
  /** True if this is visible outside this file, false otherwise */
20
21
  export function isNodePublic(node) {
@@ -635,4 +636,7 @@ export class Lazy {
635
636
  export function lazy(factory) {
636
637
  return new Lazy(factory);
637
638
  }
639
+ export function isInNamespace(node) {
640
+ return idl.getNamespacesPathFor(node).length > 0;
641
+ }
638
642
  //# sourceMappingURL=util.js.map
@@ -103,7 +103,7 @@ export class IDLDependencyCollector {
103
103
  }
104
104
  visitSupertype(type) {
105
105
  if (idl.isInterface(type)) {
106
- return this.walk(idl.createReferenceType(type.name, undefined, type));
106
+ return this.walk(idl.createReferenceType(type));
107
107
  }
108
108
  return this.walk(type);
109
109
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@idlizer/core",
3
- "version": "2.0.31",
3
+ "version": "2.0.33",
4
4
  "description": "",
5
5
  "types": "build/lib/src/index.d.ts",
6
6
  "exports": {
@@ -2073,32 +2073,35 @@ class Import extends _base_js__WEBPACK_IMPORTED_MODULE_0__.Base {
2073
2073
  return;
2074
2074
  }
2075
2075
  const tokens = { import: importKeyword };
2076
- tokens.name =
2076
+ tokens.clause =
2077
2077
  tokeniser.consumeKind("string") ||
2078
+ tokeniser.consumeKind("identifier") ||
2078
2079
  tokeniser.error("Incomplete import statement");
2080
+ tokens.as = tokeniser.consume("as");
2081
+ if (tokens.as)
2082
+ tokens.alias =
2083
+ tokeniser.consumeKind("identifier") ||
2084
+ tokeniser.error("Incomplete import statement");
2079
2085
  tokens.termination =
2080
2086
  tokeniser.consume(";") ||
2081
2087
  tokeniser.error("No terminating ; for import statement");
2082
2088
  const ret = (0,_helpers_js__WEBPACK_IMPORTED_MODULE_1__.autoParenter)(new Import({ source: tokeniser.source, tokens }));
2083
- ret.nameValue = tokens.name.value;
2089
+ ret.clause = tokens.clause.value;
2090
+ ret.alias = tokens.alias?.value;
2084
2091
  return ret.this;
2085
2092
  }
2086
2093
 
2087
2094
  get type() {
2088
2095
  return "import";
2089
2096
  }
2090
- get target() {
2091
- return (0,_helpers_js__WEBPACK_IMPORTED_MODULE_1__.unescape)(this.tokens.target.value);
2092
- }
2093
- get import() {
2094
- return (0,_helpers_js__WEBPACK_IMPORTED_MODULE_1__.unescape)(this.tokens.importName.value);
2095
- }
2096
2097
 
2097
2098
  write(w) {
2098
2099
  return w.ts.definition(
2099
2100
  w.ts.wrap([
2100
2101
  w.token(this.tokens.import),
2101
- w.reference_token(this.tokens.name, this),
2102
+ w.reference_token(this.tokens.clause, this),
2103
+ w.token(this.tokens.as),
2104
+ w.token(this.tokens.alias),
2102
2105
  w.token(this.tokens.termination),
2103
2106
  ]),
2104
2107
  { data: this },
@@ -2838,27 +2841,26 @@ class Package extends _base_js__WEBPACK_IMPORTED_MODULE_0__.Base {
2838
2841
  return;
2839
2842
  }
2840
2843
  const tokens = { base: packageKeyword };
2841
- tokens.name =
2842
- tokeniser.consumeKind("string") || tokeniser.error("No name for package");
2844
+ tokens.clause =
2845
+ tokeniser.consumeKind("string") ||
2846
+ tokeniser.consumeKind("identifier") ||
2847
+ tokeniser.error("No clause for package");
2843
2848
  tokens.termination =
2844
2849
  tokeniser.consume(";") || tokeniser.error("No semicolon after package");
2845
2850
  const ret = (0,_helpers_js__WEBPACK_IMPORTED_MODULE_1__.autoParenter)(new Package({ source: tokeniser.source, tokens }));
2846
- ret.nameValue = tokens.name.value;
2851
+ ret.clause = tokens.clause.value;
2847
2852
  return ret.this;
2848
2853
  }
2849
2854
 
2850
2855
  get type() {
2851
2856
  return "package";
2852
2857
  }
2853
- get name() {
2854
- return (0,_helpers_js__WEBPACK_IMPORTED_MODULE_1__.unescape)(this.tokens.name.value);
2855
- }
2856
2858
 
2857
2859
  write(w) {
2858
2860
  return w.ts.definition(
2859
2861
  w.ts.wrap([
2860
2862
  w.token(this.tokens.base),
2861
- w.reference_token(this.tokens.name, this),
2863
+ w.reference_token(this.tokens.clause, this),
2862
2864
  w.token(this.tokens.termination),
2863
2865
  ]),
2864
2866
  { data: this },
@@ -3640,6 +3642,7 @@ const argumentNameKeywords = [
3640
3642
  "unrestricted",
3641
3643
  "package",
3642
3644
  "import",
3645
+ "as",
3643
3646
  "version",
3644
3647
  ];
3645
3648
 
@@ -3733,9 +3736,7 @@ function tokenise(str) {
3733
3736
  const token = tokens[lastIndex];
3734
3737
  if (result !== -1) {
3735
3738
  if (reserved.includes(token.value)) {
3736
- const message = `${(0,_productions_helpers_js__WEBPACK_IMPORTED_MODULE_1__.unescape)(
3737
- token.value,
3738
- )} is a reserved identifier and must not be used.`;
3739
+ const message = `${(0,_productions_helpers_js__WEBPACK_IMPORTED_MODULE_1__.unescape)(token.value)} is a reserved identifier and must not be used.`;
3739
3740
  throw new WebIDLParseError(
3740
3741
  (0,_error_js__WEBPACK_IMPORTED_MODULE_0__.syntaxError)(tokens, lastIndex, null, message),
3741
3742
  );