Bug 1782784 - Convert UniFFI JS bindings to ESM. r=nika

Differential Revision: https://phabricator.services.mozilla.com/D176210
This commit is contained in:
Mathew Hodson 2023-05-08 13:36:45 +00:00
parent 3cde859661
commit 9840cc5f84
55 changed files with 382 additions and 644 deletions

View File

@ -15,7 +15,7 @@ interoperability.
The [`uniffi-bindgen-gecko-js`](https://searchfox.org/mozilla-central/source/toolkit/components/uniffi-bindgen-gecko-js)
tool, which lives in the Firefox source tree, generates 2 things:
- A JS interface for the scaffolding code, which uses [WebIDL](/dom/bindings/webidl/index.rst)
- A JSM module that uses the scaffolding to provide the bindings API.
- A module that uses the scaffolding to provide the bindings API.
Currently, this generated code gets checked in to source control. We are working on a system to avoid this and
auto-generate it at build time instead (see [bugzilla 1756214](https://bugzilla.mozilla.org/show_bug.cgi?id=1756214)).
@ -55,15 +55,15 @@ Here's how you can create a new set of bindings using UniFFI:
3. Generate bindings code for your crate
- Add the path of your UDL (that you made in step 1) in `toolkit/components/uniffi-bindgen-gecko-js/mach_commands.py`
- Run `./mach uniffi generate`
- add your newly generated `Rust{udl-name}.jsm` file to `toolkit/components/uniffi-bindgen-gecko-js/components/moz.build`
- Then simply import your `jsm` module to the file you want to use it in and start using your APIs!
- add your newly generated `Rust{udl-name}.sys.mjs` file to `toolkit/components/uniffi-bindgen-gecko-js/components/moz.build`
- Then simply import your module to the file you want to use it in and start using your APIs!
Example from tabs module:
``` js
XPCOMUtils.defineLazyModuleGetters(lazy, {
ChromeUtils.defineESModuleGetters(lazy, {
...
TabsStore: "resource://gre/modules/RustTabs.jsm",
TabsStore: "resource://gre/modules/RustTabs.sys.mjs",
});
...
this._rustStore = await lazy.TabsStore.init(path);

View File

@ -5,11 +5,9 @@
const STORAGE_VERSION = 1; // This needs to be kept in-sync with the rust storage version
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
import { SyncEngine, Tracker } from "resource://services-sync/engines.sys.mjs";
import { Svc, Utils } from "resource://services-sync/util.sys.mjs";
import { Log } from "resource://gre/modules/Log.sys.mjs";
import {
SCORE_INCREMENT_SMALL,
STATUS_OK,
@ -17,7 +15,6 @@ import {
} from "resource://services-sync/constants.sys.mjs";
import { CommonUtils } from "resource://services-common/utils.sys.mjs";
import { Async } from "resource://services-common/async.sys.mjs";
import {
SyncRecord,
SyncTelemetry,
@ -32,10 +29,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
PlacesUtils: "resource://gre/modules/PlacesUtils.sys.mjs",
PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.sys.mjs",
ReaderMode: "resource://gre/modules/ReaderMode.sys.mjs",
});
XPCOMUtils.defineLazyModuleGetters(lazy, {
TabsStore: "resource://gre/modules/RustTabs.jsm",
TabsStore: "resource://gre/modules/RustTabs.sys.mjs",
});
XPCOMUtils.defineLazyPreferenceGetter(

View File

@ -1,16 +1,12 @@
// This file was autogenerated by the `uniffi-bindgen-gecko-js` crate.
// Trust me, you don't want to mess with it!
const { UniFFITypeError } = ChromeUtils.importESModule("resource://gre/modules/UniFFI.sys.mjs");
import { UniFFITypeError } from "resource://gre/modules/UniFFI.sys.mjs";
"use strict";
// Objects intended to be used in the unit tests
var UnitTestObjs = {};
var EXPORTED_SYMBOLS = ["UnitTestObjs"];
export var UnitTestObjs = {};
// Write/Read data to/from an ArrayBuffer
class ArrayBufferDataStream {
@ -265,7 +261,8 @@ const uniffiObjectPtr = Symbol("uniffiObjectPtr");
const constructUniffiObject = Symbol("constructUniffiObject");
UnitTestObjs.uniffiObjectPtr = uniffiObjectPtr;
class FfiConverterI64 extends FfiConverter {
// Export the FFIConverter object to make external types work.
export class FfiConverterI64 extends FfiConverter {
static checkType(value) {
super.checkType(value);
if (!Number.isSafeInteger(value)) {
@ -290,9 +287,7 @@ class FfiConverterI64 extends FfiConverter {
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterI64");
class FfiConverterString extends FfiConverter {
export class FfiConverterString extends FfiConverter {
static checkType(value) {
super.checkType(value);
if (typeof value !== "string") {
@ -324,10 +319,7 @@ class FfiConverterString extends FfiConverter {
}
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterString");
class TabsBridgedEngine {
export class TabsBridgedEngine {
// Use `init` to instantiate this class.
// DO NOT USE THIS CONSTRUCTOR DIRECTLY
constructor(opts) {
@ -605,7 +597,8 @@ class TabsBridgedEngine {
}
class FfiConverterTypeTabsBridgedEngine extends FfiConverter {
// Export the FFIConverter object to make external types work.
export class FfiConverterTypeTabsBridgedEngine extends FfiConverter {
static lift(value) {
const opts = {};
opts[constructUniffiObject] = value;
@ -629,12 +622,7 @@ class FfiConverterTypeTabsBridgedEngine extends FfiConverter {
}
}
EXPORTED_SYMBOLS.push("TabsBridgedEngine");
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterTypeTabsBridgedEngine");
class TabsStore {
export class TabsStore {
// Use `init` to instantiate this class.
// DO NOT USE THIS CONSTRUCTOR DIRECTLY
constructor(opts) {
@ -828,7 +816,8 @@ class TabsStore {
}
class FfiConverterTypeTabsStore extends FfiConverter {
// Export the FFIConverter object to make external types work.
export class FfiConverterTypeTabsStore extends FfiConverter {
static lift(value) {
const opts = {};
opts[constructUniffiObject] = value;
@ -852,12 +841,7 @@ class FfiConverterTypeTabsStore extends FfiConverter {
}
}
EXPORTED_SYMBOLS.push("TabsStore");
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterTypeTabsStore");
class ClientRemoteTabs {
export class ClientRemoteTabs {
constructor(clientId,clientName,deviceType,lastModified,remoteTabs) {
try {
FfiConverterString.checkType(clientId)
@ -916,7 +900,8 @@ class ClientRemoteTabs {
}
}
class FfiConverterTypeClientRemoteTabs extends FfiConverterArrayBuffer {
// Export the FFIConverter object to make external types work.
export class FfiConverterTypeClientRemoteTabs extends FfiConverterArrayBuffer {
static read(dataStream) {
return new ClientRemoteTabs(
FfiConverterString.read(dataStream),
@ -989,12 +974,7 @@ class FfiConverterTypeClientRemoteTabs extends FfiConverterArrayBuffer {
}
}
EXPORTED_SYMBOLS.push("ClientRemoteTabs");
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterTypeClientRemoteTabs");
class RemoteTabRecord {
export class RemoteTabRecord {
constructor(title,urlHistory,icon,lastUsed) {
try {
FfiConverterString.checkType(title)
@ -1043,7 +1023,8 @@ class RemoteTabRecord {
}
}
class FfiConverterTypeRemoteTabRecord extends FfiConverterArrayBuffer {
// Export the FFIConverter object to make external types work.
export class FfiConverterTypeRemoteTabRecord extends FfiConverterArrayBuffer {
static read(dataStream) {
return new RemoteTabRecord(
FfiConverterString.read(dataStream),
@ -1105,12 +1086,7 @@ class FfiConverterTypeRemoteTabRecord extends FfiConverterArrayBuffer {
}
}
EXPORTED_SYMBOLS.push("RemoteTabRecord");
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterTypeRemoteTabRecord");
const TabsDeviceType = {
export const TabsDeviceType = {
DESKTOP: 1,
MOBILE: 2,
TABLET: 3,
@ -1120,7 +1096,8 @@ const TabsDeviceType = {
};
Object.freeze(TabsDeviceType);
class FfiConverterTypeTabsDeviceType extends FfiConverterArrayBuffer {
// Export the FFIConverter object to make external types work.
export class FfiConverterTypeTabsDeviceType extends FfiConverterArrayBuffer {
static read(dataStream) {
switch (dataStream.readInt32()) {
case 1:
@ -1179,18 +1156,12 @@ class FfiConverterTypeTabsDeviceType extends FfiConverterArrayBuffer {
}
}
EXPORTED_SYMBOLS.push("TabsDeviceType");
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterTypeTabsDeviceType");
class TabsApiError extends Error {}
EXPORTED_SYMBOLS.push("TabsApiError");
export class TabsApiError extends Error {}
class SyncError extends TabsApiError {
export class SyncError extends TabsApiError {
constructor(
reason,
@ -1203,8 +1174,8 @@ class SyncError extends TabsApiError {
return `SyncError: ${super.toString()}`
}
}
EXPORTED_SYMBOLS.push("SyncError");
class SqlError extends TabsApiError {
export class SqlError extends TabsApiError {
constructor(
reason,
@ -1217,8 +1188,8 @@ class SqlError extends TabsApiError {
return `SqlError: ${super.toString()}`
}
}
EXPORTED_SYMBOLS.push("SqlError");
class UnexpectedTabsError extends TabsApiError {
export class UnexpectedTabsError extends TabsApiError {
constructor(
reason,
@ -1231,9 +1202,9 @@ class UnexpectedTabsError extends TabsApiError {
return `UnexpectedTabsError: ${super.toString()}`
}
}
EXPORTED_SYMBOLS.push("UnexpectedTabsError");
class FfiConverterTypeTabsApiError extends FfiConverterArrayBuffer {
// Export the FFIConverter object to make external types work.
export class FfiConverterTypeTabsApiError extends FfiConverterArrayBuffer {
static read(dataStream) {
switch (dataStream.readInt32()) {
case 1:
@ -1292,9 +1263,7 @@ class FfiConverterTypeTabsApiError extends FfiConverterArrayBuffer {
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterTypeTabsApiError");
class FfiConverterOptionalstring extends FfiConverterArrayBuffer {
export class FfiConverterOptionalstring extends FfiConverterArrayBuffer {
static checkType(value) {
if (value !== undefined && value !== null) {
FfiConverterString.checkType(value)
@ -1331,9 +1300,7 @@ class FfiConverterOptionalstring extends FfiConverterArrayBuffer {
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterOptionalstring");
class FfiConverterSequencestring extends FfiConverterArrayBuffer {
export class FfiConverterSequencestring extends FfiConverterArrayBuffer {
static read(dataStream) {
const len = dataStream.readInt32();
const arr = [];
@ -1377,9 +1344,7 @@ class FfiConverterSequencestring extends FfiConverterArrayBuffer {
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterSequencestring");
class FfiConverterSequenceTypeClientRemoteTabs extends FfiConverterArrayBuffer {
export class FfiConverterSequenceTypeClientRemoteTabs extends FfiConverterArrayBuffer {
static read(dataStream) {
const len = dataStream.readInt32();
const arr = [];
@ -1423,9 +1388,7 @@ class FfiConverterSequenceTypeClientRemoteTabs extends FfiConverterArrayBuffer {
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterSequenceTypeClientRemoteTabs");
class FfiConverterSequenceTypeRemoteTabRecord extends FfiConverterArrayBuffer {
export class FfiConverterSequenceTypeRemoteTabRecord extends FfiConverterArrayBuffer {
static read(dataStream) {
const len = dataStream.readInt32();
const arr = [];
@ -1469,9 +1432,7 @@ class FfiConverterSequenceTypeRemoteTabRecord extends FfiConverterArrayBuffer {
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterSequenceTypeRemoteTabRecord");
class FfiConverterSequenceTypeTabsGuid extends FfiConverterArrayBuffer {
export class FfiConverterSequenceTypeTabsGuid extends FfiConverterArrayBuffer {
static read(dataStream) {
const len = dataStream.readInt32();
const arr = [];
@ -1515,10 +1476,7 @@ class FfiConverterSequenceTypeTabsGuid extends FfiConverterArrayBuffer {
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterSequenceTypeTabsGuid");
class FfiConverterTypeTabsGuid extends FfiConverter {
export class FfiConverterTypeTabsGuid extends FfiConverter {
static lift(buf) {
return FfiConverterString.lift(buf);
}
@ -1541,9 +1499,6 @@ class FfiConverterTypeTabsGuid extends FfiConverter {
}
// TODO: We should also allow JS to customize the type eventually.
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterTypeTabsGuid");

View File

@ -5,7 +5,7 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
EXTRA_JS_MODULES += [
"generated/RustTabs.jsm",
"generated/RustTabs.sys.mjs",
]
with Files("**"):

View File

@ -1,16 +1,12 @@
// This file was autogenerated by the `uniffi-bindgen-gecko-js` crate.
// Trust me, you don't want to mess with it!
const { UniFFITypeError } = ChromeUtils.importESModule("resource://gre/modules/UniFFI.sys.mjs");
import { UniFFITypeError } from "resource://gre/modules/UniFFI.sys.mjs";
"use strict";
// Objects intended to be used in the unit tests
var UnitTestObjs = {};
var EXPORTED_SYMBOLS = ["UnitTestObjs"];
export var UnitTestObjs = {};
// Write/Read data to/from an ArrayBuffer
class ArrayBufferDataStream {
@ -225,7 +221,8 @@ const uniffiObjectPtr = Symbol("uniffiObjectPtr");
const constructUniffiObject = Symbol("constructUniffiObject");
UnitTestObjs.uniffiObjectPtr = uniffiObjectPtr;
class FfiConverterU64 extends FfiConverter {
// Export the FFIConverter object to make external types work.
export class FfiConverterU64 extends FfiConverter {
static checkType(value) {
super.checkType(value);
if (!Number.isSafeInteger(value)) {
@ -253,9 +250,7 @@ class FfiConverterU64 extends FfiConverter {
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterU64");
class FfiConverterBool extends FfiConverter {
export class FfiConverterBool extends FfiConverter {
static computeSize() {
return 1;
}
@ -278,9 +273,7 @@ class FfiConverterBool extends FfiConverter {
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterBool");
class FfiConverterString extends FfiConverter {
export class FfiConverterString extends FfiConverter {
static checkType(value) {
super.checkType(value);
if (typeof value !== "string") {
@ -312,16 +305,12 @@ class FfiConverterString extends FfiConverter {
}
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterString");
class ArithmeticError extends Error {}
EXPORTED_SYMBOLS.push("ArithmeticError");
export class ArithmeticError extends Error {}
class IntegerOverflow extends ArithmeticError {
export class IntegerOverflow extends ArithmeticError {
constructor(message, ...params) {
super(...params);
@ -331,9 +320,9 @@ class IntegerOverflow extends ArithmeticError {
return `IntegerOverflow: ${super.toString()}`
}
}
EXPORTED_SYMBOLS.push("IntegerOverflow");
class FfiConverterTypeArithmeticError extends FfiConverterArrayBuffer {
// Export the FFIConverter object to make external types work.
export class FfiConverterTypeArithmeticError extends FfiConverterArrayBuffer {
static read(dataStream) {
switch (dataStream.readInt32()) {
case 1:
@ -361,13 +350,11 @@ class FfiConverterTypeArithmeticError extends FfiConverterArrayBuffer {
static errorClass = ArithmeticError;
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterTypeArithmeticError");
function add(a,b) {
export function add(a,b) {
const liftResult = (result) => FfiConverterU64.lift(result);
const liftError = (data) => FfiConverterTypeArithmeticError.lift(data);
@ -401,8 +388,7 @@ function add(a,b) {
}
}
EXPORTED_SYMBOLS.push("add");
function sub(a,b) {
export function sub(a,b) {
const liftResult = (result) => FfiConverterU64.lift(result);
const liftError = (data) => FfiConverterTypeArithmeticError.lift(data);
@ -436,8 +422,7 @@ function sub(a,b) {
}
}
EXPORTED_SYMBOLS.push("sub");
function div(dividend,divisor) {
export function div(dividend,divisor) {
const liftResult = (result) => FfiConverterU64.lift(result);
const liftError = null;
@ -471,8 +456,7 @@ function div(dividend,divisor) {
}
}
EXPORTED_SYMBOLS.push("div");
function equal(a,b) {
export function equal(a,b) {
const liftResult = (result) => FfiConverterBool.lift(result);
const liftError = null;
@ -505,5 +489,3 @@ function equal(a,b) {
return Promise.reject(error)
}
}
EXPORTED_SYMBOLS.push("equal");

View File

@ -1,16 +1,12 @@
// This file was autogenerated by the `uniffi-bindgen-gecko-js` crate.
// Trust me, you don't want to mess with it!
const { UniFFITypeError } = ChromeUtils.importESModule("resource://gre/modules/UniFFI.sys.mjs");
import { UniFFITypeError } from "resource://gre/modules/UniFFI.sys.mjs";
"use strict";
// Objects intended to be used in the unit tests
var UnitTestObjs = {};
var EXPORTED_SYMBOLS = ["UnitTestObjs"];
export var UnitTestObjs = {};
// Write/Read data to/from an ArrayBuffer
class ArrayBufferDataStream {
@ -225,7 +221,8 @@ const uniffiObjectPtr = Symbol("uniffiObjectPtr");
const constructUniffiObject = Symbol("constructUniffiObject");
UnitTestObjs.uniffiObjectPtr = uniffiObjectPtr;
class FfiConverterI64 extends FfiConverter {
// Export the FFIConverter object to make external types work.
export class FfiConverterI64 extends FfiConverter {
static checkType(value) {
super.checkType(value);
if (!Number.isSafeInteger(value)) {
@ -250,9 +247,7 @@ class FfiConverterI64 extends FfiConverter {
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterI64");
class FfiConverterString extends FfiConverter {
export class FfiConverterString extends FfiConverter {
static checkType(value) {
super.checkType(value);
if (typeof value !== "string") {
@ -284,10 +279,7 @@ class FfiConverterString extends FfiConverter {
}
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterString");
class CustomTypesDemo {
export class CustomTypesDemo {
constructor(url,handle) {
try {
FfiConverterTypeUrl.checkType(url)
@ -316,7 +308,8 @@ class CustomTypesDemo {
}
}
class FfiConverterTypeCustomTypesDemo extends FfiConverterArrayBuffer {
// Export the FFIConverter object to make external types work.
export class FfiConverterTypeCustomTypesDemo extends FfiConverterArrayBuffer {
static read(dataStream) {
return new CustomTypesDemo(
FfiConverterTypeUrl.read(dataStream),
@ -356,12 +349,8 @@ class FfiConverterTypeCustomTypesDemo extends FfiConverterArrayBuffer {
}
}
EXPORTED_SYMBOLS.push("CustomTypesDemo");
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterTypeCustomTypesDemo");
class FfiConverterOptionalTypeCustomTypesDemo extends FfiConverterArrayBuffer {
export class FfiConverterOptionalTypeCustomTypesDemo extends FfiConverterArrayBuffer {
static checkType(value) {
if (value !== undefined && value !== null) {
FfiConverterTypeCustomTypesDemo.checkType(value)
@ -398,10 +387,7 @@ class FfiConverterOptionalTypeCustomTypesDemo extends FfiConverterArrayBuffer {
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterOptionalTypeCustomTypesDemo");
class FfiConverterTypeHandle extends FfiConverter {
export class FfiConverterTypeHandle extends FfiConverter {
static lift(buf) {
return FfiConverterI64.lift(buf);
}
@ -425,10 +411,7 @@ class FfiConverterTypeHandle extends FfiConverter {
// TODO: We should also allow JS to customize the type eventually.
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterTypeHandle");
class FfiConverterTypeUrl extends FfiConverter {
export class FfiConverterTypeUrl extends FfiConverter {
static lift(buf) {
return FfiConverterString.lift(buf);
}
@ -451,13 +434,11 @@ class FfiConverterTypeUrl extends FfiConverter {
}
// TODO: We should also allow JS to customize the type eventually.
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterTypeUrl");
function getCustomTypesDemo(demo) {
export function getCustomTypesDemo(demo) {
const liftResult = (result) => FfiConverterTypeCustomTypesDemo.lift(result);
const liftError = null;
@ -481,5 +462,3 @@ function getCustomTypesDemo(demo) {
return Promise.reject(error)
}
}
EXPORTED_SYMBOLS.push("getCustomTypesDemo");

View File

@ -1,16 +1,12 @@
// This file was autogenerated by the `uniffi-bindgen-gecko-js` crate.
// Trust me, you don't want to mess with it!
const { UniFFITypeError } = ChromeUtils.importESModule("resource://gre/modules/UniFFI.sys.mjs");
import { UniFFITypeError } from "resource://gre/modules/UniFFI.sys.mjs";
"use strict";
// Objects intended to be used in the unit tests
var UnitTestObjs = {};
var EXPORTED_SYMBOLS = ["UnitTestObjs"];
export var UnitTestObjs = {};
// Write/Read data to/from an ArrayBuffer
class ArrayBufferDataStream {
@ -225,7 +221,8 @@ const uniffiObjectPtr = Symbol("uniffiObjectPtr");
const constructUniffiObject = Symbol("constructUniffiObject");
UnitTestObjs.uniffiObjectPtr = uniffiObjectPtr;
class FfiConverterF64 extends FfiConverter {
// Export the FFIConverter object to make external types work.
export class FfiConverterF64 extends FfiConverter {
static computeSize() {
return 8;
}
@ -244,9 +241,7 @@ class FfiConverterF64 extends FfiConverter {
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterF64");
class FfiConverterString extends FfiConverter {
export class FfiConverterString extends FfiConverter {
static checkType(value) {
super.checkType(value);
if (typeof value !== "string") {
@ -279,9 +274,7 @@ class FfiConverterString extends FfiConverter {
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterString");
class FfiConverterOptionalTypeLine extends FfiConverterArrayBuffer {
export class FfiConverterOptionalTypeLine extends FfiConverterArrayBuffer {
static checkType(value) {
if (value !== undefined && value !== null) {
FfiConverterTypeLine.checkType(value)
@ -317,29 +310,27 @@ class FfiConverterOptionalTypeLine extends FfiConverterArrayBuffer {
}
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterOptionalTypeLine");
const { Line, FfiConverterTypeLine } = ChromeUtils.import(
"resource://gre/modules/RustGeometry.jsm"
);
EXPORTED_SYMBOLS.push("Line");
import {
FfiConverterTypeLine,
Line,
} from "resource://gre/modules/RustGeometry.sys.mjs";
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterTypeLine");
export { FfiConverterTypeLine, Line };
const { Point, FfiConverterTypePoint } = ChromeUtils.import(
"resource://gre/modules/RustGeometry.jsm"
);
EXPORTED_SYMBOLS.push("Point");
import {
FfiConverterTypePoint,
Point,
} from "resource://gre/modules/RustGeometry.sys.mjs";
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterTypePoint");
export { FfiConverterTypePoint, Point };
function gradient(value) {
export function gradient(value) {
const liftResult = (result) => FfiConverterF64.lift(result);
const liftError = null;
@ -363,5 +354,3 @@ function gradient(value) {
return Promise.reject(error)
}
}
EXPORTED_SYMBOLS.push("gradient");

View File

@ -1,16 +1,12 @@
// This file was autogenerated by the `uniffi-bindgen-gecko-js` crate.
// Trust me, you don't want to mess with it!
const { UniFFITypeError } = ChromeUtils.importESModule("resource://gre/modules/UniFFI.sys.mjs");
import { UniFFITypeError } from "resource://gre/modules/UniFFI.sys.mjs";
"use strict";
// Objects intended to be used in the unit tests
var UnitTestObjs = {};
var EXPORTED_SYMBOLS = ["UnitTestObjs"];
export var UnitTestObjs = {};
// Write/Read data to/from an ArrayBuffer
class ArrayBufferDataStream {
@ -421,7 +417,8 @@ class UniFFICallbackHandleMapEntry {
}
}
class FfiConverterI32 extends FfiConverter {
// Export the FFIConverter object to make external types work.
export class FfiConverterI32 extends FfiConverter {
static checkType(value) {
super.checkType(value);
if (!Number.isInteger(value)) {
@ -449,9 +446,7 @@ class FfiConverterI32 extends FfiConverter {
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterI32");
class FfiConverterString extends FfiConverter {
export class FfiConverterString extends FfiConverter {
static checkType(value) {
super.checkType(value);
if (typeof value !== "string") {
@ -483,11 +478,9 @@ class FfiConverterString extends FfiConverter {
}
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterString");
class FfiConverterCallbackInterfaceLogger extends FfiConverter {
export class FfiConverterCallbackInterfaceLogger extends FfiConverter {
static lower(callbackObj) {
return callbackHandlerLogger.storeCallbackObj(callbackObj)
}
@ -510,9 +503,7 @@ class FfiConverterCallbackInterfaceLogger extends FfiConverter {
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterCallbackInterfaceLogger");
class FfiConverterSequencei32 extends FfiConverterArrayBuffer {
export class FfiConverterSequencei32 extends FfiConverterArrayBuffer {
static read(dataStream) {
const len = dataStream.readInt32();
const arr = [];
@ -555,9 +546,6 @@ class FfiConverterSequencei32 extends FfiConverterArrayBuffer {
}
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterSequencei32");
// Define callback interface handlers, this must come after the type loop since they reference the FfiConverters defined above.
@ -585,7 +573,8 @@ UnitTestObjs.callbackHandlerLogger = callbackHandlerLogger;
function logEvenNumbers(logger,items) {
export function logEvenNumbers(logger,items) {
const liftResult = (result) => undefined;
const liftError = null;
@ -619,8 +608,7 @@ function logEvenNumbers(logger,items) {
}
}
EXPORTED_SYMBOLS.push("logEvenNumbers");
function logEvenNumbersMainThread(logger,items) {
export function logEvenNumbersMainThread(logger,items) {
const liftResult = (result) => undefined;
const liftError = null;
@ -649,5 +637,3 @@ function logEvenNumbersMainThread(logger,items) {
}
return handleRustResult(functionCall(), liftResult, liftError);
}
EXPORTED_SYMBOLS.push("logEvenNumbersMainThread");

View File

@ -1,16 +1,12 @@
// This file was autogenerated by the `uniffi-bindgen-gecko-js` crate.
// Trust me, you don't want to mess with it!
const { UniFFITypeError } = ChromeUtils.importESModule("resource://gre/modules/UniFFI.sys.mjs");
import { UniFFITypeError } from "resource://gre/modules/UniFFI.sys.mjs";
"use strict";
// Objects intended to be used in the unit tests
var UnitTestObjs = {};
var EXPORTED_SYMBOLS = ["UnitTestObjs"];
export var UnitTestObjs = {};
// Write/Read data to/from an ArrayBuffer
class ArrayBufferDataStream {
@ -225,7 +221,8 @@ const uniffiObjectPtr = Symbol("uniffiObjectPtr");
const constructUniffiObject = Symbol("constructUniffiObject");
UnitTestObjs.uniffiObjectPtr = uniffiObjectPtr;
class FfiConverterF64 extends FfiConverter {
// Export the FFIConverter object to make external types work.
export class FfiConverterF64 extends FfiConverter {
static computeSize() {
return 8;
}
@ -244,9 +241,7 @@ class FfiConverterF64 extends FfiConverter {
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterF64");
class FfiConverterString extends FfiConverter {
export class FfiConverterString extends FfiConverter {
static checkType(value) {
super.checkType(value);
if (typeof value !== "string") {
@ -278,10 +273,7 @@ class FfiConverterString extends FfiConverter {
}
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterString");
class Line {
export class Line {
constructor(start,end) {
try {
FfiConverterTypePoint.checkType(start)
@ -310,7 +302,8 @@ class Line {
}
}
class FfiConverterTypeLine extends FfiConverterArrayBuffer {
// Export the FFIConverter object to make external types work.
export class FfiConverterTypeLine extends FfiConverterArrayBuffer {
static read(dataStream) {
return new Line(
FfiConverterTypePoint.read(dataStream),
@ -350,12 +343,7 @@ class FfiConverterTypeLine extends FfiConverterArrayBuffer {
}
}
EXPORTED_SYMBOLS.push("Line");
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterTypeLine");
class Point {
export class Point {
constructor(coordX,coordY) {
try {
FfiConverterF64.checkType(coordX)
@ -384,7 +372,8 @@ class Point {
}
}
class FfiConverterTypePoint extends FfiConverterArrayBuffer {
// Export the FFIConverter object to make external types work.
export class FfiConverterTypePoint extends FfiConverterArrayBuffer {
static read(dataStream) {
return new Point(
FfiConverterF64.read(dataStream),
@ -424,12 +413,8 @@ class FfiConverterTypePoint extends FfiConverterArrayBuffer {
}
}
EXPORTED_SYMBOLS.push("Point");
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterTypePoint");
class FfiConverterOptionalTypePoint extends FfiConverterArrayBuffer {
export class FfiConverterOptionalTypePoint extends FfiConverterArrayBuffer {
static checkType(value) {
if (value !== undefined && value !== null) {
FfiConverterTypePoint.checkType(value)
@ -465,13 +450,11 @@ class FfiConverterOptionalTypePoint extends FfiConverterArrayBuffer {
}
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterOptionalTypePoint");
function gradient(ln) {
export function gradient(ln) {
const liftResult = (result) => FfiConverterF64.lift(result);
const liftError = null;
@ -496,8 +479,7 @@ function gradient(ln) {
}
}
EXPORTED_SYMBOLS.push("gradient");
function intersection(ln1,ln2) {
export function intersection(ln1,ln2) {
const liftResult = (result) => FfiConverterOptionalTypePoint.lift(result);
const liftError = null;
@ -530,5 +512,3 @@ function intersection(ln1,ln2) {
return Promise.reject(error)
}
}
EXPORTED_SYMBOLS.push("intersection");

View File

@ -1,16 +1,12 @@
// This file was autogenerated by the `uniffi-bindgen-gecko-js` crate.
// Trust me, you don't want to mess with it!
const { UniFFITypeError } = ChromeUtils.importESModule("resource://gre/modules/UniFFI.sys.mjs");
import { UniFFITypeError } from "resource://gre/modules/UniFFI.sys.mjs";
"use strict";
// Objects intended to be used in the unit tests
var UnitTestObjs = {};
var EXPORTED_SYMBOLS = ["UnitTestObjs"];
export var UnitTestObjs = {};
// Write/Read data to/from an ArrayBuffer
class ArrayBufferDataStream {
@ -285,7 +281,8 @@ const uniffiObjectPtr = Symbol("uniffiObjectPtr");
const constructUniffiObject = Symbol("constructUniffiObject");
UnitTestObjs.uniffiObjectPtr = uniffiObjectPtr;
class FfiConverterU8 extends FfiConverter {
// Export the FFIConverter object to make external types work.
export class FfiConverterU8 extends FfiConverter {
static checkType(value) {
super.checkType(value);
if (!Number.isInteger(value)) {
@ -313,9 +310,7 @@ class FfiConverterU8 extends FfiConverter {
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterU8");
class FfiConverterI8 extends FfiConverter {
export class FfiConverterI8 extends FfiConverter {
static checkType(value) {
super.checkType(value);
if (!Number.isInteger(value)) {
@ -343,9 +338,7 @@ class FfiConverterI8 extends FfiConverter {
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterI8");
class FfiConverterU16 extends FfiConverter {
export class FfiConverterU16 extends FfiConverter {
static checkType(value) {
super.checkType(value);
if (!Number.isInteger(value)) {
@ -373,9 +366,7 @@ class FfiConverterU16 extends FfiConverter {
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterU16");
class FfiConverterI16 extends FfiConverter {
export class FfiConverterI16 extends FfiConverter {
static checkType(value) {
super.checkType(value);
if (!Number.isInteger(value)) {
@ -403,9 +394,7 @@ class FfiConverterI16 extends FfiConverter {
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterI16");
class FfiConverterU32 extends FfiConverter {
export class FfiConverterU32 extends FfiConverter {
static checkType(value) {
super.checkType(value);
if (!Number.isInteger(value)) {
@ -433,9 +422,7 @@ class FfiConverterU32 extends FfiConverter {
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterU32");
class FfiConverterI32 extends FfiConverter {
export class FfiConverterI32 extends FfiConverter {
static checkType(value) {
super.checkType(value);
if (!Number.isInteger(value)) {
@ -463,9 +450,7 @@ class FfiConverterI32 extends FfiConverter {
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterI32");
class FfiConverterU64 extends FfiConverter {
export class FfiConverterU64 extends FfiConverter {
static checkType(value) {
super.checkType(value);
if (!Number.isSafeInteger(value)) {
@ -493,9 +478,7 @@ class FfiConverterU64 extends FfiConverter {
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterU64");
class FfiConverterI64 extends FfiConverter {
export class FfiConverterI64 extends FfiConverter {
static checkType(value) {
super.checkType(value);
if (!Number.isSafeInteger(value)) {
@ -520,9 +503,7 @@ class FfiConverterI64 extends FfiConverter {
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterI64");
class FfiConverterF32 extends FfiConverter {
export class FfiConverterF32 extends FfiConverter {
static computeSize() {
return 4;
}
@ -541,9 +522,7 @@ class FfiConverterF32 extends FfiConverter {
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterF32");
class FfiConverterF64 extends FfiConverter {
export class FfiConverterF64 extends FfiConverter {
static computeSize() {
return 8;
}
@ -562,9 +541,7 @@ class FfiConverterF64 extends FfiConverter {
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterF64");
class FfiConverterBool extends FfiConverter {
export class FfiConverterBool extends FfiConverter {
static computeSize() {
return 1;
}
@ -587,9 +564,7 @@ class FfiConverterBool extends FfiConverter {
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterBool");
class FfiConverterString extends FfiConverter {
export class FfiConverterString extends FfiConverter {
static checkType(value) {
super.checkType(value);
if (typeof value !== "string") {
@ -621,10 +596,7 @@ class FfiConverterString extends FfiConverter {
}
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterString");
class Optionneur {
export class Optionneur {
// Use `init` to instantiate this class.
// DO NOT USE THIS CONSTRUCTOR DIRECTLY
constructor(opts) {
@ -1284,7 +1256,8 @@ class Optionneur {
}
class FfiConverterTypeOptionneur extends FfiConverter {
// Export the FFIConverter object to make external types work.
export class FfiConverterTypeOptionneur extends FfiConverter {
static lift(value) {
const opts = {};
opts[constructUniffiObject] = value;
@ -1308,12 +1281,7 @@ class FfiConverterTypeOptionneur extends FfiConverter {
}
}
EXPORTED_SYMBOLS.push("Optionneur");
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterTypeOptionneur");
class Retourneur {
export class Retourneur {
// Use `init` to instantiate this class.
// DO NOT USE THIS CONSTRUCTOR DIRECTLY
constructor(opts) {
@ -1723,7 +1691,8 @@ class Retourneur {
}
class FfiConverterTypeRetourneur extends FfiConverter {
// Export the FFIConverter object to make external types work.
export class FfiConverterTypeRetourneur extends FfiConverter {
static lift(value) {
const opts = {};
opts[constructUniffiObject] = value;
@ -1747,12 +1716,7 @@ class FfiConverterTypeRetourneur extends FfiConverter {
}
}
EXPORTED_SYMBOLS.push("Retourneur");
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterTypeRetourneur");
class Stringifier {
export class Stringifier {
// Use `init` to instantiate this class.
// DO NOT USE THIS CONSTRUCTOR DIRECTLY
constructor(opts) {
@ -2087,7 +2051,8 @@ class Stringifier {
}
class FfiConverterTypeStringifier extends FfiConverter {
// Export the FFIConverter object to make external types work.
export class FfiConverterTypeStringifier extends FfiConverter {
static lift(value) {
const opts = {};
opts[constructUniffiObject] = value;
@ -2111,12 +2076,7 @@ class FfiConverterTypeStringifier extends FfiConverter {
}
}
EXPORTED_SYMBOLS.push("Stringifier");
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterTypeStringifier");
class Dictionnaire {
export class Dictionnaire {
constructor(un,deux,petitNombre,grosNombre) {
try {
FfiConverterTypeEnumeration.checkType(un)
@ -2165,7 +2125,8 @@ class Dictionnaire {
}
}
class FfiConverterTypeDictionnaire extends FfiConverterArrayBuffer {
// Export the FFIConverter object to make external types work.
export class FfiConverterTypeDictionnaire extends FfiConverterArrayBuffer {
static read(dataStream) {
return new Dictionnaire(
FfiConverterTypeEnumeration.read(dataStream),
@ -2227,12 +2188,7 @@ class FfiConverterTypeDictionnaire extends FfiConverterArrayBuffer {
}
}
EXPORTED_SYMBOLS.push("Dictionnaire");
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterTypeDictionnaire");
class DictionnaireNombres {
export class DictionnaireNombres {
constructor(petitNombre,courtNombre,nombreSimple,grosNombre) {
try {
FfiConverterU8.checkType(petitNombre)
@ -2281,7 +2237,8 @@ class DictionnaireNombres {
}
}
class FfiConverterTypeDictionnaireNombres extends FfiConverterArrayBuffer {
// Export the FFIConverter object to make external types work.
export class FfiConverterTypeDictionnaireNombres extends FfiConverterArrayBuffer {
static read(dataStream) {
return new DictionnaireNombres(
FfiConverterU8.read(dataStream),
@ -2343,12 +2300,7 @@ class FfiConverterTypeDictionnaireNombres extends FfiConverterArrayBuffer {
}
}
EXPORTED_SYMBOLS.push("DictionnaireNombres");
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterTypeDictionnaireNombres");
class DictionnaireNombresSignes {
export class DictionnaireNombresSignes {
constructor(petitNombre,courtNombre,nombreSimple,grosNombre) {
try {
FfiConverterI8.checkType(petitNombre)
@ -2397,7 +2349,8 @@ class DictionnaireNombresSignes {
}
}
class FfiConverterTypeDictionnaireNombresSignes extends FfiConverterArrayBuffer {
// Export the FFIConverter object to make external types work.
export class FfiConverterTypeDictionnaireNombresSignes extends FfiConverterArrayBuffer {
static read(dataStream) {
return new DictionnaireNombresSignes(
FfiConverterI8.read(dataStream),
@ -2459,12 +2412,7 @@ class FfiConverterTypeDictionnaireNombresSignes extends FfiConverterArrayBuffer
}
}
EXPORTED_SYMBOLS.push("DictionnaireNombresSignes");
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterTypeDictionnaireNombresSignes");
class OptionneurDictionnaire {
export class OptionneurDictionnaire {
constructor(i8Var = -8,u8Var = 8,i16Var = -16,u16Var = 0x10,i32Var = -32,u32Var = 32,i64Var = -64,u64Var = 64,floatVar = 4.0,doubleVar = 8.0,booleanVar = true,stringVar = "default",listVar = [],enumerationVar = Enumeration.DEUX,dictionnaireVar = null) {
try {
FfiConverterI8.checkType(i8Var)
@ -2623,7 +2571,8 @@ class OptionneurDictionnaire {
}
}
class FfiConverterTypeOptionneurDictionnaire extends FfiConverterArrayBuffer {
// Export the FFIConverter object to make external types work.
export class FfiConverterTypeOptionneurDictionnaire extends FfiConverterArrayBuffer {
static read(dataStream) {
return new OptionneurDictionnaire(
FfiConverterI8.read(dataStream),
@ -2806,12 +2755,7 @@ class FfiConverterTypeOptionneurDictionnaire extends FfiConverterArrayBuffer {
}
}
EXPORTED_SYMBOLS.push("OptionneurDictionnaire");
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterTypeOptionneurDictionnaire");
class MinusculeMajusculeDict {
export class MinusculeMajusculeDict {
constructor(minusculeMajusculeField) {
try {
FfiConverterBool.checkType(minusculeMajusculeField)
@ -2830,7 +2774,8 @@ class MinusculeMajusculeDict {
}
}
class FfiConverterTypeminusculeMajusculeDict extends FfiConverterArrayBuffer {
// Export the FFIConverter object to make external types work.
export class FfiConverterTypeminusculeMajusculeDict extends FfiConverterArrayBuffer {
static read(dataStream) {
return new MinusculeMajusculeDict(
FfiConverterBool.read(dataStream)
@ -2859,19 +2804,15 @@ class FfiConverterTypeminusculeMajusculeDict extends FfiConverterArrayBuffer {
}
}
EXPORTED_SYMBOLS.push("MinusculeMajusculeDict");
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterTypeminusculeMajusculeDict");
const Enumeration = {
export const Enumeration = {
UN: 1,
DEUX: 2,
TROIS: 3,
};
Object.freeze(Enumeration);
class FfiConverterTypeEnumeration extends FfiConverterArrayBuffer {
// Export the FFIConverter object to make external types work.
export class FfiConverterTypeEnumeration extends FfiConverterArrayBuffer {
static read(dataStream) {
switch (dataStream.readInt32()) {
case 1:
@ -2912,12 +2853,7 @@ class FfiConverterTypeEnumeration extends FfiConverterArrayBuffer {
}
}
EXPORTED_SYMBOLS.push("Enumeration");
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterTypeEnumeration");
class EnumerationAvecDonnees {}
export class EnumerationAvecDonnees {}
EnumerationAvecDonnees.Zero = class extends EnumerationAvecDonnees{
constructor(
) {
@ -2943,7 +2879,8 @@ EnumerationAvecDonnees.Deux = class extends EnumerationAvecDonnees{
}
}
class FfiConverterTypeEnumerationAvecDonnees extends FfiConverterArrayBuffer {
// Export the FFIConverter object to make external types work.
export class FfiConverterTypeEnumerationAvecDonnees extends FfiConverterArrayBuffer {
static read(dataStream) {
switch (dataStream.readInt32()) {
case 1:
@ -3007,17 +2944,13 @@ class FfiConverterTypeEnumerationAvecDonnees extends FfiConverterArrayBuffer {
}
}
EXPORTED_SYMBOLS.push("EnumerationAvecDonnees");
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterTypeEnumerationAvecDonnees");
const MinusculeMajusculeEnum = {
export const MinusculeMajusculeEnum = {
MINUSCULE_MAJUSCULE_VARIANT: 1,
};
Object.freeze(MinusculeMajusculeEnum);
class FfiConverterTypeminusculeMajusculeEnum extends FfiConverterArrayBuffer {
// Export the FFIConverter object to make external types work.
export class FfiConverterTypeminusculeMajusculeEnum extends FfiConverterArrayBuffer {
static read(dataStream) {
switch (dataStream.readInt32()) {
case 1:
@ -3046,12 +2979,8 @@ class FfiConverterTypeminusculeMajusculeEnum extends FfiConverterArrayBuffer {
}
}
EXPORTED_SYMBOLS.push("MinusculeMajusculeEnum");
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterTypeminusculeMajusculeEnum");
class FfiConverterOptionali32 extends FfiConverterArrayBuffer {
export class FfiConverterOptionali32 extends FfiConverterArrayBuffer {
static checkType(value) {
if (value !== undefined && value !== null) {
FfiConverterI32.checkType(value)
@ -3088,9 +3017,7 @@ class FfiConverterOptionali32 extends FfiConverterArrayBuffer {
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterOptionali32");
class FfiConverterOptionalstring extends FfiConverterArrayBuffer {
export class FfiConverterOptionalstring extends FfiConverterArrayBuffer {
static checkType(value) {
if (value !== undefined && value !== null) {
FfiConverterString.checkType(value)
@ -3127,9 +3054,7 @@ class FfiConverterOptionalstring extends FfiConverterArrayBuffer {
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterOptionalstring");
class FfiConverterOptionalTypeminusculeMajusculeEnum extends FfiConverterArrayBuffer {
export class FfiConverterOptionalTypeminusculeMajusculeEnum extends FfiConverterArrayBuffer {
static checkType(value) {
if (value !== undefined && value !== null) {
FfiConverterTypeminusculeMajusculeEnum.checkType(value)
@ -3166,9 +3091,7 @@ class FfiConverterOptionalTypeminusculeMajusculeEnum extends FfiConverterArrayBu
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterOptionalTypeminusculeMajusculeEnum");
class FfiConverterSequencestring extends FfiConverterArrayBuffer {
export class FfiConverterSequencestring extends FfiConverterArrayBuffer {
static read(dataStream) {
const len = dataStream.readInt32();
const arr = [];
@ -3212,9 +3135,7 @@ class FfiConverterSequencestring extends FfiConverterArrayBuffer {
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterSequencestring");
class FfiConverterSequenceTypeEnumeration extends FfiConverterArrayBuffer {
export class FfiConverterSequenceTypeEnumeration extends FfiConverterArrayBuffer {
static read(dataStream) {
const len = dataStream.readInt32();
const arr = [];
@ -3258,9 +3179,7 @@ class FfiConverterSequenceTypeEnumeration extends FfiConverterArrayBuffer {
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterSequenceTypeEnumeration");
class FfiConverterMapStringTypeEnumerationAvecDonnees extends FfiConverterArrayBuffer {
export class FfiConverterMapStringTypeEnumerationAvecDonnees extends FfiConverterArrayBuffer {
static read(dataStream) {
const len = dataStream.readInt32();
const map = {};
@ -3314,13 +3233,11 @@ class FfiConverterMapStringTypeEnumerationAvecDonnees extends FfiConverterArrayB
}
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterMapStringTypeEnumerationAvecDonnees");
function copieDictionnaire(d) {
export function copieDictionnaire(d) {
const liftResult = (result) => FfiConverterTypeDictionnaire.lift(result);
const liftError = null;
@ -3345,8 +3262,7 @@ function copieDictionnaire(d) {
}
}
EXPORTED_SYMBOLS.push("copieDictionnaire");
function copieEnumeration(e) {
export function copieEnumeration(e) {
const liftResult = (result) => FfiConverterTypeEnumeration.lift(result);
const liftError = null;
@ -3371,8 +3287,7 @@ function copieEnumeration(e) {
}
}
EXPORTED_SYMBOLS.push("copieEnumeration");
function copieEnumerations(e) {
export function copieEnumerations(e) {
const liftResult = (result) => FfiConverterSequenceTypeEnumeration.lift(result);
const liftError = null;
@ -3397,8 +3312,7 @@ function copieEnumerations(e) {
}
}
EXPORTED_SYMBOLS.push("copieEnumerations");
function copieCarte(c) {
export function copieCarte(c) {
const liftResult = (result) => FfiConverterMapStringTypeEnumerationAvecDonnees.lift(result);
const liftError = null;
@ -3423,8 +3337,7 @@ function copieCarte(c) {
}
}
EXPORTED_SYMBOLS.push("copieCarte");
function switcheroo(b) {
export function switcheroo(b) {
const liftResult = (result) => FfiConverterBool.lift(result);
const liftError = null;
@ -3448,5 +3361,3 @@ function switcheroo(b) {
return Promise.reject(error)
}
}
EXPORTED_SYMBOLS.push("switcheroo");

View File

@ -1,16 +1,12 @@
// This file was autogenerated by the `uniffi-bindgen-gecko-js` crate.
// Trust me, you don't want to mess with it!
const { UniFFITypeError } = ChromeUtils.importESModule("resource://gre/modules/UniFFI.sys.mjs");
import { UniFFITypeError } from "resource://gre/modules/UniFFI.sys.mjs";
"use strict";
// Objects intended to be used in the unit tests
var UnitTestObjs = {};
var EXPORTED_SYMBOLS = ["UnitTestObjs"];
export var UnitTestObjs = {};
// Write/Read data to/from an ArrayBuffer
class ArrayBufferDataStream {
@ -245,7 +241,8 @@ const uniffiObjectPtr = Symbol("uniffiObjectPtr");
const constructUniffiObject = Symbol("constructUniffiObject");
UnitTestObjs.uniffiObjectPtr = uniffiObjectPtr;
class FfiConverterF64 extends FfiConverter {
// Export the FFIConverter object to make external types work.
export class FfiConverterF64 extends FfiConverter {
static computeSize() {
return 8;
}
@ -264,9 +261,7 @@ class FfiConverterF64 extends FfiConverter {
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterF64");
class FfiConverterString extends FfiConverter {
export class FfiConverterString extends FfiConverter {
static checkType(value) {
super.checkType(value);
if (typeof value !== "string") {
@ -298,10 +293,7 @@ class FfiConverterString extends FfiConverter {
}
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterString");
class Sprite {
export class Sprite {
// Use `init` to instantiate this class.
// DO NOT USE THIS CONSTRUCTOR DIRECTLY
constructor(opts) {
@ -448,7 +440,8 @@ class Sprite {
}
class FfiConverterTypeSprite extends FfiConverter {
// Export the FFIConverter object to make external types work.
export class FfiConverterTypeSprite extends FfiConverter {
static lift(value) {
const opts = {};
opts[constructUniffiObject] = value;
@ -472,12 +465,7 @@ class FfiConverterTypeSprite extends FfiConverter {
}
}
EXPORTED_SYMBOLS.push("Sprite");
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterTypeSprite");
class Point {
export class Point {
constructor(x,y) {
try {
FfiConverterF64.checkType(x)
@ -506,7 +494,8 @@ class Point {
}
}
class FfiConverterTypePoint extends FfiConverterArrayBuffer {
// Export the FFIConverter object to make external types work.
export class FfiConverterTypePoint extends FfiConverterArrayBuffer {
static read(dataStream) {
return new Point(
FfiConverterF64.read(dataStream),
@ -546,12 +535,7 @@ class FfiConverterTypePoint extends FfiConverterArrayBuffer {
}
}
EXPORTED_SYMBOLS.push("Point");
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterTypePoint");
class Vector {
export class Vector {
constructor(dx,dy) {
try {
FfiConverterF64.checkType(dx)
@ -580,7 +564,8 @@ class Vector {
}
}
class FfiConverterTypeVector extends FfiConverterArrayBuffer {
// Export the FFIConverter object to make external types work.
export class FfiConverterTypeVector extends FfiConverterArrayBuffer {
static read(dataStream) {
return new Vector(
FfiConverterF64.read(dataStream),
@ -620,12 +605,8 @@ class FfiConverterTypeVector extends FfiConverterArrayBuffer {
}
}
EXPORTED_SYMBOLS.push("Vector");
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterTypeVector");
class FfiConverterOptionalTypePoint extends FfiConverterArrayBuffer {
export class FfiConverterOptionalTypePoint extends FfiConverterArrayBuffer {
static checkType(value) {
if (value !== undefined && value !== null) {
FfiConverterTypePoint.checkType(value)
@ -661,13 +642,11 @@ class FfiConverterOptionalTypePoint extends FfiConverterArrayBuffer {
}
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterOptionalTypePoint");
function translate(position,direction) {
export function translate(position,direction) {
const liftResult = (result) => FfiConverterTypePoint.lift(result);
const liftError = null;
@ -700,5 +679,3 @@ function translate(position,direction) {
return Promise.reject(error)
}
}
EXPORTED_SYMBOLS.push("translate");

View File

@ -1,16 +1,12 @@
// This file was autogenerated by the `uniffi-bindgen-gecko-js` crate.
// Trust me, you don't want to mess with it!
const { UniFFITypeError } = ChromeUtils.importESModule("resource://gre/modules/UniFFI.sys.mjs");
import { UniFFITypeError } from "resource://gre/modules/UniFFI.sys.mjs";
"use strict";
// Objects intended to be used in the unit tests
var UnitTestObjs = {};
var EXPORTED_SYMBOLS = ["UnitTestObjs"];
export var UnitTestObjs = {};
// Write/Read data to/from an ArrayBuffer
class ArrayBufferDataStream {
@ -245,7 +241,8 @@ const uniffiObjectPtr = Symbol("uniffiObjectPtr");
const constructUniffiObject = Symbol("constructUniffiObject");
UnitTestObjs.uniffiObjectPtr = uniffiObjectPtr;
class FfiConverterString extends FfiConverter {
// Export the FFIConverter object to make external types work.
export class FfiConverterString extends FfiConverter {
static checkType(value) {
super.checkType(value);
if (typeof value !== "string") {
@ -277,10 +274,7 @@ class FfiConverterString extends FfiConverter {
}
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterString");
class TodoList {
export class TodoList {
// Use `init` to instantiate this class.
// DO NOT USE THIS CONSTRUCTOR DIRECTLY
constructor(opts) {
@ -536,7 +530,8 @@ class TodoList {
}
class FfiConverterTypeTodoList extends FfiConverter {
// Export the FFIConverter object to make external types work.
export class FfiConverterTypeTodoList extends FfiConverter {
static lift(value) {
const opts = {};
opts[constructUniffiObject] = value;
@ -560,12 +555,7 @@ class FfiConverterTypeTodoList extends FfiConverter {
}
}
EXPORTED_SYMBOLS.push("TodoList");
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterTypeTodoList");
class TodoEntry {
export class TodoEntry {
constructor(text) {
try {
FfiConverterString.checkType(text)
@ -584,7 +574,8 @@ class TodoEntry {
}
}
class FfiConverterTypeTodoEntry extends FfiConverterArrayBuffer {
// Export the FFIConverter object to make external types work.
export class FfiConverterTypeTodoEntry extends FfiConverterArrayBuffer {
static read(dataStream) {
return new TodoEntry(
FfiConverterString.read(dataStream)
@ -613,18 +604,12 @@ class FfiConverterTypeTodoEntry extends FfiConverterArrayBuffer {
}
}
EXPORTED_SYMBOLS.push("TodoEntry");
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterTypeTodoEntry");
class TodoError extends Error {}
EXPORTED_SYMBOLS.push("TodoError");
export class TodoError extends Error {}
class TodoDoesNotExist extends TodoError {
export class TodoDoesNotExist extends TodoError {
constructor(message, ...params) {
super(...params);
@ -634,8 +619,8 @@ class TodoDoesNotExist extends TodoError {
return `TodoDoesNotExist: ${super.toString()}`
}
}
EXPORTED_SYMBOLS.push("TodoDoesNotExist");
class EmptyTodoList extends TodoError {
export class EmptyTodoList extends TodoError {
constructor(message, ...params) {
super(...params);
@ -645,8 +630,8 @@ class EmptyTodoList extends TodoError {
return `EmptyTodoList: ${super.toString()}`
}
}
EXPORTED_SYMBOLS.push("EmptyTodoList");
class DuplicateTodo extends TodoError {
export class DuplicateTodo extends TodoError {
constructor(message, ...params) {
super(...params);
@ -656,8 +641,8 @@ class DuplicateTodo extends TodoError {
return `DuplicateTodo: ${super.toString()}`
}
}
EXPORTED_SYMBOLS.push("DuplicateTodo");
class EmptyString extends TodoError {
export class EmptyString extends TodoError {
constructor(message, ...params) {
super(...params);
@ -667,8 +652,8 @@ class EmptyString extends TodoError {
return `EmptyString: ${super.toString()}`
}
}
EXPORTED_SYMBOLS.push("EmptyString");
class DeligatedError extends TodoError {
export class DeligatedError extends TodoError {
constructor(message, ...params) {
super(...params);
@ -678,9 +663,9 @@ class DeligatedError extends TodoError {
return `DeligatedError: ${super.toString()}`
}
}
EXPORTED_SYMBOLS.push("DeligatedError");
class FfiConverterTypeTodoError extends FfiConverterArrayBuffer {
// Export the FFIConverter object to make external types work.
export class FfiConverterTypeTodoError extends FfiConverterArrayBuffer {
static read(dataStream) {
switch (dataStream.readInt32()) {
case 1:
@ -745,9 +730,7 @@ class FfiConverterTypeTodoError extends FfiConverterArrayBuffer {
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterTypeTodoError");
class FfiConverterOptionalTypeTodoList extends FfiConverterArrayBuffer {
export class FfiConverterOptionalTypeTodoList extends FfiConverterArrayBuffer {
static checkType(value) {
if (value !== undefined && value !== null) {
FfiConverterTypeTodoList.checkType(value)
@ -784,9 +767,7 @@ class FfiConverterOptionalTypeTodoList extends FfiConverterArrayBuffer {
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterOptionalTypeTodoList");
class FfiConverterSequencestring extends FfiConverterArrayBuffer {
export class FfiConverterSequencestring extends FfiConverterArrayBuffer {
static read(dataStream) {
const len = dataStream.readInt32();
const arr = [];
@ -830,9 +811,7 @@ class FfiConverterSequencestring extends FfiConverterArrayBuffer {
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterSequencestring");
class FfiConverterSequenceTypeTodoEntry extends FfiConverterArrayBuffer {
export class FfiConverterSequenceTypeTodoEntry extends FfiConverterArrayBuffer {
static read(dataStream) {
const len = dataStream.readInt32();
const arr = [];
@ -875,13 +854,11 @@ class FfiConverterSequenceTypeTodoEntry extends FfiConverterArrayBuffer {
}
}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("FfiConverterSequenceTypeTodoEntry");
function getDefaultList() {
export function getDefaultList() {
const liftResult = (result) => FfiConverterOptionalTypeTodoList.lift(result);
const liftError = null;
@ -897,8 +874,7 @@ function getDefaultList() {
}
}
EXPORTED_SYMBOLS.push("getDefaultList");
function setDefaultList(list) {
export function setDefaultList(list) {
const liftResult = (result) => undefined;
const liftError = null;
@ -923,8 +899,7 @@ function setDefaultList(list) {
}
}
EXPORTED_SYMBOLS.push("setDefaultList");
function createEntryWith(todo) {
export function createEntryWith(todo) {
const liftResult = (result) => FfiConverterTypeTodoEntry.lift(result);
const liftError = (data) => FfiConverterTypeTodoError.lift(data);
@ -948,5 +923,3 @@ function createEntryWith(todo) {
return Promise.reject(error)
}
}
EXPORTED_SYMBOLS.push("createEntryWith");

View File

@ -18,7 +18,7 @@ components = [
]
EXTRA_JS_MODULES += [
"generated/Rust{}.jsm".format(component) for component in components
"generated/Rust{}.sys.mjs".format(component) for component in components
]
XPCSHELL_TESTS_MANIFESTS += ["tests/xpcshell/xpcshell.ini"]

View File

@ -1,8 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
const Arithmetic = ChromeUtils.import(
"resource://gre/modules/RustArithmetic.jsm"
const Arithmetic = ChromeUtils.importESModule(
"resource://gre/modules/RustArithmetic.sys.mjs"
);
add_task(async function() {

View File

@ -1,8 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
const { logEvenNumbers, logEvenNumbersMainThread } = ChromeUtils.import(
"resource://gre/modules/RustFixtureCallbacks.jsm"
const { logEvenNumbers, logEvenNumbersMainThread } = ChromeUtils.importESModule(
"resource://gre/modules/RustFixtureCallbacks.sys.mjs"
);
class Logger {

View File

@ -1,8 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
const CustomTypes = ChromeUtils.import(
"resource://gre/modules/RustCustomTypes.jsm"
const CustomTypes = ChromeUtils.importESModule(
"resource://gre/modules/RustCustomTypes.sys.mjs"
);
add_task(async function() {

View File

@ -1,8 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
const ExternalTypes = ChromeUtils.import(
"resource://gre/modules/RustExternalTypes.jsm"
const ExternalTypes = ChromeUtils.importESModule(
"resource://gre/modules/RustExternalTypes.sys.mjs"
);
add_task(async function() {

View File

@ -1,7 +1,9 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
const Geometry = ChromeUtils.import("resource://gre/modules/RustGeometry.jsm");
const Geometry = ChromeUtils.importESModule(
"resource://gre/modules/RustGeometry.sys.mjs"
);
add_task(async function() {
const ln1 = new Geometry.Line(

View File

@ -1,8 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
const Rondpoint = ChromeUtils.import(
"resource://gre/modules/RustRondpoint.jsm"
const Rondpoint = ChromeUtils.importESModule(
"resource://gre/modules/RustRondpoint.sys.mjs"
);
const {

View File

@ -1,7 +1,9 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
const Sprites = ChromeUtils.import("resource://gre/modules/RustSprites.jsm");
const Sprites = ChromeUtils.importESModule(
"resource://gre/modules/RustSprites.sys.mjs"
);
add_task(async function() {
Assert.ok(Sprites.Sprite);

View File

@ -6,7 +6,7 @@ const {
TodoEntry,
getDefaultList,
setDefaultList,
} = ChromeUtils.import("resource://gre/modules/RustTodolist.jsm");
} = ChromeUtils.importESModule("resource://gre/modules/RustTodolist.sys.mjs");
add_task(async function() {
const todo = await TodoList.init();

View File

@ -1,14 +1,17 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
const Arithmetic = ChromeUtils.import(
"resource://gre/modules/RustArithmetic.jsm"
const Arithmetic = ChromeUtils.importESModule(
"resource://gre/modules/RustArithmetic.sys.mjs"
);
const Geometry = ChromeUtils.import("resource://gre/modules/RustGeometry.jsm");
const TodoList = ChromeUtils.import("resource://gre/modules/RustTodolist.jsm");
const Rondpoint = ChromeUtils.import(
"resource://gre/modules/RustRondpoint.jsm"
const Geometry = ChromeUtils.importESModule(
"resource://gre/modules/RustGeometry.sys.mjs"
);
const TodoList = ChromeUtils.importESModule(
"resource://gre/modules/RustTodolist.sys.mjs"
);
const Rondpoint = ChromeUtils.importESModule(
"resource://gre/modules/RustRondpoint.sys.mjs"
);
const { UniFFITypeError } = ChromeUtils.importESModule(
"resource://gre/modules/UniFFI.sys.mjs"

View File

@ -39,7 +39,7 @@ fn render_enum_literal(typ: &Type, variant_name: &str) -> String {
}
#[derive(Template)]
#[template(path = "js/wrapper.jsm", escape = "none")]
#[template(path = "js/wrapper.sys.mjs", escape = "none")]
pub struct JSBindingsTemplate<'a> {
pub ci: &'a ComponentInterface,
pub config: &'a Config,
@ -66,7 +66,7 @@ impl<'a> JSBindingsTemplate<'a> {
fn js_module_name_for_ci_namespace(&self, namespace: &str) -> String {
// The plain namespace name is a bit too generic as a module name for m-c, so we
// prefix it with "Rust". Later we'll probably allow this to be customized.
format!("Rust{}.jsm", namespace.to_upper_camel_case())
format!("Rust{}.sys.mjs", namespace.to_upper_camel_case())
}
fn js_module_name_for_crate_name(&self, crate_name: &str) -> String {

View File

@ -1,4 +1,5 @@
class {{ ffi_converter }} extends FfiConverter {
// Export the FFIConverter object to make external types work.
export class {{ ffi_converter }} extends FfiConverter {
static computeSize() {
return 1;
}

View File

@ -1,6 +1,7 @@
{%- let cbi = ci.get_callback_interface_definition(name).unwrap() %}
{#- See CallbackInterfaceRuntime.jsm and CallbackInterfaceHandler.jsm for the callback interface handler definition, referenced here as `{{ cbi.handler() }}` #}
class {{ ffi_converter }} extends FfiConverter {
{#- See CallbackInterfaceRuntime.sys.mjs and CallbackInterfaceHandler.sys.mjs for the callback interface handler definition, referenced here as `{{ cbi.handler() }}` #}
// Export the FFIConverter object to make external types work.
export class {{ ffi_converter }} extends FfiConverter {
static lower(callbackObj) {
return {{ cbi.handler() }}.storeCallbackObj(callbackObj)
}

View File

@ -1,5 +1,5 @@
class {{ ffi_converter }} extends FfiConverter {
// Export the FFIConverter object to make external types work.
export class {{ ffi_converter }} extends FfiConverter {
static lift(buf) {
return {{ builtin.ffi_converter() }}.lift(buf);
}

View File

@ -2,14 +2,15 @@
{%- if enum_.is_flat() -%}
const {{ enum_.nm() }} = {
export const {{ enum_.nm() }} = {
{%- for variant in enum_.variants() %}
{{ variant.name().to_shouty_snake_case() }}: {{loop.index}},
{%- endfor %}
};
Object.freeze({{ enum_.nm() }});
class {{ ffi_converter }} extends FfiConverterArrayBuffer {
// Export the FFIConverter object to make external types work.
export class {{ ffi_converter }} extends FfiConverterArrayBuffer {
static read(dataStream) {
switch (dataStream.readInt32()) {
{%- for variant in enum_.variants() %}
@ -44,7 +45,7 @@ class {{ ffi_converter }} extends FfiConverterArrayBuffer {
{%- else -%}
class {{ enum_.nm() }} {}
export class {{ enum_.nm() }} {}
{%- for variant in enum_.variants() %}
{{enum_.nm()}}.{{variant.name().to_upper_camel_case() }} = class extends {{ enum_.nm() }}{
constructor(
@ -60,7 +61,8 @@ class {{ enum_.nm() }} {}
}
{%- endfor %}
class {{ ffi_converter }} extends FfiConverterArrayBuffer {
// Export the FFIConverter object to make external types work.
export class {{ ffi_converter }} extends FfiConverterArrayBuffer {
static read(dataStream) {
switch (dataStream.readInt32()) {
{%- for variant in enum_.variants() %}
@ -111,5 +113,3 @@ class {{ ffi_converter }} extends FfiConverterArrayBuffer {
}
{%- endif %}
EXPORTED_SYMBOLS.push("{{ enum_.nm() }}");

View File

@ -2,17 +2,16 @@
{%- let string_type = Type::String %}
{%- let string_ffi_converter = string_type.ffi_converter() %}
class {{ error.nm() }} extends Error {}
EXPORTED_SYMBOLS.push("{{ error.nm() }}");
export class {{ error.nm() }} extends Error {}
{% for variant in error.variants() %}
class {{ variant.name().to_upper_camel_case() }} extends {{ error.nm() }} {
{% if error.is_flat() %}
export class {{ variant.name().to_upper_camel_case() }} extends {{ error.nm() }} {
{% if error.is_flat() %}
constructor(message, ...params) {
super(...params);
this.message = message;
}
{%- else %}
{%- else %}
constructor(
{% for field in variant.fields() -%}
{{field.nm()}},
@ -24,15 +23,15 @@ class {{ variant.name().to_upper_camel_case() }} extends {{ error.nm() }} {
this.{{field.nm()}} = {{ field.nm() }};
{%- endfor %}
}
{%- endif %}
{%- endif %}
toString() {
return `{{ variant.name().to_upper_camel_case() }}: ${super.toString()}`
}
}
EXPORTED_SYMBOLS.push("{{ variant.name().to_upper_camel_case() }}");
{%- endfor %}
class {{ ffi_converter }} extends FfiConverterArrayBuffer {
// Export the FFIConverter object to make external types work.
export class {{ ffi_converter }} extends FfiConverterArrayBuffer {
static read(dataStream) {
switch (dataStream.readInt32()) {
{%- for variant in error.variants() %}

View File

@ -1,4 +0,0 @@
const { {{ name }}, {{ ffi_converter }} } = ChromeUtils.import(
"{{ self.external_type_module(crate_name) }}"
);
EXPORTED_SYMBOLS.push("{{ name }}");

View File

@ -0,0 +1,7 @@
import {
{{ ffi_converter }},
{{ name }},
} from "{{ self.external_type_module(crate_name) }}";
// Export the FFIConverter object to make external types work.
export { {{ ffi_converter }}, {{ name }} };

View File

@ -1,4 +1,5 @@
class {{ ffi_converter }} extends FfiConverter {
// Export the FFIConverter object to make external types work.
export class {{ ffi_converter }} extends FfiConverter {
static computeSize() {
return 4;
}

View File

@ -1,4 +1,5 @@
class {{ ffi_converter }} extends FfiConverter {
// Export the FFIConverter object to make external types work.
export class {{ ffi_converter }} extends FfiConverter {
static computeSize() {
return 8;
}

View File

@ -1,4 +1,5 @@
class {{ ffi_converter }} extends FfiConverter {
// Export the FFIConverter object to make external types work.
export class {{ ffi_converter }} extends FfiConverter {
static checkType(value) {
super.checkType(value);
if (!Number.isInteger(value)) {

View File

@ -1,4 +1,5 @@
class {{ ffi_converter }} extends FfiConverter {
// Export the FFIConverter object to make external types work.
export class {{ ffi_converter }} extends FfiConverter {
static checkType(value) {
super.checkType(value);
if (!Number.isInteger(value)) {

View File

@ -1,4 +1,5 @@
class {{ ffi_converter }} extends FfiConverter {
// Export the FFIConverter object to make external types work.
export class {{ ffi_converter }} extends FfiConverter {
static checkType(value) {
super.checkType(value);
if (!Number.isSafeInteger(value)) {

View File

@ -1,4 +1,5 @@
class {{ ffi_converter }} extends FfiConverter {
// Export the FFIConverter object to make external types work.
export class {{ ffi_converter }} extends FfiConverter {
static checkType(value) {
super.checkType(value);
if (!Number.isInteger(value)) {

View File

@ -1,4 +1,5 @@
class {{ ffi_converter }} extends FfiConverterArrayBuffer {
// Export the FFIConverter object to make external types work.
export class {{ ffi_converter }} extends FfiConverterArrayBuffer {
static read(dataStream) {
const len = dataStream.readInt32();
const map = {};
@ -51,4 +52,3 @@ class {{ ffi_converter }} extends FfiConverterArrayBuffer {
}
}
}

View File

@ -1,5 +1,5 @@
{%- let object = ci.get_object_definition(name).unwrap() -%}
class {{ object.nm() }} {
export class {{ object.nm() }} {
// Use `init` to instantiate this class.
// DO NOT USE THIS CONSTRUCTOR DIRECTLY
constructor(opts) {
@ -42,7 +42,8 @@ class {{ object.nm() }} {
}
class {{ ffi_converter }} extends FfiConverter {
// Export the FFIConverter object to make external types work.
export class {{ ffi_converter }} extends FfiConverter {
static lift(value) {
const opts = {};
opts[constructUniffiObject] = value;
@ -65,5 +66,3 @@ class {{ ffi_converter }} extends FfiConverter {
return 8;
}
}
EXPORTED_SYMBOLS.push("{{ object.nm() }}");

View File

@ -1,4 +1,5 @@
class {{ ffi_converter }} extends FfiConverterArrayBuffer {
// Export the FFIConverter object to make external types work.
export class {{ ffi_converter }} extends FfiConverterArrayBuffer {
static checkType(value) {
if (value !== undefined && value !== null) {
{{ inner.ffi_converter() }}.checkType(value)

View File

@ -1,5 +1,5 @@
{%- let record = ci.get_record_definition(name).unwrap() -%}
class {{ record.nm() }} {
export class {{ record.nm() }} {
constructor({{ record.constructor_field_list() }}) {
{%- for field in record.fields() %}
try {
@ -25,7 +25,8 @@ class {{ record.nm() }} {
}
}
class {{ ffi_converter }} extends FfiConverterArrayBuffer {
// Export the FFIConverter object to make external types work.
export class {{ ffi_converter }} extends FfiConverterArrayBuffer {
static read(dataStream) {
return new {{record.nm()}}(
{%- for field in record.fields() %}
@ -62,5 +63,3 @@ class {{ ffi_converter }} extends FfiConverterArrayBuffer {
{%- endfor %}
}
}
EXPORTED_SYMBOLS.push("{{ record.nm() }}");

View File

@ -1,4 +1,5 @@
class {{ ffi_converter }} extends FfiConverterArrayBuffer {
// Export the FFIConverter object to make external types work.
export class {{ ffi_converter }} extends FfiConverterArrayBuffer {
static read(dataStream) {
const len = dataStream.readInt32();
const arr = [];
@ -40,4 +41,3 @@ class {{ ffi_converter }} extends FfiConverterArrayBuffer {
})
}
}

View File

@ -1,4 +1,5 @@
class FfiConverterString extends FfiConverter {
// Export the FFIConverter object to make external types work.
export class {{ ffi_converter }} extends FfiConverter {
static checkType(value) {
super.checkType(value);
if (typeof value !== "string") {

View File

@ -1,8 +0,0 @@
{%- for func in ci.function_definitions() %}
function {{ func.nm() }}({{ func.arg_names() }}) {
{% call js::call_scaffolding_function(func) %}
}
EXPORTED_SYMBOLS.push("{{ func.nm() }}");
{%- endfor %}

View File

@ -0,0 +1,6 @@
{%- for func in ci.function_definitions() %}
export function {{ func.nm() }}({{ func.arg_names() }}) {
{% call js::call_scaffolding_function(func) %}
}
{%- endfor %}

View File

@ -1,5 +1,5 @@
{%- if !ci.callback_interface_definitions().is_empty() %}
{%- include "CallbackInterfaceRuntime.jsm" %}
{%- include "CallbackInterfaceRuntime.sys.mjs" %}
{% endif %}
@ -8,85 +8,82 @@
{%- match type_ %}
{%- when Type::Boolean %}
{%- include "Boolean.jsm" %}
{%- include "Boolean.sys.mjs" %}
{%- when Type::UInt8 %}
{%- include "UInt8.jsm" %}
{%- include "UInt8.sys.mjs" %}
{%- when Type::UInt16 %}
{%- include "UInt16.jsm" %}
{%- include "UInt16.sys.mjs" %}
{%- when Type::UInt32 %}
{%- include "UInt32.jsm" %}
{%- include "UInt32.sys.mjs" %}
{%- when Type::UInt64 %}
{%- include "UInt64.jsm" %}
{%- include "UInt64.sys.mjs" %}
{%- when Type::Int8 %}
{%- include "Int8.jsm" %}
{%- include "Int8.sys.mjs" %}
{%- when Type::Int16 %}
{%- include "Int16.jsm" %}
{%- include "Int16.sys.mjs" %}
{%- when Type::Int32 %}
{%- include "Int32.jsm" %}
{%- include "Int32.sys.mjs" %}
{%- when Type::Int64 %}
{%- include "Int64.jsm" %}
{%- include "Int64.sys.mjs" %}
{%- when Type::Float32 %}
{%- include "Float32.jsm" %}
{%- include "Float32.sys.mjs" %}
{%- when Type::Float64 %}
{%- include "Float64.jsm" %}
{%- include "Float64.sys.mjs" %}
{%- when Type::Record with (name) %}
{%- include "Record.jsm" %}
{%- include "Record.sys.mjs" %}
{%- when Type::Optional with (inner) %}
{%- include "Optional.jsm" %}
{%- include "Optional.sys.mjs" %}
{%- when Type::String %}
{%- include "String.jsm" %}
{%- include "String.sys.mjs" %}
{%- when Type::Sequence with (inner) %}
{%- include "Sequence.jsm" %}
{%- include "Sequence.sys.mjs" %}
{%- when Type::Map with (key_type, value_type) %}
{%- include "Map.jsm" %}
{%- include "Map.sys.mjs" %}
{%- when Type::Error with (name) %}
{%- include "Error.jsm" %}
{%- include "Error.sys.mjs" %}
{%- when Type::Enum with (name) %}
{%- include "Enum.jsm" %}
{%- include "Enum.sys.mjs" %}
{%- when Type::Object with (name) %}
{%- include "Object.jsm" %}
{%- include "Object.sys.mjs" %}
{%- when Type::Custom with { name, builtin } %}
{%- include "CustomType.jsm" %}
{%- include "CustomType.sys.mjs" %}
{%- when Type::External with { name, crate_name } %}
{%- include "ExternalType.jsm" %}
{%- include "ExternalType.sys.mjs" %}
{%- when Type::CallbackInterface with (name) %}
{%- include "CallbackInterface.jsm" %}
{%- include "CallbackInterface.sys.mjs" %}
{%- else %}
{#- TODO implement the other types #}
{%- endmatch %}
// Export the FFIConverter object to make external types work.
EXPORTED_SYMBOLS.push("{{ ffi_converter }}");
{% endfor %}
{%- if !ci.callback_interface_definitions().is_empty() %}
// Define callback interface handlers, this must come after the type loop since they reference the FfiConverters defined above.
{% for cbi in ci.callback_interface_definitions() %}
{%- include "CallbackInterfaceHandler.jsm" %}
{%- include "CallbackInterfaceHandler.sys.mjs" %}
{% endfor %}
{% endif %}

View File

@ -1,4 +1,5 @@
class {{ ffi_converter }} extends FfiConverter {
// Export the FFIConverter object to make external types work.
export class {{ ffi_converter }} extends FfiConverter {
static checkType(value) {
super.checkType(value);
if (!Number.isInteger(value)) {

View File

@ -1,4 +1,5 @@
class {{ ffi_converter }} extends FfiConverter {
// Export the FFIConverter object to make external types work.
export class {{ ffi_converter }} extends FfiConverter {
static checkType(value) {
super.checkType(value);
if (!Number.isInteger(value)) {

View File

@ -1,4 +1,5 @@
class {{ ffi_converter }} extends FfiConverter {
// Export the FFIConverter object to make external types work.
export class {{ ffi_converter }} extends FfiConverter {
static checkType(value) {
super.checkType(value);
if (!Number.isSafeInteger(value)) {

View File

@ -1,4 +1,5 @@
class {{ ffi_converter }} extends FfiConverter {
// Export the FFIConverter object to make external types work.
export class {{ ffi_converter }} extends FfiConverter {
static checkType(value) {
super.checkType(value);
if (!Number.isInteger(value)) {

View File

@ -1,19 +0,0 @@
// This file was autogenerated by the `uniffi-bindgen-gecko-js` crate.
// Trust me, you don't want to mess with it!
const { UniFFITypeError } = ChromeUtils.importESModule("resource://gre/modules/UniFFI.sys.mjs");
{% import "macros.jsm" as js %}
"use strict";
// Objects intended to be used in the unit tests
var UnitTestObjs = {};
var EXPORTED_SYMBOLS = ["UnitTestObjs"];
{% include "Helpers.jsm" %}
{% include "Types.jsm" %}
{% include "TopLevelFunctions.jsm" %}

View File

@ -0,0 +1,15 @@
// This file was autogenerated by the `uniffi-bindgen-gecko-js` crate.
// Trust me, you don't want to mess with it!
import { UniFFITypeError } from "resource://gre/modules/UniFFI.sys.mjs";
{% import "macros.sys.mjs" as js %}
// Objects intended to be used in the unit tests
export var UnitTestObjs = {};
{% include "Helpers.sys.mjs" %}
{% include "Types.sys.mjs" %}
{% include "TopLevelFunctions.sys.mjs" %}