Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use .webidl extension #73

Merged
merged 1 commit into from
Sep 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ The main module's default export is a class which you can construct with a few o
- `implSuffix`: a suffix used, if any, to find files within the source directory based on the IDL file name.
- `suppressErrors`: set to true to suppress errors during generation.

The `addSource()` method can then be called multiple times to add directories containing `.idl` IDL files and `.js` implementation class files.
The `addSource()` method can then be called multiple times to add directories containing `.webidl` IDL files and `.js` implementation class files.

Finally, the `generate()` method will generate corresponding wrapper class files in the given directory.

In this example, a file at `idl/SomeInterface.idl` would generate a new wrapper class at `wrappers/SomeInterface.js`, which would refer to an implementation class at `impls/SomeInterface-impl.js`. (In practice, usually at least two of these directories are the same, making `implSuffix` a useful option.)
In this example, a file at `idl/SomeInterface.webidl` would generate a new wrapper class at `wrappers/SomeInterface.js`, which would refer to an implementation class at `impls/SomeInterface-impl.js`. (In practice, usually at least two of these directories are the same, making `implSuffix` a useful option.)

The transformer will also generate a file named `utils.js` inside the wrapper class directory, which contains utilities used by all the wrapper class files.

Expand Down
2 changes: 1 addition & 1 deletion lib/transformer.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Transformer {
if (stats[i].isDirectory()) {
const folderContents = yield fs.readdir(this.sources[i].idlPath);
for (const file of folderContents) {
if (file.endsWith(".idl")) {
if (file.endsWith(".webidl")) {
files.push({
idlPath: path.join(this.sources[i].idlPath, file),
impl: this.sources[i].impl
Expand Down
54 changes: 27 additions & 27 deletions test/__snapshots__/test.js.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Dictionary.idl 1`] = `
exports[`Dictionary.webidl 1`] = `
"\\"use strict\\";

const conversions = require(\\"webidl-conversions\\");
Expand Down Expand Up @@ -80,7 +80,7 @@ module.exports = {
"
`;

exports[`Factory.idl 1`] = `
exports[`Factory.webidl 1`] = `
"\\"use strict\\";

const conversions = require(\\"webidl-conversions\\");
Expand Down Expand Up @@ -236,7 +236,7 @@ const Impl = require(\\"../implementations/Factory.js\\");
"
`;

exports[`LegacyArrayClass.idl 1`] = `
exports[`LegacyArrayClass.webidl 1`] = `
"\\"use strict\\";

const conversions = require(\\"webidl-conversions\\");
Expand Down Expand Up @@ -355,7 +355,7 @@ const Impl = require(\\"../implementations/LegacyArrayClass.js\\");
"
`;

exports[`MixedIn.idl 1`] = `
exports[`MixedIn.webidl 1`] = `
"\\"use strict\\";

const conversions = require(\\"webidl-conversions\\");
Expand Down Expand Up @@ -638,7 +638,7 @@ const Impl = require(\\"../implementations/MixedIn.js\\");
"
`;

exports[`Mixin.idl 1`] = `
exports[`Mixin.webidl 1`] = `
"\\"use strict\\";

const conversions = require(\\"webidl-conversions\\");
Expand Down Expand Up @@ -833,7 +833,7 @@ const Impl = require(\\"../implementations/Mixin.js\\");
"
`;

exports[`MixinInherited.idl 1`] = `
exports[`MixinInherited.webidl 1`] = `
"\\"use strict\\";

const conversions = require(\\"webidl-conversions\\");
Expand Down Expand Up @@ -985,7 +985,7 @@ const Impl = require(\\"../implementations/MixinInherited.js\\");
"
`;

exports[`MixinMixin.idl 1`] = `
exports[`MixinMixin.webidl 1`] = `
"\\"use strict\\";

const conversions = require(\\"webidl-conversions\\");
Expand Down Expand Up @@ -1129,7 +1129,7 @@ const Impl = require(\\"../implementations/MixinMixin.js\\");
"
`;

exports[`Overloads.idl 1`] = `
exports[`Overloads.webidl 1`] = `
"\\"use strict\\";

const conversions = require(\\"webidl-conversions\\");
Expand Down Expand Up @@ -1281,7 +1281,7 @@ const Impl = require(\\"../implementations/Overloads.js\\");
"
`;

exports[`PromiseTypes.idl 1`] = `
exports[`PromiseTypes.webidl 1`] = `
"\\"use strict\\";

const conversions = require(\\"webidl-conversions\\");
Expand Down Expand Up @@ -1439,7 +1439,7 @@ const Impl = require(\\"../implementations/PromiseTypes.js\\");
"
`;

exports[`SeqAndRec.idl 1`] = `
exports[`SeqAndRec.webidl 1`] = `
"\\"use strict\\";

const conversions = require(\\"webidl-conversions\\");
Expand Down Expand Up @@ -1751,7 +1751,7 @@ const Impl = require(\\"../implementations/SeqAndRec.js\\");
"
`;

exports[`Static.idl 1`] = `
exports[`Static.webidl 1`] = `
"\\"use strict\\";

const conversions = require(\\"webidl-conversions\\");
Expand Down Expand Up @@ -1905,7 +1905,7 @@ const Impl = require(\\"../implementations/Static.js\\");
"
`;

exports[`Storage.idl 1`] = `
exports[`Storage.webidl 1`] = `
"\\"use strict\\";

const conversions = require(\\"webidl-conversions\\");
Expand Down Expand Up @@ -2283,7 +2283,7 @@ const Impl = require(\\"../implementations/Storage.js\\");
"
`;

exports[`StringifierAttribute.idl 1`] = `
exports[`StringifierAttribute.webidl 1`] = `
"\\"use strict\\";

const conversions = require(\\"webidl-conversions\\");
Expand Down Expand Up @@ -2407,7 +2407,7 @@ const Impl = require(\\"../implementations/StringifierAttribute.js\\");
"
`;

exports[`StringifierDefaultOperation.idl 1`] = `
exports[`StringifierDefaultOperation.webidl 1`] = `
"\\"use strict\\";

const conversions = require(\\"webidl-conversions\\");
Expand Down Expand Up @@ -2519,7 +2519,7 @@ const Impl = require(\\"../implementations/StringifierDefaultOperation.js\\");
"
`;

exports[`StringifierNamedOperation.idl 1`] = `
exports[`StringifierNamedOperation.webidl 1`] = `
"\\"use strict\\";

const conversions = require(\\"webidl-conversions\\");
Expand Down Expand Up @@ -2639,7 +2639,7 @@ const Impl = require(\\"../implementations/StringifierNamedOperation.js\\");
"
`;

exports[`StringifierOperation.idl 1`] = `
exports[`StringifierOperation.webidl 1`] = `
"\\"use strict\\";

const conversions = require(\\"webidl-conversions\\");
Expand Down Expand Up @@ -2751,7 +2751,7 @@ const Impl = require(\\"../implementations/StringifierOperation.js\\");
"
`;

exports[`TypedefsAndUnions.idl 1`] = `
exports[`TypedefsAndUnions.webidl 1`] = `
"\\"use strict\\";

const conversions = require(\\"webidl-conversions\\");
Expand Down Expand Up @@ -3246,7 +3246,7 @@ const Impl = require(\\"../implementations/TypedefsAndUnions.js\\");
"
`;

exports[`URL.idl 1`] = `
exports[`URL.webidl 1`] = `
"\\"use strict\\";

const conversions = require(\\"webidl-conversions\\");
Expand Down Expand Up @@ -3646,7 +3646,7 @@ const Impl = require(\\"../implementations/URL.js\\");
"
`;

exports[`URLList.idl 1`] = `
exports[`URLList.webidl 1`] = `
"\\"use strict\\";

const conversions = require(\\"webidl-conversions\\");
Expand Down Expand Up @@ -3955,7 +3955,7 @@ const Impl = require(\\"../implementations/URLList.js\\");
"
`;

exports[`URLSearchParams.idl 1`] = `
exports[`URLSearchParams.webidl 1`] = `
"\\"use strict\\";

const conversions = require(\\"webidl-conversions\\");
Expand Down Expand Up @@ -4408,7 +4408,7 @@ const Impl = require(\\"../implementations/URLSearchParams.js\\");
"
`;

exports[`URLSearchParamsCollection.idl 1`] = `
exports[`URLSearchParamsCollection.webidl 1`] = `
"\\"use strict\\";

const conversions = require(\\"webidl-conversions\\");
Expand Down Expand Up @@ -4770,7 +4770,7 @@ const Impl = require(\\"../implementations/URLSearchParamsCollection.js\\");
"
`;

exports[`URLSearchParamsCollection2.idl 1`] = `
exports[`URLSearchParamsCollection2.webidl 1`] = `
"\\"use strict\\";

const conversions = require(\\"webidl-conversions\\");
Expand Down Expand Up @@ -5103,7 +5103,7 @@ const Impl = require(\\"../implementations/URLSearchParamsCollection2.js\\");
"
`;

exports[`UnderscoredProperties.idl 1`] = `
exports[`UnderscoredProperties.webidl 1`] = `
"\\"use strict\\";

const conversions = require(\\"webidl-conversions\\");
Expand Down Expand Up @@ -5347,7 +5347,7 @@ const Impl = require(\\"../implementations/UnderscoredProperties.js\\");
"
`;

exports[`Unforgeable.idl 1`] = `
exports[`Unforgeable.webidl 1`] = `
"\\"use strict\\";

const conversions = require(\\"webidl-conversions\\");
Expand Down Expand Up @@ -5552,7 +5552,7 @@ const Impl = require(\\"../implementations/Unforgeable.js\\");
"
`;

exports[`UnforgeableMap.idl 1`] = `
exports[`UnforgeableMap.webidl 1`] = `
"\\"use strict\\";

const conversions = require(\\"webidl-conversions\\");
Expand Down Expand Up @@ -5844,7 +5844,7 @@ const Impl = require(\\"../implementations/UnforgeableMap.js\\");
"
`;

exports[`Variadic.idl 1`] = `
exports[`Variadic.webidl 1`] = `
"\\"use strict\\";

const conversions = require(\\"webidl-conversions\\");
Expand Down Expand Up @@ -6029,7 +6029,7 @@ const Impl = require(\\"../implementations/Variadic.js\\");
"
`;

exports[`ZeroArgConstructor.idl 1`] = `
exports[`ZeroArgConstructor.webidl 1`] = `
"\\"use strict\\";

const conversions = require(\\"webidl-conversions\\");
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const idlFiles = fs.readdirSync(casesDir);

for (const idlFile of idlFiles) {
test(idlFile, () => {
const outputFile = path.resolve(outputDir, path.basename(idlFile, ".idl") + ".js");
const outputFile = path.resolve(outputDir, path.basename(idlFile, ".webidl") + ".js");
const output = fs.readFileSync(outputFile, { encoding: "utf-8" });

expect(output).toMatchSnapshot();
Expand Down